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

The following examples show how to use org.bukkit.event.block.BlockIgniteEvent#getPlayer() . 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: 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 2
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 3
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 4
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 5
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;
        }
    }
}