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


Java EntityDeathEvent.setDroppedExp方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
    double amount = event.getDroppedExp();
    Player killer = event.getEntity().getKiller();
    if (killer != null && amount > 0) {
        ItemStack stack = killer.getItemInHand();
        if (stack != null && stack.getType() != Material.AIR) {
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS);
            if (enchantmentLevel > 0L) {
                double multiplier = enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LOOTING_PER_LEVEL;
                int result = (int) Math.ceil(amount * multiplier);
                event.setDroppedExp(result);
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:ExpMultiplierListener.java

示例4: 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

示例5: onDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onDeath(EntityDeathEvent event) {
    if(isSpawned() && event.getEntity().equals(entity.get())) {
        event.setDroppedExp(0);
        event.getDrops().clear();
        despawn(false);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:Pickup.java

示例6: onDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onDeath(EntityDeathEvent e) {
	if(MonsterModule.getInstance().getGuard(e.getEntity()) != null) {
		IGuard guard = MonsterModule.getInstance().getGuard(e.getEntity());
		e.getDrops().clear();
		e.setDroppedExp(0);
		e.getDrops().add(getGuardDrops());
		guard.remove();
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:11,代碼來源:GuardManager.java

示例7: onDragonDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onDragonDeath(EntityDeathEvent evt) {
    if (evt.getEntityType() != EntityType.ENDER_DRAGON)
        return; // If it's not a dragon, ignore it.
    evt.setDroppedExp(4000);
    Block bk = evt.getEntity().getWorld().getBlockAt(0, 75, 0);

    Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
        bk.setType(Material.DRAGON_EGG);
        bk.getWorld().getNearbyEntities(bk.getLocation(), 50, 50, 50)
                .forEach(e -> e.sendMessage(ChatColor.GRAY + "As the dragon dies, an egg forms below."));
    }, 15 * 20);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:14,代碼來源:GeneralMechanics.java

示例8: deathEvent

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void deathEvent(EntityDeathEvent event){
	if(ThreadLocalRandom.current().nextInt(100) <= 10){
		event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.ENDER_CRYSTAL);
	}
	event.setDroppedExp(0);
	if(event.getEntity() instanceof Creature){
		event.getDrops().add(createMoney(ThreadLocalRandom.current().nextInt(12)));
		return;
	}
	
	return;
}
 
開發者ID:DamoclesProject,項目名稱:Damocles,代碼行數:14,代碼來源:EventCanceller.java

示例9: onCreatureKill

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onCreatureKill(EntityDeathEvent evt) {
	if (evt.getEntity() instanceof Monster) {
		
		Monster monster = (Monster)evt.getEntity();
		Player killer = monster.getKiller();
		
		if (killer != null && perkService.playerHasPerk(killer, SurvivorTree.MercenaryId)) {
			evt.setDroppedExp((int)((double)evt.getDroppedExp() * 1.20));
		}
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:13,代碼來源:MercenaryPerk.java

示例10: onEntityDeath

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

    if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_EXP)) {
        if (!worldConfig.getBoolean(Config.FEATURE_MORE_EXP_IGNORE_SPAWNERS) || plugin.getSpawnReason(entity) != SpawnReason.SPAWNER) {
            event.setDroppedExp(event.getDroppedExp() * Math.max(worldConfig.getInt(Config.FEATURE_MORE_EXP_MULTIPLIER), 0));
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:13,代碼來源:MoreExpListener.java

示例11: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
	LivingEntity entity = event.getEntity();
	
	//don't track in worlds where claims are not enabled
       if(!GriefPrevention.instance.claimsEnabledForWorld(entity.getWorld())) return;
	
	//special rule for creative worlds: killed entities don't drop items or experience orbs
	if(GriefPrevention.instance.creativeRulesApply(entity.getLocation()))
	{
		event.setDroppedExp(0);
		event.getDrops().clear();			
	}
	
	//FEATURE: when a player is involved in a siege (attacker or defender role)
	//his death will end the siege
	
	if(!(entity instanceof Player)) return;  //only tracking players
	
	Player player = (Player)entity;
	PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
	
	//if involved in a siege
	if(playerData.siegeData != null)
	{
		//don't drop items as usual, they will be sent to the siege winner
		event.getDrops().clear();
		
		//end it, with the dieing player being the loser
		this.dataStore.endSiege(playerData.siegeData, null, player.getName(), true /*ended due to death*/);
	}
}
 
開發者ID:john01dav,項目名稱:GriefPreventionPlus,代碼行數:34,代碼來源:EntityEventHandler.java

示例12: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
   event.setDroppedExp(0);
   event.getDrops().clear();

   if (!(event.getEntity() instanceof Player) && event.getEntity().getKiller() != null && event.getEntity().getKiller() instanceof Player) { // make sure not killed by player,
                                                                                                                                             // handled above
      MMPlayer killer = MMGames.getPlugin().getPlayer(event.getEntity().getKiller());
      MMEventHandler.onKillEntity(killer, event.getEntity());
   }
}
 
開發者ID:PaulBGD,項目名稱:MiniMiniGames,代碼行數:12,代碼來源:MMEventListener.java

示例13: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
public void onEntityDeath(EntityDeathEvent event) {
	if (event.getEntity() == e) {
		event.getDrops().clear();
		event.setDroppedExp(0);
	}
	
}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:8,代碼來源:SpawnerSwitch.java

示例14: onCreatureDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
@EventHandler
public void onCreatureDeath(EntityDeathEvent event)
{
	LivingEntity creature = event.getEntity();
	if (plugin.getLegendaryEntityId() != null && plugin.getLegendaryEntityId().equals(creature.getUniqueId()))
	{
		event.getDrops().clear();

		if (event.getEntityType().equals(EntityType.GIANT))
		{
			event.setDroppedExp(plugin.getConfig().getInt("giantDropsXP"));

			Material giantDropsType = MaterialUtil.getMaterial(plugin.getConfig().getString("giantDropsType"));
			event.getDrops().add(new ItemStack(giantDropsType, plugin.getConfig().getInt("giantDropsAmount")));
		}
		else if (event.getEntityType().equals(EntityType.WITHER))
		{
			event.setDroppedExp(plugin.getConfig().getInt("witherDropsXP"));

			Material witherDropsType = MaterialUtil.getMaterial(plugin.getConfig().getString("witherDropsType"));
			event.getDrops().add(new ItemStack(witherDropsType, plugin.getConfig().getInt("witherDropsAmount")));
		}
		else if (event.getEntityType().equals(EntityType.SLIME))
		{
			event.setDroppedExp(this.plugin.getConfig().getInt("slimeDropsXP"));

			Material slimeDropsType = MaterialUtil.getMaterial(plugin.getConfig().getString("slimeDropsType"));
			event.getDrops().add(new ItemStack(slimeDropsType, plugin.getConfig().getInt("slimeDropsAmount")));
		}

		creature.remove();
		plugin.removeLegendary();
	}
}
 
開發者ID:MineSworn,項目名稱:SwornCritters,代碼行數:35,代碼來源:EntityListener.java

示例15: onEntityDeath

import org.bukkit.event.entity.EntityDeathEvent; //導入方法依賴的package包/類
/**
 * Обрабытывает смерть моба
 *
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDeath(EntityDeathEvent event) {

    LivingEntity livingEntity = event.getEntity();
    LivingEntity killer = livingEntity.getKiller();

    plugin.log("onEntityDeath: remove: " + livingEntity.getEntityId(), MyLineagePvpSystem.ANSI_RED);

    if (killer == null) {

        Mobs.remove(livingEntity.getEntityId());
        return;
    }

    long levelEntity = getLevel(livingEntity);
    long levelDamager = getLevel(killer);

    plugin.log("onEntityDeath: " + killer.getType() + "(" + levelDamager + ") -> " + livingEntity.getType() + "(" + levelEntity + ")", MyLineagePvpSystem.ANSI_RED);

    if (Math.abs(levelEntity - levelDamager) > plugin.config.getInt("rpg.levelDifferenceForExperience")) {
        event.setDroppedExp(0);
        plugin.log("onEntityDeath: noExp", MyLineagePvpSystem.ANSI_RED);
    } else {
        long levelBetween = Math.abs(levelDamager - levelEntity);
        if (levelBetween == 0) {
            levelBetween = 1;
        }
        int dropExp = (int) Math.round(event.getDroppedExp() * Math.pow(1.0 / levelBetween, plugin.config.getDouble("rpg.expDifficulty")));
        if (dropExp == 0) {
            dropExp = 1;
        }
        plugin.log("onEntityDeath: Exp: " + event.getDroppedExp() + " -> " + dropExp, MyLineagePvpSystem.ANSI_RED);
        event.setDroppedExp(dropExp);
    }

    Mobs.remove(livingEntity.getEntityId());
}
 
開發者ID:truekenny,項目名稱:MyLineagePvpSystem,代碼行數:43,代碼來源:RpgListener.java


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