Search in sources :

Example 16 with DataEntry

use of uk.co.oliwali.HawkEye.entry.DataEntry 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 17 with DataEntry

use of uk.co.oliwali.HawkEye.entry.DataEntry 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

DataEntry (uk.co.oliwali.HawkEye.entry.DataEntry)17 Player (org.bukkit.entity.Player)9 HawkEvent (uk.co.oliwali.HawkEye.HawkEvent)9 Location (org.bukkit.Location)7 Block (org.bukkit.block.Block)4 World (org.bukkit.World)3 ItemStack (org.bukkit.inventory.ItemStack)3 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 DataType (uk.co.oliwali.HawkEye.DataType)2 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 BlockState (org.bukkit.block.BlockState)1 Entity (org.bukkit.entity.Entity)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1 EntityDamageEvent (org.bukkit.event.entity.EntityDamageEvent)1 DeleteCallback (uk.co.oliwali.HawkEye.callbacks.DeleteCallback)1 SimpleRollbackEntry (uk.co.oliwali.HawkEye.entry.SimpleRollbackEntry)1