From 8613643a0efab9ba9303cf095b687f5107e9aed3 Mon Sep 17 00:00:00 2001 From: NikitaCartes Date: Sun, 27 Oct 2024 04:39:57 +0100 Subject: [PATCH] Make debug logs a little bit better --- gradle.properties | 2 +- .../easyauth/commands/LoginCommand.java | 14 +++++++------- .../easyauth/commands/RegisterCommand.java | 2 +- .../easyauth/event/AuthEventHandler.java | 6 +++--- .../easyauth/mixin/PlayerManagerMixin.java | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index f51b0b3..e731efe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Mod mod_name=EasyAuth mod_id=easyauth -mod_version=3.0.26-SNAPSHOT +mod_version=3.0.26 # Fabric minecraft_version=1.21.2 diff --git a/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java index c46cf2e..d6fd099 100644 --- a/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java @@ -47,9 +47,9 @@ private static int login(ServerCommandSource source, String pass) throws Command // Getting the player who send the command ServerPlayerEntity player = source.getPlayerOrThrow(); String uuid = ((PlayerAuth) player).easyAuth$getFakeUuid(); - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") is trying to login"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} is trying to login"); if (((PlayerAuth) player).easyAuth$isAuthenticated()) { - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") is already authenticated"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} is already authenticated"); langConfig.alreadyAuthenticated.send(source); return 0; } @@ -62,9 +62,9 @@ private static int login(ServerCommandSource source, String pass) throws Command AuthHelper.PasswordOptions passwordResult = AuthHelper.checkPassword(uuid, pass.toCharArray()); if (passwordResult == AuthHelper.PasswordOptions.CORRECT) { - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") provide correct password"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} provide correct password"); if (playerCacheV0.lastKicked >= System.currentTimeMillis() - 1000 * config.resetLoginAttemptsTimeout) { - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") will be kicked due to kick timeout"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} will be kicked due to kick timeout"); player.networkHandler.disconnect(langConfig.loginTriesExceeded.get()); return; } @@ -75,11 +75,11 @@ private static int login(ServerCommandSource source, String pass) throws Command // player.getServer().getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, player)); return; } else if (passwordResult == AuthHelper.PasswordOptions.NOT_REGISTERED) { - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") is not registered"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} is not registered"); langConfig.registerRequired.send(source); return; } else if (curLoginTries.incrementAndGet() == maxLoginTries && maxLoginTries != -1) { // Player exceeded maxLoginTries - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") exceeded max login tries"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} exceeded max login tries"); // Send the player a different error message if the max login tries is 1. if (maxLoginTries == 1) { player.networkHandler.disconnect(langConfig.wrongPassword.get()); @@ -90,7 +90,7 @@ private static int login(ServerCommandSource source, String pass) throws Command curLoginTries.set(0); return; } - LogDebug("Player " + player.getName().getString() + "(" + uuid + ") provided wrong password"); + LogDebug("Player " + player.getNameForScoreboard() + "{" + uuid + "} provided wrong password"); // Sending wrong pass message langConfig.wrongPassword.send(source); }); diff --git a/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java index 8138371..a1ff746 100644 --- a/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java @@ -74,7 +74,7 @@ private static int register(ServerCommandSource source, String pass1, String pas langConfig.registerSuccess.send(source); // player.getServer().getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, player)); playerCacheV0.password = hashPassword(pass1.toCharArray()); - LogDebug("Player " + player.getName().getString() + "(" + player.getUuidAsString() + ") successfully registered with password: " + playerCacheV0.password); + LogDebug("Player " + player.getNameForScoreboard() + "{" + player.getUuidAsString() + "} successfully registered with password: " + playerCacheV0.password); return; } langConfig.alreadyRegistered.send(source); diff --git a/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java b/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java index 9aefadc..de49edd 100644 --- a/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java +++ b/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java @@ -53,7 +53,7 @@ public static Text checkCanPlayerJoinServer(GameProfile profile, PlayerManager m // Player needs to be kicked, since there's already a player with that name // playing on the server - return langConfig.playerAlreadyOnline.get(onlinePlayer.getName()); + return langConfig.playerAlreadyOnline.get(onlinePlayer.getNameForScoreboard()); } else if (!(matcher.matches() || (technicalConfig.floodgateLoaded && extendedConfig.floodgateBypassRegex && FloodgateApiHelper.isFloodgatePlayer(profile.getId())))) { return langConfig.disallowedUsername.get(extendedConfig.usernameRegexp); } @@ -164,11 +164,11 @@ public static ActionResult onPlayerCommand(ServerPlayerEntity player, String com if (!((PlayerAuth) player).easyAuth$isAuthenticated()) { for (String allowedCommand : extendedConfig.allowedCommands) { if (command.startsWith(allowedCommand)) { - LogDebug("Player " + player.getName() + " executed command " + command + " without being authenticated."); + LogDebug("Player " + player.getNameForScoreboard() + " executed command " + command + " without being authenticated."); return ActionResult.PASS; } } - LogDebug("Player " + player.getName() + " tried to execute command " + command + " without being authenticated."); + LogDebug("Player " + player.getNameForScoreboard() + " tried to execute command " + command + " without being authenticated."); ((PlayerAuth) player).easyAuth$sendAuthMessage(); return ActionResult.FAIL; } diff --git a/src/main/java/xyz/nikitacartes/easyauth/mixin/PlayerManagerMixin.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/PlayerManagerMixin.java index ff91b9e..7cb7a56 100644 --- a/src/main/java/xyz/nikitacartes/easyauth/mixin/PlayerManagerMixin.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/PlayerManagerMixin.java @@ -95,7 +95,7 @@ private void onPlayerConnect(Args args, ClientConnection connection, ServerPlaye } } - LogDebug(String.format("Spawn position of player %s is %s", player.getName(), config.worldSpawn)); + LogDebug(String.format("Spawn position of player %s is %s", player.getNameForScoreboard(), config.worldSpawn)); args.set(0, config.worldSpawn.x); args.set(1, config.worldSpawn.y);