mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 03:25:29 +01:00
Properly cancel or modify packets intercepted in the channel thread.
This fixes ticket #204 on BukkitDev.
This commit is contained in:
parent
ad060b10af
commit
5e0000d139
@ -43,6 +43,7 @@ import com.comphenix.protocol.utility.MinecraftMethods;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.primitives.Bytes;
|
||||
|
||||
/**
|
||||
* Represents a channel injector.
|
||||
@ -311,6 +312,11 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
|
||||
} else {
|
||||
event = processSending(packet, marker);
|
||||
|
||||
// Handle the output
|
||||
if (event != null) {
|
||||
packet = !event.isCancelled() ? event.getPacket().getHandle() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event != null) {
|
||||
@ -327,6 +333,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
for (PacketOutputHandler handler : marker.getOutputHandlers()) {
|
||||
handler.handle(event, data);
|
||||
}
|
||||
|
||||
// Write the result
|
||||
output.writeBytes(data);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user