Record Class ProtocolVersionTooOldPacket
java.lang.Object
java.lang.Record
dev.jorel.commandapi.network.packets.ProtocolVersionTooOldPacket
- Record Components:
protocolVersion- TheCommandAPIProtocol.PROTOCOL_VERSIONto send in this packet.reason- The reason why this packet is being sent.
- All Implemented Interfaces:
CommandAPIPacket
public record ProtocolVersionTooOldPacket(int protocolVersion, String reason)
extends Record
implements CommandAPIPacket
A packet that informs a connected instance of the CommandAPI their
CommandAPIProtocol.PROTOCOL_VERSION is too old
to receive a different packet this instance wanted to send.
This packet may be sent in any direction. It is automatically sent whenever a ProtocolVersionTooOldException
is thrown while writing another packet. When received, a ProtocolVersionTooOldException should be thrown on the
receiving side that mimics the original exception.
-
Constructor Summary
ConstructorsConstructorDescriptionProtocolVersionTooOldPacket(int protocolVersion, String reason) Creates an instance of aProtocolVersionTooOldPacketrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic ProtocolVersionTooOldPacketdeserialize(FriendlyByteBuffer buffer) Reads the bytes from the givenFriendlyByteBufferto create a newProtocolVersionTooOldPacket.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.reason()Returns the value of thereasonrecord 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
-
ProtocolVersionTooOldPacket
Creates an instance of aProtocolVersionTooOldPacketrecord class.- Parameters:
protocolVersion- the value for theprotocolVersionrecord componentreason- the value for thereasonrecord component
-
-
Method Details
-
deserialize
Reads the bytes from the givenFriendlyByteBufferto create a newProtocolVersionTooOldPacket.- Parameters:
buffer- The buffer to read bytes from.- Returns:
- The
ProtocolVersionTooOldPacketsent 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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
protocolVersion
public int protocolVersion()Returns the value of theprotocolVersionrecord component.- Returns:
- the value of the
protocolVersionrecord component
-
reason
-