本文整理匯總了Java中org.bukkit.event.entity.EntityExplodeEvent類的典型用法代碼示例。如果您正苦於以下問題:Java EntityExplodeEvent類的具體用法?Java EntityExplodeEvent怎麽用?Java EntityExplodeEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityExplodeEvent類屬於org.bukkit.event.entity包,在下文中一共展示了EntityExplodeEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTNTChain
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTNTChain(EntityExplodeEvent event) {
if(!this.tracker.isEnabled(event.getEntity().getWorld())) return;
// Transfer ownership to chain-activated TNT
if(event.getEntity() instanceof TNTPrimed) {
Player owner = this.tracker.setOwner((TNTPrimed) event.getEntity(), null);
if(owner != null) {
for(Block block : event.blockList()) {
if(block.getType() == Material.TNT) {
this.tracker.setPlacer(block, owner);
}
}
}
}
}
示例2: onExplosion
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
/**
* Prevent the Nether spawn from being blown up
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onExplosion(final EntityExplodeEvent e) {
if (Settings.netherIslands) {
// Not used in the new nether
return;
}
// Find out what is exploding
Entity expl = e.getEntity();
if (expl == null) {
return;
}
// Check world
if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|| e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
return;
}
Location spawn = e.getLocation().getWorld().getSpawnLocation();
Location loc = e.getLocation();
if (spawn.distance(loc) < Settings.netherSpawnRadius) {
e.blockList().clear();
}
}
示例3: MobExplosion
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void MobExplosion(EntityExplodeEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
// Only cover in the island world
if (e.getEntity() == null || !Util.inWorld(e.getEntity())) {
return;
}
if (mobSpawnInfo.containsKey(e.getEntity())) {
// We know about this mob
if (DEBUG) {
plugin.getLogger().info("DEBUG: We know about this mob");
}
if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getLocation())) {
// Cancel the explosion and block damage
if (DEBUG) {
plugin.getLogger().info("DEBUG: cancel flying mob explosion");
}
e.blockList().clear();
e.setCancelled(true);
}
}
}
示例4: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent e) {
Iterator<Block> blocks = e.blockList().iterator();
while (blocks.hasNext()) {
Block block = blocks.next();
SlimefunItem item = BlockStorage.check(block);
if (item != null) {
blocks.remove();
if (!item.getID().equalsIgnoreCase("HARDENED_GLASS") && !item.getID().equalsIgnoreCase("WITHER_PROOF_OBSIDIAN") && !item.getID().equalsIgnoreCase("WITHER_PROOF_GLASS") && !item.getID().equalsIgnoreCase("FORCEFIELD_PROJECTOR") && !item.getID().equalsIgnoreCase("FORCEFIELD_RELAY")) {
boolean success = true;
if (SlimefunItem.blockhandler.containsKey(item.getID())) {
success = SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.EXPLODE);
}
if (success) {
BlockStorage.clearBlockInfo(block);
block.setType(Material.AIR);
}
}
}
}
}
示例5: testBlockChange
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
/**
* This handler only checks to see if the event should be cancelled. It does not change the
* state of any Destroyables.
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void testBlockChange(BlockTransformEvent event) {
if(this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) {
return;
}
// This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now)
if((event.getCause() instanceof EntityExplodeEvent &&
((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) ||
event.getCause() instanceof BlockPistonExtendEvent ||
event.getCause() instanceof BlockPistonRetractEvent) {
event.setCancelled(true);
return;
}
for(Destroyable destroyable : this.destroyables) {
String reasonKey = destroyable.testBlockChange(event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event));
if(reasonKey != null) {
event.setCancelled(true, new TranslatableComponent(reasonKey));
return;
}
}
}
示例6: onExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler
public void onExplode(EntityExplodeEvent event) {
if(event.getEntity() instanceof Creeper) {
Entity e = event.getEntity();
if(e.hasMetadata("challenge")) {
event.blockList().clear();
String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
final String player = meta[1];
plugin.getChallenges().addKill(Bukkit.getPlayer(player));
Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0) {
plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
}
}
}
}
示例7: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity() != null) {
if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
for (Block block : event.blockList()) {
if (block.getType() == Material.TNT && getWhoPlaced(event.getEntity()) != null) {
Location location = block.getLocation();
tntPlaced.put(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), getWhoPlaced(event.getEntity()));
}
}
for (Entity entity : event.getEntity().getNearbyEntities(8, 8, 8)) {
// F.debug("Found tnt");
if (entity instanceof TNTPrimed) {
UUID playerUUID = getWhoPlaced(event.getEntity());
if(playerUUID != null) {
Dispenser dispenser;
// F.debug("found placer: " + Bukkit.getServer().getPlayer(playerUUID));
entity.setMetadata("source", new FixedMetadataValue(GamePlate.getInstance(), playerUUID));
}
}
}
}
}
}
示例8: onBlockDestroy
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockDestroy(EntityExplodeEvent event) {
try {
if (_config.RegenerateExplodedBlocks && _zone.isInside(event.getEntity().getLocation())) {
HashMap<Location, BlockContainer> _blocks = new HashMap<Location, BlockContainer>();
for (Block b : event.blockList()) {
BlockContainer bc = new BlockContainer();
bc.TypeId = b.getTypeId();
bc.TypeData = b.getData();
_blocks.put(b.getLocation(), bc);
}
BlockRestore restore = new BlockRestore(_world, _blocks);
Executors.newSingleThreadScheduledExecutor().schedule(restore, _config.DelayBeforeRegeneration, TimeUnit.MILLISECONDS);
}
}
catch (Exception ex) {
logger.info("onblock destroy in Infestation raised an exception, it's ok!");
}
}
示例9: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : new ArrayList<>(event.blockList())) {
if (block.getType().equals(Material.TNT)) {
continue;
}
boolean cancel = this.post(event,
block,
block.getState(),
this.applyAir(block),
null,
false);
if (cancel) {
event.blockList().remove(block);
}
}
}
示例10: onBlockExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
/**
* Filters EntityExplodeEvent. It will remove from the blocks to break list blocks that can't be destroyed.
*
* <p>Applies to: block, block break.<p/>
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockExplode(EntityExplodeEvent event) {
Match match = Cardinal.getMatch(event.getWorld());
if (match == null) {
return;
}
Collection<AppliedRegion> regions = get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK);
Iterator<Block> blockIterator = event.blockList().iterator();
while (blockIterator.hasNext()) {
Block evaluating = blockIterator.next();
for (AppliedRegion reg : regions) {
if (apply(reg, evaluating.getLocation(), null, event, event, evaluating/* TODO: tnt tracker, pass player*/)) {
if (event.isCancelled()) {
event.setCancelled(false);
blockIterator.remove();
}
break;
}
}
}
}
示例11: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent e) {
Iterator<Block> iter = e.blockList().iterator();
while (iter.hasNext()) {
Block b = iter.next();
if (plugin.getAllowedInventories().contains(b.getType())) {
Sign s = findShopSign(b);
if (s != null && ShopType.getType(s).isProtectedFromExplosions()) {
iter.remove();
}
} else if (b.getState() instanceof Sign && findShopChest(b) != null) {
iter.remove();
}
}
}
示例12: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = false)
public void onEntityExplode(cn.nukkit.event.entity.EntityExplodeEvent event) {
if (canIgnore(PlayerInteractEvent.getHandlerList())) {
return;
}
List<Block> blocks = new ArrayList<Block>();
for (cn.nukkit.block.Block nukkitBlock : event.getBlockList()) {
blocks.add(PokkitBlock.toBukkit(nukkitBlock));
}
EntityExplodeEvent bukkitEvent = new EntityExplodeEvent(PokkitEntity.toBukkit(event.getEntity()), PokkitLocation.toBukkit(event.getPosition()), blocks, (float) event.getYield());
callCancellable(event, bukkitEvent);
}
示例13: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent event) {
List<Block> blocks = event.blockList();
if (!blocks.isEmpty()) {
World world = blocks.get(0).getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (plugin.isEnabled(world) && worldConfig.getBoolean(Config.FEATURE_DUNGEONS_PROTECTED)) {
Iterator<Block> iterator = blocks.iterator();
while (iterator.hasNext()) {
Block block = iterator.next();
if (this.isProtected(block.getLocation())) {
iterator.remove();
}
}
}
}
}
示例14: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
if (!event.isCancelled()) {
Player player = TntTracker.getWhoPlaced(event.getEntity()) != null && Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())).isOnline() ? Bukkit.getPlayer(TntTracker.getWhoPlaced(event.getEntity())) : null;
if (player != null) {
for (Block block : event.blockList()) {
if (filter == null || filter.evaluate(player, block).equals(FilterState.ALLOW)) {
if (region == null || region.contains(new BlockRegion(null, block.getLocation().toVector().add(new Vector(0.5, 0.5, 0.5))))) {
for (ItemStack drop : this.drops) {
GameHandler.getGameHandler().getMatchWorld().dropItemNaturally(block.getLocation(), drop);
}
if (this.experience != 0) {
ExperienceOrb xp = GameHandler.getGameHandler().getMatchWorld().spawn(block.getLocation(), ExperienceOrb.class);
xp.setExperience(this.experience);
}
block.setType(replace);
}
}
}
}
}
}
示例15: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
for (Player player : Bukkit.getOnlinePlayers()) {
Location location = block.getLocation();
location.setY(location.getY() + 1);
Location playerLoc = player.getLocation();
if (playerLoc.getBlockX() == location.getBlockX() && playerLoc.getBlockY() == location.getBlockY() && playerLoc.getBlockZ() == location.getBlockZ()) {
Description description = null;
if (player.getLocation().add(new Vector(0, 1, 0)).getBlock().getType().equals(Material.LADDER)) {
description = Description.OFF_A_LADDER;
} else if (player.getLocation().add(new Vector(0, 1, 0)).getBlock().getType().equals(Material.VINE)) {
description = Description.OFF_A_VINE;
} else if (player.getLocation().getBlock().getType().equals(Material.WATER) || player.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)) {
description = Description.OUT_OF_THE_WATER;
} else if (player.getLocation().getBlock().getType().equals(Material.LAVA) || player.getLocation().getBlock().getType().equals(Material.STATIONARY_LAVA)) {
description = Description.OUT_OF_THE_LAVA;
}
OfflinePlayer damager = (TntTracker.getWhoPlaced(event.getEntity()) != null ? Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity())) : null);
Bukkit.getServer().getPluginManager().callEvent(new TrackerDamageEvent(player, damager, damager != null && damager.getPlayer() != null ? ((Player) damager).getItemInHand() : new ItemStack(Material.AIR), Cause.TNT, description, Type.SPLEEFED));
}
}
}
}