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


Java Player.setMaxHealth方法代码示例

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


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

示例1: reset

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void reset() {
    final Player bukkit = getBukkit();
    bukkit.closeInventory();
    clearInventory();
    bukkit.setExhaustion(0);
    bukkit.setFallDistance(0);
    bukkit.setFireTicks(0);
    bukkit.setFoodLevel(20); // full
    bukkit.setMaxHealth(20);
    bukkit.setHealth(bukkit.getMaxHealth());
    bukkit.setAbsorption(0);
    bukkit.setLevel(0);
    bukkit.setExp(0); // clear xp
    bukkit.setSaturation(5); // default
    bukkit.setFastNaturalRegeneration(false);
    bukkit.setSlowNaturalRegeneration(true);
    bukkit.setAllowFlight(false);
    bukkit.setFlying(false);
    bukkit.setSneaking(false);
    bukkit.setSprinting(false);
    bukkit.setFlySpeed(0.1f);
    bukkit.setKnockbackReduction(0);
    bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT);
    AttributeUtils.removeAllModifiers(bukkit);
    resetPotions();

    // we only reset bed spawn here so people don't have to see annoying messages when they respawn
    bukkit.setBedSpawnLocation(null);

    match.callEvent(new PlayerResetEvent(this));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:MatchPlayer.java

示例2: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Give effects to all players
 *
 * @param game Game instance
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (SurvivalPlayer player : (Collection<SurvivalPlayer>)game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.addPotionEffect(PotionEffectType.SPEED.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.DAMAGE_RESISTANCE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.JUMP.createEffect(Integer.MAX_VALUE, 4));
        p.setMaxHealth(32D);
        p.setHealth(32D);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:24,代码来源:SuperheroesModule.java

示例3: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Give effects to all players
 *
 * @param game Game instance
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (SurvivalPlayer player : (Collection<SurvivalPlayer>)game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.addPotionEffect(PotionEffectType.SPEED.createEffect(Integer.MAX_VALUE, 2));
        p.addPotionEffect(PotionEffectType.FAST_DIGGING.createEffect(Integer.MAX_VALUE, 2));
        p.addPotionEffect(PotionEffectType.SATURATION.createEffect(Integer.MAX_VALUE, 10));
        p.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.DAMAGE_RESISTANCE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(Integer.MAX_VALUE, 1));
        p.addPotionEffect(PotionEffectType.JUMP.createEffect(Integer.MAX_VALUE, 4));
        p.addPotionEffect(PotionEffectType.WATER_BREATHING.createEffect(Integer.MAX_VALUE, 1));
        p.setMaxHealth(40D);
        p.setHealth(40D);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:SuperheroesPlusModule.java

示例4: onJoin

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

    event.setJoinMessage(null);

    if (!Skywars.getInstance().isSingleServerMode()) {
        player.setGameMode(GameMode.ADVENTURE);
        player.getInventory().clear();
        player.setMaxHealth(20);
        player.setHealth(player.getMaxHealth());
        player.setFoodLevel(25);

        player.teleport(Skywars.getInstance().getLobbyPoint());
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:17,代码来源:PlayerJoin.java

示例5: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Multiply max health by 2
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.setMaxHealth(this.maxHealth);
        p.setHealth(this.maxHealth / 2);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:20,代码来源:PotentialHeartsModule.java

示例6: onGameStart

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Double the health on game's start
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.setMaxHealth(40.0D);
        p.setHealth(40.0D);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:20,代码来源:DoubleHealthModule.java

示例7: activateSpectatorSettings

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void activateSpectatorSettings(Player player) {
    GamePlayer gamePlayer = getGamePlayer(player);

    player.setMaxHealth(20);
    player.setHealth(player.getMaxHealth());
    player.setGameMode(GameMode.SPECTATOR);

    if (gamePlayer != null) {
        switchToSpectator(gamePlayer);
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:12,代码来源:Game.java

示例8: onPlayerLvlChanged

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerLvlChanged(PlayerLevelChangeEvent event){
    Player player = event.getPlayer();
    if (player.getLevel() >= 60){
        return;
    }
    //增加血槽
    double healAdded = event.getNewLevel();
    player.setMaxHealth(20 + healAdded);

}
 
开发者ID:kncxstudio,项目名称:BasicSurvivalPlus,代码行数:12,代码来源:PlayerLvlListener.java

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

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

示例11: StartGame

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void StartGame() {
	gameSituation = true;
	startTime = System.currentTimeMillis();
	for (Player players : Bukkit.getOnlinePlayers()) {
		players.setGameMode(GameMode.SURVIVAL);
		players.getInventory().clear();
		players.setFoodLevel(20);
		players.setMaxHealth(40);
		players.teleport(findLocation(players));
	}
}
 
开发者ID:masste,项目名称:McPlayUHC,代码行数:12,代码来源:GameManager.java

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

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