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


Java Player.getMaxHealth方法代码示例

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


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

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

示例2: updateMonitoredHealth

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateMonitoredHealth(final EntityRegainHealthEvent event) {
    if(event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if(player.getHealth() == player.getMaxHealth()) return;
        this.scheduleCheck((Player) event.getEntity());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:ViewInventoryMatchModule.java

示例3: show

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void show(VPPlayer player) {
	Player p = player.getPlayer();
	Object nmsPlay = getNMSPlayer(p);
	Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
	final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
			.instance(addPlayerEnum, arrayPlayer);
	Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
	Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
	Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
	final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
			.instance(0, difficulty, type, gamemode);
	boolean flying = p.isFlying();
	Location location = player.getLocation();
	int level = player.getLevel();
	float xp = p.getExp();
	double maxHealth = p.getMaxHealth();
	double health = p.getHealth();
	PacketUtils.sendPacket(respawn, player);        
	p.setFlying(flying);
	player.teleport(location);
	p.updateInventory();
	player.setLevel(level);
	p.setExp(xp);
	p.setMaxHealth(maxHealth);
	p.setHealth(health);
	for(VPPlayer vp : VanillaPlusCore.getPlayerManager().getOnlinePlayers())
		PacketUtils.sendPacket(add, vp);
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:30,代码来源:CraftPlayerUtils.java

示例4: updateSelf

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void updateSelf(VPPlayer player){
	Player p = player.getPlayer();
	Object nmsPlay = getNMSPlayer(p);
	Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
	ReflectionObject del = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, removePlayerEnum.getClass(), arrayPlayer.getClass())
			.instance(removePlayerEnum, arrayPlayer);
	final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
			.instance(addPlayerEnum, arrayPlayer);
	Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
	Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
	Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
	final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
			.instance(0, difficulty, type, gamemode);
	PacketUtils.sendPacket(del, player);
	boolean flying = p.isFlying();
	Location location = player.getLocation();
	int level = player.getLevel();
	float xp = p.getExp();
	double maxHealth = p.getMaxHealth();
	double health = p.getHealth();
	PacketUtils.sendPacket(respawn, player);        
	p.setFlying(flying);
	player.teleport(location);
	p.updateInventory();
	player.setLevel(level);
	p.setExp(xp);
	p.setMaxHealth(maxHealth);
	p.setHealth(health);
	PacketUtils.sendPacket(add, player);
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:32,代码来源:CraftPlayerUtils.java

示例5: items

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void items(Player p){
    WCCore.getInstance().debugLog("Task Items");
    if(files.getUsers().contains("Users." + p.getName() + ".bypass")
            && files.getUsers().getBoolean("Users." + p.getName() + ".bypass")) return;

    if (p.getInventory().getItemInMainHand() == null) {
        return;
    }
    //Comprobación extra
    //Palo
    if (p.getInventory().getItemInMainHand().isSimilar(itemsClass.STICK.getItemStack())){
        if(p.getMaxHealth() != 30){
            p.setMaxHealth(30);
        }
        if(p.getWalkSpeed() > 0.2f){
            p.setWalkSpeed(0.2f);
        }
        return;
    }

    //Picos
    if (p.getInventory().getItemInMainHand().isSimilar(itemsClass.P1.getItemStack())){
        if(p.getMaxHealth() != 35){
            p.setMaxHealth(35);
        }
        if(p.getWalkSpeed() != 0.4f){
            p.setWalkSpeed(0.4f);
        }
        return;
    }
    if (p.getInventory().getItemInMainHand().isSimilar(itemsClass.P2.getItemStack())){
        if(p.getMaxHealth() != 35){
            p.setMaxHealth(35);
        }
        if(p.getWalkSpeed() != 0.4f){
            p.setWalkSpeed(0.4f);
        }
        return;

    }
    if (p.getInventory().getItemInMainHand().isSimilar(itemsClass.P3.getItemStack())){
        if(p.getMaxHealth() != 35){
            p.setMaxHealth(35);
        }
        if(p.getWalkSpeed() != 0.4f){
            p.setWalkSpeed(0.4f);
        }
        return;

    }

    if(!(p.getInventory().getItemInMainHand().isSimilar(itemsClass.STICK.getItemStack())
            || p.getInventory().getItemInMainHand().isSimilar(itemsClass.P1.getItemStack())
            || p.getInventory().getItemInMainHand().isSimilar(itemsClass.P2.getItemStack())
            || p.getInventory().getItemInMainHand().isSimilar(itemsClass.P3.getItemStack()))){
        if(p.getMaxHealth() > 20){
            p.setMaxHealth(20);
        }
        if(p.getWalkSpeed() > 0.2f){
            p.setWalkSpeed(0.2f);
        }
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:64,代码来源:MainRun.java

示例6: onInteract

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e){
    Player p = e.getPlayer();

    if (e.getItem() == null) return;
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getItem().isSimilar(new AllItems().getGanzua())) {
        Block b = e.getClickedBlock();
        if (b instanceof Chest) {
            Chest c = (Chest)b;
            e.setCancelled(true);
            p.closeInventory();
            this.plugin.getChestManager().openChest(c, p);
            return;
        }
    }

    if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
        switch (e.getItem().getType()){
            case PAPER:
                if (!this.plugin.getBlooding().contains(p)) return;
                this.plugin.getBlooding().remove(p);
                p.sendMessage(ChatColor.GREEN + "Buff, ya no estoy sangrando.");
                removeItem(p);
                break;
            case SAPLING:
                if (p.getMaxHealth() == p.getHealth()) return;
                if (p.getHealth() + 6 > p.getMaxHealth()){
                    p.setHealth(p.getMaxHealth());
                } else {
                    p.setHealth(p.getHealth() + 6);
                }
                p.sendMessage(ChatColor.GREEN + "Me siento mucho mejor :D.");
                removeItem(p);
                break;
            case BLAZE_ROD:
                if (p.getMaxHealth() == p.getHealth()) return;
                p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 2));
                p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 100, 1));
                p.sendMessage(ChatColor.GREEN + "Me siento mucho mejor :D.");
                removeItem(p);
                break;
        }
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:45,代码来源:WorldInteract.java

示例7: setHealth

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean setHealth(UUID player, double amount){

		Player p = Bukkit.getServer().getPlayer(player);

		if(p.getMaxHealth() == amount){

			return false;

		} else {

			p.setMaxHealth(amount);

			p.setHealth(amount);

			return true;

		}

	}
 
开发者ID:RedNyanCat,项目名称:UselessAPI,代码行数:20,代码来源:Api.java


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