diff --git a/build.gradle b/build.gradle index ab8c66a..e4dafb4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,34 +1,30 @@ plugins { id 'eclipse' + id 'idea' id 'maven-publish' - id 'net.minecraftforge.gradle' version '5.1.+' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' } version = mod_version -group = 'com.skinnydevi.playtimelimiter' -archivesBaseName = 'playtimelimiter' +group = mod_group_id + +base { + archivesName = mod_id +} java.toolchain.languageVersion = JavaLanguageVersion.of(17) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { - // The mappings can be changed at any time and must be in the following format. - // Channel: Version: - // official MCVersion Official field/method names from Mojang mapping files - // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official - // - // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. - // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md - // - // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge - // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started - // - // Use non-default mappings at your own risk. They may not always work. - // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.19.2' + mappings channel: mapping_channel, version: mapping_version // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. + // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. + // It is REQUIRED to be set to true for this template to function. + // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html + copyIdeResources = true + runs { client { workingDirectory project.file('run') @@ -37,10 +33,10 @@ minecraft { property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'playtimelimiter' + property 'forge.enabledGameTestNamespaces', mod_id mods { - playtimelimiter { + "${mod_id}" { source sourceSets.main } } @@ -53,10 +49,10 @@ minecraft { property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'playtimelimiter' + property 'forge.enabledGameTestNamespaces', mod_id mods { - playtimelimiter { + "${mod_id}" { source sourceSets.main } } @@ -69,10 +65,10 @@ minecraft { property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'playtimelimiter' + property 'forge.enabledGameTestNamespaces', mod_id mods { - playtimelimiter { + "${mod_id}" { source sourceSets.main } } @@ -85,10 +81,10 @@ minecraft { property 'forge.logging.console.level', 'debug' - args '--mod', 'playtimelimiter', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { - playtimelimiter { + "${mod_id}" { source sourceSets.main } } @@ -109,18 +105,39 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.19.2-43.2.11' + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" +} + +// This block of code expands all declared replace properties in the specified resource targets. +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html +def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] +def replaceProperties = [ + minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, + forge_version: forge_version, forge_version_range: forge_version_range, + loader_version_range: loader_version_range, + mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, + mod_authors: mod_authors, mod_description: mod_description +] +processResources { + inputs.properties replaceProperties + replaceProperties.put 'project', project + + filesMatching(resourceTargets) { + expand replaceProperties + } } jar { manifest { attributes([ - "Specification-Title" : "playtimelimiter", - "Specification-Vendor" : "playtimelimitersareus", + "Specification-Title" : mod_id, + "Specification-Vendor" : mod_authors, "Specification-Version" : "1", // We are version 1 of ourselves "Implementation-Title" : project.name, "Implementation-Version" : mod_version, - "Implementation-Vendor" : "playtimelimitersareus", + "Implementation-Vendor" : mod_authors, "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } diff --git a/gradle.properties b/gradle.properties index 572d179..e7dcb00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,46 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.2.2-1.19.2 \ No newline at end of file +## Environment Properties + +# The Minecraft version must agree with the Forge version to get a valid artifact +minecraft_version=1.20 +# The Minecraft version range can use any release version of Minecraft as bounds. +# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly +# as they do not follow standard versioning conventions. +minecraft_version_range=[1.20,1.21) +# The Forge version must agree with the Minecraft version to get a valid artifact +forge_version=46.0.14 +# The Forge version range can use any version of Forge as bounds or match the loader version range +forge_version_range=[46,) +# The loader version range can only use the major version of Forge/FML as bounds +loader_version_range=[46,) +# The mapping channel to use for mappings. +# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. +# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. +# +# | Channel | Version | | +# |-----------|----------------------|--------------------------------------------------------------------------------| +# | official | MCVersion | Official field/method names from Mojang mapping files | +# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official | +# +# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. +# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md +# +# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge. +# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started +mapping_channel=official +# The mapping version to query from the mapping channel. +# This must match the format required by the mapping channel. +mapping_version=1.20 + + +## Mod Properties + +mod_id=playtimelimiter +mod_name=Playtime Limiter +mod_license=MIT +mod_version=1.2.2-1.20 +mod_group_id=com.skinnydevi.playtimelimiter +mod_authors=SkinnyDevi (Porter), StunterLetsPlay (Original Author) +mod_description=Limits and tracks the amount of time a player can play on your server. \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..65dcd68 100644 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/settings.gradle b/settings.gradle index 3703f36..291d399 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,13 @@ pluginManagement { repositories { gradlePluginPortal() - maven { url = 'https://maven.minecraftforge.net/' } + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' } \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a9d78f5..9857dbb 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,17 +1,17 @@ modLoader="javafml" #mandatory -loaderVersion="[43,)" -license="MIT" +loaderVersion="${loader_version_range}" +license="${mod_license}" issueTrackerURL="https://github.com/SkinnyDevi/playtimelimiter/issues" [[mods]] -modId="playtimelimiter" -version="${file.jarVersion}" +modId="${mod_id}" +version="${mod_version}" displayName="§c§lPlaytime Limiter" #mandatory displayURL="https://www.curseforge.com/minecraft/mc-mods/skdvs-playtime-limiter-port-upgrade" logoFile="playtimelimiter-icon.png" credits="SkinnyDevi" -authors="SkinnyDevi (Porter), StunterLetsPlay (Original Author)" +authors="${mod_authors}" # Display Test controls the display for your mod in the server connection screen # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. @@ -21,20 +21,18 @@ authors="SkinnyDevi (Porter), StunterLetsPlay (Original Author)" displayTest="IGNORE_SERVER_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) -description=''' -Limits and tracks the amount of time a player can play on your server. -''' +description='''${mod_description}''' -[[dependencies.playtimelimiter]] +[[dependencies.${mod_id}]] modId="forge" mandatory=true - versionRange="[43,)" + versionRange="${forge_version_range}" ordering="NONE" side="BOTH" -[[dependencies.playtimelimiter]] +[[dependencies.${mod_id}]] modId="minecraft" mandatory=true - versionRange="[1.19.2,1.20)" + versionRange="${minecraft_version_range}" ordering="NONE" side="SERVER" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 05d02d7..f307a42 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "description": "Resources for Playtime Limiter", - "pack_format": 9, - "forge:resource_pack_format": 9, - "forge:data_pack_format": 10 + "description": { + "text": "Resources for ${mod_name}" + }, + "pack_format": 15 } }