From ed13f5d43115272fb8e6f60e42ad712d902f79d5 Mon Sep 17 00:00:00 2001 From: buj Date: Mon, 9 Dec 2024 04:22:15 +0700 Subject: [PATCH] ranked: hide player id --- src/main/java/darkdustry/listeners/NetHandlers.java | 4 ++-- src/main/java/darkdustry/listeners/PluginEvents.java | 9 ++++++--- src/main/java/darkdustry/utils/Admins.java | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/darkdustry/listeners/NetHandlers.java b/src/main/java/darkdustry/listeners/NetHandlers.java index 1807064b..29efa588 100644 --- a/src/main/java/darkdustry/listeners/NetHandlers.java +++ b/src/main/java/darkdustry/listeners/NetHandlers.java @@ -172,8 +172,8 @@ public static void connect(NetConnection con, ConnectPacket packet) { var data = Database.getPlayerData(uuid); if (!config.whitelistKickSpectator && (!netServer.admins.isWhitelisted(uuid, usid) || ( !config.whitelist.isEmpty() && - data == null || - !config.whitelist.contains(data.id) + (data == null || + !config.whitelist.contains(data.id)) ))) { info.adminUsid = usid; info.names.addUnique(info.lastName = name); diff --git a/src/main/java/darkdustry/listeners/PluginEvents.java b/src/main/java/darkdustry/listeners/PluginEvents.java index 8759b165..154daac5 100644 --- a/src/main/java/darkdustry/listeners/PluginEvents.java +++ b/src/main/java/darkdustry/listeners/PluginEvents.java @@ -192,7 +192,7 @@ public static void load() { app.post(() -> data.effects.join.get(event.player)); Log.info("@ has connected. [@ / @]", event.player.plainName(), event.player.uuid(), data.id); - Bundle.send("events.join", event.player.coloredName(), data.id); + Bundle.send("events.join", event.player.coloredName(), config.mode.maskUsernames ? "??" : "" + data.id); Socket.send(new ServerMessageEmbedEvent(config.mode.name(), event.player.plainName() + " [" + data.id + "] joined", Color.MEDIUM_SEA_GREEN)); @@ -214,7 +214,7 @@ else if (data.discordLink) Events.on(PlayerLeave.class, event -> { Cache.mutes.remove(event.player.uuid()); - Admins.forget(player); + Admins.forget(event.player); var data = Cache.remove(event.player); Database.savePlayerData(data); @@ -245,7 +245,10 @@ else if (data.discordLink) if (Groups.player.size() <= 1 && config.mode.restartOnNoPlayers) { Log.info("Scheduling rtv in 60s..."); - noPlayersRestartTask = Timer.schedule(() -> instance.play(() -> world.loadMap(maps.getNextMap(instance.lastMode, state.map))), 60); + noPlayersRestartTask = Timer.schedule(() -> { + instance.play(() -> world.loadMap(maps.getNextMap(instance.lastMode, state.map))); + noPlayersRestartTask = null; + }, 60); } }); diff --git a/src/main/java/darkdustry/utils/Admins.java b/src/main/java/darkdustry/utils/Admins.java index 0430a026..cd73c7d3 100644 --- a/src/main/java/darkdustry/utils/Admins.java +++ b/src/main/java/darkdustry/utils/Admins.java @@ -29,7 +29,7 @@ public static void updateRealName(Player player, String name) { } public static void forget(Player player) { - realNames.remove(player); + if (player != null) realNames.remove(player); } public static String realname(Player player) {