當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityExplodeEvent.getEntity方法代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityExplodeEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityExplodeEvent.getEntity方法的具體用法?Java EntityExplodeEvent.getEntity怎麽用?Java EntityExplodeEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.entity.EntityExplodeEvent的用法示例。


在下文中一共展示了EntityExplodeEvent.getEntity方法的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);
                }
            }
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:17,代碼來源:ExplosiveListener.java

示例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();
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:28,代碼來源:NetherEvents.java

示例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);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:25,代碼來源:FlyingMobEvents.java

示例4: 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);
			}
		}
	}
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:17,代碼來源:ChallengeListener.java

示例5: 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));
                        }
                    }
                }
            }
        }
    }
 
開發者ID:Minehut,項目名稱:GamePlate,代碼行數:26,代碼來源:TntTracker.java

示例6: onExplosion

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
/**
 * Prevents block damage due to explosions from beacon fireballs
 * Will still hurt players, so that needs to be handled elsewhere
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onExplosion(final EntityExplodeEvent e) {
    // Find out what is exploding
    Entity expl = e.getEntity();
    if (expl == null) {
        return;
    }
    // Check world
    if (!e.getEntity().getWorld().equals(getBeaconzWorld())) {
        return;
    }
    if (projectiles.containsKey(expl.getUniqueId())) {
        e.blockList().clear();
        projectiles.remove(expl.getUniqueId());
    }
}
 
開發者ID:tastybento,項目名稱:beaconz,代碼行數:22,代碼來源:BeaconProjectileDefenseListener.java

示例7: onEntityExplodeEvent

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onEntityExplodeEvent(EntityExplodeEvent event) {
    AttackType attackType = AttackType.UNKNOWN;
    Entity attacker = event.getEntity();
    if (attacker instanceof TNTPrimed) {
        attackType = AttackType.TNT;
    } else if (attacker instanceof Creeper) {
        attackType = AttackType.CREEPER;
    } else if (attacker instanceof Fireball) {
        if (((Fireball) attacker).getShooter() instanceof Ghast) {
            attackType = AttackType.GHAST;
        }
    }
    if (plugin.getChestSettings().allowDestroyBy(attackType)) {
        return;
    }
    for (Iterator<Block> it = event.blockList().iterator(); it.hasNext();) {
        Block block = it.next();
        if (isProtected(block)) {
            it.remove();
        }
    }
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:24,代碼來源:BlockDestroyListener.java

示例8: 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.newNether) {
        // 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();
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:28,代碼來源:NetherPortals.java

示例9: 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 || !IslandGuard.inWorld(e.getEntity())) {
        return;
    }
    if (mobSpawnInfo.containsKey(e.getEntity().getUniqueId())) {
        // We know about this mob
        if (DEBUG) {
            plugin.getLogger().info("DEBUG: We know about this mob");
        }
        if (!mobSpawnInfo.get(e.getEntity().getUniqueId()).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);
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:25,代碼來源:FlyingMobEvents.java

示例10: onEnitityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
/**
 * Handle EntityExplode events that involve modifying the event.
 *
 * @param event The event to modify
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
    Entity entity = event.getEntity();

    if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
        return;
    }

    // We can make this assumption because we (should) be the only ones using this exact metadata
    Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());

    if (!UserManager.hasPlayerDataKey(player)) {
        return;
    }

    MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();

    if (miningManager.canUseBlastMining()) {
        miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
        event.setYield(0);
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:28,代碼來源:EntityListener.java

示例11: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent event) {
    if (event == null || ChunkManager.getInstance().getDisabledWorlds().contains(event.getLocation().getWorld().getName())) {
        return; // do not do anything in case explosions get cancelled
    }

    final Entity detonator = event.getEntity();
    if (detonator == null || detonator.hasMetadata("ObbyEntity")) {
        return;
    }
    if (event.getLocation().getBlock().hasMetadata("ObbyEntity")) {
        return;
    }
    if (event.getYield() <= 0) {
        return;
    }

    ChunkManager.getInstance().handleExplosion(event);
}
 
開發者ID:drtshock,項目名稱:ObsidianDestroyer,代碼行數:20,代碼來源:EntityExplodeListener.java

示例12: onEntityExplodeNormal

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityExplodeNormal(EntityExplodeEvent event) {
	Map map = Rixor.getRotation().getSlot().getMap();
	
	Client client = null;
	if(event.getEntity() instanceof TNTPrimed) {
		TNTPrimed tnt = (TNTPrimed) event.getEntity();
		if(tnt.getSource() instanceof Player)
			client = Client.getClient((Player) tnt.getSource());
	}
	
	for(Block block : event.blockList()) {
		BlockState newState = block.getState();
		newState.setData(new MaterialData(Material.AIR, (byte) 0));
		BlockChangeEvent change = new BlockChangeEvent(event, map, client, block.getState(), newState);
		Rixor.callEvent(change);
	}
}
 
開發者ID:ProjectRixor,項目名稱:Rixor,代碼行數:20,代碼來源:FilterEvents.java

示例13: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityExplode(EntityExplodeEvent event) {
    Entity ent = event.getEntity();
    if (ent == null)
        return;
    
    UUID entId = ent.getUniqueId();
    if (tntIds.contains(entId)) {
        tntIds.remove(entId);
        
        event.setCancelled(true);
        World world = ent.getWorld();
        Location tntLoc = ent.getLocation();
        ent.remove();
        world.createExplosion(tntLoc.getX(), tntLoc.getY(), tntLoc.getZ(), 4.0F, false, false);
        world.dropItemNaturally(tntLoc, new ItemStack(Material.COOKED_FISH, 16));
    }
}
 
開發者ID:YaLTeR,項目名稱:UnexpectedFishing,代碼行數:19,代碼來源:UnexpectedFishingListener.java

示例14: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent event) {
	if (event.getEntity() instanceof TNTPrimed &&
			bombSites.containsKey((TNTPrimed) event.getEntity())) {
		for (Block b : event.blockList()) {
			if (Math.random() < 0.4) {
				FallingBlock block = event.getEntity().getWorld().spawnFallingBlock(b.getLocation().add(0, 1, 0), b.getType(), b.getData());
				Location bLoc = b.getLocation();
				Location tLoc = event.getEntity().getLocation();
				double power = 0.15;
				double x = (bLoc.getX() - tLoc.getX()) * power + Math.random() - 0.5;
				double z = (bLoc.getZ() - tLoc.getZ()) * power + Math.random() - 0.5;
				double y = 0.8;
				block.setVelocity(new Vector(x, y, z));
				block.setDropItem(false);
			}
			b.setType(Material.AIR);
		}
	}
}
 
開發者ID:EvilKanoa,項目名稱:RodsTwo,代碼行數:21,代碼來源:Explosion.java

示例15: onBlockExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockExplode(final EntityExplodeEvent event) {
    if (!reinforcementManager.isWorldActive(event.getLocation().getWorld().getName())) {
        return;
    }

    if (event.blockList().isEmpty()) {
        return;
    }

    final Entity entity;

    // Make sure that we can later check if the entity is a dragon.
    if (event.getEntity() instanceof EnderDragonPart) {
        entity = ((EnderDragonPart) event.getEntity()).getParent();
    } else {
        entity = event.getEntity();
    }

    reinforcementManager.explodeBlocks(event.blockList(), entity.getType());
}
 
開發者ID:MinerAp,項目名稱:block-saver,代碼行數:22,代碼來源:GeneralListener.java


注:本文中的org.bukkit.event.entity.EntityExplodeEvent.getEntity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。