类org.bukkit.event.block.BlockIgniteEvent源码实例Demo

下面列出了怎么用org.bukkit.event.block.BlockIgniteEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: GriefDefender   文件: BlockEventHandler.java
@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());
}
 
源代码2 项目: PGM   文件: BlockTransformEvent.java
/**
 * 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;
}
 
源代码3 项目: PGM   文件: BlockTransformListener.java
@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);
}
 
源代码4 项目: ProjectAres   文件: BlockTransformEvent.java
/**
 * 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;
}
 
源代码5 项目: ProjectAres   文件: BlockTransformListener.java
@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);
}
 
源代码6 项目: AdditionsAPI   文件: CustomItemBlockIgnite.java
@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);
}
 
源代码7 项目: AdditionsAPI   文件: BlockIgnite.java
@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);
	}
}
 
源代码8 项目: Sentinel   文件: SentinelEventHandler.java
@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);
            }
        }
    }
}
 
源代码9 项目: GriefDefender   文件: BlockEventTracker.java
@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);
    }
}
 
源代码10 项目: AdditionsAPI   文件: CustomItemBlockIgnite.java
@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));
	}
}
 
源代码11 项目: DungeonsXL   文件: DWorldListener.java
@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);
    }
}
 
源代码12 项目: PlotMe-Core   文件: BukkitPlotListener.java
@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);
                }
            }
        }
    }
}
 
源代码13 项目: AdditionsAPI   文件: CustomItemBlockIgniteEvent.java
public CustomItemBlockIgniteEvent(BlockIgniteEvent event, CustomItemStack cStack) {
	super(cStack);
	this.blockIgniteEvent = event;
}
 
源代码14 项目: AdditionsAPI   文件: CustomItemBlockIgniteEvent.java
public BlockIgniteEvent getBlockIgniteEvent() {
	return blockIgniteEvent;
}
 
源代码15 项目: BedwarsRel   文件: BlockListener.java
@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());
  }
}
 
源代码16 项目: civcraft   文件: BlockListener.java
@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);
	}		
}
 
源代码17 项目: civcraft   文件: ArenaListener.java
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockIgniteEvent(BlockIgniteEvent event) {
	if (ArenaManager.activeArenas.containsKey(event.getBlock().getWorld().getName())) {
		event.setCancelled(true);
	}
}
 
源代码18 项目: askyblock   文件: IslandGuard.java
@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;
        }
    }
}
 
源代码19 项目: FunnyGuilds   文件: BlockIgnite.java
@EventHandler
public void onIgnite(BlockIgniteEvent e) {
    if (ProtectionSystem.build(e.getPlayer(), e.getBlock().getLocation())) {
        e.setCancelled(true);
    }
}
 
源代码20 项目: CardinalPGM   文件: WorldFreeze.java
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event) {
    if (!match.isRunning()) {
        event.setCancelled(true);
    }
}
 
源代码21 项目: CardinalPGM   文件: BlockEventRegion.java
@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);
    }
}
 
源代码22 项目: Survival-Games   文件: LoggingManager.java
@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);


}
 
 类所在包
 同包方法