diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index b8049040c..5ad7351a6 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -613,7 +613,10 @@ public class UtilPlayer public static void clearInventory(Player player) { player.getInventory().clear(); - player.getEquipment().clear(); + player.getInventory().setHelmet(null); + player.getInventory().setChestplate(null); + player.getInventory().setLeggings(null); + player.getInventory().setBoots(null); } public static void clearPotionEffects(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverManager.java b/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverManager.java index 9b32e915e..fca1b5b8d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverManager.java @@ -10,7 +10,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -92,6 +94,30 @@ public class ObserverManager extends MiniPlugin } } + @EventHandler + public void onInventoryClick(InventoryClickEvent event) + { + ObserverData data = _observerMap.get(event.getWhoClicked()); + + if (data != null) + { + if (!data.getSettings().contains(ObserverSettings.CAN_CLICK_INVENTORY)) + event.setCancelled(true); + } + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + ObserverData data = _observerMap.get(event.getPlayer()); + + if (data != null) + { + if (!data.getSettings().contains(ObserverSettings.CAN_PICKUP_ITEMS)) + event.setCancelled(true); + } + } + @EventHandler public void onQuit(PlayerQuitEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverSettings.java b/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverSettings.java index 7165de7db..20b13384e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverSettings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/observer/ObserverSettings.java @@ -1,9 +1,23 @@ package mineplex.core.observer; +import java.util.EnumSet; + +import mineplex.core.common.Rank; + public enum ObserverSettings { CAN_OPEN_CHESTS, CAN_BREAK_BLOCKS, - CAN_INTERACT + CAN_INTERACT, + CAN_PICKUP_ITEMS, + CAN_CLICK_INVENTORY; + + public static EnumSet getSettings(Rank rank) + { + if (rank.Has(Rank.DEVELOPER)) + return EnumSet.of(CAN_OPEN_CHESTS); + + return EnumSet.noneOf(ObserverSettings.class); + } }