Record Class SetVersionPacket
java.lang.Object
java.lang.Record
dev.jorel.commandapi.network.packets.SetVersionPacket
- Record Components:
protocolVersion- TheCommandAPIProtocol.PROTOCOL_VERSIONto send in this packet.
- All Implemented Interfaces:
CommandAPIPacket
A packet that conveys what
CommandAPIProtocol.PROTOCOL_VERSION a connected instance of the CommandAPI is using.
This packet may be sent in any direction. It should be sent whenever a Player connects to a Server from the CommandAPI instances on both sides (if they exist). If this packet is never received, the protocol version defaults to 0.
-
Constructor Summary
ConstructorsConstructorDescriptionSetVersionPacket(int protocolVersion) Creates an instance of aSetVersionPacketrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic SetVersionPacketdeserialize(FriendlyByteBuffer buffer) Reads the bytes from the givenFriendlyByteBufferto create a newSetVersionPacket.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 theprotocolVersionrecord component.final StringtoString()Returns a string representation of this record class.voidwrite(FriendlyByteBuffer buffer, Object target, int protocolVersion) Writes the data of this packet to aFriendlyByteBuffer.
-
Constructor Details
-
SetVersionPacket
public SetVersionPacket(int protocolVersion) Creates an instance of aSetVersionPacketrecord class.- Parameters:
protocolVersion- the value for theprotocolVersionrecord component
-
-
Method Details
-
deserialize
Reads the bytes from the givenFriendlyByteBufferto create a newSetVersionPacket.- Parameters:
buffer- The buffer to read bytes from.- Returns:
- The
SetVersionPacketsent to this plugin.
-
write
Description copied from interface:CommandAPIPacketWrites the data of this packet to aFriendlyByteBuffer.- Specified by:
writein interfaceCommandAPIPacket- Parameters:
buffer- The byte buffer to write to.target- The OutputChannel this packet is being sent to.protocolVersion- TheCommandAPIProtocol.PROTOCOL_VERSIONof the CommandAPI instance this packet is being sent to. Implementations of this method should make sure not to send any data the receiving instance can not understand. If this packet simply cannot be sent to the receiving version, it is appropriate to throw anProtocolVersionTooOldException.
-
toString
-
hashCode
-
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. All components in this record class are compared with '=='. -
protocolVersion
public int protocolVersion()Returns the value of theprotocolVersionrecord component.- Returns:
- the value of the
protocolVersionrecord component
-