From 64bf55ccc5166e4f064fd07e69be20b046d68cac Mon Sep 17 00:00:00 2001
From: Aizistral
Date: Fri, 26 Aug 2022 18:07:23 +0200
Subject: Rename `NoReportsConfig` to `NCRConfig`
---
.../com/aizistral/nochatreports/NoChatReports.java | 6 +-
.../nochatreports/NoChatReportsClient.java | 6 +-
.../nochatreports/config/ModMenuIntegration.java | 56 ++--
.../aizistral/nochatreports/config/NCRConfig.java | 295 +++++++++++++++++++++
.../nochatreports/config/NoReportsConfig.java | 295 ---------------------
.../nochatreports/core/ServerSafetyLevel.java | 4 +-
.../nochatreports/gui/UnsafeServerScreen.java | 6 +-
.../mixins/client/MixinChatListener.java | 8 +-
.../mixins/client/MixinChatScreen.java | 4 +-
.../mixins/client/MixinClientTelemetryManager.java | 4 +-
.../mixins/client/MixinConnectScreen.java | 4 +-
.../mixins/client/MixinGuiMessageTag.java | 4 +-
.../mixins/client/MixinJoinMultiplayerScreen.java | 6 +-
.../mixins/client/MixinLocalPlayer.java | 2 +-
.../mixins/client/MixinPlayerEntry.java | 4 +-
.../mixins/client/MixinServerStatusPinger$1.java | 4 +-
.../mixins/client/MixinToastComponent.java | 4 +-
.../mixins/common/MixinServerStatus.java | 4 +-
.../mixins/common/MixinServerStatusSerializer.java | 4 +-
.../server/MixinServerGamePacketListenerImpl.java | 6 +-
.../mixins/server/MixinServerboundChatPacket.java | 4 +-
21 files changed, 365 insertions(+), 365 deletions(-)
create mode 100644 src/main/java/com/aizistral/nochatreports/config/NCRConfig.java
delete mode 100644 src/main/java/com/aizistral/nochatreports/config/NoReportsConfig.java
(limited to 'src/main')
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReports.java b/src/main/java/com/aizistral/nochatreports/NoChatReports.java
index b361852..c2f83de 100644
--- a/src/main/java/com/aizistral/nochatreports/NoChatReports.java
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReports.java
@@ -3,7 +3,7 @@ package com.aizistral.nochatreports;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.network.ServerChannelHandler;
import com.mojang.authlib.minecraft.UserApiService;
import com.mojang.patchy.MojangBlockListSupplier;
@@ -39,12 +39,12 @@ public final class NoChatReports implements ModInitializer {
ServerPlayNetworking.registerGlobalReceiver(CHANNEL, ServerChannelHandler.INSTANCE);
ServerPlayConnectionEvents.JOIN.register(this::onPlayReady);
- NoReportsConfig.loadConfig();
+ NCRConfig.loadConfig();
}
private void onPlayReady(ServerGamePacketListenerImpl handler, PacketSender sender, MinecraftServer server) {
server.execute(() -> {
- if (NoReportsConfig.demandsOnClient() && !ServerPlayNetworking.canSend(handler, CHANNEL)) {
+ if (NCRConfig.demandsOnClient() && !ServerPlayNetworking.canSend(handler, CHANNEL)) {
handler.disconnect(Component.literal("You do not have No Chat Reports, and this server is configured to require it on client!"));
}
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
index a3aab8a..a0ed8de 100644
--- a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
@@ -3,7 +3,7 @@ package com.aizistral.nochatreports;
import java.util.List;
import com.aizistral.nochatreports.core.ServerSafetyState;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.gui.UnsafeServerScreen;
import com.aizistral.nochatreports.mixins.client.AccessorDisconnectedScreen;
@@ -70,7 +70,7 @@ public final class NoChatReportsClient implements ClientModInitializer {
return;
} else if (KEY_DISCONNECT_REASONS.contains(contents.getKey())) {
if (ServerSafetyState.getLastServerAddress() != null) {
- if (!NoReportsConfig.isWhitelistedServer(ServerSafetyState.getLastServerAddress()) && !NoReportsConfig.whitelistAllServers()) {
+ if (!NCRConfig.isWhitelistedServer(ServerSafetyState.getLastServerAddress()) && !NCRConfig.whitelistAllServers()) {
client.setScreen(new UnsafeServerScreen());
} else {
if (ServerSafetyState.getReconnectCount() <= 0) {
@@ -106,7 +106,7 @@ public final class NoChatReportsClient implements ClientModInitializer {
}
}
- if (NoReportsConfig.demandsOnServer() && !ClientPlayNetworking.canSend(NoChatReports.CHANNEL)) {
+ if (NCRConfig.demandsOnServer() && !ClientPlayNetworking.canSend(NoChatReports.CHANNEL)) {
handler.getConnection().disconnect(Component.translatable("disconnect.nochatreports.client"));
}
});
diff --git a/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java b/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java
index 4862ab9..5445ce4 100644
--- a/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java
+++ b/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java
@@ -62,10 +62,10 @@ public final class ModMenuIntegration implements ModMenuApi {
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
// Set an option for showServerSafety
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.showServerSafety"), NoReportsConfig.getInstance().showServerSafety)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.showServerSafety"), NCRConfig.getInstance().showServerSafety)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.showServerSafety.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().showServerSafety = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().showServerSafety = newValue)
.build());
// Add link for documentation for showServerSafety
@@ -75,80 +75,80 @@ public final class ModMenuIntegration implements ModMenuApi {
.build());
// Set an option for hideRedChatIndicators
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideRedChatIndicators"), NoReportsConfig.getInstance().hideRedChatIndicators)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideRedChatIndicators"), NCRConfig.getInstance().hideRedChatIndicators)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.hideRedChatIndicators.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().hideRedChatIndicators = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().hideRedChatIndicators = newValue)
.build());
// Set an option for hideYellowChatIndicators
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideYellowChatIndicators"), NoReportsConfig.getInstance().hideYellowChatIndicators)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideYellowChatIndicators"), NCRConfig.getInstance().hideYellowChatIndicators)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.hideYellowChatIndicators.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().hideYellowChatIndicators = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().hideYellowChatIndicators = newValue)
.build());
// Set an option for hideGrayChatIndicators
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideGrayChatIndicators"), NoReportsConfig.getInstance().hideGrayChatIndicators)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideGrayChatIndicators"), NCRConfig.getInstance().hideGrayChatIndicators)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.hideGrayChatIndicators.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().hideGrayChatIndicators = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().hideGrayChatIndicators = newValue)
.build());
// Set an option for hideWarningToast
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideWarningToast"), NoReportsConfig.getInstance().hideWarningToast)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.hideWarningToast"), NCRConfig.getInstance().hideWarningToast)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.hideWarningToast.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().hideWarningToast = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().hideWarningToast = newValue)
.build());
// Set an option for alwaysHideReportButton
- visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.alwaysHideReportButton"), NoReportsConfig.getInstance().alwaysHideReportButton)
+ visual.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.alwaysHideReportButton"), NCRConfig.getInstance().alwaysHideReportButton)
.setDefaultValue(false)
.setTooltip(this.makeTooltip("option.NoChatReports.alwaysHideReportButton.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().alwaysHideReportButton = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().alwaysHideReportButton = newValue)
.build());
// Set an option for demandOnServer
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.demandOnServer"), NoReportsConfig.getInstance().demandOnServer)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.demandOnServer"), NCRConfig.getInstance().demandOnServer)
.setDefaultValue(false)
.setTooltip(this.makeTooltip("option.NoChatReports.demandOnServer.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().demandOnServer = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().demandOnServer = newValue)
.build());
// Set an option for enableDebugLog
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.enableDebugLog"), NoReportsConfig.getInstance().enableDebugLog)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.enableDebugLog"), NCRConfig.getInstance().enableDebugLog)
.setDefaultValue(false)
.setTooltip(this.makeTooltip("option.NoChatReports.enableDebugLog.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().enableDebugLog = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().enableDebugLog = newValue)
.build());
// Set an option for convertToGameMessage
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.convertToGameMessage"), NoReportsConfig.getInstance().convertToGameMessage)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.convertToGameMessage"), NCRConfig.getInstance().convertToGameMessage)
.setDefaultValue(false)
.setTooltip(this.makeTooltip("option.NoChatReports.convertToGameMessage.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().convertToGameMessage = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().convertToGameMessage = newValue)
.build());
// Set an option for disableTelemetry
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.disableTelemetry"), NoReportsConfig.getInstance().disableTelemetry)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.disableTelemetry"), NCRConfig.getInstance().disableTelemetry)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.disableTelemetry.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().disableTelemetry = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().disableTelemetry = newValue)
.build());
// Set an option for showReloadButton
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.showReloadButton"), NoReportsConfig.getInstance().showReloadButton)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.showReloadButton"), NCRConfig.getInstance().showReloadButton)
.setDefaultValue(true)
.setTooltip(this.makeTooltip("option.NoChatReports.showReloadButton.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().showReloadButton = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().showReloadButton = newValue)
.build());
// Set an option for whitelistAllServers
- technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.whitelistAllServers"), NoReportsConfig.getInstance().whitelistAllServers)
+ technical.addEntry(entryBuilder.startBooleanToggle(Component.translatable("option.NoChatReports.whitelistAllServers"), NCRConfig.getInstance().whitelistAllServers)
.setDefaultValue(false)
.setTooltip(this.makeTooltip("option.NoChatReports.whitelistAllServers.tooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().whitelistAllServers = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().whitelistAllServers = newValue)
.build());
// Instructions for adding servers
@@ -156,21 +156,21 @@ public final class ModMenuIntegration implements ModMenuApi {
.build());
// Add or remove whitelisted servers
- whitelistedServers.addEntry(entryBuilder.startStrList(Component.translatable("option.NoChatReports.whitelistedServers"), NoReportsConfig.getInstance().whitelistedServers)
+ whitelistedServers.addEntry(entryBuilder.startStrList(Component.translatable("option.NoChatReports.whitelistedServers"), NCRConfig.getInstance().whitelistedServers)
.setExpanded(true)
.setInsertInFront(true)
.setDefaultValue(DEFAULT_WHITELISTED_SERVERS)
.setTooltip(this.makeTooltip("option.NoChatReports.whitelistedServers.tooltip"))
.setAddButtonTooltip(Component.translatable("option.NoChatReports.whitelistedServers.addButtonTooltip"))
.setRemoveButtonTooltip(Component.translatable("option.NoChatReports.whitelistedServers.removeButtonTooltip"))
- .setSaveConsumer(newValue -> NoReportsConfig.getInstance().whitelistedServers = newValue)
+ .setSaveConsumer(newValue -> NCRConfig.getInstance().whitelistedServers = newValue)
.setCreateNewInstance(baseListEntry -> new StringListListEntry.StringListCell(Language.getInstance().getOrDefault(("option.NoChatReports.whitelistedServers.serverAddress")), baseListEntry))
.build());
// Save config
builder.setSavingRunnable(() -> {
- NoReportsConfig.saveConfig();
- NoReportsConfig.loadConfig();
+ NCRConfig.saveConfig();
+ NCRConfig.loadConfig();
});
return builder.build();
};
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java
new file mode 100644
index 0000000..7abf623
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java
@@ -0,0 +1,295 @@
+package com.aizistral.nochatreports.config;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import com.aizistral.nochatreports.NoChatReports;
+import com.aizistral.nochatreports.core.ServerSafetyLevel;
+import com.aizistral.nochatreports.gui.UnsafeServerScreen;
+import com.aizistral.nochatreports.mixins.client.MixinChatListener;
+import com.aizistral.nochatreports.mixins.client.MixinToastComponent;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
+import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
+
+import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.client.multiplayer.chat.ChatTrustLevel;
+import net.minecraft.client.multiplayer.resolver.ServerAddress;
+import net.minecraft.util.Tuple;
+
+/**
+ * Simple implementation of JSON-config for the mod. Can be loaded at any time and does not depend
+ * on modloader-specific API. The only disadvantage is that we don't get to comment options.
+ *
+ * For now, the config file is called NoChatReports.json and is located in default config
+ * folder. In the future this should be separated into client and server configs.
+ *
+ * @author Aizistral
+ */
+
+public final class NCRConfig {
+ private static final Path CONFIG_FILE = FabricLoader.getInstance().getConfigDir().resolve("NoChatReports.json");
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+ private static NCRConfig INSTANCE;
+ protected boolean demandOnClient = true, demandOnServer = false, enableDebugLog = false,
+ convertToGameMessage = false, showServerSafety = true, hideRedChatIndicators = true,
+ hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true,
+ alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true,
+ whitelistAllServers = false, addQueryData = true;
+ protected List whitelistedServers;
+
+ protected static NCRConfig getInstance() {
+ if (INSTANCE == null) {
+ loadConfig();
+ }
+
+ return INSTANCE;
+ }
+
+ /**
+ * Loads (or reloads) the config from local file, or creates default one if that fails.
+ * Re-searializes validated {@link #INSTANCE} object back into the file.
+ */
+
+ public static void loadConfig() {
+ NoChatReports.LOGGER.info(INSTANCE == null ? "Loading config..." : "Reloading config...");
+
+ INSTANCE = readFile();
+
+ if (INSTANCE == null) {
+ INSTANCE = new NCRConfig();
+ }
+
+ if (INSTANCE.whitelistedServers == null) {
+ INSTANCE.whitelistedServers = new ArrayList<>();
+ }
+
+ writeFile(INSTANCE);
+ }
+
+ /**
+ * Writes current config instance into local file.
+ */
+
+ public static void saveConfig() {
+ if (INSTANCE != null) {
+ writeFile(INSTANCE);
+ }
+ }
+
+ @Nullable
+ private static NCRConfig readFile() {
+ if (!Files.isRegularFile(CONFIG_FILE))
+ return null;
+
+ try (BufferedReader reader = Files.newBufferedReader(CONFIG_FILE)) {
+ return GSON.fromJson(reader, NCRConfig.class);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private static void writeFile(NCRConfig instance) {
+ try (BufferedWriter writer = Files.newBufferedWriter(CONFIG_FILE)) {
+ GSON.toJson(instance, writer);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * @return True if server with No Chat Reports installed should demand that mod is present on
+ * every client that tries to join. Mod's installation on client is optional otherwise.
+ *
+ * This is false by default.
+ */
+
+ public static boolean demandsOnClient() {
+ return getInstance().demandOnClient;
+ }
+
+ /**
+ * @return True if client with No Chat Reports installed should demand that mod is present on
+ * every server that it tries to join. In that case client will not be able to join servers that
+ * don't have the mod installed. Servers without the mod can still provide varying degrees of
+ * safety, which {@link ServerSafetyLevel} and respective icon in bottom-right corner of the chat
+ * screen is designed to indicate.
+ *
+ * This is false by default.
+ */
+
+ public static boolean demandsOnServer() {
+ return getInstance().demandOnServer;
+ }
+
+ /**
+ * @return True if server should convert all player messages to system messages. System messages
+ * do not feature signatures and look completely identical in the chat, with exception of gray line
+ * next to them added in pre-release 3. They are also unselectable for chat reporting.
+ *
+ * This is false by default.
+ */
+
+ public static boolean convertToGameMessage() {
+ return getInstance().convertToGameMessage;
+ }
+
+ /**
+ * @return True if current {@link ServerSafetyLevel} should be indicated on client by an icon in
+ * the bottom-right corner of chat screen.
+ *
+ * This is true by default.
+ */
+
+ public static boolean showServerSafety() {
+ return getInstance().showServerSafety;
+ }
+
+ /**
+ * @return Current list of whitelisted unsafe servers. Used on client to remember which servers
+ * user disabled unsafety warnings for.
+ *
+ * This is empty by default.
+ *
+ * @see UnsafeServerScreen
+ */
+
+ public static List getWhitelistedServers() {
+ return getInstance().whitelistedServers;
+ }
+
+ /**
+ * @param address Address of the server to be check.
+ * @return Whether this server is in the whitelist of unsafe servers, as returned by
+ * {@link #getWhitelistedServers()}.
+ * @see UnsafeServerScreen
+ */
+
+ public static boolean isWhitelistedServer(ServerAddress address) {
+ return getWhitelistedServers().contains(address.getHost() + ":" + address.getPort());
+ }
+
+ /**
+ * @return True if vanilla's unsigned messages trust indicator should be removed.
+ *
+ * This is true by default.
+ *
+ * @see MixinChatListener#onEvaluateTrustLevel
+ */
+
+ public static boolean hideRedChatIndicators() {
+ return getInstance().hideRedChatIndicators;
+ }
+
+ /**
+ * @return True if vanilla's modified/hidden messages trust indicator should be removed.
+ *
+ * This is true by default.
+ *
+ * @see MixinChatListener#onEvaluateTrustLevel
+ */
+
+ public static boolean hideYellowChatIndicators() {
+ return getInstance().hideYellowChatIndicators;
+ }
+
+ /**
+ * @return True if vanilla's system messages trust indicator should be removed.
+ *
+ * This is true by default.
+ *
+ * @see com.aizistral.nochatreports.mixins.client.MixinGuiMessageTag#onSystem
+ */
+
+ public static boolean hideGrayChatIndicators() {
+ return getInstance().hideGrayChatIndicators;
+ }
+
+ /**
+ * @return True if "Chat messages can't be verified" toast should be removed.
+ *
+ * This is true by default.
+ *
+ * @see MixinToastComponent#onAddToast
+ */
+
+ public static boolean hideWarningToast() {
+ return getInstance().hideWarningToast;
+ }
+
+ /**
+ * @return True if mod should log some additional information about its activity and message
+ * signatures. Generally only useful for debugging.
+ *
+ * This is false by default.
+ */
+
+ public static boolean enableDebugLog() {
+ return getInstance().enableDebugLog;
+ }
+
+ /**
+ * @return True if reporting buttons should always be hidden from social interactions screen,
+ * instead of simply being disabled.
+ *
+ * This is false by default.
+ */
+
+ public static boolean alwaysHideReportButton() {
+ return getInstance().alwaysHideReportButton;
+ }
+
+ /**
+ * @return True if sending telemetry to Mojang should be disabled.
+ *
+ * This is true by default.
+ */
+
+ public static boolean disableTelemetry() {
+ return getInstance().disableTelemetry;
+ }
+
+ /**
+ * @return True if the configuration reload button should be displayed in multiplayer screen.
+ *
+ *
+ * This is true by default.
+ */
+
+ public static boolean showReloadButton() {
+ return getInstance().showReloadButton;
+ }
+
+ /**
+ * @return True if the full-screen warning should be skipped for servers that require chat signing,
+ * letting users simply join the server. Because of that, servers will no longer be added to the whitelist.
+ *
+ *
+ * This is false by default.
+ */
+
+ public static boolean whitelistAllServers() {
+ return getInstance().whitelistAllServers;
+ }
+
+ /**
+ * @return True if server should include extra query data to help clients know that your server
+ * is secure.
+ *
+ * This is true by default.
+ */
+
+ public static boolean addQueryData() {
+ return getInstance().addQueryData;
+ }
+
+}
diff --git a/src/main/java/com/aizistral/nochatreports/config/NoReportsConfig.java b/src/main/java/com/aizistral/nochatreports/config/NoReportsConfig.java
deleted file mode 100644
index 4e903dc..0000000
--- a/src/main/java/com/aizistral/nochatreports/config/NoReportsConfig.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package com.aizistral.nochatreports.config;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import com.aizistral.nochatreports.NoChatReports;
-import com.aizistral.nochatreports.core.ServerSafetyLevel;
-import com.aizistral.nochatreports.gui.UnsafeServerScreen;
-import com.aizistral.nochatreports.mixins.client.MixinChatListener;
-import com.aizistral.nochatreports.mixins.client.MixinToastComponent;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
-import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
-
-import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.client.multiplayer.chat.ChatTrustLevel;
-import net.minecraft.client.multiplayer.resolver.ServerAddress;
-import net.minecraft.util.Tuple;
-
-/**
- * Simple implementation of JSON-config for the mod. Can be loaded at any time and does not depend
- * on modloader-specific API. The only disadvantage is that we don't get to comment options.
- *
- * For now, the config file is called NoChatReports.json and is located in default config
- * folder. In the future this should be separated into client and server configs.
- *
- * @author Aizistral
- */
-
-public final class NoReportsConfig {
- private static final Path CONFIG_FILE = FabricLoader.getInstance().getConfigDir().resolve("NoChatReports.json");
- private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
- private static NoReportsConfig INSTANCE;
- protected boolean demandOnClient = true, demandOnServer = false, enableDebugLog = false,
- convertToGameMessage = false, showServerSafety = true, hideRedChatIndicators = true,
- hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true,
- alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true,
- whitelistAllServers = false, addQueryData = true;
- protected List whitelistedServers;
-
- protected static NoReportsConfig getInstance() {
- if (INSTANCE == null) {
- loadConfig();
- }
-
- return INSTANCE;
- }
-
- /**
- * Loads (or reloads) the config from local file, or creates default one if that fails.
- * Re-searializes validated {@link #INSTANCE} object back into the file.
- */
-
- public static void loadConfig() {
- NoChatReports.LOGGER.info(INSTANCE == null ? "Loading config..." : "Reloading config...");
-
- INSTANCE = readFile();
-
- if (INSTANCE == null) {
- INSTANCE = new NoReportsConfig();
- }
-
- if (INSTANCE.whitelistedServers == null) {
- INSTANCE.whitelistedServers = new ArrayList<>();
- }
-
- writeFile(INSTANCE);
- }
-
- /**
- * Writes current config instance into local file.
- */
-
- public static void saveConfig() {
- if (INSTANCE != null) {
- writeFile(INSTANCE);
- }
- }
-
- @Nullable
- private static NoReportsConfig readFile() {
- if (!Files.isRegularFile(CONFIG_FILE))
- return null;
-
- try (BufferedReader reader = Files.newBufferedReader(CONFIG_FILE)) {
- return GSON.fromJson(reader, NoReportsConfig.class);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeFile(NoReportsConfig instance) {
- try (BufferedWriter writer = Files.newBufferedWriter(CONFIG_FILE)) {
- GSON.toJson(instance, writer);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * @return True if server with No Chat Reports installed should demand that mod is present on
- * every client that tries to join. Mod's installation on client is optional otherwise.
- *
- * This is false by default.
- */
-
- public static boolean demandsOnClient() {
- return getInstance().demandOnClient;
- }
-
- /**
- * @return True if client with No Chat Reports installed should demand that mod is present on
- * every server that it tries to join. In that case client will not be able to join servers that
- * don't have the mod installed. Servers without the mod can still provide varying degrees of
- * safety, which {@link ServerSafetyLevel} and respective icon in bottom-right corner of the chat
- * screen is designed to indicate.
- *
- * This is false by default.
- */
-
- public static boolean demandsOnServer() {
- return getInstance().demandOnServer;
- }
-
- /**
- * @return True if server should convert all player messages to system messages. System messages
- * do not feature signatures and look completely identical in the chat, with exception of gray line
- * next to them added in pre-release 3. They are also unselectable for chat reporting.
- *
- * This is false by default.
- */
-
- public static boolean convertToGameMessage() {
- return getInstance().convertToGameMessage;
- }
-
- /**
- * @return True if current {@link ServerSafetyLevel} should be indicated on client by an icon in
- * the bottom-right corner of chat screen.
- *
- * This is true by default.
- */
-
- public static boolean showServerSafety() {
- return getInstance().showServerSafety;
- }
-
- /**
- * @return Current list of whitelisted unsafe servers. Used on client to remember which servers
- * user disabled unsafety warnings for.
- *
- * This is empty by default.
- *
- * @see UnsafeServerScreen
- */
-
- public static List getWhitelistedServers() {
- return getInstance().whitelistedServers;
- }
-
- /**
- * @param address Address of the server to be check.
- * @return Whether this server is in the whitelist of unsafe servers, as returned by
- * {@link #getWhitelistedServers()}.
- * @see UnsafeServerScreen
- */
-
- public static boolean isWhitelistedServer(ServerAddress address) {
- return getWhitelistedServers().contains(address.getHost() + ":" + address.getPort());
- }
-
- /**
- * @return True if vanilla's unsigned messages trust indicator should be removed.
- *
- * This is true by default.
- *
- * @see MixinChatListener#onEvaluateTrustLevel
- */
-
- public static boolean hideRedChatIndicators() {
- return getInstance().hideRedChatIndicators;
- }
-
- /**
- * @return True if vanilla's modified/hidden messages trust indicator should be removed.
- *
- * This is true by default.
- *
- * @see MixinChatListener#onEvaluateTrustLevel
- */
-
- public static boolean hideYellowChatIndicators() {
- return getInstance().hideYellowChatIndicators;
- }
-
- /**
- * @return True if vanilla's system messages trust indicator should be removed.
- *
- * This is true by default.
- *
- * @see com.aizistral.nochatreports.mixins.client.MixinGuiMessageTag#onSystem
- */
-
- public static boolean hideGrayChatIndicators() {
- return getInstance().hideGrayChatIndicators;
- }
-
- /**
- * @return True if "Chat messages can't be verified" toast should be removed.
- *
- * This is true by default.
- *
- * @see MixinToastComponent#onAddToast
- */
-
- public static boolean hideWarningToast() {
- return getInstance().hideWarningToast;
- }
-
- /**
- * @return True if mod should log some additional information about its activity and message
- * signatures. Generally only useful for debugging.
- *
- * This is false by default.
- */
-
- public static boolean enableDebugLog() {
- return getInstance().enableDebugLog;
- }
-
- /**
- * @return True if reporting buttons should always be hidden from social interactions screen,
- * instead of simply being disabled.
- *
- * This is false by default.
- */
-
- public static boolean alwaysHideReportButton() {
- return getInstance().alwaysHideReportButton;
- }
-
- /**
- * @return True if sending telemetry to Mojang should be disabled.
- *
- * This is true by default.
- */
-
- public static boolean disableTelemetry() {
- return getInstance().disableTelemetry;
- }
-
- /**
- * @return True if the configuration reload button should be displayed in multiplayer screen.
- *
- *
- * This is true by default.
- */
-
- public static boolean showReloadButton() {
- return getInstance().showReloadButton;
- }
-
- /**
- * @return True if the full-screen warning should be skipped for servers that require chat signing,
- * letting users simply join the server. Because of that, servers will no longer be added to the whitelist.
- *
- *
- * This is false by default.
- */
-
- public static boolean whitelistAllServers() {
- return getInstance().whitelistAllServers;
- }
-
- /**
- * @return True if server should include extra query data to help clients know that your server
- * is secure.
- *
- * This is true by default.
- */
-
- public static boolean addQueryData() {
- return getInstance().addQueryData;
- }
-
-}
diff --git a/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java b/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java
index db0485f..11d867f 100644
--- a/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java
+++ b/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java
@@ -1,7 +1,7 @@
package com.aizistral.nochatreports.core;
import com.aizistral.nochatreports.NoChatReports;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -48,7 +48,7 @@ public enum ServerSafetyLevel {
@Environment(EnvType.CLIENT)
public Component getTooltip() {
- if(NoReportsConfig.whitelistAllServers() && this.equals(ServerSafetyLevel.INSECURE))
+ if(NCRConfig.whitelistAllServers() && this.equals(ServerSafetyLevel.INSECURE))
return Component.translatable("gui.nochatreports.status_insecure_whitelist_all_servers");
return Component.translatable("gui.nochatreports.status_" + this.name().toLowerCase());
}
diff --git a/src/main/java/com/aizistral/nochatreports/gui/UnsafeServerScreen.java b/src/main/java/com/aizistral/nochatreports/gui/UnsafeServerScreen.java
index 6e58036..a502529 100644
--- a/src/main/java/com/aizistral/nochatreports/gui/UnsafeServerScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/gui/UnsafeServerScreen.java
@@ -3,7 +3,7 @@ package com.aizistral.nochatreports.gui;
import javax.print.attribute.standard.MediaSize.NA;
import com.aizistral.nochatreports.NoChatReportsClient;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyState;
import net.fabricmc.api.EnvType;
@@ -52,8 +52,8 @@ public final class UnsafeServerScreen extends WarningScreen {
if (address != null) {
if (this.stopShowing.selected()) {
- NoReportsConfig.getWhitelistedServers().add(address.getHost() + ":" + address.getPort());
- NoReportsConfig.saveConfig();
+ NCRConfig.getWhitelistedServers().add(address.getHost() + ":" + address.getPort());
+ NCRConfig.saveConfig();
}
ServerSafetyState.setAllowsUnsafeServer(true);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
index 0c767af..d5ac4a4 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatListener.java
@@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.aizistral.nochatreports.NoChatReports;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.client.multiplayer.chat.ChatListener;
@@ -49,16 +49,16 @@ public class MixinChatListener {
return;
}
- if (evaluate == ChatTrustLevel.NOT_SECURE && NoReportsConfig.hideRedChatIndicators()) {
+ if (evaluate == ChatTrustLevel.NOT_SECURE && NCRConfig.hideRedChatIndicators()) {
info.setReturnValue(ChatTrustLevel.SECURE);
} else if ((evaluate == ChatTrustLevel.FILTERED || evaluate == ChatTrustLevel.MODIFIED)
- && NoReportsConfig.hideYellowChatIndicators()) {
+ && NCRConfig.hideYellowChatIndicators()) {
info.setReturnValue(ChatTrustLevel.SECURE);
}
}
// Debug never dies
- if (NoReportsConfig.enableDebugLog()) {
+ if (NCRConfig.enableDebugLog()) {
NoChatReports.LOGGER.info("Received message: {}, from: {}, signature: {}",
Component.Serializer.toStableJson(playerChatMessage.serverContent()),
playerChatMessage.signer().profileId(),
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
index 81ccdab..5bbf2f1 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
@@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.aizistral.nochatreports.core.ServerSafetyState;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
@@ -49,7 +49,7 @@ public abstract class MixinChatScreen extends Screen {
@Inject(method = "init", at = @At("HEAD"))
private void onInit(CallbackInfo info) {
- if (!NoReportsConfig.showServerSafety())
+ if (!NCRConfig.showServerSafety())
return;
ServerSafetyLevel trust = this.minecraft.isLocalServer() ? ServerSafetyLevel.SECURE : ServerSafetyState.getCurrent();
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientTelemetryManager.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientTelemetryManager.java
index f7f7366..578478b 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientTelemetryManager.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientTelemetryManager.java
@@ -1,6 +1,6 @@
package com.aizistral.nochatreports.mixins.client;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.mojang.authlib.minecraft.TelemetrySession;
import com.mojang.authlib.minecraft.UserApiService;
@@ -24,7 +24,7 @@ public class MixinClientTelemetryManager {
+ "newTelemetrySession(Ljava/util/concurrent/Executor;)Lcom/mojang/authlib/minecraft/TelemetrySession;",
remap = false))
private TelemetrySession onCreateTelemetrySession(UserApiService service, Executor executor) {
- if (NoReportsConfig.disableTelemetry())
+ if (NCRConfig.disableTelemetry())
return TelemetrySession.DISABLED;
else
return service.newTelemetrySession(executor);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
index 36cca0b..981bd51 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
@@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.aizistral.nochatreports.NoChatReports;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
@@ -32,7 +32,7 @@ public class MixinConnectScreen {
ServerSafetyState.updateCurrent(ServerSafetyLevel.UNKNOWN); // just to be 100% sure
ServerSafetyState.setLastConnectedServer(serverAddress, serverData);
- if (NoReportsConfig.enableDebugLog()) {
+ if (NCRConfig.enableDebugLog()) {
NoChatReports.LOGGER.info("Connecting to: {}, will expose public key: {}",
serverAddress.getHost() + ":" + serverAddress.getPort(),
ServerSafetyState.allowsUnsafeServer());
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinGuiMessageTag.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinGuiMessageTag.java
index 083d5f6..71671ef 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinGuiMessageTag.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinGuiMessageTag.java
@@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import net.minecraft.client.GuiMessageTag;
@@ -21,7 +21,7 @@ public class MixinGuiMessageTag {
@Inject(method = "system", at = @At("HEAD"), cancellable = true)
private static void onSystem(CallbackInfoReturnable info) {
- if (NoReportsConfig.hideGrayChatIndicators()) {
+ if (NCRConfig.hideGrayChatIndicators()) {
info.setReturnValue(null);
}
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
index 3dd4a66..1c3ba06 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
@@ -45,11 +45,11 @@ public abstract class MixinJoinMultiplayerScreen extends Screen {
@Inject(method = "init", at = @At("HEAD"))
private void onInit(CallbackInfo info) {
- if (!NoReportsConfig.showReloadButton())
+ if (!NCRConfig.showReloadButton())
return;
var button = new ImageButton(this.width/2 + 158, this.height - 52, 20, 20, 0, 0, 20, RELOAD_TEXTURE,
- 64, 64, btn -> NoReportsConfig.loadConfig(), (btn, poseStack, i, j) ->
+ 64, 64, btn -> NCRConfig.loadConfig(), (btn, poseStack, i, j) ->
this.renderTooltipNoGap(poseStack, this.minecraft.font.split(RELOAD_TOOLTIP, 250), i, j),
Component.translatable("gui.nochatrepords.reload_config"));
button.active = true;
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
index a88c3da..0d7e617 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
@@ -1,6 +1,6 @@
package com.aizistral.nochatreports.mixins.client;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.mojang.brigadier.ParseResults;
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
index ac98ce0..6f47163 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinPlayerEntry.java
@@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.mojang.blaze3d.vertex.PoseStack;
@@ -47,7 +47,7 @@ public class MixinPlayerEntry {
@Inject(method = "", at = @At("RETURN"))
private void onConstructed(Minecraft minecraft, SocialInteractionsScreen socialInteractionsScreen, UUID uUID, String string, Supplier supplier, boolean reportable, CallbackInfo info) {
- if (NoReportsConfig.alwaysHideReportButton()) {
+ if (NCRConfig.alwaysHideReportButton()) {
this.reportButton = new Button(0, 0, 20, 20, Component.empty(), button -> {}) {
@Override
public void render(PoseStack poseStack, int i, int j, float f) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinServerStatusPinger$1.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinServerStatusPinger$1.java
index 69e8251..3552c07 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinServerStatusPinger$1.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinServerStatusPinger$1.java
@@ -1,7 +1,7 @@
package com.aizistral.nochatreports.mixins.client;
import com.aizistral.nochatreports.NoChatReports;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerDataExtension;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
@@ -31,7 +31,7 @@ public class MixinServerStatusPinger$1 {
boolean preventsReports = ((ServerDataExtension) packet.getStatus()).preventsChatReports();
((ServerDataExtension) this.val$data).setPreventsChatReports(preventsReports);
- if (NoReportsConfig.enableDebugLog()) {
+ if (NCRConfig.enableDebugLog()) {
NoChatReports.LOGGER.info("Received status response packet from server, preventsChatReports: {}",
preventsReports);
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinToastComponent.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinToastComponent.java
index 8e67459..b233e19 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinToastComponent.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinToastComponent.java
@@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import net.minecraft.client.gui.components.toasts.SystemToast;
import net.minecraft.client.gui.components.toasts.SystemToast.SystemToastIds;
@@ -17,7 +17,7 @@ public class MixinToastComponent {
@Inject(method = "addToast", at = @At("HEAD"), cancellable = true)
private void onAddToast(Toast toast, CallbackInfo info) {
- if (NoReportsConfig.hideWarningToast())
+ if (NCRConfig.hideWarningToast())
if (toast instanceof SystemToast sys && sys.getToken() == SystemToastIds.UNSECURE_SERVER_WARNING) {
info.cancel();
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatus.java b/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatus.java
index 98a9d3d..6379fa6 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatus.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatus.java
@@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerDataExtension;
import net.minecraft.network.protocol.game.ClientboundServerDataPacket;
@@ -34,7 +34,7 @@ public class MixinServerStatus implements ServerDataExtension {
@Inject(method = "enforcesSecureChat", at = @At("HEAD"), cancellable = true)
public void onSecureChatCheck(CallbackInfoReturnable info) {
- if (NoReportsConfig.convertToGameMessage()) {
+ if (NCRConfig.convertToGameMessage()) {
info.setReturnValue(true);
}
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatusSerializer.java b/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatusSerializer.java
index acc710f..87c252d 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatusSerializer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/common/MixinServerStatusSerializer.java
@@ -1,6 +1,6 @@
package com.aizistral.nochatreports.mixins.common;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerDataExtension;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
@@ -30,7 +30,7 @@ public class MixinServerStatusSerializer {
at = @At("RETURN"))
private void onSerialize(ServerStatus serverStatus, Type type, JsonSerializationContext context,
CallbackInfoReturnable info) {
- if (!NoReportsConfig.addQueryData())
+ if (!NCRConfig.addQueryData())
return;
((JsonObject) info.getReturnValue()).addProperty("preventsChatReports", true);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
index 7726c1c..a6bb8e0 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerGamePacketListenerImpl.java
@@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
@Mixin(ServerGamePacketListenerImpl.class)
public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerConnection {
@@ -35,7 +35,7 @@ public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerC
@Inject(method = "send(Lnet/minecraft/network/protocol/Packet;)V", at = @At("HEAD"), cancellable = true)
private void onSend(Packet> packet, CallbackInfo info) {
- if (NoReportsConfig.convertToGameMessage()) {
+ if (NCRConfig.convertToGameMessage()) {
if (packet instanceof ClientboundPlayerChatHeaderPacket) {
info.cancel();
} else if (packet instanceof ClientboundPlayerChatPacket chat) {
@@ -57,7 +57,7 @@ public abstract class MixinServerGamePacketListenerImpl implements ServerPlayerC
@Inject(method = "send(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketSendListener;)V",
at = @At("HEAD"), cancellable = true)
private void onSend(Packet> packet, @Nullable PacketSendListener packetSendListener, CallbackInfo info) {
- if (NoReportsConfig.convertToGameMessage()) {
+ if (NCRConfig.convertToGameMessage()) {
if (packet instanceof ClientboundPlayerChatHeaderPacket) {
info.cancel();
} else if (packet instanceof ClientboundPlayerChatPacket chat && packetSendListener != null) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
index 54b297e..12d4a01 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/server/MixinServerboundChatPacket.java
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import com.aizistral.nochatreports.config.NoReportsConfig;
+import com.aizistral.nochatreports.config.NCRConfig;
import java.util.UUID;
@@ -20,7 +20,7 @@ public class MixinServerboundChatPacket {
/**
* @reason Strip signatures before relaying messages to other clients, if they arrive signed
* This is important for mod to be able to operate in server-only mode without
- * {@link NoReportsConfig#convertToGameMessage()} enabled.
+ * {@link NCRConfig#convertToGameMessage()} enabled.
* @author Aizistral
*/
--
cgit v1.2.3