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