From 91311dd23dd93d38c240e759b0d2aa76dc4a5bd9 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 21 Oct 2021 18:26:38 -0400 Subject: [PATCH] 1.3.0 final beta --- .../hideAndSeek/bukkit/EventListener.java | 9 ++-- .../hideAndSeek/command/Leave.java | 2 +- .../tylermurphy/hideAndSeek/command/Stop.java | 1 + .../tylermurphy/hideAndSeek/util/Board.java | 43 +++++++------------ 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java index da8f714..c50fbe4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/bukkit/EventListener.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -52,7 +53,7 @@ public class EventListener implements Listener { Main.plugin.board.remove(event.getPlayer()); } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamage(EntityDamageEvent event) { if(event.getEntity() instanceof Player) { Player p = (Player) event.getEntity(); @@ -93,7 +94,7 @@ public class EventListener implements Listener { } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onProjectile(ProjectileLaunchEvent event) { if(!Main.plugin.status.equals("Playing")) return; if(event.getEntity() instanceof Snowball) { @@ -109,7 +110,7 @@ public class EventListener implements Listener { } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onFoodLevelChange(FoodLevelChangeEvent event) { if(event.getEntity() instanceof Player) { if(!Main.plugin.board.isPlayer((Player) event.getEntity())) return; @@ -117,7 +118,7 @@ public class EventListener implements Listener { } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerRegainHealth(EntityRegainHealthEvent event) { if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) { if(event.getEntity() instanceof Player) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java index 908df5e..4144da7 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java @@ -28,9 +28,9 @@ public class Leave implements ICommand { } if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby"); else Util.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby"); + Main.plugin.board.removeBoard(player); Main.plugin.board.remove(player); player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ())); - Main.plugin.board.removeBoard(player); if(Main.plugin.status.equals("Standby")) { Main.plugin.board.reloadLobbyBoards(); } else { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java index 416d673..e2cb563 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java @@ -41,6 +41,7 @@ public class Stop implements ICommand { if(Main.plugin.status.equals("Standby")) return; Main.plugin.status = "Standby"; Main.plugin.gameId++; + Main.plugin.timeLeft = 0; Worldborder.resetWorldborder("hideandseek_"+spawnWorld); for(Player player : Main.plugin.board.getPlayers()) { player.setGameMode(GameMode.ADVENTURE); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java index 76698aa..472e326 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java @@ -60,7 +60,7 @@ public class Board { } public int size() { - return playerList.size(); + return playerList.values().size(); } public List getHiders(){ @@ -87,36 +87,27 @@ public class Board { Hider.add(player.getName()); Seeker.remove(player.getName()); Spectator.remove(player.getName()); - //HiderTeam.addEntry(player.getName()); - if(!playerList.containsKey(player.getName())) - playerList.put(player.getName(), player); + playerList.put(player.getName(), player); } public void addSeeker(Player player) { Hider.remove(player.getName()); Seeker.add(player.getName()); Spectator.remove(player.getName()); - //SeekerTeam.addEntry(player.getName()); - if(!playerList.containsKey(player.getName())) - playerList.put(player.getName(), player); + playerList.put(player.getName(), player); } public void addSpectator(Player player) { Hider.remove(player.getName()); Seeker.remove(player.getName()); Spectator.add(player.getName()); - //SpectatorTeam.addEntry(player.getName()); - if(!playerList.containsKey(player.getName())) - playerList.put(player.getName(), player); + playerList.put(player.getName(), player); } public void remove(Player player) { Hider.remove(player.getName()); Seeker.remove(player.getName()); Spectator.remove(player.getName()); - //HiderTeam.removeEntry(player.getName()); - //SeekerTeam.removeEntry(player.getName()); - //SpectatorTeam.removeEntry(player.getName()); playerList.remove(player.getName()); } @@ -137,12 +128,6 @@ public class Board { Hider.clear(); Seeker.clear(); Spectator.clear(); -// for(String entry : HiderTeam.getEntries()) -// HiderTeam.removeEntry(entry); -// for(String entry : SeekerTeam.getEntries()) -// SeekerTeam.removeEntry(entry); -// for(String entry : SpectatorTeam.getEntries()) -// SpectatorTeam.removeEntry(entry); } private void createTeamsForBoard(Scoreboard board) { @@ -171,8 +156,8 @@ public class Board { Score waiting = obj.getScore("Waiting to start..."); waiting.setScore(6); Score blank1 = obj.getScore(ChatColor.RESET.toString()); - blank1.setScore(5); - Score players = obj.getScore("Players: "+playerList.size()); + blank1.setScore(5); + Score players = obj.getScore("Players: "+playerList.values().size()); players.setScore(4); Score blank2 = obj.getScore(ChatColor.RESET.toString() + ChatColor.RESET.toString()); blank2.setScore(3); @@ -193,13 +178,15 @@ public class Board { team.setScore(6); Score blank1 = obj.getScore(ChatColor.RESET.toString()); blank1.setScore(5); - Score waiting = obj.getScore(ChatColor.GREEN + "Time Left: " + ChatColor.WHITE + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s"); - waiting.setScore(4); - Score blank2 = obj.getScore(ChatColor.RESET.toString() + ChatColor.RESET.toString()); - blank2.setScore(3); - Score seeker = obj.getScore(ChatColor.BOLD + "" + ChatColor.RED + "SEEKERS:" + ChatColor.WHITE + Seeker.size()); + if(gameLength > 0) { + Score waiting = obj.getScore(ChatColor.GREEN + "Time Left: " + ChatColor.WHITE + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s"); + waiting.setScore(4); + Score blank2 = obj.getScore(ChatColor.RESET.toString() + ChatColor.RESET.toString()); + blank2.setScore(3); + } + Score seeker = obj.getScore(ChatColor.BOLD + "" + ChatColor.RED + "SEEKERS:" + ChatColor.WHITE + " " + Seeker.size()); seeker.setScore(2); - Score hider = obj.getScore(ChatColor.BOLD + "" + ChatColor.GOLD + "HIDERS:" + ChatColor.WHITE + Hider.size()); + Score hider = obj.getScore(ChatColor.BOLD + "" + ChatColor.GOLD + "HIDERS:" + ChatColor.WHITE + " " + Hider.size()); hider.setScore(1); player.setScoreboard(board); } @@ -219,7 +206,7 @@ public class Board { } private String getSeekerPercent() { - if(playerList.size() < 2) + if(playerList.values().size() < 2) return " --"; else return " "+(int)(100*(1.0/playerList.size()));