From 0d22ddc4a4c79f25ee9f0a66dc7b37f6199172a0 Mon Sep 17 00:00:00 2001 From: Acrobot Date: Fri, 23 Nov 2012 21:03:29 +0100 Subject: [PATCH] Fixed errors in PlayerInventoryListener --- .../Listeners/Player/PlayerInventory.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java b/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java index 4760880..87f76a9 100644 --- a/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java +++ b/com/Acrobot/ChestShop/Listeners/Player/PlayerInventory.java @@ -1,6 +1,7 @@ package com.Acrobot.ChestShop.Listeners.Player; -import com.Acrobot.ChestShop.Config.Config; +import com.Acrobot.ChestShop.Configuration.Messages; +import com.Acrobot.ChestShop.Configuration.Properties; import com.Acrobot.ChestShop.Plugins.ChestShop; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -13,9 +14,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryType; -import static com.Acrobot.ChestShop.Config.Language.ACCESS_DENIED; -import static com.Acrobot.ChestShop.Config.Property.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY; - /** * @author Acrobot */ @@ -26,7 +24,7 @@ public class PlayerInventory implements Listener { return; } - if (!Config.getBoolean(TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY)) { + if (!Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY) { return; } @@ -37,10 +35,16 @@ public class PlayerInventory implements Listener { } Player player = (Player) entity; - Block chest = ((BlockState) event.getInventory().getHolder()).getBlock(); + Block chest; + + if (event.getInventory().getHolder() instanceof Chest) { + chest = ((BlockState) event.getInventory().getHolder()).getBlock(); + } else { + chest = ((DoubleChest) event.getInventory().getHolder()).getLocation().getBlock(); + } if (!PlayerInteract.canOpenOtherShops(player) && !ChestShop.canAccess(player, chest)) { - player.sendMessage(Config.getLocal(ACCESS_DENIED)); + player.sendMessage(Messages.prefix(Messages.ACCESS_DENIED)); event.setCancelled(true); } }