diff options
| -rw-r--r-- | docs/CHANGELOG.md | 15 | ||||
| -rw-r--r-- | forge/build.gradle | 6 | ||||
| -rw-r--r-- | gradle.properties | 3 | ||||
| -rw-r--r-- | neoforge/build.gradle | 6 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/common/core/ServerStatusCache.java | 7 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/common/mixins/client/MixinServerStatusPinger$1.java | 53 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/common/mixins/common/MixinJsonByteBufCodec.java | 48 |
7 files changed, 90 insertions, 48 deletions
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 798480f..ce6c4f4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,18 @@ +#### **\[Build MC1.21.11-v2.18.1\]:** + +- Moved `enableMod` option from `NCR-Client.json` to `NCR-Common.json`, so it can now be used on dedicated servers as well; previous value of the option is not carried over; +- Changing `enableMod` now only takes effect after the game is restarted, and disabling the mod suppresses all of its functionality, including most mixins; +- Removed config reload button from multiplayer menu, since config files are now only read at startup; +- Fixed state of the mod toggle button not being saved ([#496](https://github.com/Aizistral-Studios/No-Chat-Reports/issues/496)); +- Fixed messages sometimes failing to send with "On Demand" signing mode ([#539](https://github.com/Aizistral-Studios/No-Chat-Reports/issues/539)); +- Fixed "Safe Server" icon sometimes being displayed for servers that do not have the mod installed; +- Fixed server ping crash ([#556](https://github.com/Aizistral-Studios/No-Chat-Reports/issues/556)); +- Fixed startup crash on Forge and NeoForge dedicated servers that have Cloth Config installed; +- Fixed "Don't show again" choice in Realms warning screen not being saved; +- Removed stale encryption-related strings from translations; +- Redesigned some GUI textures; +- Removed Italian translation. + #### **\[Build 1.21.11-v2.18.0\]:** - Added Cloth Config compatibility for Forge/NeoForge ([thanks to rcubedev, #506](https://github.com/Aizistral-Studios/No-Chat-Reports/pull/506)). diff --git a/forge/build.gradle b/forge/build.gradle index afa5688..c7c06d9 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -140,9 +140,9 @@ jar { attributes([ "Specification-Title": "${mod_name}", "Specification-Vendor": "${mod_author}", - "Specification-Version": "${version}", + "Specification-Version": "${manifest_version}", "Implementation-Title": "${mod_name}", - "Implementation-Version": "${version}", + "Implementation-Version": "${manifest_version}", "Implementation-Vendor" :"${mod_author}", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "MixinConfigs": "mixins/common/nochatreports.mixins.json, mixins/forge/nochatreports-forge.mixins.json" @@ -161,7 +161,7 @@ processResources { // Replace properties in mods.toml with ones derived from settings.gradle include 'mods.toml' expand 'mod_license': mod_license, - 'mod_version': version, + 'mod_version': manifest_version, 'mod_id' : mod_id, 'mod_name': mod_name, 'mod_url': mod_url, diff --git a/gradle.properties b/gradle.properties index 35dc0bd..38cca6b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,8 @@ forge_version=1.21.11-61.1.5 neoforge_version=21.11.48 # Mod Properties -mod_version=1.21.11-v2.18.0 +mod_version=MC1.21.11-v2.18.1 +manifest_version=1.21.11-v2.18.1 maven_group=com.aizistral.nochatreports archives_base_name=NoChatReports-FABRIC mod_id=nochatreports diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 1093d7c..88cc178 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -116,9 +116,9 @@ jar { attributes([ "Specification-Title": "${mod_name}", "Specification-Vendor": "${mod_author}", - "Specification-Version": "${version}", + "Specification-Version": "${manifest_version}", "Implementation-Title": "${mod_name}", - "Implementation-Version": "${version}", + "Implementation-Version": "${manifest_version}", "Implementation-Vendor" :"${mod_author}", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), ]) @@ -136,7 +136,7 @@ processResources { // Replace properties in mods.toml with ones derived from settings.gradle include 'neoforge.mods.toml' expand 'mod_license': mod_license, - 'mod_version': version, + 'mod_version': manifest_version, 'mod_id' : mod_id, 'mod_name': mod_name, 'mod_url': mod_url, diff --git a/src/main/java/com/aizistral/nochatreports/common/core/ServerStatusCache.java b/src/main/java/com/aizistral/nochatreports/common/core/ServerStatusCache.java index 675c9a8..9d199ff 100644 --- a/src/main/java/com/aizistral/nochatreports/common/core/ServerStatusCache.java +++ b/src/main/java/com/aizistral/nochatreports/common/core/ServerStatusCache.java @@ -5,14 +5,15 @@ import net.fabricmc.api.Environment; //@Environment(EnvType.CLIENT) public class ServerStatusCache { - private static ThreadLocal<Boolean> preventsReports = new ThreadLocal<>(); + private static final ThreadLocal<Boolean> PREVENTS_REPORTS = new ThreadLocal<>(); public static boolean doesPreventReports() { - return preventsReports.get(); + Boolean value = PREVENTS_REPORTS.get(); + return value != null && value.booleanValue(); } public static void setPreventsReports(boolean doesPreventReports) { - preventsReports.set(doesPreventReports); + PREVENTS_REPORTS.set(Boolean.valueOf(doesPreventReports)); } } diff --git a/src/main/java/com/aizistral/nochatreports/common/mixins/client/MixinServerStatusPinger$1.java b/src/main/java/com/aizistral/nochatreports/common/mixins/client/MixinServerStatusPinger$1.java index fac9b95..7563f2c 100644 --- a/src/main/java/com/aizistral/nochatreports/common/mixins/client/MixinServerStatusPinger$1.java +++ b/src/main/java/com/aizistral/nochatreports/common/mixins/client/MixinServerStatusPinger$1.java @@ -38,36 +38,53 @@ public abstract class MixinServerStatusPinger$1 { private ServerDataExtension nochatreports$serverData; @Inject(method = "<init>", at = @At("RETURN")) - private void captureServerData(ServerStatusPinger serverStatusPinger, Connection connection, ServerData serverData, Runnable runnable, Runnable runnable2, InetSocketAddress inetSocketAddress, ServerAddress serverAddress, EventLoopGroupHolder eventLoopGroupHolder, CallbackInfo ci){ - this.nochatreports$serverData = (ServerDataExtension) serverData; + private void captureServerData( + ServerStatusPinger pinger, + Connection connection, + ServerData data, + Runnable runnableA, + Runnable runnableB, + InetSocketAddress socketAddress, + ServerAddress serverAddress, + EventLoopGroupHolder holder, + CallbackInfo info) { + try { + this.nochatreports$serverData = (ServerDataExtension) data; + } catch (Throwable ex) { + NCRCore.LOGGER.error("Failed to capture server data in MixinServerStatusPinger$1!", ex); + } } @Inject(method = "handleStatusResponse(Lnet/minecraft/network/protocol/status/ClientboundStatusResponsePacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/status/ServerStatus;" + "description()Lnet/minecraft/network/chat/Component;")) private void getNoChatReports(ClientboundStatusResponsePacket packet, CallbackInfo info) { - ServerStatus status = packet.status(); - boolean preventsReports = ServerStatusCache.doesPreventReports(); + try { + ServerStatus status = packet.status(); + boolean preventsReports = ServerStatusCache.doesPreventReports(); - if (status.version().isPresent()) { - ServerStatus.Version version = status.version().get(); + if (status.version().isPresent()) { + ServerStatus.Version version = status.version().get(); - if (version.protocol() < 759 && version.protocol() > 0) { - preventsReports = true; + if (version.protocol() < 759 && version.protocol() > 0) { + preventsReports = true; + } } - } - if (this.nochatreports$serverData == null) { - NCRCore.LOGGER.error("Failed to capture ServerData instance in MixinServerStatusPinger$1!"); - NCRCore.LOGGER.catching(new IllegalStateException()); - return; - } + if (this.nochatreports$serverData == null) { + NCRCore.LOGGER.error("Failed to capture ServerData instance in MixinServerStatusPinger$1!"); + NCRCore.LOGGER.catching(new IllegalStateException()); + return; + } - this.nochatreports$serverData.setPreventsChatReports(preventsReports); + this.nochatreports$serverData.setPreventsChatReports(preventsReports); - if (NCRConfig.getCommon().enableDebugLog()) { - NCRCore.LOGGER.info("Received status response packet from server, preventsChatReports: {}", - preventsReports); + if (NCRConfig.getCommon().enableDebugLog()) { + NCRCore.LOGGER.info("Received status response packet from server, preventsChatReports: {}", + preventsReports); + } + } catch (Throwable ex) { + NCRCore.LOGGER.error("Failed to handle status response in MixinServerStatusPinger$1!", ex); } } diff --git a/src/main/java/com/aizistral/nochatreports/common/mixins/common/MixinJsonByteBufCodec.java b/src/main/java/com/aizistral/nochatreports/common/mixins/common/MixinJsonByteBufCodec.java index 4bb95d2..a0e625d 100644 --- a/src/main/java/com/aizistral/nochatreports/common/mixins/common/MixinJsonByteBufCodec.java +++ b/src/main/java/com/aizistral/nochatreports/common/mixins/common/MixinJsonByteBufCodec.java @@ -31,38 +31,46 @@ public class MixinJsonByteBufCodec { @Inject(method = "encode(Lio/netty/buffer/ByteBuf;Lcom/google/gson/JsonElement;)V", at = @At("HEAD"), cancellable = true) private void onEncode(ByteBuf buf, JsonElement element, CallbackInfo info) { - if (!NCRConfig.getCommon().addQueryData() || !this.isServerStatusElement(element)) - return; + try { + if (!NCRConfig.getCommon().addQueryData() || !this.isServerStatusElement(element)) + return; - info.cancel(); + info.cancel(); - if (NCRConfig.getCommon().enableDebugLog()) { - NCRCore.LOGGER.info("Adding chat report prevention status to ServerStatus packet."); - } + if (NCRConfig.getCommon().enableDebugLog()) { + NCRCore.LOGGER.info("Adding chat report prevention status to ServerStatus packet."); + } - JsonObject object = element.getAsJsonObject(); - object.addProperty("preventsChatReports", true); + JsonObject object = element.getAsJsonObject(); + object.addProperty("preventsChatReports", true); - String string = GSON.toJson(object); - Utf8String.write(buf, string, 32767); + String string = GSON.toJson(object); + Utf8String.write(buf, string, 32767); + } catch (Throwable ex) { + NCRCore.LOGGER.error("Failed to process server status encoding!", ex); + } } @Inject(method = "decode(Lio/netty/buffer/ByteBuf;)Lcom/google/gson/JsonElement;", at = @At("RETURN"), cancellable = true) private void onDecode(ByteBuf buf, CallbackInfoReturnable<JsonElement> info) { - ServerStatusCache.setPreventsReports(false); - JsonElement element = info.getReturnValue(); + try { + ServerStatusCache.setPreventsReports(false); + JsonElement element = info.getReturnValue(); - if (!element.isJsonObject()) - return; + if (!element.isJsonObject()) + return; - JsonObject object = element.getAsJsonObject(); - boolean preventsReports = object.has("preventsChatReports") && object.get("preventsChatReports").getAsBoolean(); + JsonObject object = element.getAsJsonObject(); + boolean preventsReports = object.has("preventsChatReports") && object.get("preventsChatReports").getAsBoolean(); - if (NCRConfig.getCommon().enableDebugLog()) { - NCRCore.LOGGER.info("Received chat report prevention status from ServerStatus packet: " + preventsReports); - } + if (NCRConfig.getCommon().enableDebugLog()) { + NCRCore.LOGGER.info("Received chat report prevention status from ServerStatus packet: " + preventsReports); + } - ServerStatusCache.setPreventsReports(preventsReports); + ServerStatusCache.setPreventsReports(preventsReports); + } catch (Throwable ex) { + NCRCore.LOGGER.error("Failed to process server status decoding!", ex); + } } private boolean isServerStatusElement(JsonElement element) { |
