From 718ee0265dcdf14dfc1196b16f912d6ae5a36c68 Mon Sep 17 00:00:00 2001 From: RobotoRaccoon Date: Fri, 16 Jan 2015 12:11:53 +1100 Subject: [PATCH 1/5] Added a blockAnnouncer * Configurable time to announce when the remaining hiders have their block types announced to everyone in the arena. --- src/nl/Steffion/BlockHunt/BlockHunt.java | 16 ++++++++++++++++ src/nl/Steffion/BlockHunt/ConfigC.java | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index 8d27f22..e9bf05b 100644 --- a/src/nl/Steffion/BlockHunt/BlockHunt.java +++ b/src/nl/Steffion/BlockHunt/BlockHunt.java @@ -329,6 +329,22 @@ public class BlockHunt extends JavaPlugin implements Listener { } } } + + // blockAnnouncer code. + if (arena.timer == (Integer)W.config.get(ConfigC.blockAnnouncer_timer) && (Boolean)W.config.get(ConfigC.blockAnnouncer_enabled)) { + ArrayList remainingBlocks = new ArrayList(); + for (Player arenaPlayer : arena.playersInArena) { + if (!arena.seekers.contains(arenaPlayer)) { + String block = arenaPlayer.getInventory().getItem(8).getType().name(); + block = block.substring(0, 1).toUpperCase() + block.substring(1).toLowerCase(); //Make lowercase and capitalise first letter. + if (!remainingBlocks.contains(block)) { //Don't print double up block names. + remainingBlocks.add(block); + } + } + } + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + remainingBlocks.toString()); + } + 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..aedd825 100644 --- a/src/nl/Steffion/BlockHunt/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/ConfigC.java @@ -50,6 +50,8 @@ public enum ConfigC { requireInventoryClearOnJoin(false, W.config), + blockAnnouncer_enabled(true, W.config), blockAnnouncer_timer(20, W.config), + log_enabledPlugin("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", W.messages), log_disabledPlugin( "%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.", W.messages), @@ -79,7 +81,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( From 4934febd007f136f52c3be7ccb846224850579b3 Mon Sep 17 00:00:00 2001 From: addstar Date: Sun, 25 Jan 2015 00:37:29 +1100 Subject: [PATCH 2/5] Fix: Improve message output for list of remaining blocks --- src/nl/Steffion/BlockHunt/BlockHunt.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index e9bf05b..78a2502 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; @@ -56,6 +58,7 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.StringUtil; public class BlockHunt extends JavaPlugin implements Listener { /** @@ -331,18 +334,19 @@ public class BlockHunt extends JavaPlugin implements Listener { } // blockAnnouncer code. - if (arena.timer == (Integer)W.config.get(ConfigC.blockAnnouncer_timer) && (Boolean)W.config.get(ConfigC.blockAnnouncer_enabled)) { + 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 = block.substring(0, 1).toUpperCase() + block.substring(1).toLowerCase(); //Make lowercase and capitalise first letter. + block = WordUtils.capitalizeFully(block.replace("_", " ")); if (!remainingBlocks.contains(block)) { //Don't print double up block names. remainingBlocks.add(block); } } } - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + remainingBlocks.toString()); + String blocklist = StringUtils.join(remainingBlocks, ", "); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + blocklist); } if (arena.timer == 190) { From 6cb404b0d78ea8fafbbb2221addcfe3b3842702f Mon Sep 17 00:00:00 2001 From: addstar Date: Sun, 25 Jan 2015 00:39:31 +1100 Subject: [PATCH 3/5] Use per-arena configurable block announcer values instead of a global one (disable by setting to 0) --- src/nl/Steffion/BlockHunt/Arena.java | 10 +++++++--- src/nl/Steffion/BlockHunt/ConfigC.java | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) 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/ConfigC.java b/src/nl/Steffion/BlockHunt/ConfigC.java index aedd825..470561c 100644 --- a/src/nl/Steffion/BlockHunt/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/ConfigC.java @@ -50,8 +50,6 @@ public enum ConfigC { requireInventoryClearOnJoin(false, W.config), - blockAnnouncer_enabled(true, W.config), blockAnnouncer_timer(20, W.config), - log_enabledPlugin("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", W.messages), log_disabledPlugin( "%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.", W.messages), From 7380f885a30432d6de2aef26f3b95152973ce7fa Mon Sep 17 00:00:00 2001 From: addstar Date: Sun, 25 Jan 2015 00:40:00 +1100 Subject: [PATCH 4/5] Remove accidental unnecessary import --- src/nl/Steffion/BlockHunt/BlockHunt.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index 78a2502..8cfbf8c 100644 --- a/src/nl/Steffion/BlockHunt/BlockHunt.java +++ b/src/nl/Steffion/BlockHunt/BlockHunt.java @@ -58,7 +58,6 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.StringUtil; public class BlockHunt extends JavaPlugin implements Listener { /** From 397a6dc6057fd0ec3eed2262176b26abe690b4fb Mon Sep 17 00:00:00 2001 From: addstar Date: Sun, 25 Jan 2015 00:40:47 +1100 Subject: [PATCH 5/5] Add GUI option for configuring block announcer (via /bh set) --- src/nl/Steffion/BlockHunt/InventoryHandler.java | 12 +++++++++++- .../BlockHunt/Listeners/OnInventoryClickEvent.java | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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;