use of org.bukkit.event.block.BlockIgniteEvent.IgniteCause in project WorldGuard by EngineHub.
the class WorldGuardBlockListener method onBlockIgnite.
/*
* Called when a block gets ignited.
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
IgniteCause cause = event.getCause();
Block block = event.getBlock();
World world = block.getWorld();
ConfigurationManager cfg = getConfig();
if (cfg.activityHaltToggle) {
event.setCancelled(true);
return;
}
WorldConfiguration wcfg = getWorldConfig(world);
boolean isFireSpread = cause == IgniteCause.SPREAD;
if (wcfg.preventLightningFire && cause == IgniteCause.LIGHTNING) {
event.setCancelled(true);
return;
}
if (wcfg.preventLavaFire && cause == IgniteCause.LAVA) {
event.setCancelled(true);
return;
}
if (wcfg.disableFireSpread && isFireSpread) {
event.setCancelled(true);
return;
}
if (wcfg.blockLighter && (cause == IgniteCause.FLINT_AND_STEEL || cause == IgniteCause.FIREBALL) && event.getPlayer() != null && !getPlugin().hasPermission(event.getPlayer(), "worldguard.override.lighter")) {
event.setCancelled(true);
return;
}
if (wcfg.fireSpreadDisableToggle && isFireSpread) {
event.setCancelled(true);
return;
}
if (!wcfg.disableFireSpreadBlocks.isEmpty() && isFireSpread) {
int x = block.getX();
int y = block.getY();
int z = block.getZ();
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y - 1, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x + 1, y, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x - 1, y, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z - 1).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z + 1).getType()).getId())) {
event.setCancelled(true);
return;
}
}
if (wcfg.useRegions) {
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
if (wcfg.highFreqFlags && isFireSpread && !set.testState(null, Flags.FIRE_SPREAD)) {
event.setCancelled(true);
return;
}
if (wcfg.highFreqFlags && cause == IgniteCause.LAVA && !set.testState(null, Flags.LAVA_FIRE)) {
event.setCancelled(true);
return;
}
if (cause == IgniteCause.FIREBALL && event.getPlayer() == null) {
// wtf bukkit, FIREBALL is supposed to be reserved to players
if (!set.testState(null, Flags.GHAST_FIREBALL)) {
event.setCancelled(true);
return;
}
}
if (cause == IgniteCause.LIGHTNING && !set.testState(null, Flags.LIGHTNING)) {
event.setCancelled(true);
return;
}
}
}
use of org.bukkit.event.block.BlockIgniteEvent.IgniteCause in project WindSpigot by Wind-Development.
the class CraftEventFactory method callBlockIgniteEvent.
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) {
org.bukkit.World bukkitWorld = world.getWorld();
org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
IgniteCause cause;
switch(bukkitIgniter.getType()) {
case ENDER_CRYSTAL:
cause = IgniteCause.ENDER_CRYSTAL;
break;
case LIGHTNING:
cause = IgniteCause.LIGHTNING;
break;
case SMALL_FIREBALL:
case FIREBALL:
cause = IgniteCause.FIREBALL;
break;
default:
cause = IgniteCause.FLINT_AND_STEEL;
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter);
world.getServer().getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.event.block.BlockIgniteEvent.IgniteCause in project Mohist by MohistMC.
the class CraftEventFactory method callBlockIgniteEvent.
public static BlockIgniteEvent callBlockIgniteEvent(Level world, BlockPos block, BlockPos source) {
org.bukkit.World bukkitWorld = world.getWorld();
Block igniter = bukkitWorld.getBlockAt(source.getX(), source.getY(), source.getZ());
IgniteCause cause;
switch(igniter.getType()) {
case LAVA:
cause = IgniteCause.LAVA;
break;
case DISPENSER:
cause = IgniteCause.FLINT_AND_STEEL;
break;
// Fire or any other unknown block counts as SPREAD.
case FIRE:
default:
cause = IgniteCause.SPREAD;
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(block.getX(), block.getY(), block.getZ()), cause, igniter);
world.getCraftServer().getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.event.block.BlockIgniteEvent.IgniteCause in project Mohist by MohistMC.
the class CraftEventFactory method callBlockIgniteEvent.
public static BlockIgniteEvent callBlockIgniteEvent(Level world, BlockPos pos, Entity igniter) {
org.bukkit.World bukkitWorld = world.getWorld();
org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
IgniteCause cause;
switch(bukkitIgniter.getType()) {
case ENDER_CRYSTAL:
cause = IgniteCause.ENDER_CRYSTAL;
break;
case LIGHTNING:
cause = IgniteCause.LIGHTNING;
break;
case SMALL_FIREBALL:
case FIREBALL:
cause = IgniteCause.FIREBALL;
break;
case ARROW:
cause = IgniteCause.ARROW;
break;
default:
cause = IgniteCause.FLINT_AND_STEEL;
}
if (igniter instanceof net.minecraft.world.entity.projectile.Projectile) {
Entity shooter = ((net.minecraft.world.entity.projectile.Projectile) igniter).getOwner();
if (shooter != null) {
bukkitIgniter = shooter.getBukkitEntity();
}
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, bukkitIgniter);
world.getCraftServer().getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.event.block.BlockIgniteEvent.IgniteCause in project Magma by magmafoundation.
the class CraftEventFactory method callBlockIgniteEvent.
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) {
org.bukkit.World bukkitWorld = world.getWorld();
Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ);
IgniteCause cause;
switch(igniter.getType()) {
case LAVA:
case STATIONARY_LAVA:
cause = IgniteCause.LAVA;
break;
case DISPENSER:
cause = IgniteCause.FLINT_AND_STEEL;
break;
// Fire or any other unknown block counts as SPREAD.
case FIRE:
default:
cause = IgniteCause.SPREAD;
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
world.getServer().getPluginManager().callEvent(event);
return event;
}
Aggregations