Skip to content

Commit

Permalink
fix reading pre 1.4 status response strings if the server MOTD contai…
Browse files Browse the repository at this point in the history
…ns §
  • Loading branch information
KurtThiemann committed Nov 7, 2024
1 parent f39bccf commit 0dbb895
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "craftping",
"type": "module",
"version": "1.1.0",
"version": "1.1.1",
"main": "index.js",
"repository": "github:aternosorg/craftping",
"scripts": {
Expand Down
11 changes: 7 additions & 4 deletions src/JavaPing/Status/LegacyStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ export default class LegacyStatus {
*/
fromPre14String(string) {
let parts = string.split("§");
if (parts.length !== 3) {
if (parts.length < 3) {
throw new ProtocolError("Invalid legacy status string");
}

this.motd = parts[0];
this.setPlayerCount(parseInt(parts[1]))
.setMaxPlayers(parseInt(parts[2]));
let maxPlayers = parseInt(parts.pop());
let playerCount = parseInt(parts.pop());
this.motd = parts.join("§");

this.setPlayerCount(playerCount)
.setMaxPlayers(maxPlayers);
return this;
}

Expand Down

0 comments on commit 0dbb895

Please sign in to comment.