org.bukkit.event.block.BlockIgniteEvent Java Examples

The following examples show how to use org.bukkit.event.block.BlockIgniteEvent. 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: BlockTransformEvent.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Get whether the {@link Block} was probably transformed by a player.
 *
 * @return Whether the event is considered "manual."
 */
public final boolean isManual() {
  final Event event = getCause();

  if (event instanceof BlockPlaceEvent
      || event instanceof BlockBreakEvent
      || event instanceof PlayerBucketEmptyEvent
      || event instanceof PlayerBucketFillEvent) return true;

  if (event instanceof BlockIgniteEvent) {
    BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event;
    if (igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL
        && igniteEvent.getIgnitingEntity() != null) {
      return true;
    }
  }

  if (event instanceof ExplosionPrimeByEntityEvent
      && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) {
    return true;
  }

  return false;
}
 
Example #2
Source File: BlockTransformListener.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventWrapper
public void onBlockIgnite(final BlockIgniteEvent event) {
  // Flint & steel generates a BlockPlaceEvent
  if (event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) return;

  BlockState oldState = event.getBlock().getState();
  BlockState newState = BlockStates.cloneWithMaterial(event.getBlock(), Material.FIRE);
  ParticipantState igniter = null;

  if (event.getIgnitingEntity() != null) {
    // The player themselves using flint & steel, or any of
    // several types of owned entity starting or spreading a fire.
    igniter = Trackers.getOwner(event.getIgnitingEntity());
  } else if (event.getIgnitingBlock() != null) {
    // Fire, lava, or flint & steel in a dispenser
    igniter = Trackers.getOwner(event.getIgnitingBlock());
  }

  callEvent(event, oldState, newState, igniter);
}
 
Example #3
Source File: BlockTransformEvent.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Return true if the block transformation was performed "by hand".
 *
 * Handled:
 *  - place
 *  - mine
 *  - bucket fill/empty
 *  - flint & steel fire/tnt
 *
 * Not handled:
 *  - bonemeal
 *  - probably lots of other things
 */
public boolean isManual() {
    final Event event = getCause();

    if(Types.instanceOfAny(
        event,
        BlockPlaceEvent.class,
        BlockBreakEvent.class,
        PlayerBucketEmptyEvent.class,
        PlayerBucketFillEvent.class
    )) return true;

    if(event instanceof BlockIgniteEvent) {
        BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event;
        if(igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && igniteEvent.getIgnitingEntity() != null) {
            return true;
        }
    }

    if(event instanceof ExplosionPrimeByEntityEvent && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) {
        return true;
    }

    return false;
}
 
Example #4
Source File: BlockTransformListener.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventWrapper
public void onBlockIgnite(final BlockIgniteEvent event) {
    // Flint & steel generates a BlockPlaceEvent
    if(event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) return;

    BlockState oldState = event.getBlock().getState();
    BlockState newState = BlockStateUtils.cloneWithMaterial(event.getBlock(), Material.FIRE);
    ParticipantState igniter = null;

    if(event.getIgnitingEntity() != null) {
        // The player themselves using flint & steel, or any of
        // several types of owned entity starting or spreading a fire.
        igniter = entityResolver.getOwner(event.getIgnitingEntity());
    } else if(event.getIgnitingBlock() != null) {
        // Fire, lava, or flint & steel in a dispenser
        igniter = blockResolver.getOwner(event.getIgnitingBlock());
    }

    callEvent(event, oldState, newState, igniter);
}
 
Example #5
Source File: BlockEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockIgnite(BlockIgniteEvent event) {
    if (!GDFlags.BLOCK_MODIFY) {
        return;
    }

    final World world = event.getBlock().getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    if (event.getPlayer() != null) {
        GDCauseStackManager.getInstance().pushCause(event.getPlayer());
    }
    final Object source = event.getIgnitingBlock() != null ? event.getIgnitingBlock() : event.getIgnitingEntity();
    CommonBlockEventHandler.getInstance().handleBlockModify(event, source, event.getBlock().getState());
}
 
Example #6
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 #7
Source File: BlockIgnite.java    From AdditionsAPI with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockIgnite(BlockIgniteEvent event) {
	if (event.getPlayer() == null)
		return;
	PlayerInventory inv = event.getPlayer().getInventory();
	ItemStack item = inv.getItemInMainHand();
	if (ItemType.getItemType(item) != ItemType.FLINT_AND_STEEL) {
		item = inv.getItemInOffHand();
		if (ItemType.getItemType(item) != ItemType.FLINT_AND_STEEL)
			return;
	}
	if (AdditionsAPI.isCustomItem(item)) {
		CustomItemBlockIgniteEvent customEvent = new CustomItemBlockIgniteEvent(event, new CustomItemStack(item));
		Bukkit.getServer().getPluginManager().callEvent(customEvent);
	}
}
 
Example #8
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 #9
Source File: BlockEventTracker.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
    //event
    final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getBlock().getWorld().getUID());
    final GDChunk gpChunk = claimWorldManager.getChunk(event.getBlock().getChunk());
    if (event.getPlayer() != null) {
        gpChunk.addTrackedBlockPosition(event.getBlock(), event.getPlayer().getUniqueId(), PlayerTracker.Type.NOTIFIER);
    }
}
 
Example #10
Source File: CustomItemBlockIgnite.java    From AdditionsAPI with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onCustomItemBlockIgnite(CustomItemBlockIgniteEvent customEvent) {
	if (customEvent.isCancelled())
		return;
	CustomItem cItem = customEvent.getCustomItem();
	BlockIgniteEvent event = customEvent.getBlockIgniteEvent();
	Player player = event.getPlayer();
	ItemDurability mechanics = cItem.getDurabilityMechanics();
	if (mechanics instanceof FlintAndSteelDurability) {
		ItemStack item = customEvent.getCustomItemStack().getItemStack();
		FlintAndSteelDurability fsMechanics = (FlintAndSteelDurability) cItem.getDurabilityMechanics();
		Bukkit.getServer().getPluginManager().callEvent(new PlayerCustomItemDamageEvent(player, item, fsMechanics.getFire(), cItem));
	}
}
 
Example #11
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 #12
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 #13
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);
    }
}
 
Example #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: CustomItemBlockIgniteEvent.java    From AdditionsAPI with MIT License 4 votes vote down vote up
public BlockIgniteEvent getBlockIgniteEvent() {
	return blockIgniteEvent;
}
 
Example #21
Source File: CustomItemBlockIgniteEvent.java    From AdditionsAPI with MIT License 4 votes vote down vote up
public CustomItemBlockIgniteEvent(BlockIgniteEvent event, CustomItemStack cStack) {
	super(cStack);
	this.blockIgniteEvent = event;
}
 
Example #22
Source File: LoggingManager.java    From Survival-Games with GNU General Public License v3.0 3 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void blockChange(BlockIgniteEvent e){
	if(e.isCancelled())return;

	logBlockCreated(e.getBlock());
	i.put("BSTARTFIRE", i.get("BSTARTFIRE")+1);

	//     System.out.println(5);


}