We don't expect consumers to create asynchronous markers, so
don't allow them to set it in the packet event.
Dieser Commit ist enthalten in:
Ursprung
a6db5419c0
Commit
65b5a0e8ec
@ -24,6 +24,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.async.AsyncFilterManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import com.comphenix.protocol.injector.PacketConstructor;
|
||||
@ -122,4 +123,10 @@ public interface ProtocolManager extends PacketStream {
|
||||
* @return TRUE if it has, FALSE otherwise.
|
||||
*/
|
||||
public boolean isClosed();
|
||||
|
||||
/**
|
||||
* Retrieve the current asyncronous packet manager.
|
||||
* @return Asyncronous packet manager.
|
||||
*/
|
||||
public AsyncFilterManager getAsyncFilterManager();
|
||||
}
|
@ -79,6 +79,7 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimap<AsyncList
|
||||
Collection<PrioritizedListener<AsyncListenerHandler>> list = getListener(packet.getPacketID());
|
||||
AsyncMarker marker = packet.getAsyncMarker();
|
||||
|
||||
// Yes, removing the marker will cause the chain to stop
|
||||
if (list != null) {
|
||||
Iterator<PrioritizedListener<AsyncListenerHandler>> iterator = list.iterator();
|
||||
|
||||
@ -89,7 +90,7 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimap<AsyncList
|
||||
}
|
||||
}
|
||||
|
||||
// The packet has no listeners. Just send it.
|
||||
// The packet has no further listeners. Just send it.
|
||||
sendingQueue.signalPacketUpdate(packet);
|
||||
signalProcessingDone();
|
||||
|
||||
|
@ -42,7 +42,7 @@ class PacketSendingQueue {
|
||||
AsyncMarker marker = current.getAsyncMarker();
|
||||
|
||||
if (marker.isProcessed() || marker.hasExpired()) {
|
||||
if (marker.isProcessed())
|
||||
if (marker.isProcessed() && !current.isCancelled())
|
||||
sendPacket(current);
|
||||
|
||||
sendingQueue.poll();
|
||||
|
@ -60,6 +60,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
||||
super(origial.source);
|
||||
this.packet = origial.packet;
|
||||
this.player = origial.player;
|
||||
this.cancel = origial.cancel;
|
||||
this.serverPacket = origial.serverPacket;
|
||||
this.asyncMarker = asyncMarker;
|
||||
this.asynchronous = true;
|
||||
@ -156,7 +157,7 @@ public class PacketEvent extends EventObject implements Cancellable {
|
||||
/**
|
||||
* Retrieve the asynchronous marker.
|
||||
* <p>
|
||||
* If the packet is synchronous, this marker will be used to schedule an asynchronous event. In this
|
||||
* If the packet is synchronous, this marker will be used to schedule an asynchronous event. In the following
|
||||
* asynchronous event, the marker is used to correctly pass the packet around to the different threads.
|
||||
* <p>
|
||||
* Note that if there are no asynchronous events that can receive this packet, the marker is NULL.
|
||||
@ -166,19 +167,6 @@ public class PacketEvent extends EventObject implements Cancellable {
|
||||
return asyncMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the asynchronous marker.
|
||||
* <p>
|
||||
* If the marker is non-null at the end of an synchronous event processing, the packet will be scheduled
|
||||
* to be processed asynchronously with the given settings.
|
||||
* <p>
|
||||
* Note that if there are no asynchronous events that can receive this packet, the marker should be NULL.
|
||||
* @param asyncMarker - the new asynchronous marker, or NULL.
|
||||
*/
|
||||
public void setAsyncMarker(AsyncMarker asyncMarker) {
|
||||
this.asyncMarker = asyncMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the packet event has been executed asynchronously or not.
|
||||
* @return TRUE if this packet event is asynchronous, FALSE otherwise.
|
||||
|
@ -137,10 +137,7 @@ public final class PacketFilterManager implements ProtocolManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current async packet filter manager.
|
||||
* @return Async filter manager.
|
||||
*/
|
||||
@Override
|
||||
public AsyncFilterManager getAsyncFilterManager() {
|
||||
return asyncFilterManager;
|
||||
}
|
||||
@ -313,9 +310,11 @@ public final class PacketFilterManager implements ProtocolManager {
|
||||
// Process synchronous events
|
||||
packetListeners.invokePacketRecieving(logger, event);
|
||||
|
||||
// To cancel the asynchronous processing, use the async marker
|
||||
// To cancel asynchronous processing, use the async marker
|
||||
if (!event.isCancelled() && !hasAsyncCancelled(event.getAsyncMarker())) {
|
||||
asyncFilterManager.enqueueSyncPacket(event, event.getAsyncMarker());
|
||||
|
||||
// The above makes a copy of the event, so it's safe to cancel it
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren