From d7f6da48492140f9b602c8a4e72ffdee60247e10 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Tue, 30 Aug 2022 12:42:25 +0200 Subject: Rename config classes once more --- .../nochatreports/config/ModMenuIntegration.java | 2 +- .../nochatreports/config/NCRClientConfig.java | 202 --------------------- .../nochatreports/config/NCRCommonConfig.java | 79 -------- .../aizistral/nochatreports/config/NCRConfig.java | 12 +- .../nochatreports/config/NCRConfigClient.java | 202 +++++++++++++++++++++ .../nochatreports/config/NCRConfigCommon.java | 79 ++++++++ 6 files changed, 288 insertions(+), 288 deletions(-) delete mode 100644 src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java delete mode 100644 src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java create mode 100644 src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java create mode 100644 src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java (limited to 'src/main/java/com/aizistral') diff --git a/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java b/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java index 8a18f3d..5253fe1 100644 --- a/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java +++ b/src/main/java/com/aizistral/nochatreports/config/ModMenuIntegration.java @@ -171,7 +171,7 @@ public final class ModMenuIntegration implements ModMenuApi { whitelistedServers.addEntry(entryBuilder.startStrList(Component.translatable("option.NoChatReports.whitelistedServers"), NCRConfig.getClient().whitelistedServers) .setExpanded(true) .setInsertInFront(true) - .setDefaultValue(NCRClientConfig.DEFAULT_WHITELISTED_SERVERS) + .setDefaultValue(NCRConfigClient.DEFAULT_WHITELISTED_SERVERS) .setTooltip(this.makeTooltip("option.NoChatReports.whitelistedServers.tooltip")) .setAddButtonTooltip(Component.translatable("option.NoChatReports.whitelistedServers.addButtonTooltip")) .setRemoveButtonTooltip(Component.translatable("option.NoChatReports.whitelistedServers.removeButtonTooltip")) diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java deleted file mode 100644 index a07c92d..0000000 --- a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.aizistral.nochatreports.config; - -import java.util.ArrayList; -import java.util.List; - -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 net.minecraft.client.multiplayer.resolver.ServerAddress; - -public final class NCRClientConfig extends JSONConfig { - protected static final String FILE_NAME = "NoChatReports/NCR-Client.json"; - protected static final List DEFAULT_WHITELISTED_SERVERS = new ArrayList<>(); - - protected boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true, - hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true, - alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true, - whitelistAllServers = false, verifiedIconEnabled = true; - protected int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0; - protected List whitelistedServers = DEFAULT_WHITELISTED_SERVERS; - - protected NCRClientConfig() { - super(FILE_NAME); - } - - @Override - public NCRClientConfig getDefault() { - return new NCRClientConfig(); - } - - /** - * @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 boolean demandOnServer() { - return this.demandOnServer; - } - - /** - * @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 boolean showServerSafety() { - return this.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 List getWhitelistedServers() { - return this.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 boolean isWhitelistedServer(ServerAddress address) { - return this.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 boolean hideRedChatIndicators() { - return this.hideRedChatIndicators; - } - - /** - * @return True if vanilla's modified/hidden messages trust indicator should be removed.

- * - * This is true by default. - * - * @see MixinChatListener#onEvaluateTrustLevel - */ - - public boolean hideYellowChatIndicators() { - return this.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 boolean hideGrayChatIndicators() { - return this.hideGrayChatIndicators; - } - - /** - * @return True if "Chat messages can't be verified" toast should be removed.

- * - * This is true by default. - * - * @see MixinToastComponent#onAddToast - */ - - public boolean hideWarningToast() { - return this.hideWarningToast; - } - - /** - * @return True if reporting buttons should always be hidden from social interactions screen, - * instead of simply being disabled.

- * - * This is false by default. - */ - - public boolean alwaysHideReportButton() { - return this.alwaysHideReportButton; - } - - /** - * @return True if sending telemetry to Mojang should be disabled.

- * - * This is true by default. - */ - - public boolean disableTelemetry() { - return this.disableTelemetry; - } - - /** - * @return True if the configuration reload button should be displayed in multiplayer screen. - *

- * - * This is true by default. - */ - - public boolean showReloadButton() { - return this.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 boolean whitelistAllServers() { - return this.whitelistAllServers; - } - - /** - * @return True if "Safe Server" icon should be displayed in multiplayer menu for servers that - * declare themselves as preventing chat reports.

- * - * This is true by default. - */ - - public boolean verifiedIconEnabled() { - return this.verifiedIconEnabled; - } - - - /** - * @return X offset for "Safe Server" icon in multiplayer menu. - */ - - public int getVerifiedIconOffsetX() { - return 16 + this.verifiedIconOffsetX; - } - - /** - * @return Y offset for "Safe Server" icon in multiplayer menu. - */ - - public int getVerifiedIconOffsetY() { - return 12 + this.verifiedIconOffsetY; - } - -} diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java deleted file mode 100644 index 509100f..0000000 --- a/src/main/java/com/aizistral/nochatreports/config/NCRCommonConfig.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.aizistral.nochatreports.config; - -import java.util.ArrayList; -import java.util.List; - -import com.google.common.base.Preconditions; - -public final class NCRCommonConfig extends JSONConfig { - protected static final String FILE_NAME = "NoChatReports/NCR-Common.json"; - - protected String demandOnClientMessage = "You do not have No Chat Reports, and this server is" - + " configured to require it on client!"; - protected boolean demandOnClient = true, enableDebugLog = false, convertToGameMessage = false, - addQueryData = true; - - protected NCRCommonConfig() { - super(FILE_NAME); - } - - @Override - public NCRCommonConfig getDefault() { - return new NCRCommonConfig(); - } - - /** - * @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 boolean demandOnClient() { - return this.demandOnClient; - } - - /** - * @return Disconnect message that should be shown to client if demandOnClient is - * true and it tries to join without No Chat Reports installed. - */ - - public String demandOnClientMessage() { - return this.demandOnClientMessage; - } - - /** - * @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 boolean convertToGameMessage() { - return this.convertToGameMessage; - } - - /** - * @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 boolean enableDebugLog() { - return this.enableDebugLog; - } - - /** - * @return True if server should include extra query data to help clients know that your server - * is secure.

- * - * This is true by default. - */ - - public boolean addQueryData() { - return this.addQueryData; - } - -} diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java index 450934c..d1b51ff 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfig.java @@ -13,14 +13,14 @@ import net.fabricmc.api.Environment; import net.fabricmc.loader.api.FabricLoader; public final class NCRConfig { - private static NCRCommonConfig common = null; - private static NCRClientConfig client = null; + private static NCRConfigCommon common = null; + private static NCRConfigClient client = null; private NCRConfig() { throw new IllegalStateException("Can't touch this"); } - public static NCRCommonConfig getCommon() { + public static NCRConfigCommon getCommon() { if (common == null) { load(); } @@ -29,7 +29,7 @@ public final class NCRConfig { } @Environment(EnvType.CLIENT) - public static NCRClientConfig getClient() { + public static NCRConfigClient getClient() { if (client == null) { load(); } @@ -38,10 +38,10 @@ public final class NCRConfig { } public static void load() { - common = JSONConfig.loadConfig(NCRCommonConfig.class, NCRCommonConfig::new, NCRCommonConfig.FILE_NAME); + common = JSONConfig.loadConfig(NCRConfigCommon.class, NCRConfigCommon::new, NCRConfigCommon.FILE_NAME); if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - client = JSONConfig.loadConfig(NCRClientConfig.class, NCRClientConfig::new, NCRClientConfig.FILE_NAME); + client = JSONConfig.loadConfig(NCRConfigClient.class, NCRConfigClient::new, NCRConfigClient.FILE_NAME); } save(); diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java new file mode 100644 index 0000000..4ae79cd --- /dev/null +++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java @@ -0,0 +1,202 @@ +package com.aizistral.nochatreports.config; + +import java.util.ArrayList; +import java.util.List; + +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 net.minecraft.client.multiplayer.resolver.ServerAddress; + +public final class NCRConfigClient extends JSONConfig { + protected static final String FILE_NAME = "NoChatReports/NCR-Client.json"; + protected static final List DEFAULT_WHITELISTED_SERVERS = new ArrayList<>(); + + protected boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true, + hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true, + alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true, + whitelistAllServers = false, verifiedIconEnabled = true; + protected int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0; + protected List whitelistedServers = DEFAULT_WHITELISTED_SERVERS; + + protected NCRConfigClient() { + super(FILE_NAME); + } + + @Override + public NCRConfigClient getDefault() { + return new NCRConfigClient(); + } + + /** + * @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 boolean demandOnServer() { + return this.demandOnServer; + } + + /** + * @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 boolean showServerSafety() { + return this.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 List getWhitelistedServers() { + return this.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 boolean isWhitelistedServer(ServerAddress address) { + return this.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 boolean hideRedChatIndicators() { + return this.hideRedChatIndicators; + } + + /** + * @return True if vanilla's modified/hidden messages trust indicator should be removed.

+ * + * This is true by default. + * + * @see MixinChatListener#onEvaluateTrustLevel + */ + + public boolean hideYellowChatIndicators() { + return this.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 boolean hideGrayChatIndicators() { + return this.hideGrayChatIndicators; + } + + /** + * @return True if "Chat messages can't be verified" toast should be removed.

+ * + * This is true by default. + * + * @see MixinToastComponent#onAddToast + */ + + public boolean hideWarningToast() { + return this.hideWarningToast; + } + + /** + * @return True if reporting buttons should always be hidden from social interactions screen, + * instead of simply being disabled.

+ * + * This is false by default. + */ + + public boolean alwaysHideReportButton() { + return this.alwaysHideReportButton; + } + + /** + * @return True if sending telemetry to Mojang should be disabled.

+ * + * This is true by default. + */ + + public boolean disableTelemetry() { + return this.disableTelemetry; + } + + /** + * @return True if the configuration reload button should be displayed in multiplayer screen. + *

+ * + * This is true by default. + */ + + public boolean showReloadButton() { + return this.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 boolean whitelistAllServers() { + return this.whitelistAllServers; + } + + /** + * @return True if "Safe Server" icon should be displayed in multiplayer menu for servers that + * declare themselves as preventing chat reports.

+ * + * This is true by default. + */ + + public boolean verifiedIconEnabled() { + return this.verifiedIconEnabled; + } + + + /** + * @return X offset for "Safe Server" icon in multiplayer menu. + */ + + public int getVerifiedIconOffsetX() { + return 16 + this.verifiedIconOffsetX; + } + + /** + * @return Y offset for "Safe Server" icon in multiplayer menu. + */ + + public int getVerifiedIconOffsetY() { + return 12 + this.verifiedIconOffsetY; + } + +} diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java new file mode 100644 index 0000000..7aa0322 --- /dev/null +++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java @@ -0,0 +1,79 @@ +package com.aizistral.nochatreports.config; + +import java.util.ArrayList; +import java.util.List; + +import com.google.common.base.Preconditions; + +public final class NCRConfigCommon extends JSONConfig { + protected static final String FILE_NAME = "NoChatReports/NCR-Common.json"; + + protected String demandOnClientMessage = "You do not have No Chat Reports, and this server is" + + " configured to require it on client!"; + protected boolean demandOnClient = true, enableDebugLog = false, convertToGameMessage = false, + addQueryData = true; + + protected NCRConfigCommon() { + super(FILE_NAME); + } + + @Override + public NCRConfigCommon getDefault() { + return new NCRConfigCommon(); + } + + /** + * @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 boolean demandOnClient() { + return this.demandOnClient; + } + + /** + * @return Disconnect message that should be shown to client if demandOnClient is + * true and it tries to join without No Chat Reports installed. + */ + + public String demandOnClientMessage() { + return this.demandOnClientMessage; + } + + /** + * @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 boolean convertToGameMessage() { + return this.convertToGameMessage; + } + + /** + * @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 boolean enableDebugLog() { + return this.enableDebugLog; + } + + /** + * @return True if server should include extra query data to help clients know that your server + * is secure.

+ * + * This is true by default. + */ + + public boolean addQueryData() { + return this.addQueryData; + } + +} -- cgit v1.2.3