diff options
| author | Aizistral | 2022-07-07 17:20:01 +0200 |
|---|---|---|
| committer | Aizistral | 2022-07-07 17:24:32 +0200 |
| commit | bb5971b80a7c9b4dd8df28e82a3c75d592cce7cc (patch) | |
| tree | acf833299a2fcb6d0472e37c8282f095e13a864f | |
| parent | 4bbddd0de6ca2e2bc449e53ecbb8cc432068fd2d (diff) | |
Add config option to always hide report button
Closes #62
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/core/NoReportsConfig.java | 6 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/mixins/MixinPlayerEntry.java | 11 |
2 files changed, 15 insertions, 2 deletions
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<String> 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 = "<init>", at = @At("RETURN")) private void onConstructed(Minecraft minecraft, SocialInteractionsScreen socialInteractionsScreen, UUID uUID, String string, Supplier<ResourceLocation> 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) { |
