mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
Merge pull request #163 from P4sca1/master
Fix wrong player count in minecraftvanilla protocol
This commit is contained in:
commit
1a3e778c5f
1 changed files with 6 additions and 1 deletions
|
@ -47,6 +47,7 @@ class MinecraftVanilla extends Core {
|
||||||
|
|
||||||
state.raw = json;
|
state.raw = json;
|
||||||
state.maxplayers = json.players.max;
|
state.maxplayers = json.players.max;
|
||||||
|
|
||||||
if(json.players.sample) {
|
if(json.players.sample) {
|
||||||
for(const player of json.players.sample) {
|
for(const player of json.players.sample) {
|
||||||
state.players.push({
|
state.players.push({
|
||||||
|
@ -55,7 +56,11 @@ class MinecraftVanilla extends Core {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < Math.min(json.players.online, 10000); i++) {
|
|
||||||
|
// players.sample may not contain all players or no players at all, depending on how many players are online.
|
||||||
|
// Insert a dummy player object for every online player that is not listed in players.sample.
|
||||||
|
// Limit player amount to 10.000 players for performance reasons.
|
||||||
|
for (let i = state.players.length; i < Math.min(json.players.online, 10000); i++) {
|
||||||
state.players.push({});
|
state.players.push({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue