Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.server.v1_7_R4;
- import com.google.common.base.Joiner;
- import com.google.common.collect.ImmutableSet;
- import java.net.SocketAddress;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Queue;
- import java.util.UUID;
- import javax.crypto.SecretKey;
- import net.minecraft.util.com.google.common.collect.Queues;
- import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder;
- import net.minecraft.util.com.mojang.authlib.properties.Property;
- import net.minecraft.util.io.netty.channel.Channel;
- import net.minecraft.util.io.netty.channel.ChannelFutureListener;
- import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
- import net.minecraft.util.io.netty.channel.SimpleChannelInboundHandler;
- import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup;
- import net.minecraft.util.io.netty.util.AttributeKey;
- import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
- import net.minecraft.util.org.apache.commons.lang3.Validate;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import org.apache.logging.log4j.Marker;
- import org.apache.logging.log4j.MarkerManager;
- import org.bukkit.Bukkit;
- import org.bukkit.event.player.GCheatEvent;
- import org.spigotmc.SpigotCompressor;
- import org.spigotmc.SpigotConfig;
- import org.spigotmc.SpigotDecompressor;
- public class NetworkManager
- extends SimpleChannelInboundHandler {
- private static final Logger i = LogManager.getLogger();
- public static final Marker a = MarkerManager.getMarker("NETWORK");
- public static final Marker b = MarkerManager.getMarker("NETWORK_PACKETS", a);
- public static final Marker c = MarkerManager.getMarker("NETWORK_STAT", a);
- public static final AttributeKey d = new AttributeKey("protocol");
- public static final AttributeKey e = new AttributeKey("receivable_packets");
- public static final AttributeKey f = new AttributeKey("sendable_packets");
- public static final NioEventLoopGroup g = new NioEventLoopGroup(false, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
- public static final NetworkStatistics h = new NetworkStatistics();
- private final boolean j;
- private final Queue k;
- private final Queue l;
- private Channel m;
- public SocketAddress n;
- public UUID spoofedUUID;
- public Property[] spoofedProfile;
- public boolean preparing;
- private PacketListener o;
- private EnumProtocol p;
- private IChatBaseComponent q;
- private boolean r;
- public static final AttributeKey<Integer> protocolVersion = new AttributeKey("protocol_version");
- public static final ImmutableSet<Integer> SUPPORTED_VERSIONS = ImmutableSet.of(Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(47), Integer.valueOf(107), Integer.valueOf(108), Integer.valueOf(109), new Integer[] { null, (new Integer[2][0] = Integer.valueOf(110)).valueOf(210) }); public static final int CURRENT_VERSION = 5; private int version; public boolean stopReadingPackets; private Packet[] packets; private long[] limitTimes; public long lastTickNetworkProcessed; public long ticksSinceLastPacket; private int numOfH; private List<Long> numOfHLogs; private int numOfI; private List<Long> numOfILogs; private long lastKTick;
- public long currentTime;
- public long lastVehicleTick;
- public int numOfFlyingPacketsInARow;
- public static int getVersion(Channel attr) {
- Integer ver = (Integer)attr.attr(protocolVersion).get();
- return (ver != null) ? ver.intValue() : 5;
- }
- public int getVersion() {
- if (this.version == 0) {
- Integer ver = (Integer)this.m.attr(protocolVersion).get();
- if (ver == null) {
- return 5;
- }
- this.version = ver.intValue();
- }
- return this.version;
- }
- public NetworkManager(boolean flag) { this.k = Queues.newConcurrentLinkedQueue();
- this.l = Queues.newConcurrentLinkedQueue();
- this.preparing = true;
- this.version = 0;
- this.stopReadingPackets = false;
- this.packets = new Packet[10];
- this.limitTimes = new long[12];
- this.lastTickNetworkProcessed = MinecraftServer.currentTick;
- this.ticksSinceLastPacket = -1L;
- this.numOfH = 0;
- this.numOfHLogs = new ArrayList();
- this.numOfI = 0;
- this.numOfILogs = new ArrayList();
- this.lastKTick = MinecraftServer.currentTick;
- this.currentTime = System.currentTimeMillis();
- this.lastVehicleTick = -1L;
- this.numOfFlyingPacketsInARow = 0; this.j = flag; this.limitTimes[0] = 4000L; this.limitTimes[1] = 4000L; this.limitTimes[2] = 4000L; this.limitTimes[3] = 4000L; this.limitTimes[4] = 5000L; this.limitTimes[5] = 6000L; this.limitTimes[6] = 7000L; this.limitTimes[7] = 7000L; this.limitTimes[8] = 7000L; this.limitTimes[9] = 7000L; this.limitTimes[10] = 7000L; this.limitTimes[11] = 7000L; } public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { super.channelActive(channelhandlercontext); this.m = channelhandlercontext.channel(); this.n = this.m.remoteAddress(); this.preparing = false; a(EnumProtocol.HANDSHAKING); } public void a(EnumProtocol enumprotocol) { this.p = (EnumProtocol)this.m.attr(d).getAndSet(enumprotocol); this.m.attr(e).set(enumprotocol.a(this.j)); this.m.attr(f).set(enumprotocol.b(this.j)); this.m.config().setAutoRead(true); i.debug("Enabled auto read"); }
- public void channelInactive(ChannelHandlerContext channelhandlercontext) throws Exception { close(new ChatMessage("disconnect.endOfStream", new Object[0])); }
- public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { ChatMessage chatmessage; if (throwable instanceof net.minecraft.util.io.netty.handler.timeout.TimeoutException) { chatmessage = new ChatMessage("disconnect.timeout", new Object[0]); } else { chatmessage = new ChatMessage("disconnect.genericReason", new Object[] { "Internal Exception: " + throwable }); } close(chatmessage); if (MinecraftServer.getServer().isDebugging()) throwable.printStackTrace(); }
- public void a() { i();
- EnumProtocol enumprotocol = (EnumProtocol)this.m.attr(d).get();
- if (this.p != enumprotocol) {
- if (this.p != null) {
- this.o.a(this.p, enumprotocol);
- }
- this.p = enumprotocol;
- }
- if (this.o != null) {
- boolean processed = false;
- int i = SpigotConfig.maxPacketsPerPlayer; while (true) { Packet packet; if ((packet = (Packet)this.k.poll()) != null && i >= 0)
- {
- if (this.stopReadingPackets || !isConnected() || !this.m.config().isAutoRead()) {
- continue;
- }
- if (!processed) {
- this.ticksSinceLastPacket = MinecraftServer.currentTick - this.lastTickNetworkProcessed;
- this.lastTickNetworkProcessed = MinecraftServer.currentTick;
- this.currentTime = System.currentTimeMillis();
- processed = true;
- }
- if (this.o instanceof PlayerConnection)
- { PlayerConnection connection = (PlayerConnection)this.o;
- if (packet instanceof PacketPlayInKeepAlive)
- { ((PlayerConnection)this.o).handleKeepAliveSync((PacketPlayInKeepAlive)packet);
- }
- else if (packet instanceof PacketPlayInChat || packet instanceof PacketPlayInCustomPayload)
- { packet.handle(this.o); }
- else
- { if (connection.isAntiCheatActivated() &&
- !MinecraftServer.getServer().getAllowFlight() && !connection.player.abilities.canFly && !connection.player.abilities.canInstantlyBuild) {
- boolean eventFired = false;
- int size = connection.lastPacketsQueue.size();
- if (size >= this.packets.length) {
- if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity)packet).c() == EnumEntityUseAction.ATTACK) {
- for (int j = 0; j < this.packets.length; j++) {
- this.packets[j] = (Packet)connection.lastPacketsQueue.removeLast();
- }
- Class packet0Class = this.packets[0].getClass();
- if (packet0Class.equals(PacketPlayInArmAnimation.class))
- {
- if (this.packets[1].getClass().equals(PacketPlayInUseEntity.class) && this.packets[2].getClass().equals(PacketPlayInArmAnimation.class) && ((PacketPlayInUseEntity)this.packets[true])
- .c() == EnumEntityUseAction.ATTACK && getVersion() <= 47) {
- if (this.packets[3].getClass().equals(PacketPlayInUseEntity.class) && this.packets[4].getClass().equals(PacketPlayInArmAnimation.class) && ((PacketPlayInUseEntity)this.packets[3])
- .c() == EnumEntityUseAction.ATTACK) {
- if (this.packets[5].getClass().equals(PacketPlayInUseEntity.class) && this.packets[6].getClass().equals(PacketPlayInArmAnimation.class) && ((PacketPlayInUseEntity)this.packets[5])
- .c() == EnumEntityUseAction.ATTACK) {
- if (this.packets[7].getClass().equals(PacketPlayInUseEntity.class) && this.packets[8].getClass().equals(PacketPlayInArmAnimation.class) && ((PacketPlayInUseEntity)this.packets[7])
- .c() == EnumEntityUseAction.ATTACK) {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura K");
- }
- if (this.lastKTick != MinecraftServer.currentTick) {
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type K (Experimental) " + this.ticksSinceLastPacket));
- this.lastKTick = MinecraftServer.currentTick;
- }
- } else {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura J");
- }
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type J (Experimental) " + this.ticksSinceLastPacket));
- }
- } else {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura I");
- }
- this.numOfILogs.add(Long.valueOf(this.ticksSinceLastPacket));
- if (++this.numOfI == 3) {
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type I | " + Joiner.on(" ").join(this.numOfILogs)));
- this.numOfI = 0;
- this.numOfILogs.clear();
- }
- }
- } else {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura H");
- }
- this.numOfHLogs.add(Long.valueOf(this.ticksSinceLastPacket));
- if (++this.numOfH == 5) {
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type H | " + Joiner.on(" ").join(this.numOfHLogs)));
- this.numOfH = 0;
- this.numOfHLogs.clear();
- }
- }
- } else {
- int numberOfPreviousPacketPlayInPositionLooks = 0;
- boolean foundPrevHitPacket = false;
- for (int j = 1; j < this.packets.length; j++) {
- Class packetJClass = this.packets[j].getClass();
- if (packetJClass.equals(PacketPlayInPositionLook.class) || packetJClass.equals(PacketPlayInPosition.class) || packetJClass
- .equals(PacketPlayInLook.class) || packetJClass.equals(PacketPlayInFlying.class)) {
- numberOfPreviousPacketPlayInPositionLooks++;
- foundPrevHitPacket = true;
- } else if (packetJClass.equals(PacketPlayInUseEntity.class)) {
- break;
- }
- }
- if (foundPrevHitPacket) {
- PacketPlayInUseEntity packetPlayInUseEntity = (PacketPlayInUseEntity)packet;
- EnumEntityUseAction action = packetPlayInUseEntity.c();
- WorldServer worldserver = MinecraftServer.getServer().getWorldServer(connection.player.dimension);
- Entity entity = packetPlayInUseEntity.a(worldserver);
- boolean validData = false;
- validData = (action == EnumEntityUseAction.ATTACK && entity != connection.player && entity != null && entity instanceof EntityPlayer);
- if (validData) {
- EntityPlayer entityPlayer = (EntityPlayer)entity;
- validData = entityPlayer.playerConnection.hasMovedInHalfSecond;
- }
- if (validData) {
- List<Long> times = (List)connection.killAuraViolationsTypeC.get(Integer.valueOf(numberOfPreviousPacketPlayInPositionLooks));
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " has sent " + numberOfPreviousPacketPlayInPositionLooks + " position packets since last hit");
- }
- if (connection.killAuraViolationsTypeC.size() > 1) {
- connection.killAuraViolationsTypeC.clear();
- if (connection.hackDebug) {
- Bukkit.getLogger().info("Reset");
- }
- }
- if (times == null) {
- times = new ArrayList<Long>();
- connection.killAuraViolationsTypeC.put(Integer.valueOf(numberOfPreviousPacketPlayInPositionLooks), times);
- }
- long currentTime = System.currentTimeMillis();
- int typeCViolations = 0;
- times.add(Long.valueOf(currentTime));
- for (Iterator<Long> iterator = times.iterator(); iterator.hasNext(); ) {
- Long time = (Long)iterator.next();
- long timeLimiter = (numberOfPreviousPacketPlayInPositionLooks < 12) ? this.limitTimes[numberOfPreviousPacketPlayInPositionLooks] : 4000L;
- if (time.longValue() + timeLimiter >= currentTime) {
- typeCViolations++; continue;
- }
- iterator.remove();
- }
- if (typeCViolations >= 10) {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura with lvl " + numberOfPreviousPacketPlayInPositionLooks);
- }
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type C (Experimental). " + numberOfPreviousPacketPlayInPositionLooks));
- times.clear();
- eventFired = true;
- }
- }
- }
- }
- }
- for (int j = this.packets.length - 1; j >= 0; j--) {
- connection.lastPacketsQueue.add(this.packets[j]);
- }
- } else if (packet instanceof PacketPlayInBlockPlace) {
- for (int j = 0; j < 3; j++) {
- this.packets[j] = (Packet)connection.lastPacketsQueue.removeLast();
- }
- if (this.packets[0] instanceof PacketPlayInFlying && this.packets[1] instanceof PacketPlayInBlockPlace && this.packets[2] instanceof PacketPlayInBlockDig) {
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.FAST_EAT_MACHINE_GUN, GCheatEvent.Level.MOD, connection.getPlayer().getName() + " is eating or shooting too fast Type A."));
- }
- for (int j = 2; j >= 0; j--) {
- connection.lastPacketsQueue.add(this.packets[j]);
- }
- } else if (packet instanceof PacketPlayInHeldItemSlot) {
- for (int j = 0; j < 3; j++) {
- this.packets[j] = (Packet)connection.lastPacketsQueue.removeLast();
- }
- if (this.packets[0] instanceof PacketPlayInBlockPlace && this.packets[1] instanceof PacketPlayInFlying && this.packets[2] instanceof PacketPlayInBlockDig) {
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.FAST_EAT_MACHINE_GUN, GCheatEvent.Level.MOD, connection.getPlayer().getName() + " is eating or shooting too fast Type B."));
- }
- for (int j = 2; j >= 0; j--) {
- connection.lastPacketsQueue.add(this.packets[j]);
- }
- }
- if (connection.isDigging) {
- if (packet instanceof PacketPlayInFlying) {
- connection.typeRStage = 1;
- } else if (packet instanceof PacketPlayInArmAnimation) {
- if (connection.typeRStage == 1) {
- connection.typeRStage = 2;
- } else if (connection.typeRStage == 2) {
- connection.typeRStage = 0;
- if (connection.digHorizontalMovement > 1) {
- connection.typeRThreshold++;
- if (connection.typeRThreshold >= 3) {
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " was caught using kill aura R (" + connection.typeRThreshold + ")");
- }
- Bukkit.getPluginManager().callEvent(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type R (Experimental) (" + connection.typeRThreshold + ")."));
- }
- }
- }
- } else {
- connection.typeRStage = 0;
- }
- } else {
- connection.typeRStage = 0;
- }
- }
- if (size == 10) {
- connection.lastPacketsQueue.removeFirst();
- }
- connection.lastPacketsQueue.add(packet);
- if (eventFired) {
- connection.lastPacketsQueue.clear();
- }
- if (connection.hackDebug) {
- Bukkit.getLogger().info(connection.getPlayer().getName() + " has received packet " + packet.toString() + " " + MinecraftServer.currentTick);
- }
- }
- packet.handle(this.o); } continue; } } else { break; } packet.handle(this.o);
- i--; }
- this.o.a();
- }
- this.m.flush(); }
- protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) { if (this.m.isOpen()) if (packet.a()) { packet.handle(this.o); if (packet instanceof PacketPlayInKeepAlive) this.k.add(packet); } else { if (this.o instanceof PlayerConnection) { PlayerConnection connection = (PlayerConnection)this.o; if (connection.hackDebug) Bukkit.getLogger().info(connection.getPlayer().getName() + " raw packet " + packet + " at " + System.currentTimeMillis()); if (packet instanceof PacketPlayInChat || packet instanceof PacketPlayInCustomPayload) { this.k.add(packet); return; } if (packet instanceof PacketPlayInFlying) { connection.movesReceived++; connection.typeE2Swing = false; if (packet.getClass() != PacketPlayInFlying.class) { this.numOfFlyingPacketsInARow = 0; } else if (++this.numOfFlyingPacketsInARow == 21 && connection.isAntiCheatActivated()) { runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.REGEN, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Regen Type B")); } } if (!connection.player.abilities.canInstantlyBuild) if (connection.lastAttackPlayerTime == 0L || this.currentTime - connection.lastAttackPlayerTime > 5000L || !connection.isAntiCheatActivated()) { connection.typeOStage = connection.typeOThreshold = 0; connection.typePStage = connection.typePThreshold = connection.typePOther = 0; connection.typeQStage = connection.typeQThreshold = 0; } else { if (connection.typeOStage == 0) { if (packet instanceof PacketPlayInArmAnimation) connection.typeOStage = 1; } else if (connection.typeOStage == 1) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 0) { connection.typeOStage = 2; } else { connection.typeOStage = 0; } } else if (connection.typeOStage == 2) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 1) { if (++connection.typeOThreshold == 5) { connection.typeOThreshold = 0; runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type O (Experimental)")); } } else { connection.typeOThreshold = 0; } connection.typeOStage = 0; } if (connection.typePStage == 0) { if (packet instanceof PacketPlayInArmAnimation) connection.typePStage = 1; } else if (connection.typePStage == 1) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 0) { connection.typePStage = 2; } else { connection.typePStage = 0; } } else if (connection.typePStage == 2) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 1) { if (++connection.typePThreshold == 5) { if (connection.typePOther > 0) runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type P (Experimental) " + connection.typePOther)); connection.typePThreshold = connection.typePOther = 0; } connection.typePStage = 0; } else if (packet instanceof PacketPlayInArmAnimation) { connection.typePStage = 3; } else { connection.typePStage = connection.typePThreshold = connection.typePOther = 0; } } else if (connection.typePStage == 3) { if (packet instanceof PacketPlayInFlying) { connection.typePStage = 4; } else { connection.typePStage = connection.typePThreshold = connection.typePOther = 0; } } else if (connection.typePStage == 4) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 1) { connection.typePOther++; connection.typePStage = 0; } else { connection.typePStage = connection.typePThreshold = connection.typePOther = 0; } } if (connection.typeQStage != 1 && packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 0) connection.typeQThreshold = 0; if (connection.typeQStage == 0) { if (packet instanceof PacketPlayInArmAnimation) connection.typeQStage = 1; } else if (connection.typeQStage == 1) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 0) { connection.typeQStage = 2; } else { connection.typeQStage = 0; } } else if (connection.typeQStage == 2) { if (packet instanceof PacketPlayInFlying) { connection.typeQStage = 3; } else { connection.typeQStage = 0; } } else if (connection.typeQStage == 3) { if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).g() == 1 && ++connection.typeQThreshold == 5) { connection.typeQThreshold = 0; runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type Q (Experimental)")); } connection.typeQStage = 0; } } if (packet instanceof PacketPlayInArmAnimation) connection.typeE2Swing = true; if (connection.movesReceived > 20L && getVersion() <= 47 && !connection.typeE2Swing && connection.isAntiCheatActivated() && packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity)packet).c() == EnumEntityUseAction.ATTACK) runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Kill Aura Type E2.")); if (connection.isAntiCheatActivated())
- if (packet instanceof PacketPlayInFlying && ((PacketPlayInFlying)packet).hasPos) { if (((PacketPlayInFlying)packet).i()) { connection.criticalTypeBStage = 1; connection.criticalTypeBY = ((PacketPlayInFlying)packet).d(); } else if (connection.criticalTypeBStage == 1 && ((PacketPlayInFlying)packet).d() < connection.criticalTypeBY) { connection.criticalTypeBStage = 2; connection.criticalTypeBHeight = connection.criticalTypeBY - ((PacketPlayInFlying)packet).d(); connection.criticalTypeBY = ((PacketPlayInFlying)packet).d(); } else if (connection.criticalTypeBStage == 2 && ((PacketPlayInFlying)packet).d() > connection.criticalTypeBY) { connection.criticalTypeBStage = 3; connection.criticalTypeBY = ((PacketPlayInFlying)packet).d(); } else if (connection.criticalTypeBStage == 3 && ((PacketPlayInFlying)packet).d() < connection.criticalTypeBY) { connection.criticalTypeBStage = 4; connection.criticalTypeBY = ((PacketPlayInFlying)packet).d(); } else { connection.criticalTypeBStage = 0; } } else { if (packet instanceof PacketPlayInArmAnimation && connection.criticalTypeBStage == 4) { String msg = String.format("%s is using Criticals Type B %.4f", new Object[] { connection.getPlayer().getName(), Double.valueOf(connection.criticalTypeBHeight) }); runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.CRIT, GCheatEvent.Level.ADMIN, msg)); } connection.criticalTypeBStage = 0; } if (getVersion() <= 47) { if (connection.justSentSprint)
- if (packet instanceof PacketPlayInFlying) { connection.justSentSprint = false; } else if (packet instanceof PacketPlayInEntityAction && (((PacketPlayInEntityAction)packet).d() == 1 || ((PacketPlayInEntityAction)packet).d() == 2)) { connection.justSentSprint = false; } else { long now = System.currentTimeMillis(); if (now - connection.lastSprintViolationTime > 1000L) { connection.lastSprintViolationTime = now; runSync(new GCheatEvent(connection.getPlayer(), GCheatEvent.Type.UNKNOWN, GCheatEvent.Level.ADMIN, connection.getPlayer().getName() + " is using Bad Packets Type A (" + packet.getClass().getSimpleName() + ")")); } connection.justSentSprint = false; } if (packet instanceof PacketPlayInEntityAction && (((PacketPlayInEntityAction)packet).d() == 4 || ((PacketPlayInEntityAction)packet).d() == 5))
- connection.justSentSprint = true; } } this.k.add(packet); } } public SocketAddress getSocketAddress() { return this.n; }
- public void a(PacketListener packetlistener) { Validate.notNull(packetlistener, "packetListener", new Object[0]); i.debug("Set listener of {} to {}", new Object[] { this, packetlistener }); this.o = packetlistener; }
- public void handle(Packet packet, GenericFutureListener... agenericfuturelistener) { if (this.m != null && this.m.isOpen()) { i(); b(packet, agenericfuturelistener); } else { this.l.add(new QueuedPacket(packet, agenericfuturelistener)); } }
- private void b(Packet packet, GenericFutureListener[] agenericfuturelistener) { EnumProtocol enumprotocol = EnumProtocol.a(packet); if (enumprotocol == null) enumprotocol = EnumProtocol.PLAY; EnumProtocol enumprotocol1 = (EnumProtocol)this.m.attr(d).get(); if (enumprotocol1 != enumprotocol) { i.debug("Disabled auto read"); this.m.config().setAutoRead(false); } if (this.m.eventLoop().inEventLoop()) { if (enumprotocol != enumprotocol1) a(enumprotocol); this.m.writeAndFlush(packet).addListeners(agenericfuturelistener).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } else { this.m.eventLoop().execute(new QueuedProtocolSwitch(this, enumprotocol, enumprotocol1, packet, agenericfuturelistener)); } }
- private void i() { if (this.m != null && this.m.isOpen()) { QueuedPacket queuedpacket; while ((queuedpacket = (QueuedPacket)this.l.poll()) != null)
- b(QueuedPacket.a(queuedpacket), QueuedPacket.b(queuedpacket)); } } public void close(IChatBaseComponent ichatbasecomponent) { this.preparing = false;
- if (this.m.isOpen()) {
- this.m.close();
- this.q = ichatbasecomponent;
- } }
- public boolean c() { return (this.m instanceof net.minecraft.util.io.netty.channel.local.LocalChannel || this.m instanceof net.minecraft.util.io.netty.channel.local.LocalServerChannel); }
- public void a(SecretKey secretkey) {
- this.m.pipeline().addBefore("splitter", "decrypt", new PacketDecrypter(MinecraftEncryption.a(2, secretkey)));
- this.m.pipeline().addBefore("prepender", "encrypt", new PacketEncrypter(MinecraftEncryption.a(1, secretkey)));
- this.r = true;
- }
- public boolean isConnected() { return (this.m != null && this.m.isOpen()); }
- public PacketListener getPacketListener() { return this.o; }
- public IChatBaseComponent f() { return this.q; }
- public void g() { this.m.config().setAutoRead(false); }
- protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) { a(channelhandlercontext, (Packet)object); }
- static Channel a(NetworkManager networkmanager) { return networkmanager.m; }
- public SocketAddress getRawAddress() { return this.m.remoteAddress(); }
- public void enableCompression() {
- if (this.m.pipeline().get("protocol_lib_decoder") != null) {
- this.m.pipeline().addBefore("protocol_lib_decoder", "decompress", new SpigotDecompressor());
- } else {
- this.m.pipeline().addBefore("decoder", "decompress", new SpigotDecompressor());
- }
- this.m.pipeline().addBefore("encoder", "compress", new SpigotCompressor());
- }
- public Channel getChannel() { return this.m; }
- private void runSync(Runnable r) { (MinecraftServer.getServer()).processQueue.add(r); }
- private void runSync(final GCheatEvent event) {
- (MinecraftServer.getServer()).processQueue.add(new Runnable()
- {
- public void run() {
- if (((PlayerConnection)this.this$0.o).hackDebug) {
- Bukkit.getLogger().info(event.getMsg());
- }
- Bukkit.getPluginManager().callEvent(event);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement