SteamWar/MissileWars
Archiviert
13
0

Merge pull request 'Make RespawnSystem more consistent' (#25) from RespawnCreator into master

Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
YoyoNow 2020-12-22 18:32:58 +01:00
Commit 61b7d5fea2

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());
}
} }