Search in sources :

Example 11 with EventHandler

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

the class PrismVehicleEvents method onVehicleDestroy.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVehicleDestroy(final VehicleDestroyEvent event) {
    final Vehicle vehicle = event.getVehicle();
    final Entity attacker = event.getAttacker();
    // Was it broken by an attack
    if (attacker != null) {
        if (attacker instanceof Player) {
            if (!Prism.getIgnore().event("vehicle-break", ((Player) attacker)))
                return;
            RecordingQueue.addToQueue(ActionFactory.createVehicle("vehicle-break", vehicle, ((Player) attacker).getName()));
        } else {
            if (!Prism.getIgnore().event("vehicle-break", attacker.getWorld()))
                return;
            RecordingQueue.addToQueue(ActionFactory.createVehicle("vehicle-break", vehicle, attacker.getType().name().toLowerCase()));
        }
    } else {
        // Otherwise its driver was reckless
        final Entity passenger = vehicle.getPassenger();
        if (passenger != null && passenger instanceof Player) {
            if (!Prism.getIgnore().event("vehicle-break", ((Player) passenger)))
                return;
            RecordingQueue.addToQueue(ActionFactory.createVehicle("vehicle-break", vehicle, ((Player) passenger).getName()));
        }
    }
}
Also used : Vehicle(org.bukkit.entity.Vehicle) Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 12 with EventHandler

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

the class PrismMiscEvents method onPrismBlocksExtinguishEvent.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPrismBlocksExtinguishEvent(final PrismBlocksExtinguishEvent event) {
    // Get all block changes for this event
    final ArrayList<BlockStateChange> blockStateChanges = event.getBlockStateChanges();
    if (!blockStateChanges.isEmpty()) {
        // Create an entry for the rollback as a whole
        final Handler primaryAction = ActionFactory.createPrismProcess("prism-process", PrismProcessType.EXTINGUISH, event.onBehalfOf(), "" + event.getRadius());
        final int id = RecordingTask.insertActionIntoDatabase(primaryAction);
        if (id == 0) {
            return;
        }
        for (final BlockStateChange stateChange : blockStateChanges) {
            final BlockState orig = stateChange.getOriginalBlock();
            final BlockState newBlock = stateChange.getNewBlock();
            // Build the action
            RecordingQueue.addToQueue(ActionFactory.createPrismRollback("prism-extinguish", orig, newBlock, event.onBehalfOf().getName(), id));
        }
    // ActionQueue.save();
    }
}
Also used : BlockStateChange(me.botsko.prism.events.BlockStateChange) BlockState(org.bukkit.block.BlockState) Handler(me.botsko.prism.actions.Handler) EventHandler(org.bukkit.event.EventHandler) EventHandler(org.bukkit.event.EventHandler)

Example 13 with EventHandler

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

the class PrismBlockEvents method onPistonRetract.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonRetract(final BlockPistonRetractEvent event) {
    if (!Prism.getIgnore().event("block-shift", event.getBlock()))
        return;
    if (!event.isSticky())
        return;
    final Block block = event.getBlock();
    if (block.getType().equals(Material.AIR))
        return;
    RecordingQueue.addToQueue(ActionFactory.createBlockShift("block-shift", event.getRetractLocation().getBlock(), block.getRelative(event.getDirection()).getLocation(), "Piston"));
}
Also used : Block(org.bukkit.block.Block) EventHandler(org.bukkit.event.EventHandler)

Example 14 with EventHandler

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

the class PrismBlockEvents method onSetFire.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSetFire(final BlockIgniteEvent event) {
    String cause = null;
    switch(event.getCause()) {
        case FIREBALL:
            cause = "fireball";
            break;
        case FLINT_AND_STEEL:
            cause = "lighter";
            break;
        case LAVA:
            cause = "lava-ignite";
            break;
        case LIGHTNING:
            cause = "lightning";
            break;
        default:
    }
    if (cause != null) {
        if (!Prism.getIgnore().event(cause, event.getBlock().getWorld()))
            return;
        final Player player = event.getPlayer();
        if (player != null) {
            if ((cause.equals("lighter") || cause.equals("fireball")) && plugin.getConfig().getBoolean("prism.alerts.uses.lighter") && !player.hasPermission("prism.alerts.use.lighter.ignore") && !player.hasPermission("prism.alerts.ignore")) {
                plugin.useMonitor.alertOnItemUse(player, "used a " + cause);
            }
        }
        RecordingQueue.addToQueue(ActionFactory.createBlock(cause, event.getBlock(), (player == null ? "Environment" : player.getName())));
    }
}
Also used : Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 15 with EventHandler

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

the class PrismBlockEvents method onBlockBreak.

/**
     * 
     * @param event
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event) {
    final Player player = event.getPlayer();
    Block block = event.getBlock();
    if (block.getType().equals(Material.AIR))
        return;
    // Run ore find alerts
    if (!player.hasPermission("prism.alerts.ores.ignore") && !player.hasPermission("prism.alerts.ignore")) {
        plugin.oreMonitor.processAlertsFromBlock(player, block);
    }
    if (!Prism.getIgnore().event("block-break", player))
        return;
    // Change handling a bit if it's a long block
    final Block sibling = me.botsko.elixr.BlockUtils.getSiblingForDoubleLengthBlock(block);
    if (sibling != null && !block.getType().equals(Material.CHEST) && !block.getType().equals(Material.TRAPPED_CHEST)) {
        block = sibling;
    }
    // log items removed from container
    // note: done before the container so a "rewind" for rollback will work
    // properly
    logItemRemoveFromDestroyedContainer(player.getName(), block);
    RecordingQueue.addToQueue(ActionFactory.createBlock("block-break", block, player.getName()));
    // check for block relationships
    logBlockRelationshipsForBlock(player.getName(), block);
    // if obsidian, log portal blocks
    if (block.getType().equals(Material.OBSIDIAN)) {
        final ArrayList<Block> blocks = me.botsko.elixr.BlockUtils.findConnectedBlocksOfType(Material.PORTAL, block, null);
        if (!blocks.isEmpty()) {
            // Only log 1 portal break, we don't need all 8
            RecordingQueue.addToQueue(ActionFactory.createBlock("block-break", blocks.get(0), player.getName()));
        }
    }
    // Pass to the break alerter
    if (!player.hasPermission("prism.alerts.use.break.ignore") && !player.hasPermission("prism.alerts.ignore")) {
        plugin.useMonitor.alertOnBlockBreak(player, event.getBlock());
    }
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) 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