diff options
Diffstat (limited to 'src/test/java/com/aizistral')
6 files changed, 0 insertions, 238 deletions
diff --git a/src/test/java/com/aizistral/nochatreports/debug/NoChatReportsDebug.java b/src/test/java/com/aizistral/nochatreports/debug/NoChatReportsDebug.java deleted file mode 100644 index 3d04e27..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/NoChatReportsDebug.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.aizistral.nochatreports.debug; - -import java.util.UUID; - -import com.mojang.authlib.minecraft.BanDetails; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.networking.v1.PacketSender; -import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; -import net.minecraft.network.chat.Component; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerGamePacketListenerImpl; - -public final class NoChatReportsDebug implements ModInitializer { - @Override - public void onInitialize() { - ServerPlayConnectionEvents.JOIN.register(this::onPlayReady); - } - - private void onPlayReady(ServerGamePacketListenerImpl handler, PacketSender sender, MinecraftServer server) { - server.execute(() -> { - UnrealPlayer player = new UnrealPlayer(UUID.fromString("069a79f4-44e9-4726-a5be-fca90e38aaf5"), "Notch"); - //player.join(server, handler); - Component component = Component.Serializer.fromJson("{\"translate\":\"%s\",\"with\":[{\"extra\":[{\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/tell Aizistral \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":{\"id\":\"bfa45411-874a-4ee0-b3bd-00c716059d95\",\"name\":{\"text\":\"Aizistral\"},\"type\":\"minecraft:player\"}},\"insertion\":\"Aizistral\",\"text\":\"Aizistral\"},{\"text\":\"> \"},{\"text\":\"['(9^~©²~.2>5¶(4,+:.9!¿¿\"}],\"text\":\"<\"},{\"text\":\"['(9^~©²~.2>5¶(4,+:.9!¿¿\"}]}"); - //player.sendSystem(server, handler, component); - - //player.sendMessage(server, handler, "This message is so real and legit", null); - - //UnrealPlayer.DEFAULT.join(server, handler); - //UnrealPlayer.DEFAULT.sendMessage(server, handler, "I'm definitely not gay", "§8I§a'§bM §cG§dA§eY"); - //UnrealPlayer.DEFAULT.sendMessage(server, handler, "gOODBYE LOL", null); - //UnrealPlayer.DEFAULT.leave(server, handler); - - //NoChatReports.LOGGER.info("Unreal player deployed"); - }); - } - - public static BanDetails getFakeBan() { - return null; - // return new BanDetails(UUID.fromString(Minecraft.getInstance().getUser().getUuid()), - // null, null, null); - } - -} diff --git a/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java b/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java deleted file mode 100644 index 538841b..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/ReportWriter.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.aizistral.nochatreports.debug; - -import java.io.BufferedWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Date; - -import com.aizistral.nochatreports.debug.mixins.MixinAbuseReportSenderServices; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.ibm.icu.text.SimpleDateFormat; -import com.mojang.authlib.minecraft.client.ObjectMapper; -import com.mojang.authlib.yggdrasil.request.AbuseReportRequest; - -import net.fabricmc.loader.api.FabricLoader; - -/** - * Allows to save chat reports locally. See {@link MixinAbuseReportSenderServices} for details. - * - * @author Aizistral - */ - -public final class ReportWriter { - private static final ObjectMapper MAPPER = ObjectMapper.create(); - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - - public static void saveReport(AbuseReportRequest report) { - String string = MAPPER.writeValueAsString(report); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_hh.mm.ss"); - Path path = FabricLoader.getInstance().getGameDir().resolve("intercepted-reports/report-" - + format.format(Date.from(report.report.createdTime)) + ".json"); - path.getParent().toFile().mkdirs(); - - try (BufferedWriter writer = Files.newBufferedWriter(path)) { - GSON.toJson(GSON.fromJson(string, Object.class), writer); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - -} diff --git a/src/test/java/com/aizistral/nochatreports/debug/UnrealPlayer.java b/src/test/java/com/aizistral/nochatreports/debug/UnrealPlayer.java deleted file mode 100644 index 8681ae5..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/UnrealPlayer.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.aizistral.nochatreports.debug; - -import java.util.UUID; - -/** - * Exists solely to help with testing some of the features of the mod. - * You can use this to trick client into thinking there is another player - * on server, and send chat messages as if they are from that player. - * <br><br> - * DON'T FORGET TO TURN "convertToGameMessage" OFF! - * - * @author Aizistral - */ - -public class UnrealPlayer { - public static final UnrealPlayer DEFAULT = new UnrealPlayer(UUID.fromString("bfa45411-874a-4ee0-b3bd-00c716059d95"), "Aizistral"); - private final UUID id; - private final String name; - - public UnrealPlayer(UUID id, String name) { - this.id = id; - this.name = name; - } - - // public void join(MinecraftServer server, ServerGamePacketListenerImpl connection) { - // ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, - // this.getPlayer(server)); - // connection.send(packet); - // } - // - // public void leave(MinecraftServer server, ServerGamePacketListenerImpl connection) { - // ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(Action.REMOVE_PLAYER, - // this.getPlayer(server)); - // connection.send(packet); - // } - // - // public ServerPlayer getPlayer(MinecraftServer server) { - // return new ServerPlayer(server, server.overworld(), new GameProfile(this.id, this.name), null); - // } - // - // public void sendSystem(MinecraftServer server, ServerGamePacketListenerImpl connection, Component message) { - // ServerPlayer player = this.getPlayer(server); - // ClientboundSystemChatPacket packet = new ClientboundSystemChatPacket(message, false); - // connection.send(packet); - // } - // - // public void sendMessage(MinecraftServer server, ServerGamePacketListenerImpl connection, String message, @Nullable String unsigned) { - // ServerPlayer player = this.getPlayer(server); - // ClientboundPlayerChatPacket packet = new ClientboundPlayerChatPacket(new PlayerChatMessage( - // new SignedMessageHeader(MessageSignature.EMPTY, this.id), MessageSignature.EMPTY, - // new SignedMessageBody(new ChatMessageContent(message, Component.literal(message)), Instant.now(), 0, - // LastSeenMessages.EMPTY), unsigned != null ? Optional.of(Component.literal(unsigned)) - // : Optional.empty(), FilterMask.PASS_THROUGH), - // ChatType.bind(ChatType.CHAT, player).toNetwork(server.registryAccess())); - // - // - // // new ClientboundPlayerChatPacket(Component.literal(message), - // // unsigned != null ? Optional.of(Component.literal(unsigned)) : Optional.empty(), 0, - // // new ChatSender(this.id, Component.literal(this.name)), Instant.now(), - // // Crypt.SaltSignaturePair.EMPTY); - // connection.send(packet); - // } - -} diff --git a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java deleted file mode 100644 index a3e7339..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinAbuseReportSenderServices.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.aizistral.nochatreports.debug.mixins; - -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -import com.aizistral.nochatreports.debug.ReportWriter; -import com.mojang.authlib.minecraft.report.AbuseReport; -import com.mojang.authlib.yggdrasil.request.AbuseReportRequest; -import com.mojang.datafixers.util.Unit; - -import net.minecraft.client.multiplayer.chat.report.AbuseReportSender; -import net.minecraft.client.multiplayer.chat.report.ReportEnvironment; - -@Mixin(AbuseReportSender.Services.class) -public class MixinAbuseReportSenderServices { - @Shadow @Final - private ReportEnvironment environment; - - /** - * @reason Write report locally instead of trying to send it to Mojang. - * Allows to intercept and examine contents of the report. - * @author Aizistral - */ - - @Overwrite - public CompletableFuture<Unit> send(UUID uuid, AbuseReport abuseReport) { - AbuseReportRequest abuseReportRequest = new AbuseReportRequest(1, uuid, - abuseReport, this.environment.clientInfo(), this.environment.thirdPartyServerInfo(), - this.environment.realmInfo()); - ReportWriter.saveReport(abuseReportRequest); - return CompletableFuture.supplyAsync(() -> Unit.INSTANCE); - } - -} diff --git a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinMinecraft.java b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinMinecraft.java deleted file mode 100644 index 34fcf9f..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinMinecraft.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.aizistral.nochatreports.debug.mixins; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import com.aizistral.nochatreports.debug.NoChatReportsDebug; -import com.mojang.authlib.minecraft.BanDetails; - -import net.minecraft.client.Minecraft; - -@Mixin(Minecraft.class) -public class MixinMinecraft { - /** - * Replaces real ban screen with a fake one for testing. - * @return Fake ban screen - * @reason Testing - * @author Aizistral - */ - @Overwrite - public BanDetails multiplayerBan() { - return NoChatReportsDebug.getFakeBan(); - } - -} diff --git a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java b/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java deleted file mode 100644 index e7e4cfc..0000000 --- a/src/test/java/com/aizistral/nochatreports/debug/mixins/MixinPlayerEntry.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.aizistral.nochatreports.debug.mixins; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import net.minecraft.client.gui.screens.social.PlayerEntry; -import net.minecraft.client.multiplayer.chat.report.AbuseReportSender; - -@Mixin(PlayerEntry.class) -public class MixinPlayerEntry { - - /** - * @reason Always allow to report players on server, even if services are - * unreachable (which they are in IDE). Useful when used along with - * {@link MixinAbuseReportSenderServices}. - * @author Aizistral - */ - - @Redirect(method = "<init>", at = @At(value = "INVOKE", target = - "Lnet/minecraft/client/multiplayer/chat/report/AbuseReportSender;isEnabled()Z")) - private boolean forceEnableReporting(AbuseReportSender sender) { - return true; - } - -} |
