Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bb721b7ab | ||
|
|
711aad60b7 | ||
|
|
fa02392ca1 | ||
|
|
cd9d316087 |
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'hu.kozelkaricsi.minecraft'
|
||||
version = '1.0'
|
||||
version = '1.0.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user