More debug messages

This commit is contained in:
Cyanoure
2026-03-29 17:48:50 +02:00
parent cd9d316087
commit fa02392ca1
2 changed files with 19 additions and 6 deletions

View File

@@ -23,24 +23,31 @@ public class Events implements Listener {
}
if (!e.getPlayer().hasPlayedBefore()) {
if (GoSpawn.instance.getConfig().getBoolean("debug")) {
GoSpawn.instance.getLogger().info("Player '" + e.getPlayer().getName() + "' has not played here before.");
}
GoSpawn.instance.debug("Player '" + e.getPlayer().getName() + "' has not played here before.");
e.setSpawnLocation(loc);
return;
} else {
if (GoSpawn.instance.getConfig().getBoolean("debug")) {
GoSpawn.instance.getLogger().info("Player '" + e.getPlayer().getName() + "' has already played here before.");
}
GoSpawn.instance.debug("Player '" + e.getPlayer().getName() + "' has already played here before.");
}
Location currentLoc = e.getSpawnLocation();
GoSpawn.instance.debug("Current world of player '" + e.getPlayer().getName() + "' is " + currentLoc.getWorld().getName() + "(" + currentLoc.getWorld().getUID() + ")");
if (GoSpawn.instance.shouldForceRespawnIfInWorld(currentLoc.getWorld())) {
e.setSpawnLocation(loc);
GoSpawn.instance.debug("Config says that " + e.getPlayer().getName() + " should be teleported to the spawn, because their world is not whitelisted.");
return;
}
UUID lastWorld = GoSpawn.instance.getPlayerLastWorld(e.getPlayer());
if (lastWorld == null) {
GoSpawn.instance.debug("No last world stored for player " + e.getPlayer().getName() + ".");
} else {
GoSpawn.instance.debug("The UID of the last world of player " + e.getPlayer().getName() + " is " + lastWorld + ".");
}
if (lastWorld != null && Bukkit.getWorld(lastWorld) == null) {
e.setSpawnLocation(loc);
}

View File

@@ -201,4 +201,10 @@ public final class GoSpawn extends JavaPlugin {
long configCooldown = getConfig().getLong("spawn-cooldown") * 1000;
return Math.max(0, configCooldown - timeElapsed);
}
public void debug(String msg) {
if (getConfig().getBoolean("debug")) {
getLogger().info("[DEBUG] " + msg);
}
}
}