Fixed a bug introduced in #218 causing packet loops. FIXES 202.
In 659f01cc63
, I attempted to
execute packet listeners for receiveClientPacket() on the channel
thread, inadvertently causing them to be executed regardless if
filtered was FALSE, and twice if it is TRUE.
Since asynchronous packet listeners use this feature to take out
packets from the packet stream, they wound up causing an infinite
packet loop. This prevented them from ever being received by the
server.
Dieser Commit ist enthalten in:
Ursprung
75a5efcaa1
Commit
ad060b10af
@ -485,20 +485,15 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveClientPacket(final Object packet, final NetworkMarker marker, final boolean filtered) {
|
||||
public void recieveClientPacket(final Object packet) {
|
||||
// TODO: Ensure the packet listeners are executed in the channel thread.
|
||||
|
||||
// Execute this in the channel thread
|
||||
Runnable action = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PacketEvent event = filtered ? channelListener.onPacketReceiving(ChannelInjector.this, packet, marker) : null;
|
||||
Object result = event != null ? event.getPacket().getHandle() : packet;
|
||||
|
||||
// See if the packet has been cancelled
|
||||
if (event != null && event.isCancelled())
|
||||
return;
|
||||
|
||||
try {
|
||||
MinecraftMethods.getNetworkManagerReadPacketMethod().invoke(networkManager, null, result);
|
||||
MinecraftMethods.getNetworkManagerReadPacketMethod().invoke(networkManager, null, packet);
|
||||
} catch (Exception e) {
|
||||
// Inform the user
|
||||
ProtocolLibrary.getErrorReporter().reportMinimal(factory.getPlugin(), "recieveClientPacket", e);
|
||||
|
@ -36,7 +36,7 @@ class ClosedInjector implements Injector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveClientPacket(Object packet, NetworkMarker marker, boolean filtered) {
|
||||
public void recieveClientPacket(Object packet) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,8 @@ interface Injector {
|
||||
/**
|
||||
* Recieve a packet on the server.
|
||||
* @param packet - the (NMS) packet to send.
|
||||
* @param marker - the network marker.
|
||||
* @param filtered - whether or not the packet is filtered.
|
||||
*/
|
||||
public abstract void recieveClientPacket(Object packet, NetworkMarker marker, boolean filtered);
|
||||
public abstract void recieveClientPacket(Object packet);
|
||||
|
||||
/**
|
||||
* Retrieve the current protocol state.
|
||||
|
@ -331,7 +331,7 @@ public class NettyProtocolInjector implements ChannelListener {
|
||||
@Override
|
||||
public void recieveClientPacket(Player player, Object mcPacket) throws IllegalAccessException, InvocationTargetException {
|
||||
injectionFactory.fromPlayer(player, listener).
|
||||
recieveClientPacket(mcPacket, null, true);
|
||||
recieveClientPacket(mcPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren