org.bukkit.event.block.BlockIgniteEvent.IgniteCause Java Examples

The following examples show how to use org.bukkit.event.block.BlockIgniteEvent.IgniteCause. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
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;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #2
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(net.minecraft.world.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;
        case FIRE: // Fire or any other unknown block counts as SPREAD.
        default:
            cause = IgniteCause.SPREAD;
    }

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #4
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(net.minecraft.world.World world, int x, int y, int z, net.minecraft.entity.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;
}
 
Example #5
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.exploder == null ? null : explosion.exploder.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #6
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(net.minecraft.world.World world, int x, int y, int z, net.minecraft.world.Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.exploder == null ? null : explosion.exploder.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #7
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBlockStartBurn(BlockIgniteEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is BlockIgniteEvent event");

    Block b = e.getBlock();
    Block bignit = e.getIgnitingBlock();
    if (b == null) {
        return;
    }

    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null && !r.canFire()) {
        if (e.getIgnitingEntity() != null) {
            if (e.getIgnitingEntity() instanceof Player) {
                Player p = (Player) e.getIgnitingEntity();
                if (!r.canBuild(p)) {
                    RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantplace");
                    e.setCancelled(true);
                    return;
                }
            } else {
                e.setCancelled(true);
                return;
            }
        }

        if (bignit != null && (bignit.getType().equals(Material.FIRE) || bignit.getType().name().contains("LAVA"))) {
            e.setCancelled(true);
            return;
        }
        if (e.getCause().equals(IgniteCause.LIGHTNING) || e.getCause().equals(IgniteCause.EXPLOSION) || e.getCause().equals(IgniteCause.FIREBALL)) {
            e.setCancelled(true);
        }
    }
}
 
Example #8
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, IgniteCause cause, Entity igniter) {
    BlockIgniteEvent event = new BlockIgniteEvent(world.getWorld().getBlockAt(x, y, z), cause, igniter.getBukkitEntity());
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #9
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(net.minecraft.world.World world, int x, int y, int z, IgniteCause cause, net.minecraft.entity.Entity igniter) {
    BlockIgniteEvent event = new BlockIgniteEvent(world.getWorld().getBlockAt(x, y, z), cause, igniter.getBukkitEntity());
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #10
Source File: BlockListener.java    From BedwarsRel with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onIgnite(BlockIgniteEvent ignite) {

  if (ignite.getIgnitingBlock() == null && ignite.getIgnitingEntity() == null) {
    return;
  }

  Game game = null;
  if (ignite.getIgnitingBlock() == null) {
    if (ignite.getIgnitingEntity() instanceof Player) {
      game = BedwarsRel.getInstance().getGameManager()
          .getGameOfPlayer((Player) ignite.getIgnitingEntity());
    } else {
      game = BedwarsRel.getInstance().getGameManager()
          .getGameByLocation(ignite.getIgnitingEntity().getLocation());
    }
  } else {
    game = BedwarsRel.getInstance().getGameManager()
        .getGameByLocation(ignite.getIgnitingBlock().getLocation());
  }

  if (game == null) {
    return;
  }

  if (game.getState() == GameState.STOPPED) {
    return;
  }

  if (ignite.getCause() == IgniteCause.ENDER_CRYSTAL || ignite.getCause() == IgniteCause.LIGHTNING
      || ignite.getCause() == IgniteCause.SPREAD) {
    ignite.setCancelled(true);
    return;
  }

  if (ignite.getIgnitingEntity() == null) {
    ignite.setCancelled(true);
    return;
  }

  if (game.getState() == GameState.WAITING) {
    return;
  }

  if (!game.getRegion().isPlacedBlock(ignite.getIgnitingBlock())
      && ignite.getIgnitingBlock() != null) {
    game.getRegion().addPlacedBlock(ignite.getIgnitingBlock(),
        ignite.getIgnitingBlock().getState());
  }
}