network: rename getCommand methods

This commit is contained in:
Bixilon 2021-02-28 17:19:52 +01:00
parent a8fcc8efe1
commit 7101fd04f3
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 8 additions and 8 deletions

View File

@ -20,6 +20,6 @@ import de.bixilon.minosoft.protocol.protocol.Packets;
public class PacketNotImplementedException extends PacketParseException { public class PacketNotImplementedException extends PacketParseException {
public PacketNotImplementedException(InPacketBuffer buffer, Packets.Clientbound packetType, Connection connection) { public PacketNotImplementedException(InPacketBuffer buffer, Packets.Clientbound packetType, Connection connection) {
super(String.format("Packet not implemented yet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", buffer.getCommand(), packetType, buffer.getLength(), buffer.getBytesLeft(), connection.getVersion(), connection.getConnectionState())); super(String.format("Packet not implemented yet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", buffer.getPacketTypeId(), packetType, buffer.getLength(), buffer.getBytesLeft(), connection.getVersion(), connection.getConnectionState()));
} }
} }

View File

@ -65,9 +65,9 @@ public abstract class Network {
Packets.Clientbound packetType = null; Packets.Clientbound packetType = null;
try { try {
packetType = this.connection.getPacketByCommand(this.connection.getConnectionState(), data.getCommand()); packetType = this.connection.getPacketByCommand(this.connection.getConnectionState(), data.getPacketTypeId());
if (packetType == null) { if (packetType == null) {
throw new UnknownPacketException(String.format("Server sent us an unknown packet (id=0x%x, length=%d, data=%s)", data.getCommand(), bytes.length, data.getBase64())); throw new UnknownPacketException(String.format("Server sent us an unknown packet (id=0x%x, length=%d, data=%s)", data.getPacketTypeId(), bytes.length, data.getBase64()));
} }
ClientboundPacket packet; ClientboundPacket packet;

View File

@ -23,7 +23,7 @@ public class InPacketBuffer extends InByteBuffer {
this.command = readVarInt(); this.command = readVarInt();
} }
public int getCommand() { public int getPacketTypeId() {
return this.command; return this.command;
} }
} }

View File

@ -18,19 +18,19 @@ import de.bixilon.minosoft.protocol.network.Connection;
public class OutPacketBuffer extends OutByteBuffer { public class OutPacketBuffer extends OutByteBuffer {
private final int command; private final int command;
public OutPacketBuffer(Connection connection, Packets.Serverbound command) { public OutPacketBuffer(Connection connection, Packets.Serverbound packetType) {
super(connection); super(connection);
this.command = connection.getPacketCommand(command); this.command = connection.getPacketCommand(packetType);
} }
@Override @Override
public byte[] toByteArray() { public byte[] toByteArray() {
OutByteBuffer ret = new OutByteBuffer(this); OutByteBuffer ret = new OutByteBuffer(this);
ret.prefixVarInt(getCommand()); ret.prefixVarInt(getPacketTypeId());
return ret.toByteArray(); return ret.toByteArray();
} }
public int getCommand() { public int getPacketTypeId() {
return this.command; return this.command;
} }
} }