Skip to content

Commit

Permalink
Fix unique player count sometimes doubled
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisD3D committed Nov 13, 2023
1 parent 0481411 commit 8621fbf
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public GlobalEntity getServerData() {
}

MinecraftServer server = Mc2DiscordMinecraft.server;
return new GlobalEntity(onlinePlayerCount, server.getMaxPlayers(), Optional.of(server.playerDataStorage.getSeenPlayers()).map(strings -> strings.length).orElse(0), server.getMotd(), server.getServerVersion(), server.getLocalIp(), String.valueOf(server.getPort()));
return new GlobalEntity(onlinePlayerCount, server.getMaxPlayers(), Optional.ofNullable(server.playerDataStorage.playerDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".dat"))).map(files -> files.length).orElse(0), server.getMotd(), server.getServerVersion(), server.getLocalIp(), String.valueOf(server.getPort()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessWidener v1 named
accessible field net/minecraft/world/damagesource/CombatTracker mob Lnet/minecraft/world/entity/LivingEntity;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/world/level/storage/PlayerDataStorage playerDir Ljava/io/File;
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
public net.minecraft.server.MinecraftServer f_129745_ # playerDataStorage
public net.minecraft.world.damagesource.CombatTracker f_19277_ # mob
public net.minecraft.server.MinecraftServer f_129745_ # playerDataStorage
public net.minecraft.world.level.storage.PlayerDataStorage f_78427_ # playerDir
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ public GlobalEntity getServerData() {
MinecraftServer server = Mc2DiscordMinecraft.server;
return new GlobalEntity(onlinePlayerCount,
server.getMaxPlayers(),
Optional.of(server.playerDataStorage.getSeenPlayers())
.map(strings -> strings.length)
.orElse(0),
Optional.ofNullable(server.playerDataStorage.playerDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".dat"))).map(files -> files.length).orElse(0),
server.getMotd(),
server.getServerVersion(),
server.getLocalIp(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessWidener v1 named
accessible field net/minecraft/world/damagesource/CombatTracker mob Lnet/minecraft/world/entity/LivingEntity;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/world/level/storage/PlayerDataStorage playerDir Ljava/io/File;
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
public net.minecraft.server.MinecraftServer f_129745_ # playerDataStorage
public net.minecraft.world.damagesource.CombatTracker f_19277_ # mob
public net.minecraft.server.MinecraftServer f_129745_ # playerDataStorage
public net.minecraft.world.level.storage.PlayerDataStorage f_78427_ # playerDir
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ public GlobalEntity getServerData() {
MinecraftServer server = Mc2DiscordMinecraft.server;
return new GlobalEntity(onlinePlayerCount,
server.getMaxPlayers(),
Optional.of(server.playerDataStorage.getSeenPlayers())
.map(strings -> strings.length)
.orElse(0),
Optional.ofNullable(server.playerDataStorage.playerDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".dat"))).map(files -> files.length).orElse(0),
server.getMotd(),
server.getServerVersion(),
server.getLocalIp(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessWidener v1 named
accessible field net/minecraft/world/damagesource/CombatTracker mob Lnet/minecraft/world/entity/LivingEntity;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/server/MinecraftServer playerDataStorage Lnet/minecraft/world/level/storage/PlayerDataStorage;
accessible field net/minecraft/world/level/storage/PlayerDataStorage playerDir Ljava/io/File;
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
public net.minecraft.world.damagesource.CombatTracker f_19277_ # mob
public net.minecraft.server.MinecraftServer f_129745_ # playerDataStorage
public net.minecraft.world.damagesource.CombatTracker f_19277_ # mob
public net.minecraft.world.level.storage.PlayerDataStorage f_78427_ # playerDir

0 comments on commit 8621fbf

Please sign in to comment.