mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-05-31 05:51:55 +00:00
Fixed false positives in movement emulation while sprinting, and fixed bug that prevents some chunks from loading on the client side
This commit is contained in:
@@ -45,7 +45,7 @@ public class JoinListener implements Listener {
|
||||
|
||||
APlayer player = op.get();
|
||||
|
||||
if(player.isSendingPackets() || !player.isInitialized()) return;
|
||||
if(!player.isInitialized()) return;
|
||||
|
||||
if(event.getType().equals(PacketType.CLIENT_TRANSACTION)) {
|
||||
if(!player.getPacketQueue().isEmpty()) {
|
||||
@@ -68,6 +68,7 @@ public class JoinListener implements Listener {
|
||||
player.getPacketQueue().add(event.getPacket());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.getBukkitPlayer().sendMessage("§cPlease wait a moment before sending packets again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
//TODO Make this feature-parody with ModernHandler
|
||||
public class LegacyHandler extends HandlerAbstract {
|
||||
@@ -48,7 +49,9 @@ public class LegacyHandler extends HandlerAbstract {
|
||||
} else uninjectedChannels.add(channel);
|
||||
}
|
||||
} catch(IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
Anticheat.INSTANCE.getLogger().log(Level.WARNING, "Failed to add packet handler for player " + player.getName(), e);
|
||||
} catch (Exception e) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Unexpected error while adding packet handler for player " + player.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,28 +110,38 @@ public class LegacyHandler extends HandlerAbstract {
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
String name = msg.getClass().getName();
|
||||
int index = name.lastIndexOf(".");
|
||||
String packetName = name.substring(index + 1);
|
||||
|
||||
Object packet = Anticheat.INSTANCE.getPacketProcessor().call(player, msg, PacketType
|
||||
.getByPacketId(packetName).orElse(PacketType.UNKNOWN));
|
||||
try {
|
||||
String name = msg.getClass().getName();
|
||||
int index = name.lastIndexOf(".");
|
||||
String packetName = name.substring(index + 1);
|
||||
Object packet = Anticheat.INSTANCE.getPacketProcessor().call(player, msg, PacketType
|
||||
.getByPacketId(packetName).orElse(PacketType.UNKNOWN));
|
||||
|
||||
if(packet != null) {
|
||||
super.channelRead(ctx, packet);
|
||||
if(packet != null) {
|
||||
super.channelRead(ctx, packet);
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.WARNING, "Error on channel read for player " + player.getName(), throwable);
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
String name = msg.getClass().getName();
|
||||
int index = name.lastIndexOf(".");
|
||||
String packetName = name.substring(index + 1);
|
||||
Object packet = Anticheat.INSTANCE.getPacketProcessor().call(player, msg, PacketType
|
||||
.getByPacketId(packetName).orElse(PacketType.UNKNOWN));
|
||||
try {
|
||||
String name = msg.getClass().getName();
|
||||
int index = name.lastIndexOf(".");
|
||||
String packetName = name.substring(index + 1);
|
||||
Object packet = Anticheat.INSTANCE.getPacketProcessor().call(player, msg, PacketType
|
||||
.getByPacketId(packetName).orElse(PacketType.UNKNOWN));
|
||||
|
||||
if(packet != null) {
|
||||
super.write(ctx, packet, promise);
|
||||
if(packet != null) {
|
||||
super.write(ctx, packet, promise);
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.WARNING, "Error on channel write for player " + player.getName(), throwable);
|
||||
super.write(ctx, msg, promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,37 +214,43 @@ public class ModernHandler extends HandlerAbstract {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketType type = HandlerAbstract.getPacketType(msg);
|
||||
try {
|
||||
PacketType type = HandlerAbstract.getPacketType(msg);
|
||||
|
||||
if(type == PacketType.LOGIN_START) {
|
||||
PacketLoginInStart packet = (PacketLoginInStart) msg;
|
||||
if(type == PacketType.LOGIN_START) {
|
||||
PacketLoginInStart packet = (PacketLoginInStart) msg;
|
||||
|
||||
channelCache.put(packet.a().getName(), ctx.channel());
|
||||
} else if(type == PacketType.LOGIN_HANDSHAKE) {
|
||||
WPacketHandshakingInSetProtocol packet = (WPacketHandshakingInSetProtocol) PacketType.processType(type, msg);
|
||||
channelCache.put(packet.a().getName(), ctx.channel());
|
||||
} else if(type == PacketType.LOGIN_HANDSHAKE) {
|
||||
WPacketHandshakingInSetProtocol packet = (WPacketHandshakingInSetProtocol) PacketType.processType(type, msg);
|
||||
|
||||
if(packet.getProtocol() == WPacketHandshakingInSetProtocol.EnumProtocol.LOGIN) {
|
||||
protocolLookup.put(ctx.channel(), packet.getVersionNumber());
|
||||
}
|
||||
}
|
||||
|
||||
if(player != null && Anticheat.INSTANCE.getPacketProcessor() != null) {
|
||||
try {
|
||||
Object returnedObject = Anticheat.INSTANCE.getPacketProcessor().call(player, msg,
|
||||
type);
|
||||
|
||||
if (returnedObject != null) {
|
||||
super.channelRead(ctx, returnedObject);
|
||||
if(packet.getProtocol() == WPacketHandshakingInSetProtocol.EnumProtocol.LOGIN) {
|
||||
protocolLookup.put(ctx.channel(), packet.getVersionNumber());
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, throwable);
|
||||
}
|
||||
|
||||
if(player != null && Anticheat.INSTANCE.getPacketProcessor() != null) {
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
} catch (Exception e) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, e);
|
||||
Object returnedObject = Anticheat.INSTANCE.getPacketProcessor().call(player, msg,
|
||||
type);
|
||||
|
||||
if (returnedObject != null) {
|
||||
super.channelRead(ctx, returnedObject);
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, throwable);
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
} catch (Exception e) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
} else {
|
||||
} catch (Throwable t) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Error on channel read for player: "
|
||||
+ player.getName(), t);
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
}
|
||||
@@ -257,19 +263,25 @@ public class ModernHandler extends HandlerAbstract {
|
||||
return;
|
||||
}
|
||||
|
||||
if(player != null) {
|
||||
try {
|
||||
Object returnedObject = Anticheat.INSTANCE.getPacketProcessor().call(player, msg,
|
||||
HandlerAbstract.getPacketType(msg));
|
||||
try {
|
||||
if(player != null) {
|
||||
try {
|
||||
Object returnedObject = Anticheat.INSTANCE.getPacketProcessor().call(player, msg,
|
||||
HandlerAbstract.getPacketType(msg));
|
||||
|
||||
if (returnedObject != null) {
|
||||
super.write(ctx, returnedObject, promise);
|
||||
if (returnedObject != null) {
|
||||
super.write(ctx, returnedObject, promise);
|
||||
}
|
||||
} catch(Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, throwable);
|
||||
super.write(ctx, msg, promise);
|
||||
}
|
||||
} catch(Throwable throwable) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Cannot call packet " + msg, throwable);
|
||||
super.write(ctx, msg, promise);
|
||||
}
|
||||
} else super.write(ctx, msg, promise);
|
||||
} else super.write(ctx, msg, promise);
|
||||
} catch (Throwable t) {
|
||||
Anticheat.INSTANCE.getLogger().log(Level.SEVERE, "Error on channel write for player: "
|
||||
+ (player != null ? player.getName() : "Unknown"), t);
|
||||
super.write(ctx, msg, promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
Submodule Neo updated: 493c3bda35...10cf844dd2
Reference in New Issue
Block a user