Class ProtocolManager
java.lang.Object
dev.magicmq.pyspigot.bungee.manager.protocol.ProtocolManager
Manager to interface with Protocolize. Primarily used by scripts to register and unregister packet listeners on the BungeeCord proxy.
Do not call this manager if Protocolize is not loaded and enabled on the server! It will not work.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProtocolManagerget()getPacketListener(dev.magicmq.pyspigot.manager.script.Script script, Class<?> packet) Get the packet listener for a particular packet associated with a script.getPacketListeners(dev.magicmq.pyspigot.manager.script.Script script) Get all packet listeners associated with a script.registerPacketListener(PyFunction receiveFunction, PyFunction sendFunction, Class<?> packet, dev.simplix.protocolize.api.Direction direction) Register a new packet listener with default priority.registerPacketListener(PyFunction receiveFunction, PyFunction sendFunction, Class<?> packet, dev.simplix.protocolize.api.Direction direction, int priority) Register a new packet listener with default priority.voidsendPacket(UUID playerUUID, dev.simplix.protocolize.api.packet.AbstractPacket packet) Send a Protocolize packet to the player with the given UUID.voidsendPacket(UUID playerUUID, net.md_5.bungee.protocol.DefinedPacket packet) Send a generic BungeeCord packet to the player with the given UUID.voidunregisterPacketListener(ScriptPacketListener<?> listener) Unregister a packet listener.voidunregisterPacketListeners(dev.magicmq.pyspigot.manager.script.Script script) Unregister all packet listeners belonging to a script.
-
Method Details
-
registerPacketListener
public ScriptPacketListener<?> registerPacketListener(PyFunction receiveFunction, PyFunction sendFunction, Class<?> packet, dev.simplix.protocolize.api.Direction direction) Register a new packet listener with default priority.Note: This should be called from scripts only!
- Parameters:
receiveFunction- The function that should be called when the packet is receivedsendFunction- The function that should be called when the packet is sentpacket- The packet to listen todirection- The direction (eitherDirection.UPSTREAMorDirection.DOWNSTREAM- Returns:
- A
ScriptPacketListenerrepresenting the packet listener that was registered
-
registerPacketListener
public ScriptPacketListener<?> registerPacketListener(PyFunction receiveFunction, PyFunction sendFunction, Class<?> packet, dev.simplix.protocolize.api.Direction direction, int priority) Register a new packet listener with default priority.Note: This should be called from scripts only!
- Parameters:
receiveFunction- The function that should be called when the packet is receivedsendFunction- The function that should be called when the packet is sentpacket- The packet to listen todirection- The direction (eitherDirection.UPSTREAMorDirection.DOWNSTREAMpriority- The priority of the listener- Returns:
- A
ScriptPacketListenerrepresenting the packet listener that was registered
-
unregisterPacketListener
Unregister a packet listener.Note: This should be called from scripts only!
- Parameters:
listener- The packet listener to unregister
-
unregisterPacketListeners
public void unregisterPacketListeners(dev.magicmq.pyspigot.manager.script.Script script) Unregister all packet listeners belonging to a script.- Parameters:
script- The script whose normal packet listeners should be unregistered
-
getPacketListeners
public List<ScriptPacketListener<?>> getPacketListeners(dev.magicmq.pyspigot.manager.script.Script script) Get all packet listeners associated with a script.- Parameters:
script- The script to get normal packet listeners from- Returns:
- An immutable list of
ScriptPacketListenercontaining all packet listeners associated with this script. Will return an empty list if there are no packet listeners associated with the script
-
getPacketListener
public ScriptPacketListener<?> getPacketListener(dev.magicmq.pyspigot.manager.script.Script script, Class<?> packet) Get the packet listener for a particular packet associated with a script.- Parameters:
script- The scriptpacket- The packet- Returns:
- The
ScriptPacketListenerassociated with the script and packet type, null if there is none
-
sendPacket
Send a Protocolize packet to the player with the given UUID.Note: This should be called from scripts only!
- Parameters:
playerUUID- The UUID of the player to send the packet topacket- The packet to send
-
sendPacket
Send a generic BungeeCord packet to the player with the given UUID.Note: This should be called from scripts only!
- Parameters:
playerUUID- The UUID of the player to send the packet topacket- The packet to send
-
get
-