Skip to content

Commit

Permalink
Fixed packet snapshot for minimal version
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan1t committed Jan 28, 2022
1 parent 04a18a5 commit 970d5cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'ru.nanit'
version '1.4'
version '1.3.2'

repositories {
mavenCentral()
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/ru/nanit/limbo/protocol/PacketSnapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public PacketSnapshot encodePacket() {
mappings.put(version, hashed);
} else {
hashes.put(hash, version);
mappings.put(version, version);
versionMessages.put(version, encodedMessage.toByteArray());
}

Expand All @@ -69,6 +70,10 @@ public PacketSnapshot encodePacket() {
@Override
public void encode(ByteMessage msg, Version version) {
Version mapped = mappings.get(version);

if (mapped == null)
throw new IllegalArgumentException("No mapped version is for " + version);

byte[] message = versionMessages.get(mapped);

if (message != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public void encode(ByteMessage msg, Version version) {

String ver = server.getConfig().getPingData().getVersion();
String desc = server.getConfig().getPingData().getDescription();
String json = getResponseJson(ver, protocol,
server.getConfig().getMaxPlayers(), server.getConnections().getCount(), desc);

msg.writeString(json);
msg.writeString(getResponseJson(ver, protocol,
server.getConfig().getMaxPlayers(),
server.getConnections().getCount(), desc));
}

@Override
Expand Down

0 comments on commit 970d5cf

Please sign in to comment.