Observer mode changes
This commit is contained in:
parent
1ef6fe3ed6
commit
d94f4f96a7
@ -613,7 +613,10 @@ public class UtilPlayer
|
|||||||
public static void clearInventory(Player player)
|
public static void clearInventory(Player player)
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
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)
|
public static void clearPotionEffects(Player player)
|
||||||
|
@ -10,7 +10,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event)
|
public void onQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
package mineplex.core.observer;
|
package mineplex.core.observer;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
|
|
||||||
public enum ObserverSettings
|
public enum ObserverSettings
|
||||||
{
|
{
|
||||||
CAN_OPEN_CHESTS,
|
CAN_OPEN_CHESTS,
|
||||||
CAN_BREAK_BLOCKS,
|
CAN_BREAK_BLOCKS,
|
||||||
CAN_INTERACT
|
CAN_INTERACT,
|
||||||
|
CAN_PICKUP_ITEMS,
|
||||||
|
CAN_CLICK_INVENTORY;
|
||||||
|
|
||||||
|
|
||||||
|
public static EnumSet<ObserverSettings> getSettings(Rank rank)
|
||||||
|
{
|
||||||
|
if (rank.Has(Rank.DEVELOPER))
|
||||||
|
return EnumSet.of(CAN_OPEN_CHESTS);
|
||||||
|
|
||||||
|
return EnumSet.noneOf(ObserverSettings.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user