From b01a4fd3c01a0486f0257c46e9f8bde5acc9660a Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sat, 29 Jul 2023 15:54:12 -0400 Subject: [PATCH] 1.7.5 rc3 --- .../hideAndSeek/configuration/Config.java | 6 ++++- .../configuration/Localization.java | 6 +++-- .../tylermurphy/hideAndSeek/game/Board.java | 13 +++++------ .../tylermurphy/hideAndSeek/game/Game.java | 23 ++++++++++++++++--- .../game/listener/ChatHandler.java | 2 +- .../hideAndSeek/util/PAPIExpansion.java | 16 +++++++++---- src/main/resources/config.yml | 9 ++++++++ .../resources/lang/localization_de-DE.yml | 12 +++++++--- .../resources/lang/localization_en-US.yml | 14 +++++++---- 9 files changed, 76 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index 67fc4bf..8a71903 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -67,6 +67,7 @@ public class Config { dropItems, respawnAsSpectator, waitTillNoneLeft, + gameOverTitle, regenHealth; public static int @@ -86,7 +87,8 @@ public class Config { flightToggleItemPosition, teleportItemPosition, startingSeekerCount, - delayedRespawnDelay; + delayedRespawnDelay, + endGameDelay; public static float seekerPingLeadingVolume, @@ -196,6 +198,8 @@ public class Config { saveInventory = config.getBoolean("saveInventory"); respawnAsSpectator = config.getBoolean("respawnAsSpectator"); dontRewardQuit = config.getBoolean("dontRewardQuit"); + endGameDelay = Math.max(0,config.getInt("endGameDelay")); + gameOverTitle = config.getBoolean("gameOverTitle"); try { countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay")); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java index b9f9b69..babf759 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Localization.java @@ -15,12 +15,14 @@ public class Localization { put("en-US", new String[][]{ {"WORLDBORDER_DECREASING"}, {"START","TAUNTED"}, - {"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"} + {"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"}, + {"GAME_PLAYER_FOUND", "GAME_PLAYER_FOUND_BY"} }); put("de-DE", new String[][]{ {}, {"TAUNTED"}, - {"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"} + {"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"}, + {"GAME_PLAYER_FOUND", "GAME_PLAYER_FOUND_BY"} }); }}; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java index 4c56453..4f6be2f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java @@ -34,6 +34,10 @@ public class Board { return Players.containsKey(player.getUniqueId()); } + public boolean containsUUID(UUID uuid) { + return Players.containsKey(uuid); + } + public boolean isHider(Player player) { return isHider(player.getUniqueId()); } @@ -418,13 +422,8 @@ class CustomBoard { seekerTeam.setNameTagVisibility(NameTagVisibility.NEVER); } } - if (Main.getInstance().supports(12)) { - hiderTeam.setColor(ChatColor.GOLD); - seekerTeam.setColor(ChatColor.RED); - } else { - hiderTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&6")); - seekerTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&c")); - } + hiderTeam.setPrefix(message("HIDER_TEAM_NAME").toString() + " " + ChatColor.RESET); + seekerTeam.setPrefix(message("SEEKER_TEAM_NAME").toString() + " " + ChatColor.RESET); } public void setLine(String key, String message) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 5213c87..36e48b0 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -151,7 +151,7 @@ public class Game { } Main.getInstance().getDatabase().getGameData().addWins(board, players, winners, board.getHiderKills(), board.getHiderDeaths(), board.getSeekerKills(), board.getSeekerDeaths(), type); } - Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), this::end, 5*20); + Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), this::end, endGameDelay*20); } public void end() { @@ -347,6 +347,12 @@ public class Game { } } + public void broadcastTitle(String title, String subtitle) { + for (Player player : board.getPlayers()) { + Titles.sendTitle(player, 10, 70, 20, title, subtitle); + } + } + public boolean isCurrentMapValid() { return currentMap != null && !currentMap.isNotSetup(); } @@ -371,19 +377,30 @@ public class Game { if (hiderLeft && dontRewardQuit) { if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT")); else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT")); + if (gameOverTitle) broadcastTitle(message("GAME_TITLE_NO_WIN").toString(), message("GAME_GAMEOVER_HIDERS_QUIT").toString()); stop(WinType.NONE); } else { - if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); - else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); + if (hiderCount < 1 || waitTillNoneLeft) { + if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); + else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); + if (gameOverTitle) broadcastTitle(message("GAME_TITLE_SEEKERS_WIN").toString(), message("GAME_GAMEOVER_HIDERS_FOUND").toString()); + } else { + Player hider = board.getHiders().get(0); + if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_LAST_HIDER").addPlayer(hider)); + else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_LAST_HIDER").addPlayer(hider)); + if (gameOverTitle) broadcastTitle(message("GAME_TITLE_SINGLE_HIDER_WIN").addPlayer(hider).toString(), message("GAME_SUBTITLE_SINGLE_HIDER_WIN").addPlayer(hider).toString()); + } stop(WinType.SEEKER_WIN); } } else if (board.sizeSeeker() < 1) { if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT")); else broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT")); + if (gameOverTitle) broadcastTitle(message("GAME_TITLE_NO_WIN").toString(), message("GAME_GAMEOVER_SEEKERS_QUIT").toString()); stop(dontRewardQuit ? WinType.NONE : WinType.HIDER_WIN); } else if (gameTimer < 1) { if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_TIME")); else broadcastMessage(gameOverPrefix + message("GAME_GAMEOVER_TIME")); + if (gameOverTitle) broadcastTitle(message("GAME_TITLE_HIDERS_WIN").toString(), message("GAME_GAMEOVER_TIME").toString()); stop(WinType.HIDER_WIN); } hiderLeft = false; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java index 27347c2..d83b702 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/ChatHandler.java @@ -9,7 +9,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; public class ChatHandler implements Listener { - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onChat(AsyncPlayerChatEvent event) { if (Main.getInstance().getBoard().isSpectator(event.getPlayer())) { event.setCancelled(true); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java index 3a58940..2d80b88 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java @@ -4,6 +4,7 @@ import me.clip.placeholderapi.expansion.PlaceholderExpansion; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.database.Database; import net.tylermurphy.hideAndSeek.database.util.PlayerInfo; +import net.tylermurphy.hideAndSeek.game.Board; import net.tylermurphy.hideAndSeek.game.util.Status; import org.bukkit.OfflinePlayer; @@ -44,19 +45,26 @@ public class PAPIExpansion extends PlaceholderExpansion { Database database = Main.getInstance().getDatabase(); String[] args = params.split("_"); Status status = Main.getInstance().getGame().getStatus(); + Board board = Main.getInstance().getBoard(); + + System.out.println(args); if (args.length < 1) return null; - if (args.length == 1 && args[0] == "hiders") { - if (status == Status.PLAYING || status == Status.STARTING) { + if (args.length == 1 && args[0].equals("hiders")) { + if (!board.containsUUID(player.getUniqueId())) { + return "-"; + } else if (status == Status.PLAYING || status == Status.STARTING) { return "" + Main.getInstance().getBoard().getHiders().size(); } else { return "-"; } } - if (args.length == 1 && args[0] == "seekers") { - if (status == Status.PLAYING || status == Status.STARTING) { + if (args.length == 1 && args[0].equals("seekers")) { + if (!board.containsUUID(player.getUniqueId())) { + return "-"; + } else if (status == Status.PLAYING || status == Status.STARTING) { return "" + Main.getInstance().getBoard().getSeekers().size(); } else { return "-"; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1642b82..a514b56 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -59,6 +59,7 @@ respawnAsSpectator: false # If enabled, the game will go until no hiders are left. If the timer runs out all hiders left will be marked as winning. # If disabled the game wll go until there is only one hider left. If the timer runs out, all hiders left win, if t here is one # hider left, all inital seekers win along with the last hider. +# default: true waitTillNoneLeft: true # By default, if the last hider or seeker quits the game, a win type of NONE is given, which doesnt mark anyone as winning. This can be @@ -66,6 +67,14 @@ waitTillNoneLeft: true # default: true dontRewardQuit: true +# The amount of seconds the game will wait until the players are teleported to the lobby after a game over +# default: 5 +endGameDelay: 5 + +# Along with a chat message, display a title describing the gameover +# default: false +gameOverTitle: false + # This plugin by default functions as not tag to catch Hiders, but to pvp. All players are given weapons, # and seekers slightly better weapons (this can be changed in items.yml). If you want, you can disable this # entire pvp functionality, and make Hiders get found on a single hit. Hiders would also not be able to fight diff --git a/src/main/resources/lang/localization_de-DE.yml b/src/main/resources/lang/localization_de-DE.yml index 92309ee..ca98ea2 100644 --- a/src/main/resources/lang/localization_de-DE.yml +++ b/src/main/resources/lang/localization_de-DE.yml @@ -12,12 +12,18 @@ Localization: COMMAND_ERROR: "Ein unbekannter Fehler ist aufgetreten." COMMAND_INVALID_ARG: "Ungültiges Argument: {AMOUNT}" GAME_PLAYER_DEATH: "&c{PLAYER}&f ist gestorben." - GAME_PLAYER_FOUND: "&e{PLAYER}&f wurde gefunden und ist nun ein Seeker." - GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f wurde von &c{PLAYER}&f gefunden und ist nun ein Seeker." + GAME_PLAYER_FOUND: "&e{PLAYER}&f wurde gefunden" + GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f wurde von &c{PLAYER}&f gefunden" GAME_GAMEOVER_HIDERS_FOUND: "Alle Hider wurden gefunden." + GAME_GAMEOVER_LAST_HIDER: "Der letzte Hider, &e{PLAYER}&f, hat gewonnen!" GAME_GAMEOVER_SEEKERS_QUIT: "All Seeker haben das Spiel verlassen." GAME_GAMEOVER_HIDERS_QUIT: "All Hider haben das Spiel verlassen." GAME_GAMEOVER_TIME: "Seekers haben keine Spielzeit mehr. Die Hiders haben gewonnen!" + GAME_TITLE_HIDERS_WIN: "&aHiders haben gewonnen!" + GAME_TITLE_SINGLE_HIDER_WIN: "&a{PLAYER} haben gewonnen!" + GAME_TITLE_SEEKERS_WIN: "&cSeekers haben gewonnen!" + GAME_TITLE_NO_WIN: "&bSpiel ist aus" + GAME_SUBTITLE_SINGLE_HIDER_WIN: "{PLAYER} ist der letzte lebende Hider!" GAME_SETUP: "Es gibt keine Setup-Karten! Führen Sie /hs map status auf einer Karte aus, um zu sehen, was Sie tun müssen." GAME_INGAME: "Du bist bereits in der Lobby oder im Spiel." GAME_NOT_INGAME: "Du bist weder in einer Lobby noch in einem Spiel." @@ -128,5 +134,5 @@ Localization: CONFIRMATION: "Führen Sie /hs confirm innerhalb von 10s aus, um zu bestätigen." # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE -version: 4 +version: 5 type: "de-DE" diff --git a/src/main/resources/lang/localization_en-US.yml b/src/main/resources/lang/localization_en-US.yml index 062f4f2..a2a2223 100644 --- a/src/main/resources/lang/localization_en-US.yml +++ b/src/main/resources/lang/localization_en-US.yml @@ -12,12 +12,18 @@ Localization: COMMAND_ERROR: "An internal error has occurred." COMMAND_INVALID_ARG: "Invalid argument: {AMOUNT}" GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed." - GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker." - GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker." + GAME_PLAYER_FOUND: "&e{PLAYER}&f was found" + GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f" GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found." + GAME_GAMEOVER_LAST_HIDER: "The last hider, &e{PLAYER}&f, has won!" GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit." GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit." GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!" + GAME_TITLE_HIDERS_WIN: "&aHiders Win!" + GAME_TITLE_SINGLE_HIDER_WIN: "&a{PLAYER} Wins!" + GAME_TITLE_SEEKERS_WIN: "&cSeekers Win!" + GAME_TITLE_NO_WIN: "&bGame Over" + GAME_SUBTITLE_SINGLE_HIDER_WIN: "{PLAYER} is the last hider alive!" GAME_SETUP: "There are no setup maps! Run /hs map status on a map to see what you need to do." GAME_INGAME: "You are already in the lobby/game." GAME_NOT_INGAME: "You are not in a lobby/game." @@ -128,5 +134,5 @@ Localization: CONFIRMATION: "Run /hs confirm within 10s to confirm." # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE -version: 4 -type: "en-US" \ No newline at end of file +version: 5 +type: "en-US"