Class ScriptPacketListener

java.lang.Object
com.comphenix.protocol.events.PacketAdapter
dev.magicmq.pyspigot.bukkit.manager.protocol.ScriptPacketListener
All Implemented Interfaces:
PacketListener
Direct Known Subclasses:
PacketReceivingListener, PacketSendingListener

public abstract class ScriptPacketListener extends PacketAdapter
An abstract class designed to represent a basic script packet listener.
See Also:
  • Constructor Details

    • ScriptPacketListener

      public ScriptPacketListener(dev.magicmq.pyspigot.manager.script.Script script, PyFunction function, PacketType packetType, ListenerPriority listenerPriority, ListenerType listenerType)
      Parameters:
      script - The script associated with this packet listener
      function - The function to be called when the packet event occurs
      packetType - The packet type to listen for
      listenerPriority - The ListenerPriority of this listener
      listenerType - The ListenerType of this listener
  • Method Details

    • getScript

      public dev.magicmq.pyspigot.manager.script.Script getScript()
      Get the script associated with this listener.
      Returns:
      The script associated with this listener
    • getFunction

      public PyFunction getFunction()
      Get the function that should be called when the packet event occurs.
      Returns:
      The function that should be called
    • getPacketType

      public PacketType getPacketType()
      Get the packet type being listener for.
      Returns:
      The packet type beign listened for
    • getListenerType

      public ListenerType getListenerType()
      The listener type of this listener.
      Returns:
      The ListenerType of this listener
    • callToScript

      public void callToScript(PacketEvent event)
      A helper method to call a script's packet listener function when the packet event occurs.
      Parameters:
      event - The event that occurred, will be passed to the script's function
    • toString

      public String toString()
      Prints a representation of this ScriptPacketListener in string format, including the packet type listened to by the listener
      Overrides:
      toString in class PacketAdapter
      Returns:
      A string representation of the ScriptPacketListener