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


Java EntityDeathEvent.getEntity方法代碼示例

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


在下文中一共展示了EntityDeathEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEndermanDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:29,代碼來源:IslandGuard.java

示例2: onMobDie

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onMobDie(EntityDeathEvent e){
    AllItems items = new AllItems();
    Location l = e.getEntity().getLocation();
    World w = l.getWorld();

    e.getDrops().clear();
    e.setDroppedExp(0);

    if (e.getEntity() instanceof Zombie){
        if (new Random().nextInt(5) >= 3){
            w.dropItemNaturally(l, new ItemMaker(Material.EMERALD).setAmount(new Random().nextInt(4) + 1).build());
            if (new Random().nextBoolean()){
                w.dropItemNaturally(l, items.weapons.get(new Random().nextInt(items.weapons.size())));
            } else {
                w.dropItemNaturally(l, items.health.get(new Random().nextInt(items.health.size())));
            }
        }
    }

    if (e.getEntity() instanceof Giant){
        if (new Random().nextInt(5) > 3){
            w.dropItemNaturally(l, new ItemMaker(Material.NETHER_STAR).setAmount(new Random().nextInt(4) + 1).build());
        }
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:27,代碼來源:WorldInteract.java

示例3: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
/**
 * Utilizes a random chance to either spawn a skeleton with gold armor or resources.
 *
 * @param event The event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
  Entity entity = event.getEntity();
  if (entity instanceof Sheep) {
    double chance = Math.random();
    if (0.25 > chance) {
      Skeleton skeleton = entity.getWorld().spawn(entity.getLocation(), Skeleton.class);
      skeleton.getEquipment().setArmorContents(
          new ItemStack[]{
              new ItemStack(Material.GOLD_HELMET),
              new ItemStack(Material.GOLD_CHESTPLATE),
              new ItemStack(Material.GOLD_LEGGINGS),
              new ItemStack(Material.GOLD_BOOTS)
          }
      );
    } else if (0.5 > chance) {
      event.getDrops().add(new ItemStack(Material.IRON_INGOT));
    } else if (0.75 > chance) {
      event.getDrops().add(new ItemStack(Material.GOLD_INGOT));
    } else {
      event.getDrops().add(new ItemStack(Material.DIAMOND));
    }
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:30,代碼來源:GoldenFleece.java

示例4: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
/**
 * Drop cooked food
 * 
 * @param event Event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
    LivingEntity entity = event.getEntity();
    List<ItemStack> newDrops = null;

    if (this.drops.containsKey(entity.getType()))
    {
        newDrops = new ArrayList<>();

        for (ConfigurationBuilder.IRapidFoodHook rapidFoodHook : this.drops.get(entity.getType()))
            newDrops.addAll(rapidFoodHook.getDrops(event.getDrops(), this.random));
    }

    if (newDrops != null && !newDrops.isEmpty())
    {
        event.getDrops().clear();
        event.getDrops().addAll(newDrops);
    }

    event.setDroppedExp(event.getDroppedExp() * 2);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:28,代碼來源:RapidFoodModule.java

示例5: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) { // If a pinata is killed, have a 12% chance of dropping something extra.
    if (evt.getEntity() instanceof Zombie && getArena().contains(evt.getEntity().getLocation()) && Utils.randChance(8))
        evt.getDrops().add(Utils.randElement(
                ItemManager.createItem(Material.DIAMOND, ChatColor.AQUA + "Rock Candy", "So delicious, so rare."),
                ItemManager.createItem(Material.CAKE, ChatColor.LIGHT_PURPLE + "Birthday Cake", "Happy 3rd Anniversary, Kineticraft!"),
                ItemManager.createItem(Material.SEA_LANTERN, ChatColor.RED + "Jaw Breaker", "Suck it, Piñatas!"),
                ItemManager.createItem(Material.IRON_BLOCK, ChatColor.RED + "Hershey's Kiss", "Mmmm, so chocolatey."),
                ItemManager.createItem(Material.TNT, ChatColor.LIGHT_PURPLE + "Pop Rocks", "An explosion for your taste buds."),
                ItemManager.createItem(Material.MAGMA_CREAM, ChatColor.RED + "Atomic Fireball", "It burns so good."),
                ItemManager.createItem(Material.EXP_BOTTLE, ChatColor.AQUA + "Soda", "Refreshing and fizzy."),
                ItemManager.createItem(Material.SLIME_BALL, ChatColor.AQUA + "Taffy", "Chewy...careful not to glue your teeth together!"),
                ItemManager.createItem(Material.NETHER_STALK, ChatColor.RED + "Twizzlers", "Gimme some sugar."),
                ItemManager.createItem(Material.MYCEL, ChatColor.RED + "Fudge", "What the fudge!?"),
                ItemManager.createItem(Material.WEB, ChatColor.LIGHT_PURPLE + "Cotton Candy", "So fluffy!"),
                ItemManager.createItem(Material.RAW_FISH, (byte) 1, ChatColor.LIGHT_PURPLE + "Swedish Fish", "A yummy, gummy candy."),
                ItemManager.createItem(Material.RED_ROSE, (byte) 2, ChatColor.AQUA + "Lollipop", "I'm a sucker for puns."),
                ItemManager.createItem(Material.COOKIE, ChatColor.YELLOW + "Birthday Cookie", "You're one smart cookie!"),
                ItemManager.createItem(Material.BLAZE_ROD, ChatColor.RED + "Hot Tamale", "You're one hot Tamale!"),
                ItemManager.createItem(Material.PUMPKIN_PIE, ChatColor.GOLD + "Seasonal Treat", "Pumpkin Spice flavor ALL THE THINGS!"),
                ItemManager.createItem(Material.EMERALD, ChatColor.GREEN + "Gumball", "I chews you! <3"),
                ItemManager.createItem(Material.GOLDEN_APPLE, ChatColor.GOLD + "Caramel Apple", "...and we lived apple-y ever after <3"),
                ItemManager.createItem(Material.HUGE_MUSHROOM_2, ChatColor.RED + "Strawberry Bon Bon", "You're the berry best."),
                evt.getEntity().getEquipment().getHelmet(),
                evt.getEntity().getEquipment().getItemInMainHand()));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:27,代碼來源:Pinata.java

示例6: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
    if (e.getEntity() instanceof Monster && e.getEntity().getKiller() instanceof Player) {
        TOAUser u = TOA.getPlayer(e.getEntity().getKiller());
        String name = e.getEntity().getCustomName().split(" ")[1];
        int level = Utils.isInt(name) ? Integer.parseInt(name) : 0;

        new Experience(u).addExp(Mob.getXP(level));

        e.getDrops().clear();
        e.setDroppedExp(0);

        Drop.drop(MobType.parseMobType(e.getEntityType()), u.getUserData().getKit()).forEach(d -> {
            BagEvents.addItem(u, d);
            u.sendSound(Sounds.ITEM_PICKUP);
        });

        if (plugin.getSpawnTask().getCount() == 0) return;
        plugin.getSpawnTask().setCount(plugin.getSpawnTask().getCount() - 1);
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:22,代碼來源:GameEvents.java

示例7: onMobDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
	if(event.getEntity() instanceof Entity){
		Entity e = (Entity) event.getEntity();
		if(e.hasMetadata("challenge")){
			event.getDrops().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(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
				e.remove();
			}
			if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
				plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
			}
		}
	}
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:20,代碼來源:ChallengeListener.java

示例8: onDragonDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onDragonDeath(EntityDeathEvent event) {
	if (!(event.getEntity() instanceof EnderDragon)) return;
	
	EnderDragon dragon = (EnderDragon) event.getEntity();
	DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
	
	World world = event.getEntity().getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	
	BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_COMMENCED, BattleState.BATTLE_END);
	Bukkit.getPluginManager().callEvent(bscEventCrystals);

	new BukkitRunnable() {
		@Override
		public void run() {
			if (plugin.getNMSAbstract().getEnderDragonDeathAnimationTime(dragon) >= 185) { // Dragon is dead at 200
				new DragonDeathRunnable(plugin, worldWrapper, dragon);
				this.cancel();
			}
		}
	}.runTaskTimer(plugin, 0L, 1L);
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:24,代碼來源:DragonLifeListeners.java

示例9: kill

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void kill(EntityDeathEvent e) {
	// 殺されたエンティティ
	LivingEntity entity = e.getEntity();
	// エンティティを殺したプレイヤー
	Player player = entity.getKiller();

	// null=プレイヤーが殺したのではないなら
	if (player == null) {
		return; // 何もしない
	}

	// 出力する
	player.sendMessage("このMOBはスポナーから沸いたMOB" +
			(isSpawnerSpawn(entity) ? "です。" : "ではありません。")); // <-三項演算子、説明は要らないよね?
}
 
開發者ID:HimaJyun,項目名稱:BukkitPluginDevelopment,代碼行數:17,代碼來源:Main.java

示例10: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
	Entity killedEntity = event.getEntity();
	
	if (killedEntity instanceof LivingEntity) {
		LivingEntity livingEntity = (LivingEntity)killedEntity;
		Player killer = livingEntity.getKiller();
		
		if (killer != null && getPlayer() == killer) {
			if (entityIds.contains(EntityUtilities.getEntityId(livingEntity)) && 
				(getZone() == null || getZone().isInside(livingEntity.getLocation()))) {
				advance();
			}
		}
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:17,代碼來源:KillObjective.java

示例11: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
	if (_scenario.isActive() && _currentWave != null) {
		Entity entity = event.getEntity();
		if (entity instanceof Player) {
			
			try {
				_scenario.getPlayers().remove((Player)entity);
				if (_scenario.getEventListener() != null) {
					_scenario.getEventListener().playerDied((Player)entity, _scenario.getPlayers());
				}
			}
			catch (Exception ex) { }
		}
		else {
			_currentWave.processEntityDeath(entity);
		}
	}
	
	
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:22,代碼來源:MonsterFuryListener.java

示例12: monsterDies

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void monsterDies(EntityDeathEvent event) {
	
	if (_apocalypseOn && event.getEntity().getLastDamageCause().getCause() != DamageCause.FIRE_TICK) {
		
		if (event.getEntity() instanceof Monster) {
			_monsterDead++;
		}
		
		if (_monsterDead >= _maxMonsters) {
			_completed = true;
			distributeLoot();
			resetEvent();
		}		
		
		try {
			_spawner.spawnMonsterCloseToPlayer(event.getEntity().getLocation());
		}
		catch (Exception ex) {
			_logger.info("exception raised in Mayhem.monsterDies(EntityDeathEvent event) while using the ApocalypseSpawner");
		}
		
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:25,代碼來源:Mayhem.java

示例13: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
    Entity entity = event.getEntity();
    World world = entity.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.SPAWN_ON_KILL)) {
        Creature creature = (Creature) entity;
        EntityDamageEvent lastDamage = entity.getLastDamageCause();

        if (lastDamage != null && creature.getTarget() instanceof Player && playerCauses.contains(lastDamage.getCause()) && worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_MOBS).contains(creature.getType().name().toUpperCase())) {
            if (this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_SPAWN_ON_KILL_CHANCE)) {
                String mobName = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_SPAWN));
                EntityType creatureType = EntityType.fromName(mobName.toUpperCase());

                if (creatureType != null) {
                    world.spawnEntity(creature.getLocation(), creatureType);
                    //world.spawn(creature.getLocation(), creatureType.getEntityClass(), SpawnReason.NATURAL);
                }
            }
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:24,代碼來源:SpawnOnKillListener.java

示例14: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
	Player killer = e.getEntity().getKiller();
	if ((e.getEntity() instanceof Player)) {
		Player playerKilled = (Player) e.getEntity();
		incrementStatistic(Statistic.PLAYERS_KILLED);
		incrementPlayerStat(playerKilled, PlayerStat.DEATHS);
		if (killer instanceof Player) {
			incrementPlayerStat(killer, PlayerStat.PLAYERS_KILLED);
		}
	} else {
		incrementStatistic(Statistic.MOBS_KILLED);
		if (killer instanceof Player) {
			incrementPlayerStat(killer, PlayerStat.MOBS_KILLED);
		}
	}
}
 
開發者ID:kmecpp,項目名稱:MCAnalytics,代碼行數:18,代碼來源:EventListener.java

示例15: on

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Spider)) return;

    Entity entity = ((CraftEntity) event.getEntity()).getHandle();

    // spawn 5 random webs
    for (int i = 0; i < 5; i++) {
        spawnRandomWeb(entity);
    }

    // spawn 30 random particle effects
    for (int i = 0; i < 30; i++) {
        spawnRandomRedstoneParticle(entity);
    }
}
 
開發者ID:Eluinhost,項目名稱:UberHardcore,代碼行數:17,代碼來源:SpiderDeathHandler.java


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