Skip to content

Commit

Permalink
Make debug logs a little bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Oct 27, 2024
1 parent fdc682f commit 8613643
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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());
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8613643

Please sign in to comment.