use of org.bukkit.block.BlockState in project Prism-Bukkit by prism.
the class PrismMiscEvents method onPrismBlocksDrainEvent.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPrismBlocksDrainEvent(final PrismBlocksDrainEvent 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.DRAIN, 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-drain", orig, newBlock, event.onBehalfOf().getName(), id));
}
// ActionQueue.save();
}
}
use of org.bukkit.block.BlockState in project Prism-Bukkit by prism.
the class PrismBlockEvents method onBlockFade.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFade(final BlockFadeEvent event) {
if (!Prism.getIgnore().event("block-fade", event.getBlock()))
return;
final Block b = event.getBlock();
if (b.getType().equals(Material.FIRE))
return;
final BlockState s = event.getNewState();
RecordingQueue.addToQueue(ActionFactory.createBlockChange("block-fade", b.getLocation(), b.getTypeId(), b.getData(), s.getTypeId(), s.getRawData(), "Environment"));
}
use of org.bukkit.block.BlockState in project Prism-Bukkit by prism.
the class PrismBlockEvents method onBlockSpread.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockSpread(final BlockSpreadEvent event) {
// If fire, do we track fire spread? If not, do we track block-spread
String type = "block-spread";
if (event.getNewState().getType().equals(Material.FIRE)) {
if (!Prism.getIgnore().event("fire-spread"))
return;
type = "fire-spread";
} else {
if (!Prism.getIgnore().event("block-spread", event.getBlock()))
return;
}
final Block b = event.getBlock();
final BlockState s = event.getNewState();
RecordingQueue.addToQueue(ActionFactory.createBlockChange(type, b.getLocation(), b.getTypeId(), b.getData(), s.getTypeId(), s.getRawData(), "Environment"));
}
use of org.bukkit.block.BlockState in project Prism-Bukkit by prism.
the class PrismEntityEvents method onEntityBlockForm.
/**
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockForm(final EntityBlockFormEvent event) {
if (!Prism.getIgnore().event("entity-form", event.getBlock()))
return;
final Block block = event.getBlock();
final Location loc = block.getLocation();
final BlockState newState = event.getNewState();
final String entity = event.getEntity().getType().name().toLowerCase();
RecordingQueue.addToQueue(ActionFactory.createBlockChange("entity-form", loc, block.getTypeId(), block.getData(), newState.getTypeId(), newState.getRawData(), entity));
}
use of org.bukkit.block.BlockState in project Prism-Bukkit by prism.
the class PrismInventoryEvents method onInventoryDrag.
/**
* Handle inventory transfers
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryDrag(final InventoryDragEvent event) {
if (!plugin.getConfig().getBoolean("prism.tracking.item-insert") && !plugin.getConfig().getBoolean("prism.tracking.item-remove"))
return;
// Get container
final InventoryHolder ih = event.getInventory().getHolder();
Location containerLoc = null;
if (ih instanceof BlockState) {
final BlockState eventChest = (BlockState) ih;
containerLoc = eventChest.getLocation();
}
// Store some info
final Player player = (Player) event.getWhoClicked();
final Map<Integer, ItemStack> newItems = event.getNewItems();
for (final Entry<Integer, ItemStack> entry : newItems.entrySet()) {
recordInvAction(player, containerLoc, entry.getValue(), entry.getKey(), "item-insert");
}
}
Aggregations