Package crow.game.codec
Record Class PacketRule
java.lang.Object
java.lang.Record
crow.game.codec.PacketRule
public record PacketRule(int minVersion, int maxVersion, short prefix, int data, PacketRule.Type type, String name, Class<?> clz)
extends Record
Represents a specification for which packet ID (labeled 'prefix' here) is of what type (STATIC or
DYNAMIC), what name and Java class POJO, and what kRO packet version the POJO maps to.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe type of packet, currently only 2. -
Constructor Summary
ConstructorsConstructorDescriptionPacketRule(int minVersion, int maxVersion, short prefix, int data, PacketRule.Type type, String name, Class<?> clz) Packet rule constructor.PacketRule(short prefix, int data, PacketRule.Type type, Class<?> clz) Simpler packet rule constructor.PacketRule(short prefix, int data, PacketRule.Type type, String name, Class<?> clz) Simpler packet rule constructor. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>clz()Returns the value of theclzrecord component.intdata()Returns the value of thedatarecord component.static PacketRulestatic PacketRuleUtility constructor for building a non-packet version specific dynamic packet whose name is derived from the given class.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxVersionrecord component.intReturns the value of theminVersionrecord component.name()Returns the value of thenamerecord component.shortprefix()Returns the value of theprefixrecord component.static PacketRulestatic PacketRuleUtility constructor for building a non-packet version specific static packet whose name is derived from the given class.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
PacketRule
Simpler packet rule constructor.- Parameters:
prefix- The 2-byte code prefix for matching the packet.data- The static or dynamic size tag indicator.type- The type of the packet, STATIC or DYNAMICclz- The class of the POJO we are serializing and deserializing.
-
PacketRule
Simpler packet rule constructor.- Parameters:
prefix- The 2-byte code prefix for matching the packet.data- The static or dynamic size tag indicator.type- The type of the packet, STATIC or DYNAMICname- The name of the packet, currently only for logging.clz- The class of the POJO we are serializing and deserializing.
-
PacketRule
public PacketRule(int minVersion, int maxVersion, short prefix, int data, PacketRule.Type type, String name, Class<?> clz) Packet rule constructor.- Parameters:
minVersion- the min version, in YYYYMMDD format, or -1 for "as early as possible".maxVersion- the maximum packet version this rule supports, in YYYYMMDD format, or -1 for "most recent"prefix- The 2-byte code prefix for matching the packet.data- The static or dynamic size tag indicator.type- The type of the packet, STATIC or DYNAMICname- The name of the packet, currently only for logging.clz- The class of the POJO we are serializing and deserializing.
-
-
Method Details
-
Dynamic
Utility constructor for building a non-packet version specific dynamic packet whose name is derived from the given class.- Parameters:
prefix- The 2-byte code prefix for matching the packet.sizeTag- The size of the following "packet size" indicator, 2 or 4.clz- The class that we are serializing and deserializing.- Returns:
- The packet rule object.
-
Dynamic
-
Static
Utility constructor for building a non-packet version specific static packet whose name is derived from the given class.- Parameters:
prefix- The 2-byte code prefix for matching the packet.size- The size of the following full packet.clz- The class that we are serializing and deserializing.- Returns:
- The packet rule object.
-
Static
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
minVersion
public int minVersion()Returns the value of theminVersionrecord component.- Returns:
- the value of the
minVersionrecord component
-
maxVersion
public int maxVersion()Returns the value of themaxVersionrecord component.- Returns:
- the value of the
maxVersionrecord component
-
prefix
public short prefix()Returns the value of theprefixrecord component.- Returns:
- the value of the
prefixrecord component
-
data
public int data()Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
clz
Returns the value of theclzrecord component.- Returns:
- the value of the
clzrecord component
-