mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 13:15:52 +01:00
Fix the server packet cancelling feature.
This commit is contained in:
parent
16d231f778
commit
5a6f3be219
@ -418,6 +418,14 @@ public final class PacketFilterManager implements ProtocolManager {
|
||||
throw new IllegalArgumentException("Player has no injected handler.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current plugin class loader.
|
||||
* @return Class loader.
|
||||
*/
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return hasClosed;
|
||||
|
@ -218,19 +218,21 @@ class PlayerInjector {
|
||||
@Override
|
||||
public boolean add(Packet packet) {
|
||||
|
||||
Packet result = null;
|
||||
|
||||
// Check for fake packets and ignored packets
|
||||
if (packet instanceof FakePacket) {
|
||||
return true;
|
||||
} else if (ignoredPackets.contains(packet)) {
|
||||
ignoredPackets.remove(packet);
|
||||
} else {
|
||||
packet = handlePacketRecieved(packet);
|
||||
result = handlePacketRecieved(packet);
|
||||
}
|
||||
|
||||
// A NULL packet indicate cancelling
|
||||
try {
|
||||
if (packet != null) {
|
||||
super.add(packet);
|
||||
if (result != null) {
|
||||
super.add(result);
|
||||
} else {
|
||||
// We'll use the FakePacket marker instead of preventing the filters
|
||||
sendServerPacket(createNegativePacket(packet), true);
|
||||
@ -280,7 +282,7 @@ class PlayerInjector {
|
||||
// }
|
||||
ex.setInterfaces(new Class[] { FakePacket.class } );
|
||||
ex.setUseCache(true);
|
||||
ex.setClassLoader(type.getClassLoader());
|
||||
ex.setClassLoader(manager.getClassLoader());
|
||||
ex.setSuperclass(type);
|
||||
ex.setCallback(new MethodInterceptor() {
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user