java.lang.Object
net.joseplay.allianceutils.api.pluginComunicate.packets.PacketRegistry

public class PacketRegistry extends Object
Registry responsible for mapping packet types to their corresponding classes and handling deserialization.

Each packet must:

  • Be registered with a unique string identifier
  • Provide a constructor accepting a JSONObject

This class also acts as a bridge to Redis configuration via PluginChannelDispatcher.

  • Constructor Details

    • PacketRegistry

      public PacketRegistry(PluginChannelDispatcher pluginChannelDispatcher)
      Creates a new registry and registers default packets.
      Parameters:
      pluginChannelDispatcher - dispatcher instance
  • Method Details

    • register

      public void register(String type, Class<? extends UniPacket> clazz)
      Registers a packet type.
      Parameters:
      type - unique identifier
      clazz - packet class
    • deserialize

      public UniPacket deserialize(org.json.JSONObject json)
      Deserializes a JSON object into a UniPacket.
      Parameters:
      json - packet data
      Returns:
      reconstructed packet instance
      Throws:
      IllegalArgumentException - if type is unknown
      RuntimeException - if instantiation fails
    • getRedis

      public RedisManager getRedis()
      Returns the Redis manager.
    • useRedis

      public boolean useRedis()
      Indicates whether Redis is enabled.