From 95fe40aef38c414109b85c6470335f9e0bd7e4b7 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Wed, 21 Nov 2012 02:48:14 +0100 Subject: [PATCH] Discurage sending of cancelled packets in ProtocolManager too. --- .../comphenix/protocol/ProtocolManager.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java index cbdc93f1..3e319249 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java @@ -17,6 +17,7 @@ package com.comphenix.protocol; +import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Set; @@ -25,6 +26,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import com.comphenix.protocol.async.AsyncMarker; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketListener; import com.comphenix.protocol.injector.PacketConstructor; @@ -37,6 +39,37 @@ import com.google.common.collect.ImmutableSet; */ public interface ProtocolManager extends PacketStream { + /** + * Send a packet to the given player. + *

+ * Re-sending a previously cancelled packet is discuraged. Use {@link AsyncMarker#incrementProcessingDelay()} + * to delay a packet until a certain condition has been met. + * + * @param reciever - the reciever. + * @param packet - packet to send. + * @param filters - whether or not to invoke any packet filters. + * @throws InvocationTargetException - if an error occured when sending the packet. + */ + @Override + public void sendServerPacket(Player reciever, PacketContainer packet, boolean filters) + throws InvocationTargetException; + + /** + * Simulate recieving a certain packet from a given player. + *

+ * Receiving a previously cancelled packet is discuraged. Use {@link AsyncMarker#incrementProcessingDelay()} + * to delay a packet until a certain condition has been met. + * + * @param sender - the sender. + * @param packet - the packet that was sent. + * @param filters - whether or not to invoke any packet filters. + * @throws InvocationTargetException If the reflection machinery failed. + * @throws IllegalAccessException If the underlying method caused an error. + */ + @Override + public void recieveClientPacket(Player sender, PacketContainer packet, boolean filters) + throws IllegalAccessException, InvocationTargetException; + /** * Retrieves a list of every registered packet listener. * @return Every registered packet listener.