From 51f3c4caa38f704141de995ce43cd8990c9cdfda Mon Sep 17 00:00:00 2001 From: Bella Date: Sat, 7 Mar 2020 14:43:40 -0500 Subject: [PATCH] fix kick on some servers --- .../java/me/zeroeightsix/kami/KamiMod.java | 4 - .../client/MixinNettyCompressionDecoder.java | 74 ------------------- .../kami/module/modules/player/AntiBan.java | 22 ------ src/main/resources/mixins.kami.json | 1 - 4 files changed, 101 deletions(-) delete mode 100644 src/main/java/me/zeroeightsix/kami/mixin/client/MixinNettyCompressionDecoder.java delete mode 100644 src/main/java/me/zeroeightsix/kami/module/modules/player/AntiBan.java diff --git a/src/main/java/me/zeroeightsix/kami/KamiMod.java b/src/main/java/me/zeroeightsix/kami/KamiMod.java index 27ce80c2..0453dfc2 100644 --- a/src/main/java/me/zeroeightsix/kami/KamiMod.java +++ b/src/main/java/me/zeroeightsix/kami/KamiMod.java @@ -22,7 +22,6 @@ import me.zeroeightsix.kami.module.modules.chat.CustomChat; import me.zeroeightsix.kami.module.modules.gui.CleanGUI; import me.zeroeightsix.kami.module.modules.gui.PrefixChat; import me.zeroeightsix.kami.module.modules.misc.DiscordSettings; -import me.zeroeightsix.kami.module.modules.player.AntiBan; import me.zeroeightsix.kami.module.modules.render.TabFriends; import me.zeroeightsix.kami.setting.Setting; import me.zeroeightsix.kami.setting.Settings; @@ -203,9 +202,6 @@ public class KamiMod { if (((DiscordSettings) ModuleManager.getModuleByName("DiscordSettings")).startupGlobal.getValue()) { ModuleManager.getModuleByName("DiscordSettings").setEnabled(true); } - if (((AntiBan) ModuleManager.getModuleByName("AntiBan")).startupGlobal.getValue()) { - ModuleManager.getModuleByName("AntiBan").setEnabled(true); - } if (((TabFriends) ModuleManager.getModuleByName("TabFriends")).startupGlobal.getValue()) { ModuleManager.getModuleByName("TabFriends").setEnabled(true); } diff --git a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinNettyCompressionDecoder.java b/src/main/java/me/zeroeightsix/kami/mixin/client/MixinNettyCompressionDecoder.java deleted file mode 100644 index 01b4328d..00000000 --- a/src/main/java/me/zeroeightsix/kami/mixin/client/MixinNettyCompressionDecoder.java +++ /dev/null @@ -1,74 +0,0 @@ -package me.zeroeightsix.kami.mixin.client; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.DecoderException; -import me.zeroeightsix.kami.command.Command; -import me.zeroeightsix.kami.module.modules.player.AntiBan; -import net.minecraft.network.NettyCompressionDecoder; -import net.minecraft.network.PacketBuffer; -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 java.util.List; -import java.util.zip.DataFormatException; -import java.util.zip.Inflater; - -/** - * Created by 0x2E | PretendingToCode on 29/12/19 - * Updated by 0x2E on 01/02/20 - * Updated by S-B99 on 09/02/20 - */ -@Mixin(NettyCompressionDecoder.class) -public class MixinNettyCompressionDecoder { - public int readVarIntFromBuffer(PacketBuffer arg) { - int i = 0; - int j = 0; - - while (true) { - byte b0 = arg.readByte(); - i |= (b0 & 127) << j++ * 7; - - if (j > 5) { - throw new RuntimeException("VarInt too big"); - } - - if ((b0 & 128) != 128) { - break; - } - } - return i; - } - - @Inject(method = "decode", at = @At("HEAD"), cancellable = true) - private void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List p_decode_3_, CallbackInfo info) throws DataFormatException { - Inflater packetInflater = new Inflater(); - - if (p_decode_2_.readableBytes() != 0) { - PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_); - int i = readVarIntFromBuffer(packetbuffer); - if (i == 0) { - p_decode_3_.add(packetbuffer.readBytes(packetbuffer.readableBytes())); - } else { - if (i > 2097152) { - if (AntiBan.enabled()) { - Command.sendWarningMessage("&7[&c&lDecoderException&r&7] &rBadly compressed packet - size of " + i + " is larger than protocol maximum of 2097152"); - throw new DecoderException("Badly compressed packet - size of " + i + " is larger than protocol maximum of 2097152"); - } - } - byte[] aByte = new byte[packetbuffer.readableBytes()]; - packetbuffer.readBytes(aByte); - packetInflater.setInput(aByte); - byte[] aByte1 = new byte[i]; - packetInflater.inflate(aByte1); - p_decode_3_.add(Unpooled.wrappedBuffer(aByte1)); - packetInflater.reset(); - } - } - return; - } - -} diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiBan.java b/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiBan.java deleted file mode 100644 index 3c671901..00000000 --- a/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiBan.java +++ /dev/null @@ -1,22 +0,0 @@ -package me.zeroeightsix.kami.module.modules.player; - -import me.zeroeightsix.kami.module.Module; -import me.zeroeightsix.kami.setting.Setting; -import me.zeroeightsix.kami.setting.Settings; - -/** - * Created by S-B99 on 11/01/20 - */ -@Module.Info(name = "AntiBan", category = Module.Category.PLAYER, description = "Correctly parses oversized packets to prevent disconnect", showOnArray = Module.ShowOnArray.OFF) -public class AntiBan extends Module { - public Setting startupGlobal = register(Settings.b("Enable Automatically", true)); - private static AntiBan INSTANCE = new AntiBan(); - - public AntiBan() { - INSTANCE = this; - } - - public static boolean enabled() { - return INSTANCE.isEnabled(); - } -} diff --git a/src/main/resources/mixins.kami.json b/src/main/resources/mixins.kami.json index 59764e87..7222d0ad 100644 --- a/src/main/resources/mixins.kami.json +++ b/src/main/resources/mixins.kami.json @@ -22,7 +22,6 @@ "MixinMinecraft", "MixinModelBoat", "MixinNetHandlerPlayClient", - "MixinNettyCompressionDecoder", "MixinNetworkManager", "MixinPlayerControllerMP", "MixinRenderLiving",