From a76167b7c8b303bf019a3b1493ea54cf2473c667 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Sat, 25 Jun 2022 14:16:08 +0200 Subject: Implement ban notices suppression --- .../aizistral/nochatreports/handlers/NoReportsConfig.java | 8 ++++++-- .../com/aizistral/nochatreports/mixins/MixinMinecraft.java | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java b/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java index 0a9734e..4579529 100644 --- a/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java +++ b/src/main/java/com/aizistral/nochatreports/handlers/NoReportsConfig.java @@ -17,14 +17,14 @@ public class NoReportsConfig { private static final Path CONFIG_FILE = FabricLoader.getInstance().getConfigDir().resolve("NoChatReports.json"); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static NoReportsConfig INSTANCE; - private boolean demandOnClient, demandOnServer, convertToGameMessage; + private boolean demandOnClient, demandOnServer, convertToGameMessage, suppressBanNotices; public static void loadConfig() { INSTANCE = readFile(); if (INSTANCE == null) { INSTANCE = new NoReportsConfig(); - //INSTANCE.demandOnServer = true; + INSTANCE.suppressBanNotices = true; } writeFile(INSTANCE); @@ -62,4 +62,8 @@ public class NoReportsConfig { return INSTANCE.convertToGameMessage; } + public static boolean suppressBanNotices() { + return INSTANCE.suppressBanNotices; + } + } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/MixinMinecraft.java b/src/main/java/com/aizistral/nochatreports/mixins/MixinMinecraft.java index 6ee3a26..4ede8a5 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/MixinMinecraft.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/MixinMinecraft.java @@ -1,11 +1,16 @@ package com.aizistral.nochatreports.mixins; +import java.time.Instant; +import java.util.UUID; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.aizistral.nochatreports.handlers.NoReportsConfig; +import com.mojang.authlib.minecraft.BanDetails; import com.mojang.authlib.minecraft.UserApiService; import net.minecraft.client.Minecraft; @@ -22,4 +27,11 @@ public class MixinMinecraft { } } + @Inject(method = "multiplayerBan", at = @At("HEAD"), cancellable = true) + private void onFetchBanDetails(CallbackInfoReturnable info) { + if (NoReportsConfig.suppressBanNotices()) { + info.setReturnValue(null); + } + } + } -- cgit v1.2.3