Search in sources :

Example 6 with EventHandler

use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.

the class PrismInventoryMoveItemEvent method onInventoryMoveItem.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItem(final InventoryMoveItemEvent event) {
    // Hopper inserted
    if (Prism.getIgnore().event("item-insert") && event.getDestination() != null) {
        // Get container
        final InventoryHolder ih = event.getDestination().getHolder();
        Location containerLoc = null;
        if (ih instanceof BlockState) {
            final BlockState eventChest = (BlockState) ih;
            containerLoc = eventChest.getLocation();
        }
        if (containerLoc == null)
            return;
        if (event.getSource().getType().equals(InventoryType.HOPPER)) {
            RecordingQueue.addToQueue(ActionFactory.createItemStack("item-insert", event.getItem(), event.getItem().getAmount(), 0, null, containerLoc, "hopper"));
        }
    }
    // Hopper removed
    if (Prism.getIgnore().event("item-remove") && event.getSource() != null) {
        // Get container
        final InventoryHolder ih = event.getSource().getHolder();
        Location containerLoc = null;
        if (ih instanceof BlockState) {
            final BlockState eventChest = (BlockState) ih;
            containerLoc = eventChest.getLocation();
        }
        if (containerLoc == null)
            return;
        if (event.getDestination().getType().equals(InventoryType.HOPPER)) {
            RecordingQueue.addToQueue(ActionFactory.createItemStack("item-remove", event.getItem(), event.getItem().getAmount(), 0, null, containerLoc, "hopper"));
        }
    }
}
Also used : BlockState(org.bukkit.block.BlockState) InventoryHolder(org.bukkit.inventory.InventoryHolder) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 7 with EventHandler

use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.

the class PrismPlayerEvents method onCraftItem.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(final CraftItemEvent event) {
    final Player player = (Player) event.getWhoClicked();
    if (!Prism.getIgnore().event("craft-item", player))
        return;
    final ItemStack item = event.getRecipe().getResult();
    RecordingQueue.addToQueue(ActionFactory.createItemStack("craft-item", item, 1, -1, null, player.getLocation(), player.getName()));
}
Also used : Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 8 with EventHandler

use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.

the class PrismPlayerEvents method onCommandPreprocess.

/**
     * Log command use
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
    final Player player = event.getPlayer();
    final String cmd = event.getMessage().toLowerCase();
    final String[] cmdArgs = cmd.split(" ");
    final String primaryCmd = cmdArgs[0].substring(1);
    if (plugin.getConfig().getBoolean("prism.alerts.illegal-commands.enabled")) {
        if (illegalCommands.contains(primaryCmd)) {
            final String msg = player.getName() + " attempted an illegal command: " + primaryCmd + ". Originally: " + cmd;
            player.sendMessage(Prism.messenger.playerError("Sorry, this command is not available in-game."));
            plugin.alertPlayers(null, msg);
            event.setCancelled(true);
            // Log to console
            if (plugin.getConfig().getBoolean("prism.alerts.illegal-commands.log-to-console")) {
                Prism.log(msg);
            }
            // Log to commands
            List<String> commands = plugin.getConfig().getStringList("prism.alerts.illegal-commands.log-commands");
            MiscUtils.dispatchAlert(msg, commands);
        }
    }
    if (!Prism.getIgnore().event("player-command", player))
        return;
    // Ignore some commands based on config
    if (ignoreCommands.contains(primaryCmd)) {
        return;
    }
    RecordingQueue.addToQueue(ActionFactory.createPlayer("player-command", player, event.getMessage()));
}
Also used : Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 9 with EventHandler

use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.

the class PrismPlayerEvents method onPlayerBucketFill.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
    final Player player = event.getPlayer();
    if (!Prism.getIgnore().event("bucket-fill", player))
        return;
    final Block spot = event.getBlockClicked().getRelative(event.getBlockFace());
    String liquid_type = "milk";
    if (spot.getTypeId() == 8 || spot.getTypeId() == 9) {
        liquid_type = "water";
    } else if (spot.getTypeId() == 10 || spot.getTypeId() == 11) {
        liquid_type = "lava";
    }
    final Handler pa = ActionFactory.createPlayer("bucket-fill", player, liquid_type);
    // Override the location with the area taken
    pa.setX(spot.getX());
    pa.setY(spot.getY());
    pa.setZ(spot.getZ());
    RecordingQueue.addToQueue(pa);
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Handler(me.botsko.prism.actions.Handler) EventHandler(org.bukkit.event.EventHandler) EventHandler(org.bukkit.event.EventHandler)

Example 10 with EventHandler

use of org.bukkit.event.EventHandler in project Prism-Bukkit by prism.

the class PrismPlayerEvents method onPlayerJoin.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(final PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    // Lookup player for cache reasons
    PlayerIdentification.cachePrismPlayer(player);
    // Track the join event
    if (!Prism.getIgnore().event("player-join", player))
        return;
    String ip = null;
    if (plugin.getConfig().getBoolean("prism.track-player-ip-on-join")) {
        ip = player.getAddress().getAddress().getHostAddress().toString();
    }
    RecordingQueue.addToQueue(ActionFactory.createPlayer("player-join", event.getPlayer(), ip));
}
Also used : Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)409 Player (org.bukkit.entity.Player)126 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Entity (org.bukkit.entity.Entity)58 Block (org.bukkit.block.Block)47 Location (org.bukkit.Location)43 Element (net.aufdemrand.denizencore.objects.Element)38 ItemStack (org.bukkit.inventory.ItemStack)33 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)31 Minigame (au.com.mineauz.minigames.minigame.Minigame)29 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)29 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)28 LivingEntity (org.bukkit.entity.LivingEntity)24 Projectile (org.bukkit.entity.Projectile)19 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 FPlayer (me.totalfreedom.totalfreedommod.player.FPlayer)15 BlockState (org.bukkit.block.BlockState)15 User (com.earth2me.essentials.User)14 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)14