diff options
| author | Aizistral | 2022-10-24 14:33:53 +0200 |
|---|---|---|
| committer | Aizistral | 2022-10-24 14:33:53 +0200 |
| commit | 4cc029ff8f59edda92795e9072a2cc4f3dcf5ed5 (patch) | |
| tree | c25d6227173d423f51a6a105bce8a567cce26e2b | |
| parent | 8150801a451fa7a6a07f61d7fdc989fc454aa38a (diff) | |
Add config option to disable encryption indicators
Closes #238
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java | 6 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatComponent.java | 21 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java index 71ca2f6..ec552b2 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java @@ -18,7 +18,7 @@ import net.minecraft.util.StringUtil; public class NCRConfigEncryption extends JSONConfig { protected static final String FILE_NAME = "NoChatReports/NCR-Encryption.json"; protected boolean skipWarning = false, enableEncryption = false, encryptPublic = true, - showEncryptionButton = true; + showEncryptionButton = true, showEncryptionIndicators = true; protected String encryptionKey = Encryption.AES_CFB8.getDefaultKey(), encryptionPassphrase = "", algorithmName = Encryption.AES_CFB8.getName(); protected List<String> encryptableCommands = List.of("msg:1", "w:1", "whisper:1", "tell:1", "r:0", "dm:1", @@ -103,6 +103,10 @@ public class NCRConfigEncryption extends JSONConfig { return this.encryptPublic; } + public boolean showEncryptionIndicators() { + return this.showEncryptionIndicators; + } + public boolean isEnabledAndValid() { return this.isEnabled() && this.isValid(); } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatComponent.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatComponent.java index ce6d522..cad93cd 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatComponent.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatComponent.java @@ -47,18 +47,17 @@ public class MixinChatComponent { + "wrapComponents(Lnet/minecraft/network/chat/FormattedText;ILnet/minecraft/client/gui/Font;" + ")Ljava/util/List;", ordinal = 0, shift = Shift.AFTER), argsOnly = true) private synchronized GuiMessageTag modifyGUITag(GuiMessageTag tag) { - if (this.lastMessageEncrypted) { - this.lastMessageEncrypted = false; - Component tooltip = Component.empty().append(Component.translatable("tag.nochatreports.encrypted", - Component.literal(NCRConfig.getEncryption().getAlgorithm().getName()) - .withStyle(ChatFormatting.BOLD))).append(CommonComponents.NEW_LINE).append( - Component.translatable("tag.nochatreports.encrypted_original", - this.lastMessageOriginal)); - - //System.out.println("Last message original: " + last); - return new GuiMessageTag(0x8B3EC7, ENCRYPTED_ICON, tooltip, "Encrypted"); - } else + if (!NCRConfig.getEncryption().showEncryptionIndicators() || !this.lastMessageEncrypted) return tag; + + this.lastMessageEncrypted = false; + Component tooltip = Component.empty().append(Component.translatable("tag.nochatreports.encrypted", + Component.literal(NCRConfig.getEncryption().getAlgorithm().getName()) + .withStyle(ChatFormatting.BOLD))).append(CommonComponents.NEW_LINE).append( + Component.translatable("tag.nochatreports.encrypted_original", + this.lastMessageOriginal)); + + return new GuiMessageTag(0x8B3EC7, ENCRYPTED_ICON, tooltip, "Encrypted"); } @ModifyArg(index = 0, method = "addMessage(Lnet/minecraft/network/chat/Component;" |
