Archiviert
13
0

Prevent cancelled packets from been cancelled over and over again.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-12-08 00:51:46 +01:00
Ursprung fa55e2cb27
Commit a74d2ca8bc
2 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -304,7 +304,7 @@ class ChannelInjector extends ByteToMessageDecoder {
// Schedule the transmission on the main thread instead // Schedule the transmission on the main thread instead
if (channelListener.hasMainThreadListener(clazz)) { if (channelListener.hasMainThreadListener(clazz)) {
// Delay the packet // Delay the packet
scheduleMainThread(marker, packet); scheduleMainThread(packet);
packet = null; packet = null;
} else { } else {
@ -338,11 +338,14 @@ class ChannelInjector extends ByteToMessageDecoder {
} }
} }
private void scheduleMainThread(final NetworkMarker marker, final Object packetCopy) { private void scheduleMainThread(final Object packetCopy) {
// Do not process this packet agai
processedPackets.add(packetCopy);
ProtocolLibrary.getExecutorSync().execute(new Runnable() { ProtocolLibrary.getExecutorSync().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
sendServerPacket(packetCopy, marker, true); invokeSendPacket(packetCopy);
} }
}); });
} }
@ -433,7 +436,14 @@ class ChannelInjector extends ByteToMessageDecoder {
} else { } else {
ignoredPackets.remove(packet); ignoredPackets.remove(packet);
} }
invokeSendPacket(packet);
}
/**
* Invoke the sendPacket method in Minecraft.
* @param packet - the packet to send.
*/
private void invokeSendPacket(Object packet) {
// Attempt to send the packet with NetworkMarker.handle(), or the PlayerConnection if its active // Attempt to send the packet with NetworkMarker.handle(), or the PlayerConnection if its active
try { try {
if (player instanceof Factory) { if (player instanceof Factory) {

Datei anzeigen

@ -91,7 +91,7 @@ abstract class ChannelProxy implements Channel {
if (packet != null) if (packet != null)
accessor.set(runnable, packet); accessor.set(runnable, packet);
else else
getEmptyRunnable(); return getEmptyRunnable();
} }
return runnable; return runnable;
} }
@ -106,7 +106,7 @@ abstract class ChannelProxy implements Channel {
if (packet != null) if (packet != null)
accessor.set(callable, packet); accessor.set(callable, packet);
else else
getEmptyCallable(); return getEmptyCallable();
} }
return callable; return callable;
} }