From 3a88b109910f4d78ef3569c319a3d2a79e3930a2 Mon Sep 17 00:00:00 2001 From: Steffion Date: Sat, 5 Oct 2013 20:40:24 +0200 Subject: [PATCH] + Added way to require inventory empty on join. Closes #6. --- src/nl/Steffion/BlockHunt/ArenaHandler.java | 23 +++++++++++++++++++++ src/nl/Steffion/BlockHunt/ConfigC.java | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/nl/Steffion/BlockHunt/ArenaHandler.java b/src/nl/Steffion/BlockHunt/ArenaHandler.java index c74d172..b5bd5ef 100644 --- a/src/nl/Steffion/BlockHunt/ArenaHandler.java +++ b/src/nl/Steffion/BlockHunt/ArenaHandler.java @@ -67,6 +67,29 @@ public class ArenaHandler { MessageM.sendFMessage(player, ConfigC.error_joinNoBlocksSet); } else { + boolean inventoryempty = true; + for (ItemStack invitem : player.getInventory()) { + if (invitem != null) { + if (invitem.getType() != Material.AIR) { + inventoryempty = false; + } + } + } + + for (ItemStack invitem : player.getInventory() + .getArmorContents()) { + if (invitem.getType() != Material.AIR) { + inventoryempty = false; + } + } + + if ((Boolean) W.config + .get(ConfigC.require_inventory_clear_onJoin) + && !inventoryempty) { + MessageM.sendFMessage(player, + ConfigC.error_joinInventoryNotEmpty); + return; + } LocationSerializable zero = new LocationSerializable( Bukkit.getWorld(player.getWorld().getName() .toString()), 0, 0, 0, 0, 0); diff --git a/src/nl/Steffion/BlockHunt/ConfigC.java b/src/nl/Steffion/BlockHunt/ConfigC.java index e4f602d..eab2d91 100644 --- a/src/nl/Steffion/BlockHunt/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/ConfigC.java @@ -89,6 +89,8 @@ public enum ConfigC { scoreboard_seekers ("%NSeekers:", W.config), scoreboard_hiders ("%NHiders:", W.config), + require_inventory_clear_onJoin (false, 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.", @@ -202,6 +204,8 @@ public enum ConfigC { W.messages), error_joinArenaIngame ("%TAG%EThis game has already started.", W.messages), error_joinFull ("%TAG%EUnable to join this arena. It's full!", W.messages), + error_joinInventoryNotEmpty ("%TAG%EYour inventory should be empty before joining!", + W.messages), error_leaveNotInArena ("%TAG%EYou're not in an arena!", W.messages), error_createSelectionFirst ("%TAG%EMake a selection first. Use the wand command: %A/" + BlockHunt.pdfFile.getName() + " %E.",