Class PacketRegistry
java.lang.Object
net.joseplay.allianceutils.api.pluginComunicate.packets.PacketRegistry
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 Summary
ConstructorsConstructorDescriptionPacketRegistry(PluginChannelDispatcher pluginChannelDispatcher) Creates a new registry and registers default packets. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(org.json.JSONObject json) Deserializes a JSON object into aUniPacket.getRedis()Returns the Redis manager.voidRegisters a packet type.booleanuseRedis()Indicates whether Redis is enabled.
-
Constructor Details
-
PacketRegistry
Creates a new registry and registers default packets.- Parameters:
pluginChannelDispatcher- dispatcher instance
-
-
Method Details
-
register
Registers a packet type.- Parameters:
type- unique identifierclazz- packet class
-
deserialize
Deserializes a JSON object into aUniPacket.- Parameters:
json- packet data- Returns:
- reconstructed packet instance
- Throws:
IllegalArgumentException- if type is unknownRuntimeException- if instantiation fails
-
getRedis
Returns the Redis manager. -
useRedis
public boolean useRedis()Indicates whether Redis is enabled.
-