diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index df7253a..983ee4c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,7 +19,7 @@ jobs: - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: Build with Gradle uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021 diff --git a/build.gradle b/build.gradle index a83db42..4bfe9a1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } @@ -22,7 +22,7 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}" + modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}" modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" modRuntimeOnly "me.djtheredstoner:DevAuth-fabric:${project.devauth_version}" } @@ -36,33 +36,24 @@ processResources { } } -def targetJavaVersion = 16 -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = 'UTF-8' - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { - it.options.release = targetJavaVersion - } +base { + archivesName = project.archives_base_name } java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } - archivesBaseName = project.archives_base_name - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + withSourcesJar() } +tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" +} + jar { - from('LICENSE') { - rename { "${it}_${project.archivesBaseName}" } + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}" } } } diff --git a/gradle.properties b/gradle.properties index 8109e5b..bf67bed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.6 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.1 +loader_version=0.15.11 # Mod Properties mod_version=1.2.2 maven_group=io.toadlabs archives_base_name=numeralping # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.96.1+1.20.4 -yacl_version=3.3.1+1.20.4 -mod_menu_version=9.0.0 +fabric_version=0.98.0+1.20.6 +yacl_version=3.4.2+1.20.5-fabric +mod_menu_version=10.0.0-beta.1 devauth_version=1.2.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index fcb6fca..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +145,7 @@ 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 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -201,11 +202,11 @@ fi # 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"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 6689b85..7101f8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/io/toadlabs/numeralping/mixin/ServerEntryMixin.java b/src/main/java/io/toadlabs/numeralping/mixin/ServerEntryMixin.java index e15480e..6ebaf2b 100644 --- a/src/main/java/io/toadlabs/numeralping/mixin/ServerEntryMixin.java +++ b/src/main/java/io/toadlabs/numeralping/mixin/ServerEntryMixin.java @@ -1,9 +1,11 @@ package io.toadlabs.numeralping.mixin; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import io.toadlabs.numeralping.config.NumeralConfig; import io.toadlabs.numeralping.util.Utils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget; import net.minecraft.client.network.ServerInfo; import net.minecraft.text.Text; @@ -18,8 +20,6 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; -import java.util.List; - // a priority of 2000 means it will apply later // this is combined with `require = 0` to allow other mods to apply more integral functionality first without the game crashing @Mixin(value = MultiplayerServerListWidget.ServerEntry.class, priority = 0) @@ -35,12 +35,9 @@ public void shiftText(Args args) { } // hide the tooltip if it's redundant - @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V"), require = 0) - public void setTooltip(Args args) { - var tooltip = (List) args.get(0); - if (tooltip != null && tooltip.size() == 1 && NumeralConfig.instance().serverList && tooltip.get(0).getContent() instanceof TranslatableTextContent translatable && translatable.getKey().equals("multiplayer.status.ping")) { - args.set(0, null); - } + @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) + public boolean hideTooltip(MultiplayerScreen instance, Text text) { + return !(NumeralConfig.instance().serverList && text.getContent() instanceof TranslatableTextContent content && content.getKey().equalsIgnoreCase("multiplayer.status.ping")); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0)) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2d61976..8ae29d1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,9 +33,9 @@ "numeralping.mixins.json" ], "depends": { - "fabricloader": ">=0.12.12", - "fabric": "*", - "minecraft": "~1.20", + "fabricloader": ">=0.15", + "fabric-api": "*", + "minecraft": "~1.20.5", "yet_another_config_lib_v3": "*" }, "suggests": {