Make RespawnSystem more consistent #25
@ -27,14 +27,19 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DeathListener extends BasicListener {
|
||||
|
||||
private static final Vector ZERO = new Vector(0, 0, 0);
|
||||
private final Set<Player> respawnedPlayers = new HashSet<>();
|
||||
|
||||
public DeathListener() {
|
||||
super(EnumSet.allOf(FightState.class));
|
||||
@ -56,6 +61,21 @@ public class DeathListener extends BasicListener {
|
||||
|
||||
e.setRespawnLocation(team.getSpawn());
|
||||
e.getPlayer().setVelocity(ZERO);
|
||||
new SpawnPlatformCreator(p);
|
||||
respawnedPlayers.add(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (respawnedPlayers.isEmpty()) return;
|
||||
Player player = event.getPlayer();
|
||||
if (!respawnedPlayers.contains(player)) return;
|
||||
respawnedPlayers.remove(player);
|
||||
new SpawnPlatformCreator(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
respawnedPlayers.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren