mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2025-07-16 06:00:13 +02:00
Changed packet signature to support different versions
This commit is contained in:
parent
ff5b605ee3
commit
62fbc0e8f2
@ -97,6 +97,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
|||||||
PacketHandshake handshake = (PacketHandshake) packet;
|
PacketHandshake handshake = (PacketHandshake) packet;
|
||||||
clientVersion = handshake.getVersion();
|
clientVersion = handshake.getVersion();
|
||||||
updateState(State.getById(handshake.getNextState()));
|
updateState(State.getById(handshake.getNextState()));
|
||||||
|
|
||||||
Logger.debug("Pinged from " + address);
|
Logger.debug("Pinged from " + address);
|
||||||
|
|
||||||
if (server.getConfig().getInfoForwarding().isLegacy()) {
|
if (server.getConfig().getInfoForwarding().isLegacy()) {
|
||||||
@ -128,7 +129,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clientVersion.equals(Version.getCurrentSupported())) {
|
if (clientVersion.equals(Version.UNDEFINED)) {
|
||||||
disconnectLogin("Incompatible client version");
|
disconnectLogin("Incompatible client version");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class PacketDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
|
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
try {
|
try {
|
||||||
packet.decode(msg);
|
packet.decode(msg, );
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.warning("Cannot decode packet 0x%s: %s", Integer.toHexString(packetId), e.getMessage());
|
Logger.warning("Cannot decode packet 0x%s: %s", Integer.toHexString(packetId), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class PacketEncoder extends MessageToByteEncoder<Packet> {
|
|||||||
msg.writeVarInt(packetId);
|
msg.writeVarInt(packetId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
packet.encode(msg);
|
packet.encode(msg, );
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.warning("Cannot encode packet 0x%s: %s", Integer.toHexString(packetId), e.getMessage());
|
Logger.warning("Cannot encode packet 0x%s: %s", Integer.toHexString(packetId), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ru.nanit.limbo.protocol;
|
package ru.nanit.limbo.protocol;
|
||||||
|
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public interface Packet {
|
public interface Packet {
|
||||||
|
|
||||||
void encode(ByteMessage msg);
|
void encode(ByteMessage msg, Version version);
|
||||||
|
|
||||||
void decode(ByteMessage msg);
|
void decode(ByteMessage msg, Version version);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ru.nanit.limbo.protocol;
|
package ru.nanit.limbo.protocol;
|
||||||
|
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public interface PacketIn extends Packet {
|
public interface PacketIn extends Packet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void encode(ByteMessage msg) {
|
default void encode(ByteMessage msg, Version version) {
|
||||||
// Can be ignored for incoming packets
|
// Can be ignored for incoming packets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ru.nanit.limbo.protocol;
|
package ru.nanit.limbo.protocol;
|
||||||
|
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public interface PacketOut extends Packet {
|
public interface PacketOut extends Packet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void decode(ByteMessage msg) {
|
default void decode(ByteMessage msg, Version version) {
|
||||||
// Can be ignored for outgoing packets
|
// Can be ignored for outgoing packets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package ru.nanit.limbo.protocol;
|
package ru.nanit.limbo.protocol;
|
||||||
|
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PreEncodedPacket implements PacketOut {
|
public class PreEncodedPacket implements PacketOut {
|
||||||
|
|
||||||
private final PacketOut packet;
|
private final PacketOut packet;
|
||||||
@ -15,14 +17,14 @@ public class PreEncodedPacket implements PacketOut {
|
|||||||
|
|
||||||
public PreEncodedPacket encodePacket() {
|
public PreEncodedPacket encodePacket() {
|
||||||
ByteMessage encodedMessage = ByteMessage.create();
|
ByteMessage encodedMessage = ByteMessage.create();
|
||||||
packet.encode(encodedMessage);
|
packet.encode(encodedMessage, );
|
||||||
this.message = encodedMessage.toByteArray();
|
this.message = encodedMessage.toByteArray();
|
||||||
encodedMessage.release();
|
encodedMessage.release();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeBytes(message);
|
msg.writeBytes(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,36 +15,16 @@ public class PacketHandshake implements Packet {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(Version version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHost(String host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNextState() {
|
public int getNextState() {
|
||||||
return nextState;
|
return nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextState(int nextState) {
|
|
||||||
this.nextState = nextState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeVarInt(this.version.getProtocolNumber());
|
msg.writeVarInt(this.version.getProtocolNumber());
|
||||||
msg.writeString(host);
|
msg.writeString(host);
|
||||||
msg.writeShort(port);
|
msg.writeShort(port);
|
||||||
@ -52,7 +32,7 @@ public class PacketHandshake implements Packet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
this.version = Version.of(msg.readVarInt());
|
this.version = Version.of(msg.readVarInt());
|
||||||
this.host = msg.readString();
|
this.host = msg.readString();
|
||||||
this.port = msg.readUnsignedShort();
|
this.port = msg.readUnsignedShort();
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.login;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketDisconnect implements PacketOut {
|
public class PacketDisconnect implements PacketOut {
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ public class PacketDisconnect implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeString(String.format("{\"text\": \"%s\"}", reason));
|
msg.writeString(String.format("{\"text\": \"%s\"}", reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package ru.nanit.limbo.protocol.packets.login;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketLoginPluginRequest implements PacketOut {
|
public class PacketLoginPluginRequest implements PacketOut {
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public class PacketLoginPluginRequest implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeVarInt(messageId);
|
msg.writeVarInt(messageId);
|
||||||
msg.writeString(channel);
|
msg.writeString(channel);
|
||||||
msg.writeBytes(data);
|
msg.writeBytes(data);
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.login;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketIn;
|
import ru.nanit.limbo.protocol.PacketIn;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketLoginPluginResponse implements PacketIn {
|
public class PacketLoginPluginResponse implements PacketIn {
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public class PacketLoginPluginResponse implements PacketIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
messageId = msg.readVarInt();
|
messageId = msg.readVarInt();
|
||||||
successful = msg.readBoolean();
|
successful = msg.readBoolean();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ru.nanit.limbo.protocol.packets.login;
|
package ru.nanit.limbo.protocol.packets.login;
|
||||||
|
|
||||||
import ru.nanit.limbo.protocol.*;
|
import ru.nanit.limbo.protocol.*;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketLoginStart implements PacketIn {
|
public class PacketLoginStart implements PacketIn {
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ public class PacketLoginStart implements PacketIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
this.username = msg.readString();
|
this.username = msg.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.login;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ public class PacketLoginSuccess implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeUuid(uuid);
|
msg.writeUuid(uuid);
|
||||||
msg.writeString(username);
|
msg.writeString(username);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
import ru.nanit.limbo.server.data.BossBar;
|
import ru.nanit.limbo.server.data.BossBar;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -25,7 +26,7 @@ public class PacketBossBar implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeUuid(uuid);
|
msg.writeUuid(uuid);
|
||||||
msg.writeVarInt(0); // Create bossbar
|
msg.writeVarInt(0); // Create bossbar
|
||||||
msg.writeString(bossBar.getText());
|
msg.writeString(bossBar.getText());
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class PacketChatMessage implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeString(jsonData);
|
msg.writeString(jsonData);
|
||||||
msg.writeByte(position.index);
|
msg.writeByte(position.index);
|
||||||
msg.writeUuid(sender);
|
msg.writeUuid(sender);
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class PacketDeclareCommands implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeVarInt(commands.size() * 2 + 1); // +1 because declaring root node
|
msg.writeVarInt(commands.size() * 2 + 1); // +1 because declaring root node
|
||||||
|
|
||||||
// Declare root node
|
// Declare root node
|
||||||
|
@ -3,6 +3,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketJoinGame implements PacketOut {
|
public class PacketJoinGame implements PacketOut {
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeInt(entityId);
|
msg.writeInt(entityId);
|
||||||
msg.writeBoolean(isHardcore);
|
msg.writeBoolean(isHardcore);
|
||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.Packet;
|
import ru.nanit.limbo.protocol.Packet;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketKeepAlive implements Packet {
|
public class PacketKeepAlive implements Packet {
|
||||||
|
|
||||||
@ -16,12 +17,12 @@ public class PacketKeepAlive implements Packet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeLong(id);
|
msg.writeLong(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
this.id = msg.readLong();
|
this.id = msg.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketPlayerAbilities implements PacketOut {
|
public class PacketPlayerAbilities implements PacketOut {
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public class PacketPlayerAbilities implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeByte(flags);
|
msg.writeByte(flags);
|
||||||
msg.writeFloat(flyingSpeed);
|
msg.writeFloat(flyingSpeed);
|
||||||
msg.writeFloat(fieldOfView);
|
msg.writeFloat(fieldOfView);
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class PacketPlayerInfo implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeVarInt(0);
|
msg.writeVarInt(0);
|
||||||
msg.writeVarInt(1);
|
msg.writeVarInt(1);
|
||||||
msg.writeUuid(uuid);
|
msg.writeUuid(uuid);
|
||||||
|
@ -2,6 +2,7 @@ package ru.nanit.limbo.protocol.packets.play;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.PacketOut;
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketPlayerPositionAndLook implements PacketOut {
|
public class PacketPlayerPositionAndLook implements PacketOut {
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class PacketPlayerPositionAndLook implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeDouble(x);
|
msg.writeDouble(x);
|
||||||
msg.writeDouble(y);
|
msg.writeDouble(y);
|
||||||
msg.writeDouble(z);
|
msg.writeDouble(z);
|
||||||
|
@ -2,18 +2,19 @@ package ru.nanit.limbo.protocol.packets.status;
|
|||||||
|
|
||||||
import ru.nanit.limbo.protocol.ByteMessage;
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
import ru.nanit.limbo.protocol.Packet;
|
import ru.nanit.limbo.protocol.Packet;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketStatusPing implements Packet {
|
public class PacketStatusPing implements Packet {
|
||||||
|
|
||||||
private long randomId;
|
private long randomId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeLong(randomId);
|
msg.writeLong(randomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
this.randomId = msg.readLong();
|
this.randomId = msg.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package ru.nanit.limbo.protocol.packets.status;
|
package ru.nanit.limbo.protocol.packets.status;
|
||||||
|
|
||||||
import ru.nanit.limbo.protocol.*;
|
import ru.nanit.limbo.protocol.*;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
public class PacketStatusRequest implements PacketIn {
|
public class PacketStatusRequest implements PacketIn {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteMessage msg) {
|
public void decode(ByteMessage msg, Version version) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ public class PacketStatusResponse implements PacketOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
String ver = server.getConfig().getPingData().getVersion();
|
String ver = server.getConfig().getPingData().getVersion();
|
||||||
String desc = server.getConfig().getPingData().getDescription();
|
String desc = server.getConfig().getPingData().getDescription();
|
||||||
String json = getResponseJson(ver, Version.getCurrentSupported().getProtocolNumber(),
|
String json = getResponseJson(ver, Version.getMinimal().getProtocolNumber(),
|
||||||
server.getConfig().getMaxPlayers(), server.getConnections().getCount(), desc);
|
server.getConfig().getMaxPlayers(), server.getConnections().getCount(), desc);
|
||||||
|
|
||||||
msg.writeString(json);
|
msg.writeString(json);
|
||||||
|
@ -31,7 +31,10 @@ public enum Version {
|
|||||||
V1_16_1(736),
|
V1_16_1(736),
|
||||||
V1_16_2(751),
|
V1_16_2(751),
|
||||||
V1_16_3(753),
|
V1_16_3(753),
|
||||||
V1_16_4(754);
|
V1_16_4(754),
|
||||||
|
// 1.16.5 has same protocol number
|
||||||
|
V1_17(755),
|
||||||
|
V1_17_1(756);
|
||||||
|
|
||||||
public static final Map<Integer, Version> VERSION_MAP;
|
public static final Map<Integer, Version> VERSION_MAP;
|
||||||
|
|
||||||
@ -43,8 +46,8 @@ public enum Version {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version getCurrentSupported() {
|
public static Version getMinimal() {
|
||||||
return V1_16_4;
|
return V1_9;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version of(int protocolNumber) {
|
public static Version of(int protocolNumber) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user