[DEV] Backport Fixes from DEV branch

- BUG - Server being pinged constantly during direct connect or lan
- BUG - Single Player Nojang Server not returning null in multiplayer
- FEAT - Way to check if login/logout event was sent from vanish
This commit is contained in:
2024-07-05 21:06:03 +02:00
parent ce6ee95256
commit a0dcfe501a
55 changed files with 209 additions and 122 deletions

View File

@@ -6,21 +6,18 @@
import net.kyori.adventure.text.Component;
+import net.minecraft.ChatFormatting;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.ServerStatusPinger;
@@ -24,13 +25,17 @@
@RequiredArgsConstructor(staticName = "of")
@@ -23,11 +24,15 @@
}
public int getMaxPlayers() {
- if (internal.players == null) {
+ if (!internal.pinged || internal.status.getString() == null) {
try {
- new ServerStatusPinger().pingServer(internal, () -> {}, () -> {});
+ new ServerStatusPinger().pingServer(internal, () -> {});
} catch (Exception ignored) {}
return internal.playerList.size() + 1;
}
- return internal.players == null ? 0 : internal.players.max();
- return internal.players.max();
+ try {
+ return Integer.parseInt(ChatFormatting.stripFormatting(internal.status.getString()).split("/")[1]);
+ } catch (Exception ignored) {}