From fa02392ca138a972b14691175586fb02123ea42c Mon Sep 17 00:00:00 2001 From: Cyanoure Date: Sun, 29 Mar 2026 17:48:50 +0200 Subject: [PATCH] More debug messages --- .../minecraft/gospawn/Events.java | 19 +++++++++++++------ .../minecraft/gospawn/GoSpawn.java | 6 ++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/hu/kozelkaricsi/minecraft/gospawn/Events.java b/src/main/java/hu/kozelkaricsi/minecraft/gospawn/Events.java index 05d473a..f38af86 100644 --- a/src/main/java/hu/kozelkaricsi/minecraft/gospawn/Events.java +++ b/src/main/java/hu/kozelkaricsi/minecraft/gospawn/Events.java @@ -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); } diff --git a/src/main/java/hu/kozelkaricsi/minecraft/gospawn/GoSpawn.java b/src/main/java/hu/kozelkaricsi/minecraft/gospawn/GoSpawn.java index e7af6bf..6bb3f83 100644 --- a/src/main/java/hu/kozelkaricsi/minecraft/gospawn/GoSpawn.java +++ b/src/main/java/hu/kozelkaricsi/minecraft/gospawn/GoSpawn.java @@ -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); + } + } }