From bb5971b80a7c9b4dd8df28e82a3c75d592cce7cc Mon Sep 17 00:00:00 2001 From: Aizistral Date: Thu, 7 Jul 2022 17:20:01 +0200 Subject: Add config option to always hide report button Closes #62 --- .../com/aizistral/nochatreports/core/NoReportsConfig.java | 6 +++++- .../com/aizistral/nochatreports/mixins/MixinPlayerEntry.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/com/aizistral/nochatreports/core/NoReportsConfig.java b/src/main/java/com/aizistral/nochatreports/core/NoReportsConfig.java index bc37e7c..3bd8bfc 100644 --- a/src/main/java/com/aizistral/nochatreports/core/NoReportsConfig.java +++ b/src/main/java/com/aizistral/nochatreports/core/NoReportsConfig.java @@ -28,7 +28,7 @@ public class NoReportsConfig { private static NoReportsConfig INSTANCE; private boolean demandOnClient, demandOnServer, enableDebugLog, convertToGameMessage = true, forceAllowMultiplayer = true, showServerSafety = true, suppressMessageTrustIndicators = true, - scrambleTimestamps = true; + scrambleTimestamps = true, alwaysHideReportButton = false; private List whitelistedServers; private static NoReportsConfig getInstance() { @@ -121,4 +121,8 @@ public class NoReportsConfig { return getInstance().scrambleTimestamps; } + public static boolean alwaysHideReportButton() { + return getInstance().alwaysHideReportButton; + } + } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayerEntry.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayerEntry.java index 4b7a5eb..b084732 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayerEntry.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinPlayerEntry.java @@ -12,6 +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.core.NoReportsConfig; import com.aizistral.nochatreports.core.ServerSafetyLevel; import com.aizistral.nochatreports.core.ServerSafetyState; import com.mojang.blaze3d.vertex.PoseStack; @@ -46,7 +47,15 @@ public class MixinPlayerEntry { @Inject(method = "", at = @At("RETURN")) private void onConstructed(Minecraft minecraft, SocialInteractionsScreen socialInteractionsScreen, UUID uUID, String string, Supplier supplier, CallbackInfo info) { - if (ServerSafetyState.getCurrent() == ServerSafetyLevel.SECURE && this.reportButton != null) { + if (NoReportsConfig.alwaysHideReportButton()) { + this.reportButton = new Button(0, 0, 20, 20, Component.empty(), button -> {}) { + @Override + public void render(PoseStack poseStack, int i, int j, float f) { + // NO-OP + } + }; + this.reportButton.active = this.reportButton.visible = false; + } else if (ServerSafetyState.getCurrent() == ServerSafetyLevel.SECURE && this.reportButton != null) { this.reportButton = new ImageButton(0, 0, 20, 20, 0, 0, 20, REPORT_BUTTON_LOCATION, 64, 64, button -> {}, new Button.OnTooltip() { @Override public void onTooltip(Button button, PoseStack poseStack, int i, int j) { -- cgit v1.2.3