Java Code Examples for org.bukkit.event.block.BlockIgniteEvent#setCancelled()

The following examples show how to use org.bukkit.event.block.BlockIgniteEvent#setCancelled() . 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: CustomItemBlockIgnite.java    From AdditionsAPI with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onCustomItemBlockIgniteLowest(CustomItemBlockIgniteEvent customEvent) {
	if (customEvent.isCancelled())
		return;

	CustomItem cItem = customEvent.getCustomItem();

	if (!(cItem.getPermissions() instanceof FlintAndSteelPermissions))
		return;
	FlintAndSteelPermissions perm = (FlintAndSteelPermissions) cItem.getPermissions();

	BlockIgniteEvent event = customEvent.getBlockIgniteEvent();

	if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getFire()))
		event.setCancelled(true);
}
 
Example 2
Source File: SentinelEventHandler.java    From Sentinel with MIT License 6 votes vote down vote up
@EventHandler
public void onBlockIgnites(BlockIgniteEvent event) {
    if (event.isCancelled()) {
        return;
    }
    if (!SentinelPlugin.instance.preventExplosionBlockDamage) {
        return;
    }
    if (event.getIgnitingEntity() instanceof Projectile) {
        ProjectileSource source = ((Projectile) event.getIgnitingEntity()).getShooter();
        if (source instanceof Entity) {
            SentinelTrait sourceSentinel = SentinelUtilities.tryGetSentinel((Entity) source);
            if (sourceSentinel != null) {
                event.setCancelled(true);
            }
        }
    }
}
 
Example 3
Source File: DWorldListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockIgnite(BlockIgniteEvent event) {
    if (!plugin.isInstance(event.getBlock().getWorld())) {
        return;
    }

    if (event.getCause() != BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
        event.setCancelled(true);
    }
}
 
Example 4
Source File: BukkitPlotListener.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
    if (event.getIgnitingEntity() == null) {
        return;
    }
    Location location = BukkitUtil.adapt(event.getBlock().getLocation());

    PlotMapInfo pmi = manager.getMap(location);

    if (pmi != null) {
        if (pmi.isDisableIgnition()) {
            event.setCancelled(true);
        } else {
            Plot plot = manager.getPlot(location);
            if (plot == null) {
                event.setCancelled(true);
            } else {
                if (plot.getOwnerId().equals(event.getPlayer().getUniqueId())) {
                    return;
                }
                Optional<Plot.AccessLevel> member = plot.isMember(event.getIgnitingEntity().getUniqueId());
                if (member.isPresent()) {
                    if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) {
                        event.setCancelled(true);
                    } else if (api.isPlotLocked(plot.getId())) {
                        event.setCancelled(true);
                    }
                } else {
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
Example 5
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());
  }
}
 
Example 6
Source File: BlockListener.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockIgniteEvent(BlockIgniteEvent event) {
//	CivLog.debug("block ignite event");

	for (int x = -1; x <= 1; x++) {
		for (int y = -1; y <= 1; y++) {
			for (int z = -1; z <= 1; z++) {
				Block b = event.getBlock().getRelative(x, y, z);		
				bcoord.setFromLocation(b.getLocation());
				StructureBlock sb = CivGlobal.getStructureBlock(bcoord);
				if (sb != null) {
					if (b.getType().isBurnable()) {
						event.setCancelled(true);
					}
					return;
				}

				RoadBlock rb = CivGlobal.getRoadBlock(bcoord);
				if (rb != null) {
					event.setCancelled(true);
					return;
				}

				CampBlock cb = CivGlobal.getCampBlock(bcoord);
				if (cb != null) {
					event.setCancelled(true);
					return;
				}

				StructureSign structSign = CivGlobal.getStructureSign(bcoord);
				if (structSign != null) {
					event.setCancelled(true);
					return;
				}

				StructureChest structChest = CivGlobal.getStructureChest(bcoord);
				if (structChest != null) {
					event.setCancelled(true);
					return;
				}
			}
		}
    }


	coord.setFromLocation(event.getBlock().getLocation());
	TownChunk tc = CivGlobal.getTownChunk(coord);

	if (tc == null) {
		return;
	}

	if (tc.perms.isFire() == false) {
		CivMessage.sendError(event.getPlayer(), "Fire disabled in this chunk.");
		event.setCancelled(true);
	}		
}
 
Example 7
Source File: ArenaListener.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockIgniteEvent(BlockIgniteEvent event) {
	if (ArenaManager.activeArenas.containsKey(event.getBlock().getWorld().getName())) {
		event.setCancelled(true);
	}
}
 
Example 8
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockIgnite(final BlockIgniteEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info(e.getCause().name());
    }
    if (!inWorld(e.getBlock())) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    // Check if this is a portal lighting
    if (e.getBlock() != null && e.getBlock().getType().equals(Material.OBSIDIAN)) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: portal lighting");
        return;
    }
    if (e.getCause() != null) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: ignite cause = " + e.getCause());
        switch (e.getCause()) {
        case ENDER_CRYSTAL:
        case EXPLOSION:
        case FIREBALL:
        case LIGHTNING:
            if (!actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE)) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: canceling fire");
                e.setCancelled(true);
            }
            break;
        case FLINT_AND_STEEL:
            Set<Material> transparent = new HashSet<Material>();
            transparent.add(Material.AIR);
            if (DEBUG) {
                plugin.getLogger().info("DEBUG: block = " + e.getBlock());
                //plugin.getLogger().info("DEBUG: target block = " + e.getPlayer().getTargetBlock(transparent, 10));
            }
            // Check if this is allowed
            if (e.getPlayer() != null && (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypass"))) {
                return;
            }
            if (!actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE)) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: canceling fire");
                // If this was not a player, just stop it
                if (e.getPlayer() == null) {
                    e.setCancelled(true);
                    break;
                }
                // Get target block
                Block targetBlock = e.getPlayer().getTargetBlock(transparent, 10);
                if (targetBlock.getType().equals(Material.OBSIDIAN)) {
                    final MaterialData md = new MaterialData(e.getBlock().getType(), e.getBlock().getData());
                    new BukkitRunnable() {

                        @Override
                        public void run() {
                            if (e.getBlock().getType().equals(Material.FIRE)) {
                                e.getBlock().setType(md.getItemType());
                                e.getBlock().setData(md.getData());
                            }

                        }
                    }.runTask(plugin);
                } else {
                    e.setCancelled(true);
                }
            }
            break;

        case LAVA:
        case SPREAD:
            // Check if this is a portal lighting
            if (e.getBlock() != null && e.getBlock().getType().equals(Material.OBSIDIAN)) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: obsidian lighting");
                return;
            }
            if (!actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE_SPREAD)) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: canceling fire spread");
                e.setCancelled(true);
            }
            break;
        default:
            break;
        }
    }
}
 
Example 9
Source File: BlockIgnite.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
@EventHandler
public void onIgnite(BlockIgniteEvent e) {
    if (ProtectionSystem.build(e.getPlayer(), e.getBlock().getLocation())) {
        e.setCancelled(true);
    }
}
 
Example 10
Source File: WorldFreeze.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event) {
    if (!match.isRunning()) {
        event.setCancelled(true);
    }
}
 
Example 11
Source File: BlockEventRegion.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event) {
    if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) {
        event.setCancelled(true);
    }
}