diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-06-03 16:34:27 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-06-03 16:34:27 +0100 |
commit | f299771044b102a46e54ac9e3f4e56618d76ee5e (patch) | |
tree | 5ea6ce1ef10c64f10efd88de11fc71261b24b50d | |
parent | 7f5f6b6ac9a8b6c9ba6986d61a8c502e85f8c8ee (diff) | |
download | Essentials-f299771044b102a46e54ac9e3f4e56618d76ee5e.tar Essentials-f299771044b102a46e54ac9e3f4e56618d76ee5e.tar.gz Essentials-f299771044b102a46e54ac9e3f4e56618d76ee5e.tar.lz Essentials-f299771044b102a46e54ac9e3f4e56618d76ee5e.tar.xz Essentials-f299771044b102a46e54ac9e3f4e56618d76ee5e.zip |
Fix broken preventmodify permissions check in invsee (*scowls at ementalo*)
Also added check to prevent duping items
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 551833fc0..8eee65182 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -14,6 +14,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -24,6 +25,7 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; @@ -427,11 +429,16 @@ public class EssentialsPlayerListener implements Listener if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) { final User user = ess.getUser(event.getWhoClicked()); - final User invOwner = ess.getUser(event.getView().getPlayer()); - if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") - || invOwner.isAuthorized("essentials.invsee.preventmodify"))) + final InventoryHolder invHolder = event.getView().getTopInventory().getHolder(); + if (invHolder != null && invHolder instanceof HumanEntity) { - event.setCancelled(true); + final User invOwner = ess.getUser((HumanEntity)invHolder); + if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify") + || invOwner.isAuthorized("essentials.invsee.preventmodify") + || !invOwner.isOnline())) + { + event.setCancelled(true); + } } } } |