Search in sources :

Example 6 with HawkEvent

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

the class MonitorPlayerListener method onPlayerTeleport.

@HawkEvent(dataType = DataType.TELEPORT)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(event.getPlayer());
    Location from = event.getFrom();
    Location to = event.getTo();
    if (Util.distance(from, to) > 5)
        DataManager.addEntry(new DataEntry(event.getPlayer(), DataType.TELEPORT, from, to.getWorld().getName() + ": " + to.getX() + ", " + to.getY() + ", " + to.getZ()));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Location(org.bukkit.Location) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 7 with HawkEvent

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

the class MonitorBlockListener method onBlockFromTo.

@HawkEvent(dataType = { DataType.LAVA_FLOW, DataType.WATER_FLOW })
public void onBlockFromTo(BlockFromToEvent event) {
    List<Integer> fluidBlocks = Arrays.asList(0, 27, 28, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 69, 70, 75, 76, 78, 93, 94);
    //Only interested in liquids flowing
    if (!event.getBlock().isLiquid())
        return;
    Location loc = event.getToBlock().getLocation();
    BlockState from = event.getBlock().getState();
    BlockState to = event.getToBlock().getState();
    MaterialData data = from.getData();
    //Lava
    if (from.getTypeId() == 10 || from.getTypeId() == 11) {
        //Flowing into a normal block
        if (fluidBlocks.contains(to.getTypeId())) {
            data.setData((byte) (from.getRawData() + 1));
            from.setData(data);
        } else //Flowing into water
        if (to.getTypeId() == 8 || to.getTypeId() == 9) {
            from.setTypeId(event.getFace() == BlockFace.DOWN ? 10 : 4);
            data.setData((byte) 0);
            from.setData(data);
        }
        DataManager.addEntry(new BlockChangeEntry("Environment", DataType.LAVA_FLOW, loc, to, from));
    } else //Water
    if (from.getTypeId() == 8 || from.getTypeId() == 9) {
        //Normal block
        if (fluidBlocks.contains(to.getTypeId())) {
            data.setData((byte) (from.getRawData() + 1));
            from.setData(data);
            DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, to, from));
        }
        //If we are flowing over lava, cobble or obsidian will form
        BlockState lower = event.getToBlock().getRelative(BlockFace.DOWN).getState();
        if (lower.getTypeId() == 10 || lower.getTypeId() == 11) {
            from.setTypeId(lower.getData().getData() == 0 ? 49 : 4);
            loc.setY(loc.getY() - 1);
            DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, lower, from));
        }
    }
}
Also used : BlockState(org.bukkit.block.BlockState) BlockChangeEntry(uk.co.oliwali.HawkEye.entry.BlockChangeEntry) MaterialData(org.bukkit.material.MaterialData) Location(org.bukkit.Location) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 8 with HawkEvent

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

the class MonitorPlayerListener method onPlayerDropItem.

@HawkEvent(dataType = DataType.ITEM_DROP)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    Player player = event.getPlayer();
    ItemStack stack = event.getItemDrop().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_DROP, 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 9 with HawkEvent

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

the class MonitorPlayerListener method onPlayerJoin.

@HawkEvent(dataType = DataType.JOIN)
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    Location loc = player.getLocation();
    DataManager.addEntry(new DataEntry(player, DataType.JOIN, loc, Config.LogIpAddresses ? player.getAddress().getAddress().getHostAddress().toString() : ""));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Player(org.bukkit.entity.Player) Location(org.bukkit.Location) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 10 with HawkEvent

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

the class MonitorPlayerListener method onPlayerChat.

@HawkEvent(dataType = DataType.CHAT)
public void onPlayerChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(event.getPlayer());
    DataManager.addEntry(new DataEntry(player, DataType.CHAT, player.getLocation(), event.getMessage()));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Player(org.bukkit.entity.Player) 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