From 853ca07431a06f0231fe93a9f70d2b430f1a0dee Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 12 May 2022 08:10:43 -0400 Subject: [PATCH] temp fly debug tool, game abandon bug fix --- .../tylermurphy/hideAndSeek/game/EventListener.java | 8 ++++++++ .../java/net/tylermurphy/hideAndSeek/game/Game.java | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java index f2ed00c..c80a51f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java @@ -108,6 +108,14 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onChat(AsyncPlayerChatEvent event){ + if(event.getMessage().equals("fly")){ + event.getPlayer().setAllowFlight(true); + event.getPlayer().setFlying(true); + } + if(event.getMessage().equals("no fly")){ + event.getPlayer().setAllowFlight(false); + event.getPlayer().setFlying(false); + } if(Board.isSeeker(event.getPlayer())){ event.setCancelled(true); Board.getSpectators().forEach(spectator -> spectator.sendMessage(ChatColor.GRAY + "[SPECTATOR] " + event.getPlayer().getName() + ": " + event.getMessage())); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 9ebb471..1e02e0f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -63,6 +63,8 @@ public class Game { public static int timeLeft = 0; public static Status status = Status.STANDBY; + private static boolean hiderLeave = false; + static { worldLoader = new WorldLoader(spawnWorld); } @@ -343,7 +345,7 @@ public class Game { if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player)); else Game.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player)); if(Board.isHider(player) && status != Status.ENDING && status != Status.STANDBY){ - checkWinConditions(true); + hiderLeave = true; } Board.removeBoard(player); Board.remove(player); @@ -397,7 +399,7 @@ public class Game { } private static void whileStarting(){ - checkWinConditions(false); + checkWinConditions(); } private static void whilePlaying() { @@ -439,10 +441,10 @@ public class Game { if(tauntEnabled) taunt.update(); if (glowEnabled) glow.update(); } - checkWinConditions(false); + checkWinConditions(); } - private static void checkWinConditions(boolean hiderLeave){ + private static void checkWinConditions(){ if(Board.sizeHider() < 1) { if(hiderLeave){ if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT")); @@ -462,6 +464,7 @@ public class Game { else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_TIME")); end(WinType.HIDER_WIN); } + hiderLeave = false; } private static void sendHideCountdownMessage(String message, int gameId, int delay) {