4 Commits
1.0 ... main

Author SHA1 Message Date
Cyanoure
2bb721b7ab v1.0.1 2026-03-29 21:29:39 +02:00
Cyanoure
711aad60b7 Fix: Teleports to spawn at every join 2026-03-29 21:25:31 +02:00
Cyanoure
fa02392ca1 More debug messages 2026-03-29 17:48:50 +02:00
Cyanoure
cd9d316087 Debug messages 2026-03-29 17:32:08 +02:00
4 changed files with 34 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group = 'hu.kozelkaricsi.minecraft'
version = '1.0'
version = '1.0.1'
repositories {
mavenCentral()

View File

@@ -6,38 +6,48 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import org.bukkit.event.player.*;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class Events implements Listener {
@EventHandler (priority = EventPriority.LOWEST)
public void onSpawn(PlayerSpawnLocationEvent e) {
@EventHandler (priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
Location loc = GoSpawn.instance.getSpawnLocation();
if (loc == null) {
return;
}
if (!e.getPlayer().hasPlayedBefore()) {
e.setSpawnLocation(loc);
UUID lastWorld = GoSpawn.instance.getPlayerLastWorld(player);
if (!player.hasPlayedBefore() && lastWorld == null) {
GoSpawn.instance.debug("Player '" + player.getName() + "' has not played here before.");
player.teleport(loc);
return;
} else {
GoSpawn.instance.debug("Player '" + player.getName() + "' has already played here before.");
}
Location currentLoc = e.getSpawnLocation();
Location currentLoc = player.getLocation();
GoSpawn.instance.debug("Current world of player '" + player.getName() + "' is " + currentLoc.getWorld().getName() + "(" + currentLoc.getWorld().getUID() + ")");
if (GoSpawn.instance.shouldForceRespawnIfInWorld(currentLoc.getWorld())) {
e.setSpawnLocation(loc);
GoSpawn.instance.debug("Config says that " + player.getName() + " should be teleported to the spawn, because their world is not whitelisted.");
player.teleport(loc);
return;
}
UUID lastWorld = GoSpawn.instance.getPlayerLastWorld(e.getPlayer());
if (lastWorld == null) {
GoSpawn.instance.debug("No last world stored for player " + player.getName() + ".");
} else {
GoSpawn.instance.debug("The UID of the last world of player " + player.getName() + " is " + lastWorld + ".");
}
if (lastWorld != null && Bukkit.getWorld(lastWorld) == null) {
e.setSpawnLocation(loc);
player.teleport(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);
}
}
}

View File

@@ -1,3 +1,5 @@
debug: true
message-spawn-cooldown: "&cEzt a parancsot %seconds% másodperc múlva használatod újra!"
message-spawn-delay: "&6Elteleportálunk %seconds% másodpercen belül, ne mozdulj..."
message-teleporting: "&aTeleportálás..."