Fix the server packet cancelling feature.

This commit is contained in:
Kristian S. Stangeland 2012-09-13 14:56:14 +02:00
parent 16d231f778
commit 5a6f3be219
2 changed files with 14 additions and 4 deletions

View File

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

View File

@ -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