当前位置: 首页>>代码示例>>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;未经允许,请勿转载。