fix seeker death and other things

This commit is contained in:
Tyler Murphy 2022-05-10 13:24:19 -04:00
parent 0fdc77157f
commit 487ce5e3f5
2 changed files with 30 additions and 1 deletions

View file

@ -116,6 +116,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent event){ public void onMove(PlayerMoveEvent event){
if(!Board.isPlayer(event.getPlayer())) return;
if(!event.getPlayer().getWorld().getName().equals(Game.getGameWorld())) return; if(!event.getPlayer().getWorld().getName().equals(Game.getGameWorld())) return;
if(event.getPlayer().hasPermission("hideandseek.leavebounds")) return; if(event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
if(event.getTo() == null || event.getTo().getWorld() == null) return; if(event.getTo() == null || event.getTo().getWorld() == null) return;
@ -188,6 +189,15 @@ public class EventListener implements Listener {
} else if(!pvpEnabled && !allowNaturalCauses){ } else if(!pvpEnabled && !allowNaturalCauses){
event.setCancelled(true); event.setCancelled(true);
return; return;
// Spectators cannot take damage
} else if(Board.isSpectator(player)){
event.setCancelled(true);
if(Version.atLeast("1.18") && player.getLocation().getY() < -64){
player.teleport(new Location(Bukkit.getWorld(Game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
} else if(player.getLocation().getY() < 0){
player.teleport(new Location(Bukkit.getWorld(Game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
}
return;
} }
// Handle death event // Handle death event
event.setCancelled(true); event.setCancelled(true);
@ -216,6 +226,9 @@ public class EventListener implements Listener {
// Add leaderboard stats // Add leaderboard stats
Board.addDeath(player.getUniqueId()); Board.addDeath(player.getUniqueId());
if(attacker != null){ Board.addKill(attacker.getUniqueId()); } if(attacker != null){ Board.addKill(attacker.getUniqueId()); }
Game.resetPlayer(player);
Board.reloadBoardTeams();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View file

@ -186,6 +186,11 @@ public class Game {
} }
worldBorder.resetWorldborder(getGameWorld()); worldBorder.resetWorldborder(getGameWorld());
for(Player player : Board.getPlayers()) { for(Player player : Board.getPlayers()) {
for(Player player2 : Board.getPlayers()){
player.showPlayer(player2);
}
player.setFlying(false);
player.setAllowFlight(false);
if(Version.atLeast("1.9")){ if(Version.atLeast("1.9")){
for(Player temp : Board.getPlayers()) { for(Player temp : Board.getPlayers()) {
Packet.setGlow(player, temp, false); Packet.setGlow(player, temp, false);
@ -299,7 +304,12 @@ public class Game {
} else { } else {
Board.addSpectator(player); Board.addSpectator(player);
player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR")); player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.ADVENTURE);
for(Player player2 : Board.getPlayers()){
player2.hidePlayer(player);
}
player.setFlying(true);
player.setAllowFlight(true);
Board.createGameBoard(player); Board.createGameBoard(player);
player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString()); Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString());
@ -315,6 +325,12 @@ public class Game {
} }
public static void leave(Player player){ public static void leave(Player player){
player.setFlying(false);
player.setAllowFlight(false);
for(Player player2 : Board.getPlayers()){
player2.showPlayer(player);
player.showPlayer(player2);
}
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player)); if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
else Game.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player)); else Game.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
Board.removeBoard(player); Board.removeBoard(player);