Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bb721b7ab | ||
|
|
711aad60b7 | ||
|
|
fa02392ca1 | ||
|
|
cd9d316087 |
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'hu.kozelkaricsi.minecraft'
|
group = 'hu.kozelkaricsi.minecraft'
|
||||||
version = '1.0'
|
version = '1.0.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -6,38 +6,48 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.*;
|
||||||
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 java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Events implements Listener {
|
public class Events implements Listener {
|
||||||
@EventHandler (priority = EventPriority.LOWEST)
|
@EventHandler (priority = EventPriority.HIGH)
|
||||||
public void onSpawn(PlayerSpawnLocationEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
Location loc = GoSpawn.instance.getSpawnLocation();
|
Location loc = GoSpawn.instance.getSpawnLocation();
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.getPlayer().hasPlayedBefore()) {
|
UUID lastWorld = GoSpawn.instance.getPlayerLastWorld(player);
|
||||||
e.setSpawnLocation(loc);
|
|
||||||
|
if (!player.hasPlayedBefore() && lastWorld == null) {
|
||||||
|
GoSpawn.instance.debug("Player '" + player.getName() + "' has not played here before.");
|
||||||
|
player.teleport(loc);
|
||||||
return;
|
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())) {
|
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;
|
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) {
|
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;
|
long configCooldown = getConfig().getLong("spawn-cooldown") * 1000;
|
||||||
return Math.max(0, configCooldown - timeElapsed);
|
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-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-spawn-delay: "&6Elteleportálunk %seconds% másodpercen belül, ne mozdulj..."
|
||||||
message-teleporting: "&aTeleportálás..."
|
message-teleporting: "&aTeleportálás..."
|
||||||
|
|||||||
Reference in New Issue
Block a user