diff --git a/src/nl/Steffion/BlockHunt/Arena.java b/src/nl/Steffion/BlockHunt/Arena.java index 52a4090..0a9bc9c 100644 --- a/src/nl/Steffion/BlockHunt/Arena.java +++ b/src/nl/Steffion/BlockHunt/Arena.java @@ -27,6 +27,7 @@ public class Arena implements ConfigurationSerializable { public int waitingTimeSeeker; public int gameTime; public int timeUntilHidersSword; + public int blockAnnouncerTime; public ArrayList disguiseBlocks; public LocationSerializable lobbyWarp; public LocationSerializable hidersWarp; @@ -46,7 +47,7 @@ public class Arena implements ConfigurationSerializable { public Scoreboard scoreboard; public Arena(String arenaName, LocationSerializable pos1, LocationSerializable pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart, - int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, ArrayList disguiseBlocks, + int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, int blockAnnouncerTime, ArrayList disguiseBlocks, LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable seekersWarp, LocationSerializable spawnWarp, List seekersWinCommands, List hidersWinCommands, List allowedCommands, int seekersTokenWin, int hidersTokenWin, int killTokens, List playersInArena, ArenaState gameState, int timer, List seekers, Scoreboard scoreboard) { @@ -60,6 +61,7 @@ public class Arena implements ConfigurationSerializable { this.waitingTimeSeeker = waitingTimeSeeker; this.gameTime = gameTime; this.timeUntilHidersSword = timeUntilHidersSword; + this.blockAnnouncerTime = blockAnnouncerTime; this.disguiseBlocks = disguiseBlocks; this.lobbyWarp = lobbyWarp; this.hidersWarp = hidersWarp; @@ -89,7 +91,8 @@ public class Arena implements ConfigurationSerializable { timeUntilHidersSword, hidersTokenWin, seekersTokenWin, - killTokens; + killTokens, + blockAnnouncerTime; } public enum ArenaState { @@ -111,6 +114,7 @@ public class Arena implements ConfigurationSerializable { map.put("amountSeekersOnStart", amountSeekersOnStart); map.put("timeInLobbyUntilStart", timeInLobbyUntilStart); map.put("waitingTimeSeeker", waitingTimeSeeker); + map.put("blockAnnouncerTime", blockAnnouncerTime); map.put("gameTime", gameTime); map.put("timeUntilHidersSword", timeUntilHidersSword); map.put("disguiseBlocks", disguiseBlocks); @@ -133,7 +137,7 @@ public class Arena implements ConfigurationSerializable { return new Arena((String) M.g(map, "arenaName", "UNKNOWN_NAME"), (LocationSerializable) M.g(map, "pos1", loc), (LocationSerializable) M.g(map, "pos2", loc), (Integer) M.g(map, "maxPlayers", 12), (Integer) M.g(map, "minPlayers", 3), (Integer) M.g(map, "amountSeekersOnStart", 1), (Integer) M.g(map, "timeInLobbyUntilStart", 90), (Integer) M.g(map, "waitingTimeSeeker", 20), (Integer) M.g(map, "gameTime", 200), (Integer) M.g(map, - "timeUntilHidersSword", 30), (ArrayList) M.g(map, "disguiseBlocks", new ArrayList()), (LocationSerializable) M.g(map, + "timeUntilHidersSword", 30), (Integer) M.g(map, "blockAnnouncerTime", 45), (ArrayList) M.g(map, "disguiseBlocks", new ArrayList()), (LocationSerializable) M.g(map, "lobbyWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc), (LocationSerializable) M.g(map, "spawnWarp", loc), (ArrayList) M.g(map, "seekersWinCommands", new ArrayList()), (ArrayList) M.g( map, "hidersWinCommands", new ArrayList()), (ArrayList) M.g(map, "allowedCommands", new ArrayList()), (Integer) M.g(map, diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index 8d27f22..8cfbf8c 100644 --- a/src/nl/Steffion/BlockHunt/BlockHunt.java +++ b/src/nl/Steffion/BlockHunt/BlockHunt.java @@ -41,6 +41,8 @@ import nl.Steffion.BlockHunt.Managers.MessageM; import nl.Steffion.BlockHunt.Managers.PermissionsM; import nl.Steffion.BlockHunt.Serializables.LocationSerializable; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -329,6 +331,23 @@ public class BlockHunt extends JavaPlugin implements Listener { } } } + + // blockAnnouncer code. + if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) { + ArrayList remainingBlocks = new ArrayList(); + for (Player arenaPlayer : arena.playersInArena) { + if (!arena.seekers.contains(arenaPlayer)) { + String block = arenaPlayer.getInventory().getItem(8).getType().name(); + block = WordUtils.capitalizeFully(block.replace("_", " ")); + if (!remainingBlocks.contains(block)) { //Don't print double up block names. + remainingBlocks.add(block); + } + } + } + String blocklist = StringUtils.join(remainingBlocks, ", "); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + blocklist); + } + if (arena.timer == 190) { ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-190"); } else if (arena.timer == 60) { diff --git a/src/nl/Steffion/BlockHunt/ConfigC.java b/src/nl/Steffion/BlockHunt/ConfigC.java index 04a2cfc..470561c 100644 --- a/src/nl/Steffion/BlockHunt/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/ConfigC.java @@ -79,7 +79,7 @@ public enum ConfigC { "%TAG%NPlayer %A%playername%%N %N%option% %A%amount%%N %option2% your tokens.", W.messages), normal_ingameNowSolid( "%TAG%NYou're now a solid '%A%block%%N' block!", W.messages), normal_ingameNoMoreSolid("%TAG%NYou're no longer a solid block!", W.messages), normal_shopBoughtItem( "%TAG%NYou've bought the '%A%itemname%%N' item!", W.messages), normal_shopChoosenBlock("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!", W.messages), normal_shopChoosenSeeker( - "%TAG%NYou've choosen to be a %Aseeker%N!", W.messages), normal_shopChoosenHiders("%TAG%NYou've choosen to be a %Ahider%N!", W.messages), + "%TAG%NYou've choosen to be a %Aseeker%N!", W.messages), normal_shopChoosenHiders("%TAG%NYou've choosen to be a %Ahider%N!", W.messages), normal_ingameBlocksLeft("%TAG%NRemaining blocks: %A%1%%N", W.messages), warning_lobbyNeedAtleast("%TAG%WYou need atleast %A%1%%W player(s) to start the game!", W.messages), warning_ingameNEWSeekerChoosen( "%TAG%WThe last seeker left and a new seeker has been choosen!", W.messages), warning_unableToCommand( diff --git a/src/nl/Steffion/BlockHunt/InventoryHandler.java b/src/nl/Steffion/BlockHunt/InventoryHandler.java index a9decb0..85a1052 100644 --- a/src/nl/Steffion/BlockHunt/InventoryHandler.java +++ b/src/nl/Steffion/BlockHunt/InventoryHandler.java @@ -69,7 +69,11 @@ public class InventoryHandler { ItemMeta disguiseBlocks_NOTE_IM = disguiseBlocks_NOTE.getItemMeta(); disguiseBlocks_NOTE_IM.setDisplayName(MessageM.replaceAll("%NSet the %AdisguiseBlocks%N.")); disguiseBlocks_NOTE.setItemMeta(disguiseBlocks_NOTE_IM); - panel.setItem(37, disguiseBlocks_NOTE); + panel.setItem(36, disguiseBlocks_NOTE); + + ItemStack blockAnnouncerTime_UP = new ItemStack(Material.GOLD_NUGGET, 1); + ItemStack blockAnnouncerTime = new ItemStack(Material.BEDROCK, arena.blockAnnouncerTime); + ItemStack blockAnnouncerTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1); ItemStack timeUntilHidersSword_UP = new ItemStack(Material.GOLD_NUGGET, 1); ItemStack timeUntilHidersSword = new ItemStack(Material.BEDROCK, arena.timeUntilHidersSword); @@ -104,6 +108,9 @@ public class InventoryHandler { updownButton(panel, arena, ArenaType.gameTime, "gameTime", "1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17, 26); + updownButton(panel, arena, ArenaType.blockAnnouncerTime, "blockAnnouncerTime", "5 %Nseconds", blockAnnouncerTime_UP, blockAnnouncerTime, + blockAnnouncerTime_DOWN, 29, 38, 47); + updownButton(panel, arena, ArenaType.timeUntilHidersSword, "timeUntilHidersSword", "1 %Nsecond", timeUntilHidersSword_UP, timeUntilHidersSword, timeUntilHidersSword_DOWN, 30, 39, 48); @@ -148,6 +155,9 @@ public class InventoryHandler { case timeUntilHidersSword: setting = arena.timeUntilHidersSword; break; + case blockAnnouncerTime: + setting = arena.blockAnnouncerTime; + break; case hidersTokenWin: setting = arena.hidersTokenWin; break; diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java index e0f7bea..7f1a042 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java @@ -202,6 +202,8 @@ public class OnInventoryClickEvent implements Listener { updownButton(player, item, arena, ArenaType.waitingTimeSeeker, arena.waitingTimeSeeker, 1000, 5, 1, 1); } else if (item.getItemMeta().getDisplayName().contains("gameTime")) { updownButton(player, item, arena, ArenaType.gameTime, arena.gameTime, 1000, 5, 1, 1); + } else if (item.getItemMeta().getDisplayName().contains("blockAnnouncerTime")) { + updownButton(player, item, arena, ArenaType.blockAnnouncerTime, arena.blockAnnouncerTime, 1000, 0, 5, 5); } else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) { updownButton(player, item, arena, ArenaType.timeUntilHidersSword, arena.timeUntilHidersSword, 1000, 0, 1, 1); } else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) { @@ -253,6 +255,9 @@ public class OnInventoryClickEvent implements Listener { case gameTime: arena.gameTime = option + add; break; + case blockAnnouncerTime: + arena.blockAnnouncerTime = option + add; + break; case timeUntilHidersSword: arena.timeUntilHidersSword = option + add; break; @@ -290,6 +295,9 @@ public class OnInventoryClickEvent implements Listener { case gameTime: arena.gameTime = option - remove; break; + case blockAnnouncerTime: + arena.blockAnnouncerTime = option - remove; + break; case timeUntilHidersSword: arena.timeUntilHidersSword = option - remove; break;