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));
}
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;
}
}
}
}
Aggregations