[BUG] Don't ping server constantly for player data, if server status is null
This commit is contained in:
@@ -4,7 +4,6 @@ import com.hypherionmc.craterlib.utils.ChatUtils;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor(staticName = "of")
|
@RequiredArgsConstructor(staticName = "of")
|
||||||
public class BridgedServerData {
|
public class BridgedServerData {
|
||||||
@@ -25,12 +24,10 @@ public class BridgedServerData {
|
|||||||
|
|
||||||
public int getMaxPlayers() {
|
public int getMaxPlayers() {
|
||||||
if (internal.players == null) {
|
if (internal.players == null) {
|
||||||
try {
|
return internal.playerList.size() + 1;
|
||||||
new ServerStatusPinger().pingServer(internal, () -> {}, () -> {});
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return internal.players == null ? 0 : internal.players.max();
|
return internal.players.max();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerData toMojang() {
|
public ServerData toMojang() {
|
||||||
|
Reference in New Issue
Block a user