SteamWar/MissileWars
Archiviert
13
0

Make RespawnSystem more consistent #25

Manuell gemergt
YoyoNow hat 1 Commits von RespawnCreator nach master 2020-12-22 18:33:00 +01:00 zusammengeführt
Nur Änderungen aus Commit 1c1b81aada werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -27,14 +27,19 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent; 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.event.player.PlayerRespawnEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class DeathListener extends BasicListener { public class DeathListener extends BasicListener {
private static final Vector ZERO = new Vector(0, 0, 0); private static final Vector ZERO = new Vector(0, 0, 0);
private final Set<Player> respawnedPlayers = new HashSet<>();
public DeathListener() { public DeathListener() {
super(EnumSet.allOf(FightState.class)); super(EnumSet.allOf(FightState.class));
@ -56,6 +61,21 @@ public class DeathListener extends BasicListener {
e.setRespawnLocation(team.getSpawn()); e.setRespawnLocation(team.getSpawn());
e.getPlayer().setVelocity(ZERO); 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());
}
} }