Search in sources :

Example 11 with HawkEvent

use of uk.co.oliwali.HawkEye.HawkEvent in project HawkEye by oliverwoodings.

the class MonitorPlayerListener method onPlayerPickupItem.

@HawkEvent(dataType = DataType.ITEM_PICKUP)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();
    ItemStack stack = event.getItem().getItemStack();
    String data = null;
    if (stack.getData() != null)
        data = stack.getAmount() + "x " + stack.getTypeId() + ":" + stack.getData().getData();
    else
        data = stack.getAmount() + "x " + stack.getTypeId();
    DataManager.addEntry(new DataEntry(player, DataType.ITEM_PICKUP, player.getLocation(), data));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 12 with HawkEvent

use of uk.co.oliwali.HawkEye.HawkEvent in project HawkEye by oliverwoodings.

the class MonitorPlayerListener method onPlayerInteract.

/**
	 * Handles several actions:
	 * OPEN_CHEST, DOOR_INTERACT, LEVER, STONE_BUTTON, FLINT_AND_STEEL, LAVA_BUCKET, WATER_BUCKET
	 */
@HawkEvent(dataType = { DataType.OPEN_CONTAINER, DataType.DOOR_INTERACT, DataType.LEVER, DataType.STONE_BUTTON, DataType.LAVA_BUCKET, DataType.WATER_BUCKET })
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Block block = event.getClickedBlock();
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(player);
    if (block != null) {
        Location loc = block.getLocation();
        switch(block.getType()) {
            case FURNACE:
            case DISPENSER:
            case CHEST:
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    //Call container manager for inventory open
                    HawkEye.containerManager.checkInventoryOpen(player, block);
                    DataManager.addEntry(new DataEntry(player, DataType.OPEN_CONTAINER, loc, Integer.toString(block.getTypeId())));
                }
                break;
            case WOODEN_DOOR:
            case TRAP_DOOR:
            case FENCE_GATE:
                DataManager.addEntry(new DataEntry(player, DataType.DOOR_INTERACT, loc, ""));
                break;
            case LEVER:
                DataManager.addEntry(new DataEntry(player, DataType.LEVER, loc, ""));
                break;
            case STONE_BUTTON:
                DataManager.addEntry(new DataEntry(player, DataType.STONE_BUTTON, loc, ""));
                break;
        }
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            loc = block.getRelative(event.getBlockFace()).getLocation();
            switch(player.getItemInHand().getType()) {
                case FLINT_AND_STEEL:
                    DataManager.addEntry(new SimpleRollbackEntry(player, DataType.FLINT_AND_STEEL, loc, ""));
                    break;
                case LAVA_BUCKET:
                    DataManager.addEntry(new SimpleRollbackEntry(player, DataType.LAVA_BUCKET, loc, ""));
                    break;
                case WATER_BUCKET:
                    DataManager.addEntry(new SimpleRollbackEntry(player, DataType.WATER_BUCKET, loc, ""));
                    break;
            }
        }
    }
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Location(org.bukkit.Location) SimpleRollbackEntry(uk.co.oliwali.HawkEye.entry.SimpleRollbackEntry) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Aggregations

HawkEvent (uk.co.oliwali.HawkEye.HawkEvent)12 DataEntry (uk.co.oliwali.HawkEye.entry.DataEntry)9 Player (org.bukkit.entity.Player)8 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)3 Block (org.bukkit.block.Block)2 BlockChangeEntry (uk.co.oliwali.HawkEye.entry.BlockChangeEntry)2 Method (java.lang.reflect.Method)1 BlockState (org.bukkit.block.BlockState)1 Entity (org.bukkit.entity.Entity)1 Event (org.bukkit.event.Event)1 EventException (org.bukkit.event.EventException)1 Listener (org.bukkit.event.Listener)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1 EntityDamageEvent (org.bukkit.event.entity.EntityDamageEvent)1 MaterialData (org.bukkit.material.MaterialData)1 EventExecutor (org.bukkit.plugin.EventExecutor)1 PluginManager (org.bukkit.plugin.PluginManager)1 DataType (uk.co.oliwali.HawkEye.DataType)1 SimpleRollbackEntry (uk.co.oliwali.HawkEye.entry.SimpleRollbackEntry)1