Archiviert
13
0

Don't create a network marker unnecessarily.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-08-06 19:44:38 +02:00
Ursprung 50c2931484
Commit 65f1371cf4
5 geänderte Dateien mit 18 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.comphenix.protocol.PacketStream; import com.comphenix.protocol.PacketStream;
import com.comphenix.protocol.events.NetworkMarker;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.PrioritizedListener; import com.comphenix.protocol.injector.PrioritizedListener;
import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldAccessException;
@ -381,9 +382,9 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
void sendPacket(PacketEvent event) throws IOException { void sendPacket(PacketEvent event) throws IOException {
try { try {
if (event.isServerPacket()) { if (event.isServerPacket()) {
packetStream.sendServerPacket(event.getPlayer(), event.getPacket(), event.getNetworkMarker(), false); packetStream.sendServerPacket(event.getPlayer(), event.getPacket(), NetworkMarker.getNetworkMarker(event), false);
} else { } else {
packetStream.recieveClientPacket(event.getPlayer(), event.getPacket(), event.getNetworkMarker(), false); packetStream.recieveClientPacket(event.getPlayer(), event.getPacket(), NetworkMarker.getNetworkMarker(event), false);
} }
transmitted = true; transmitted = true;

Datei anzeigen

@ -189,4 +189,15 @@ public class NetworkMarker {
} }
return null; return null;
} }
/**
* Retrieve the network marker of a particular event without creating it.
* <p>
* This is an internal method that should not be used by API users.
* @param event - the event.
* @return The network marker.
*/
public static NetworkMarker getNetworkMarker(PacketEvent event) {
return event.networkMarker;
}
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class PacketEvent extends EventObject implements Cancellable {
private boolean asynchronous; private boolean asynchronous;
// Network input and output handlers // Network input and output handlers
private NetworkMarker networkMarker; NetworkMarker networkMarker;
// Whether or not a packet event is read only // Whether or not a packet event is read only
private boolean readOnly; private boolean readOnly;

Datei anzeigen

@ -643,7 +643,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
sendingListeners.invokePacketSending( sendingListeners.invokePacketSending(
reporter, event, ListenerPriority.MONITOR); reporter, event, ListenerPriority.MONITOR);
marker = event.getNetworkMarker(); marker = NetworkMarker.getNetworkMarker(event);
} }
playerInjection.sendServerPacket(reciever, packet, marker, filters); playerInjection.sendServerPacket(reciever, packet, marker, filters);
} }

Datei anzeigen

@ -611,7 +611,7 @@ public abstract class PlayerInjector implements SocketInjector {
// Right, remember to replace the packet again // Right, remember to replace the packet again
Object result = event.getPacket().getHandle(); Object result = event.getPacket().getHandle();
marker = event.getNetworkMarker(); marker = NetworkMarker.getNetworkMarker(event);
// See if we need to proxy the write method // See if we need to proxy the write method
if (result != null && NetworkMarker.hasOutputHandlers(marker)) { if (result != null && NetworkMarker.hasOutputHandlers(marker)) {