当前位置: 首页>>代码示例>>Java>>正文


Java Entity.hasMetadata方法代码示例

本文整理汇总了Java中org.bukkit.entity.Entity.hasMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.hasMetadata方法的具体用法?Java Entity.hasMetadata怎么用?Java Entity.hasMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Entity的用法示例。


在下文中一共展示了Entity.hasMetadata方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finishChallenge

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void finishChallenge(Player player, boolean buy) {
	if(!buy) {
		for(Entity e : player.getWorld().getEntities()) {
			if(e.hasMetadata(metaData) && e.getMetadata(metaData).get(0).asString().contains(player.getName())) {
				e.remove();
			}
		}
		player.teleport(plugin.getChallengesFile().getVictorySpawnpoint(getChallenge(player)));
		loadData(player);
		player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_TWINKLE, 1F, 1F);
	}
	for(String cmd : plugin.getChallengesFile().getCommands(getChallenge(player))) {
		cmd = cmd.replaceAll("%s", player.getName());
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
	}
	if(!isTesting(player)) {
		plugin.getPlayerManager().setRank(player, getChallenge(player));
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString() 
				+ Lang.CHALLENGES_COMPLETE.toString()
					.replaceAll("%s", plugin.getChallengesFile().getTitle(getChallenge(player))));
	} else {
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.CHALLENGES_TEST_COMPLETE.toString());
	}
	playerChallenge.remove(player.getName());
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:27,代码来源:Challenge.java

示例2: quitChallenge

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void quitChallenge(Player player) {
	for(Entity e : player.getWorld().getEntities()){
		if(e.hasMetadata("") && e.getMetadata(metaData).get(0).asString().contains(player.getName())) {
			e.remove();
		}
	}
	player.teleport(getLocation(player));
	if(!isTesting(player)){
		plugin.getEconomy().depositPlayer(player, plugin.getChallengesFile().getPrice(getChallenge(player)) 
				* (plugin.getPlayerManager().getPrestige(player) + 1));
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.CHALLENGES_LEAVE.toString()
					.replaceAll("%s", plugin.getChallengesFile().getTitle(getChallenge(player))));
	} else {
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.CHALLENGES_TEST_COMPLETE.toString());
	}
	loadData(player);
	playerChallenge.remove(player.getName());
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:21,代码来源:Challenge.java

示例3: onMobDeath

import org.bukkit.entity.Entity; //导入方法依赖的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

示例4: onExplode

import org.bukkit.entity.Entity; //导入方法依赖的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: oNEntityRemove

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void oNEntityRemove(EntityRemoveEvent e)
{
    for(Iterator iterator = e.getEntityList().iterator(); iterator.hasNext();)
    {
        Entity n = (Entity)iterator.next();
        if((n instanceof Item) && n.hasMetadata("no_pickup"))
            iterator.remove();
    }

}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:11,代码来源:ClearLaggIntegration.java

示例6: fixEntityDamage

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void fixEntityDamage(EntityDamageByEntityEvent event) {
    Entity projectile = event.getDamager();
    if(projectile.hasMetadata("customProjectile")) {

        // If the custom projectile replaced an arrow, recreate some effects specific to arrows
        if(projectile.hasMetadata("damage")) {
            boolean critical = projectile.getMetadata("critical").get(0).asBoolean();
            int knockback = projectile.getMetadata("knockback").get(0).asInt();
            double damage = projectile.getMetadata("damage").get(0).asDouble();
            double speed = projectile.getVelocity().length();

            // Reproduce the damage calculation from nms.EntityArrow with the addition of our modifier
            int finalDamage = (int) Math.ceil(speed * damage * this.velocityMod);
            if(critical) {
                finalDamage += random.nextInt(finalDamage / 2 + 2);
            }
            event.setDamage(finalDamage);

            // Flame arrows - target burns for 5 seconds always
            if(projectile.getFireTicks() > 0) {
                event.getEntity().setFireTicks(100);
            }

            // Reproduce the knockback calculation for punch bows
            if(knockback > 0) {
                Vector projectileVelocity = projectile.getVelocity();
                double horizontalSpeed = Math.sqrt(projectileVelocity.getX() * projectileVelocity.getX() +
                                                   projectileVelocity.getZ() * projectileVelocity.getZ());
                Vector velocity = event.getEntity().getVelocity();
                velocity.setX(velocity.getX() + projectileVelocity.getX() * knockback * 0.6 / horizontalSpeed);
                velocity.setY(velocity.getY() + 0.1);
                velocity.setZ(velocity.getZ() + projectileVelocity.getZ() * knockback * 0.6 / horizontalSpeed);
                event.getEntity().setVelocity(velocity);
            }
        }

        // Apply any potion effects attached to the projectile
        if(event.getEntity() instanceof LivingEntity) {
            for(PotionEffect potionEffect : this.potionEffects) {
                ((LivingEntity) event.getEntity()).addPotionEffect(potionEffect);
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:46,代码来源:ModifyBowProjectileMatchModule.java

示例7: checkCustomNpc

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static boolean checkCustomNpc(Entity entity) {
	return entity == null || entity.hasMetadata("NPC") || entity.hasMetadata("MyPet");
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:4,代码来源:NeverLagUtils.java


注:本文中的org.bukkit.entity.Entity.hasMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。