fix kick on some servers

This commit is contained in:
Bella 2020-03-07 14:43:40 -05:00
parent abcecf8db2
commit 51f3c4caa3
No known key found for this signature in database
GPG Key ID: 03B01AC937D1C89C
4 changed files with 0 additions and 101 deletions

View File

@ -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);
}

View File

@ -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<Object> 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;
}
}

View File

@ -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<Boolean> startupGlobal = register(Settings.b("Enable Automatically", true));
private static AntiBan INSTANCE = new AntiBan();
public AntiBan() {
INSTANCE = this;
}
public static boolean enabled() {
return INSTANCE.isEnabled();
}
}

View File

@ -22,7 +22,6 @@
"MixinMinecraft",
"MixinModelBoat",
"MixinNetHandlerPlayClient",
"MixinNettyCompressionDecoder",
"MixinNetworkManager",
"MixinPlayerControllerMP",
"MixinRenderLiving",