Search in sources :

Example 1 with IgniteCause

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;
        }
    }
}
Also used : BukkitWorldConfiguration(com.sk89q.worldguard.bukkit.BukkitWorldConfiguration) WorldConfiguration(com.sk89q.worldguard.config.WorldConfiguration) Block(org.bukkit.block.Block) World(org.bukkit.World) ConfigurationManager(com.sk89q.worldguard.config.ConfigurationManager) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) EventHandler(org.bukkit.event.EventHandler)

Example 2 with IgniteCause

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;
}
Also used : BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause)

Example 3 with IgniteCause

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;
}
Also used : Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause)

Example 4 with IgniteCause

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;
}
Also used : FireworkRocketEntity(net.minecraft.world.entity.projectile.FireworkRocketEntity) ItemEntity(net.minecraft.world.entity.item.ItemEntity) Entity(net.minecraft.world.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) LivingEntity(net.minecraft.world.entity.LivingEntity) HumanEntity(org.bukkit.entity.HumanEntity) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause) Projectile(org.bukkit.entity.Projectile)

Example 5 with IgniteCause

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;
}
Also used : Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock) IgniteCause(org.bukkit.event.block.BlockIgniteEvent.IgniteCause)

Aggregations

IgniteCause (org.bukkit.event.block.BlockIgniteEvent.IgniteCause)13 Block (org.bukkit.block.Block)7 BlockIgniteEvent (org.bukkit.event.block.BlockIgniteEvent)6 CraftBlock (org.bukkit.craftbukkit.block.CraftBlock)3 org.bukkit.event.entity (org.bukkit.event.entity)3 HumanEntity (org.bukkit.entity.HumanEntity)2 BukkitWorldConfiguration (com.sk89q.worldguard.bukkit.BukkitWorldConfiguration)1 ConfigurationManager (com.sk89q.worldguard.config.ConfigurationManager)1 WorldConfiguration (com.sk89q.worldguard.config.WorldConfiguration)1 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)1 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)1 Entity (net.minecraft.entity.Entity)1 MobEntity (net.minecraft.entity.MobEntity)1 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)1 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 VillagerEntity (net.minecraft.entity.merchant.villager.VillagerEntity)1 AbstractRaiderEntity (net.minecraft.entity.monster.AbstractRaiderEntity)1 GhastEntity (net.minecraft.entity.monster.GhastEntity)1 MonsterEntity (net.minecraft.entity.monster.MonsterEntity)1