summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/aizistral
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/aizistral')
-rw-r--r--src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java3
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java19
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java4
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java6
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/NCRServerWhitelist.java2
-rw-r--r--src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java73
-rw-r--r--src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java97
-rw-r--r--src/main/java/com/aizistral/nochatreports/gui/RealmsWarningScreen.java50
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java32
9 files changed, 213 insertions, 73 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
index f67821d..7c020f4 100644
--- a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
@@ -8,10 +8,12 @@ import com.aizistral.nochatreports.core.ServerDataExtension;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.aizistral.nochatreports.gui.AwaitConnectionScreen;
+import com.aizistral.nochatreports.gui.RealmsWarningScreen;
import com.aizistral.nochatreports.gui.UnsafeServerScreen;
import com.aizistral.nochatreports.mixins.client.AccessorDisconnectedScreen;
import com.aizistral.nochatreports.network.ClientChannelHandler;
import com.google.common.collect.ImmutableList;
+import com.mojang.realmsclient.RealmsMainScreen;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
@@ -32,6 +34,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.TranslatableContents;
+import net.minecraft.realms.RealmsScreen;
/**
* Client initializer for the mod. Some networking setup here, as well as few screen-related events.
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
index 3ae3deb..0d99199 100644
--- a/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
@@ -18,12 +18,13 @@ import net.minecraft.util.StringUtil;
public final class NCRConfigClient extends JSONConfig {
protected static final String FILE_NAME = "NoChatReports/NCR-Client.json";
- protected boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true,
+ protected volatile boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true,
hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true,
alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true,
whitelistAllServers = false, verifiedIconEnabled = true, showNCRButton = true,
- enableMod = true;
- protected int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0, reconnectAwaitSeconds = 4, postDisconnectAwaitSeconds = 10;
+ enableMod = true, skipRealmsWarning = false;
+ protected volatile int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0, reconnectAwaitSeconds = 4,
+ postDisconnectAwaitSeconds = 10;
protected NCRConfigClient() {
super(FILE_NAME);
@@ -218,4 +219,16 @@ public final class NCRConfigClient extends JSONConfig {
return this.postDisconnectAwaitSeconds;
}
+ /**
+ * @return Whether warning on entering Realms screen should not be displayed.
+ */
+
+ public boolean skipRealmsWarning() {
+ return this.skipRealmsWarning;
+ }
+
+ public void setSkipRealmsWarning(boolean skipRealmsWarning) {
+ this.skipRealmsWarning = skipRealmsWarning;
+ }
+
}
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java
index 7aa0322..e00669d 100644
--- a/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigCommon.java
@@ -8,9 +8,9 @@ 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"
+ protected volatile 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,
+ protected volatile boolean demandOnClient = true, enableDebugLog = false, convertToGameMessage = false,
addQueryData = true;
protected NCRConfigCommon() {
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java
index 71ca2f6..f7470b7 100644
--- a/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigEncryption.java
@@ -17,11 +17,11 @@ 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,
+ protected volatile boolean skipWarning = false, enableEncryption = false, encryptPublic = true,
showEncryptionButton = true;
- protected String encryptionKey = Encryption.AES_CFB8.getDefaultKey(), encryptionPassphrase = "",
+ protected volatile 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",
+ protected volatile List<String> encryptableCommands = List.of("msg:1", "w:1", "whisper:1", "tell:1", "r:0", "dm:1",
"me:0", "m:1", "t:1", "pm:1", "emsg:1", "epm:1", "etell:1", "ewhisper:1");
private transient Encryption algorithm;
private transient boolean isValid = false;
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRServerWhitelist.java b/src/main/java/com/aizistral/nochatreports/config/NCRServerWhitelist.java
index 48658e7..15f343e 100644
--- a/src/main/java/com/aizistral/nochatreports/config/NCRServerWhitelist.java
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRServerWhitelist.java
@@ -10,7 +10,7 @@ import net.minecraft.client.multiplayer.resolver.ServerAddress;
public class NCRServerWhitelist extends JSONConfig {
protected static final String FILE_NAME = "NoChatReports/NCR-ServerWhitelist.json";
protected static final List<String> DEFAULT_WHITELISTED_SERVERS = new ArrayList<>();
- protected List<String> whitelistedServers = DEFAULT_WHITELISTED_SERVERS;
+ protected volatile List<String> whitelistedServers = DEFAULT_WHITELISTED_SERVERS;
protected NCRServerWhitelist() {
super(FILE_NAME);
diff --git a/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java b/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
index 72734c8..f2c459e 100644
--- a/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
@@ -26,85 +26,30 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
@Environment(EnvType.CLIENT)
-public class EncryptionWarningScreen extends Screen {
+public class EncryptionWarningScreen extends ExtendedWarningScreen {
private static final Component TITLE = Component.translatable("gui.nochatreports.encryption_warning.header").withStyle(ChatFormatting.BOLD);
private static final Component CONTENT = Component.translatable("gui.nochatreports.encryption_warning.contents");
private static final Component CHECK = Component.translatable("gui.nochatreports.encryption_warning.check");
- private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT);
private static final String WIKI_LINK = "https://github.com/Aizistral-Studios/No-Chat-Reports/wiki/To-Encrypt-or-Not-to-Encrypt";
private static boolean sessionSeen = false;
- private final Screen previous;
- private MultiLineLabel message = MultiLineLabel.EMPTY;
- private Checkbox stopShowing = null;
public EncryptionWarningScreen(Screen previous) {
- super(TITLE);
- this.previous = previous;
+ super(TITLE, CONTENT, CHECK, WIKI_LINK, previous);
}
@Override
- protected void init() {
- this.clearWidgets();
- super.init();
- this.message = MultiLineLabel.create(this.font, CONTENT, this.width - 100);
- int i = (this.message.getLineCount() + 1) * this.getLineHeight();
- if (CHECK != null) {
- int checkY = this.hugeGUI() ? 32 : 76;
- int j = this.font.width(CHECK);
- this.stopShowing = new Checkbox(this.width / 2 - j / 2 - 8, checkY + i, j + 24, 20, CHECK, false);
- this.addRenderableWidget(this.stopShowing);
+ protected void onProceed(Button button) {
+ this.minecraft.setScreen(new EncryptionConfigScreen(this.previous));
+ if (this.stopShowing.selected()) {
+ NCRConfig.getEncryption().disableWarning();
}
- this.initButtons(i);
- }
-
- private void initButtons(int i) {
- int offset = 28;
- int buttonY = this.hugeGUI() ? 60 : 100;
-
- this.addRenderableWidget(new Button(this.width / 2 - 260 + offset, buttonY + i, 150, 20, CommonComponents.GUI_PROCEED, button -> {
- this.minecraft.setScreen(new EncryptionConfigScreen(this.previous));
- if (this.stopShowing.selected()) {
- NCRConfig.getEncryption().disableWarning();
- }
- sessionSeen = true;
- }));
- this.addRenderableWidget(new Button(this.width / 2 - 100 + offset, buttonY + i, 150, 20, Component.translatable("gui.nochatreports.encryption_warning.learn_more"), button -> {
- Minecraft.getInstance().setScreen(new ConfirmLinkScreen(agree -> {
- if (agree) {
- Util.getPlatform().openUri(WIKI_LINK);
- }
-
- Minecraft.getInstance().setScreen(this);
- }, WIKI_LINK, true));
- }));
- this.addRenderableWidget(new Button(this.width / 2 + 60 + offset, buttonY + i, 150, 20, CommonComponents.GUI_BACK, button -> {
- this.minecraft.setScreen(this.previous);
- }));
+ sessionSeen = true;
}
@Override
- public void render(PoseStack poseStack, int i, int j, float f) {
- this.renderBackground(poseStack);
- this.renderTitle(poseStack);
- int k = this.width / 2 - this.message.getWidth() / 2;
- this.message.renderLeftAligned(poseStack, k, this.hugeGUI() ? 40 : 70, this.getLineHeight(), 0xFFFFFF);
- super.render(poseStack, i, j, f);
- }
-
- private void renderTitle(PoseStack poseStack) {
- drawString(poseStack, this.font, this.title, 25, this.hugeGUI() ? 15 : 30, 0xFFFFFF);
- }
-
- private int getLineHeight() {
- if (this.hugeGUI())
- return (int) (this.minecraft.font.lineHeight * 1.5) + 1;
- else
- return this.minecraft.font.lineHeight * 2;
- }
-
- private boolean hugeGUI() {
- return this.height <= 1080 / 4;
+ protected void onBack(Button button) {
+ this.minecraft.setScreen(this.previous);
}
public static boolean seenOnThisSession() {
diff --git a/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java b/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java
new file mode 100644
index 0000000..d3327e3
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java
@@ -0,0 +1,97 @@
+package com.aizistral.nochatreports.gui;
+
+import com.aizistral.nochatreports.config.NCRConfig;
+import com.mojang.blaze3d.vertex.PoseStack;
+
+import net.minecraft.ChatFormatting;
+import net.minecraft.Util;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Checkbox;
+import net.minecraft.client.gui.components.MultiLineLabel;
+import net.minecraft.client.gui.screens.ConfirmLinkScreen;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.CommonComponents;
+import net.minecraft.network.chat.Component;
+
+public abstract class ExtendedWarningScreen extends Screen {
+ private final Component TITLE;
+ private final Component CONTENT;
+ private final Component CHECK;
+ private final Component NARRATION;
+ private final String WIKI_LINK;
+ protected final Screen previous;
+ protected MultiLineLabel message = MultiLineLabel.EMPTY;
+ protected Checkbox stopShowing = null;
+
+ public ExtendedWarningScreen(Component title, Component content, Component check, String wikiLink, Screen previous) {
+ super(title);
+ this.TITLE = title;
+ this.CONTENT = content;
+ this.CHECK = check;
+ this.WIKI_LINK = wikiLink;
+ this.NARRATION = this.TITLE.copy().append("\n").append(this.CONTENT);
+ this.previous = previous;
+ }
+
+ @Override
+ protected void init() {
+ this.clearWidgets();
+ super.init();
+ this.message = MultiLineLabel.create(this.font, this.CONTENT, this.width - 100);
+ int i = (this.message.getLineCount() + 1) * this.getLineHeight();
+ if (this.CHECK != null) {
+ int checkY = this.hugeGUI() ? 32 : 76;
+ int j = this.font.width(this.CHECK);
+ this.stopShowing = new Checkbox(this.width / 2 - j / 2 - 8, checkY + i, j + 24, 20, this.CHECK, false);
+ this.addRenderableWidget(this.stopShowing);
+ }
+ this.initButtons(i);
+ }
+
+ private void initButtons(int i) {
+ int offset = 28;
+ int buttonY = this.hugeGUI() ? 60 : 100;
+
+ this.addRenderableWidget(new Button(this.width / 2 - 260 + offset, buttonY + i, 150, 20, CommonComponents.GUI_PROCEED, this::onProceed));
+ this.addRenderableWidget(new Button(this.width / 2 - 100 + offset, buttonY + i, 150, 20, Component.translatable("gui.nochatreports.encryption_warning.learn_more"), button -> {
+ Minecraft.getInstance().setScreen(new ConfirmLinkScreen(agree -> {
+ if (agree) {
+ Util.getPlatform().openUri(this.WIKI_LINK);
+ }
+
+ Minecraft.getInstance().setScreen(this);
+ }, this.WIKI_LINK, true));
+ }));
+ this.addRenderableWidget(new Button(this.width / 2 + 60 + offset, buttonY + i, 150, 20, CommonComponents.GUI_BACK, this::onBack));
+ }
+
+ protected abstract void onProceed(Button button);
+
+ protected abstract void onBack(Button button);
+
+ @Override
+ public void render(PoseStack poseStack, int i, int j, float f) {
+ this.renderBackground(poseStack);
+ this.renderTitle(poseStack);
+ int k = this.width / 2 - this.message.getWidth() / 2;
+ this.message.renderLeftAligned(poseStack, k, this.hugeGUI() ? 40 : 70, this.getLineHeight(), 0xFFFFFF);
+ super.render(poseStack, i, j, f);
+ }
+
+ private void renderTitle(PoseStack poseStack) {
+ drawString(poseStack, this.font, this.title, 25, this.hugeGUI() ? 15 : 30, 0xFFFFFF);
+ }
+
+ private boolean hugeGUI() {
+ return this.height <= 1080 / 4;
+ }
+
+ protected int getLineHeight() {
+ if (this.hugeGUI())
+ return (int) (this.minecraft.font.lineHeight * 1.5) + 1;
+ else
+ return this.minecraft.font.lineHeight * 2;
+ }
+
+}
diff --git a/src/main/java/com/aizistral/nochatreports/gui/RealmsWarningScreen.java b/src/main/java/com/aizistral/nochatreports/gui/RealmsWarningScreen.java
new file mode 100644
index 0000000..29f4d5d
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/gui/RealmsWarningScreen.java
@@ -0,0 +1,50 @@
+package com.aizistral.nochatreports.gui;
+
+import org.jetbrains.annotations.Nullable;
+
+import com.aizistral.nochatreports.config.NCRConfig;
+
+import net.minecraft.ChatFormatting;
+import net.minecraft.Util;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.screens.ConfirmLinkScreen;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.screens.TitleScreen;
+import net.minecraft.client.gui.screens.multiplayer.WarningScreen;
+import net.minecraft.network.chat.CommonComponents;
+import net.minecraft.network.chat.Component;
+
+public class RealmsWarningScreen extends ExtendedWarningScreen {
+ private static final Component TITLE = Component.translatable("gui.nochatreports.realms_warning.header").withStyle(ChatFormatting.BOLD);
+ private static final Component CONTENT = Component.translatable("gui.nochatreports.realms_warning.contents");
+ private static final Component CHECK = Component.translatable("gui.nochatreports.realms_warning.check");
+ private static final String WIKI_LINK = "https://github.com/Aizistral-Studios/No-Chat-Reports/wiki/The-Realms-Question";
+ private static boolean sessionSeen = false;
+ private final Screen realms;
+
+ public RealmsWarningScreen(Screen previous, Screen realms) {
+ super(TITLE, CONTENT, CHECK, WIKI_LINK, previous);
+ this.realms = realms;
+ }
+
+ @Override
+ protected void onProceed(Button button) {
+ this.minecraft.setScreen(this.realms);
+ if (this.stopShowing.selected()) {
+ NCRConfig.getClient().setSkipRealmsWarning(true);
+ }
+
+ sessionSeen = true;
+ }
+
+ @Override
+ protected void onBack(Button button) {
+ this.minecraft.setScreen(null);
+ }
+
+ public static boolean shouldShow() {
+ return !sessionSeen && !NCRConfig.getClient().skipRealmsWarning();
+ }
+
+}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java
new file mode 100644
index 0000000..39fe9e0
--- /dev/null
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinTitleScreen.java
@@ -0,0 +1,32 @@
+package com.aizistral.nochatreports.mixins.client;
+
+import org.spongepowered.asm.mixin.Mixin;
+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.gui.RealmsWarningScreen;
+import com.mojang.realmsclient.RealmsMainScreen;
+
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.screens.TitleScreen;
+import net.minecraft.network.chat.CommonComponents;
+import net.minecraft.network.chat.Component;
+
+@Mixin(TitleScreen.class)
+public class MixinTitleScreen extends Screen {
+
+ protected MixinTitleScreen() {
+ super(CommonComponents.EMPTY);
+ throw new IllegalStateException("Can't touch this");
+ }
+
+ @Inject(method = "realmsButtonClicked", at = @At("HEAD"), cancellable = true)
+ private void onRealmsButtonClicked(CallbackInfo info) {
+ if (RealmsWarningScreen.shouldShow()) {
+ this.minecraft.setScreen(new RealmsWarningScreen(new TitleScreen(), new RealmsMainScreen(this)));
+ info.cancel();
+ }
+ }
+
+}