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


Java Player.damage方法代码示例

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


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

示例1: damageSelfTrue

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void damageSelfTrue(int damageAmount) {
    if (classType == ClassType.PALADIN) {
        if (hasBuff(HolyGuardian.BUFF_ID))
            damageAmount *= getBuffValue(HolyGuardian.BUFF_ID);
        if (hasBuff(ChantOfNecessarius.BUFF_ID))
            damageAmount = 0;
    }
    if (damageAmount < 1)
        damageAmount = 1;
    hp -= damageAmount;
    if (hp < 0)
        hp = 0;
    Player p = getPlayer();
    if (p != null) {
        OptionsManager.msgDamage(p, this, ChatColor.GRAY + ">> " + ChatColor.RED + ChatColor.BOLD + "-" + damageAmount + " HP" + ChatColor.YELLOW + " [" + hp + " HP]" + ChatColor.WHITE + " from yourself");
        p.damage(0.0);
        if (hp < 1) {
            if (p != null)
                die();
        } else {
            updateHealthManaDisplay();
            if (board != null)
                board.getObjective("hpdisplay").getScore(name).setScore(hp);
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:27,代码来源:PlayerDataRPG.java

示例2: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
    for(Item item : Bukkit.getWorlds().get(0).getEntitiesByClass(Item.class)) {
        if(item.getItemStack().getType() != Material.GHAST_TEAR) continue;
        UUID skip = Gizmos.gunGizmo.items.get(item);

        for(Entity entity : item.getNearbyEntities(0.5d, 0.5d, 0.5d)) {
            if(entity instanceof Player && !entity.getUniqueId().equals(skip)) {
                Player player = (Player) entity;
                if(player.hasPermission("gizmo.immunity")) continue;
                player.damage(0d, item);
                Gizmos.gunGizmo.gifts.add(player.getUniqueId());
                item.remove();
                break;
            }
        }

        if(item.getTicksLived() >= 6000) item.remove();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:GunGizmo.java

示例3: check

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void check(Player player, MovingData data) {
    if (data.getGroundLocation() == null) {
        return;
    }

    Location location = data.getCurrentLocation();
    Location ground = data.getGroundLocation();

    double toGround = LocationHelper.distanceVertical(ground, location);
    boolean isDescending = toGround >= 3.0 && data.isDescending() && !data.isOnGround();

    // make sure we meet the req.
    if (isDescending && !data.isClimbing()) {
        boolean ccOnGround = data.isFlyingClientOnGround();
        // we're not on ground but the client is?
        if (ccOnGround && player.getFallDistance() == 0.0) {
            boolean cancel = checkViolation(player, "Fall distance is 0 while not onGround. (Client faked)");
            // if we cancel damage the player. (not accurate)
            // TODO: Make accurate
            if (cancel) {
                player.damage(toGround);
            }
        }
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:27,代码来源:NoFall.java

示例4: Stomper

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void Stomper(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		if (Kit.getKit(p).getName().equalsIgnoreCase("stomper")) {
			if (e.getCause() == DamageCause.FALL) {
				List<Entity> nearbyEntities = e.getEntity()
						.getNearbyEntities(5, 5, 5);
				for (Entity target : nearbyEntities) {
					if (target instanceof Player) {
						Player t = (Player) target;
						if (Team.getTeam(p) == Team.getTeam(t))
							continue;
						if (t.isSneaking())
							t.damage(e.getDamage() / 2, e.getEntity());
						else
							t.damage(e.getDamage(), e.getEntity());
					}
				}
				e.setDamage(0);
			}
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:25,代码来源:KitEvents.java

示例5: checkRegen

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean checkRegen(Player player) {
    long l = lastHeal.containsKey(player)?lastHeal.get(player):System.currentTimeMillis() - (MagicNumbers
            .HEAL_TIME_MIN + 10);
    if(System.currentTimeMillis() - l >= MagicNumbers.HEAL_RESET) {
        lastHeal.remove(player);
        l = System.currentTimeMillis() - (MagicNumbers.HEAL_TIME_MIN + 10);
    }
    if (((System.currentTimeMillis() - l) < MagicNumbers.HEAL_TIME_MIN) && player.getWorld().getDifficulty() !=
            Difficulty.PEACEFUL) {
        for(Player pla : DynamicAC.instance.onlinestaff) {
            pla.sendMessage(DynamicAC.prefix + player.getName() + " failed Regen check!");
        }
        for(double i = player.getHealth(); i < player.getMaxHealth() && player.isOnline(); i += 1) {
            DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
                    "Regen");
        }
        player.damage(1.0);
        return true;
    }
    logHeal(player);
    return false;
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:23,代码来源:BackendChecks.java

示例6: checkFastFall

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkFastFall(Player player, Distance distance) {
    double from = Math.round(distance.fromY());
    double to = Math.round(distance.toY());

    if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) {
        return;
    }

    for (int i = 0; i < Math.round(distance.getYDifference()) + 1; i++) {
        Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation()
                .getZ()).getBlock();
        if (block.getType() != Material.AIR && block.getType().isSolid()) {
            for (Player pla : DynamicAC.instance.onlinestaff) {
                pla.sendMessage(DynamicAC.prefix + player.getName() + " tried to move through a solid block!");
            }
            DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
                    "Phase");
        }
        player.damage(3);
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:22,代码来源:BackendChecks.java

示例7: handleDetonate

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleDetonate(Player player, Rune rune) {
	player.spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 1);
	player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
	for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
		if(!(entity instanceof Player)) {
			continue;
		}
		Player target = (Player) entity;
		
		if(Utility.canAttack(player, target)) {
			if(target.getHealth() > 6) {
				target.setHealth(target.getHealth() - 6);
			}
			else {
				target.damage(1000000D, player);
			}
		}
	}
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:21,代码来源:RuneManager.java

示例8: onLeave

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onLeave(PlayerQuitEvent event) {
    Player player = event.getPlayer();

    event.setQuitMessage(null);

    Game game = Skywars.getInstance().getGame(player);
    if (game != null && game.getGamePlayer(player) != null) {
        GamePlayer gamePlayer = game.getGamePlayer(player);

        if (gamePlayer.isTeamClass()) {
            if (gamePlayer.getTeam().isPlayer(player)) {
                player.damage(player.getMaxHealth()); // Kill player to make game process this as a death
            }
        } else {
            if (gamePlayer.getPlayer() == player) {
                player.damage(player.getMaxHealth()); // Kill player to make game process this as a death
            }
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:22,代码来源:PlayerLeave.java

示例9: onEntityDeath

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Upon a bat's death, drops a golden apple the majority of the time, with a small chance of instantly killing the
 * player.
 *
 * @param event The event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
  Entity entity = event.getEntity();
  Player player = event.getEntity().getKiller();
  if (entity instanceof Bat && player != null) {
    if (0.01 > Math.random()) {
      player.damage(Integer.MAX_VALUE, entity);
    } else {
      entity.getWorld().dropItem(entity.getLocation(), new ItemStack(Material.GOLDEN_APPLE));
    }
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:19,代码来源:Bats.java

示例10: handleLightning

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleLightning(Player player, Rune rune) {
	@SuppressWarnings("deprecation")
	Block block = player.getTargetBlock((HashSet<Byte>) null, 15);
	if(!Utility.isPVPEnabled(block.getLocation())) {
		return;
	}
	
	block.getWorld().strikeLightning(block.getLocation());
	for(Entity e : block.getWorld().getEntities()) {
		if(!(e instanceof Player)) {
			continue;
		}
		Player target = (Player) e;
		if(!Utility.canAttack(player, target)) {
			continue;
		}
		double distance = target.getLocation().distance(block.getLocation());
		double damage = 0;
		if(distance < 1) {
			damage = 16;
		}
		else if(distance <= 3) {
			damage = 10;
		}
		
		if(damage < 1)
			continue;
		
		if(target.getHealth() > damage)
			target.setHealth(target.getHealth() - damage);
		else
			target.damage(1000000, player);
		target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_LIGHTNING.toString()
			.replaceAll("%s", player.getName()));
	}
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:38,代码来源:RuneManager.java

示例11: giantAttacks

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void giantAttacks(Giant boss, Player damager){
    int attack = r.nextInt(8);
    List<Player> near = new ArrayList<>();

    boss.getNearbyEntities(7, 7, 7).forEach(en -> {
        if (en instanceof Player) {
            near.add((Player) en);
        }
    });

    switch (attack){
        case 0:
            near.forEach(p -> {
                if (!p.equals(damager)) {
                    p.getWorld().strikeLightningEffect(p.getLocation());
                    p.damage(0.5);

                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
                }
            });

            damager.getWorld().strikeLightningEffect(damager.getLocation());
            damager.damage(0.5);

            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
            break;
        case 1:
            ArrayList<Location> locs = Utils.getCircle(boss.getEyeLocation(), 7, 30);

            locs.forEach(l -> { //Change Color
                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(100, 60, 50), l, 50);
                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(200, 60, 50), l.subtract(0, 7, 0), 50);
            });

            near.forEach(p -> {
                if (!p.equals(damager)) {
                    ParticleEffect.EXPLOSION_NORMAL.display(new Vector(0, 0, 0), 4, p.getLocation(), 50);
                    p.damage(0.5);
                }
            });

            ParticleEffect.EXPLOSION_NORMAL.display(new Vector(0, 0, 0), 4, damager.getLocation(), 50);
            damager.damage(0.5);
            break;
        case 2:
            if (boss.getHealth() + 20 >= boss.getMaxHealth()) boss.setHealth(boss.getMaxHealth());
            boss.setHealth(boss.getHealth() + 20);
            break;
        default:
            break;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:55,代码来源:MobAttack.java

示例12: skeletonAttacks

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void skeletonAttacks(Skeleton boss, Player damager){
    int attack = r.nextInt(8);
    List<Player> near = new ArrayList<>();

    boss.getNearbyEntities(7, 7, 7).forEach(en -> {
        if (en instanceof Player) {
            near.add((Player) en);
        }
    });

    switch (attack){
        case 0:
            if (boss.getHealth() + 20 >= boss.getMaxHealth()) boss.setHealth(boss.getMaxHealth());
            boss.setHealth(boss.getHealth() + 20);
            break;
        case 1:
            List<Item> bones = new ArrayList<>();

            for (int i = 0 ; i < 20; i++) {
                ItemStack osso = new ItemStack(Material.BONE, 1);
                Location dropLoc = boss.getLocation();
                dropLoc.setX(dropLoc.getX() + r.nextDouble() - r.nextDouble());
                dropLoc.setY(dropLoc.getY() + r.nextDouble() - r.nextDouble());
                dropLoc.setZ(dropLoc.getZ() + r.nextDouble() - r.nextDouble());
                final Item bone = boss.getWorld().dropItem(dropLoc, osso);
                Vector v = new Vector(Math.random() - Math.random(), Math.random(), Math.random() - Math.random()).multiply(1);

                bone.setVelocity(v);
                bone.setPickupDelay(Integer.MAX_VALUE);

                bones.add(bone);
            }
            ParticleEffect.EXPLOSION_HUGE.display(new Vector(0, 0, 0), 2, boss.getLocation(), 50);

            near.forEach(p -> {
                if (!p.equals(damager)) {
                    WCTWD.getPlayer(p).sendSound(Sound.ENTITY_GENERIC_EXPLODE);
                    p.damage(3);
                }
            });
            WCTWD.getPlayer(damager).sendSound(Sound.ENTITY_GENERIC_EXPLODE);
            damager.damage(3);

            bs.runTaskLater(plugin, () -> bones.forEach(b -> b.remove()), 40);
            break;

        default:
            break;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:51,代码来源:MobAttack.java

示例13: attackPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Make a {@link FakeMob} attack a {@link Player}
 *
 * @param p        the {@link Player} whp can see the attack
 * @param toAttack the {@link Player} who should be attacked
 * @param mob      the {@link FakeMob} who should attack
 * @param damage   the damage which should be done by the {@link FakeMob}
 */
public static void attackPlayer(Player p, Player toAttack, FakeMob mob, double damage) {
    if (!FakeAPI.getFakeEntitysInRadius(toAttack, 4).contains(mob)) return;

    lookAtPlayer(p, toAttack, mob);

    ReflectionUtil.sendPacket(p, new PPOAnimation(mob.getNmsEntity(), 0));

    toAttack.damage(damage);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:18,代码来源:MobFakeUtil.java

示例14: attackPlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Make a {@link FakePlayer} attack a {@link Player}
 *
 * @param p        the {@link Player} who can see the attack
 * @param toAttack the {@link Player} who should be attacked
 * @param npc      the {@link FakePlayer} who should attack
 * @param damage   the damage which should be done by the {@link FakePlayer}
 */
public static void attackPlayer(Player p, Player toAttack, FakePlayer npc, double damage) {
    if (!FakeAPI.getFakeEntitysInRadius(toAttack, 4).contains(npc)) return;

    lookAtPlayer(p, toAttack, npc);

    ReflectionUtil.sendPacket(p, new PPOAnimation(npc.getNmsEntity(), 0));

    toAttack.damage(damage);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:18,代码来源:PlayerFakeUtil.java


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