Java Code Examples for org.bukkit.entity.Player#getMaxHealth()
The following examples show how to use
org.bukkit.entity.Player#getMaxHealth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Vampire.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageByEntityEvent event) { if(event.getDamager().getType() == EntityType.PLAYER) { Player player = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null && p.getKit().equals(this)) { if(rand.nextInt(3) == 1) { double health = player.getHealth()+1D; if(health > player.getMaxHealth()) health = player.getMaxHealth(); player.setHealth(health); } } } }
Example 2
Source File: EntityListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onRegainHealth(EntityRegainHealthEvent rhe) { if (rhe.getEntityType() != EntityType.PLAYER) { return; } Player player = (Player) rhe.getEntity(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.RUNNING) { return; } if (player.getHealth() >= player.getMaxHealth()) { game.setPlayerDamager(player, null); } }
Example 3
Source File: ViewInventoryMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@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()); } }
Example 4
Source File: ViewInventoryMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@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()); } }
Example 5
Source File: BestPvEListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler (priority = EventPriority.HIGHEST) public void onPlayerDamage(EntityDamageEvent e){ if (e.isCancelled()){ return; } if (e.getDamage() < 0.2){ return; } if (!(e.getEntity() instanceof Player)){ return; } Player p = (Player) e.getEntity(); UhcPlayer uhcPlayer = GameManager.getGameManager().getPlayersManager().getUhcPlayer(p); if (!pveList.containsKey(uhcPlayer)){ return; // Only playing players on list } if (pveList.get(uhcPlayer)) { pveList.put(uhcPlayer, false); uhcPlayer.sendMessage(Lang.SCENARIO_BESTPVE_REMOVED); } if (p.getMaxHealth() > maxHealth){ double hp = p.getHealth(); if (hp < maxHealth){ p.setMaxHealth(maxHealth); }else{ p.setMaxHealth(hp + 1); } } }
Example 6
Source File: BestPvEListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@Override public void run(){ for (UhcPlayer uhcPlayer : GameManager.getGameManager().getPlayersManager().getOnlinePlayingPlayers()){ Player player; try{ player = uhcPlayer.getPlayer(); }catch (UhcPlayerNotOnlineException ex){ continue; // No hp for offline players } if (!pveList.containsKey(uhcPlayer)){ pveList.put(uhcPlayer,true); // Should never occur, playing players are always on list. Bukkit.getLogger().warning("[UhcCore] " + player.getName() + " was not on best PvE list yet! Please contact a server administrator."); } if (player.getGameMode().equals(GameMode.SURVIVAL) && pveList.get(uhcPlayer)){ // heal player if (player.getHealth() + 2 > player.getMaxHealth()){ player.setMaxHealth(player.getMaxHealth() + 2); } player.setHealth(player.getHealth() + 2); } } taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(UhcCore.getPlugin(),this,delay*TimeUtils.SECOND_TICKS); }
Example 7
Source File: Berserker.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void damageListener(final EntityDamageByEntityEvent event) { if(event.getEntity().getType() == EntityType.PLAYER && event.getDamager().getType() == EntityType.PLAYER) { Player one = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(one.getUniqueId()); if(p != null && p.getKit().equals(this)) { if((one.getHealth() / one.getMaxHealth()) <= .42) event.setDamage(event.getDamage()+1); } } }
Example 8
Source File: Berserker.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void damageListener(final PlayerDeathEvent event) { Player killer = event.getEntity().getKiller(); if(killer != null) { AnniPlayer p = AnniPlayer.getPlayer(killer.getUniqueId()); if(p != null && p.getKit().equals(this)) { if(killer.getMaxHealth() <= 24) killer.setMaxHealth(killer.getMaxHealth()+2); } } }
Example 9
Source File: PWIPlayer.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
PWIPlayer(Player player, Group group, double bankBalance, double balance, boolean useAttributes) { this.uuid = player.getUniqueId(); this.name = player.getName(); this.location = player.getLocation(); this.group = group; this.saved = false; this.armor = player.getInventory().getArmorContents(); this.enderChest = player.getEnderChest().getContents(); this.inventory = player.getInventory().getContents(); this.canFly = player.getAllowFlight(); this.displayName = player.getDisplayName(); this.exhaustion = player.getExhaustion(); this.experience = player.getExp(); this.isFlying = player.isFlying(); this.foodLevel = player.getFoodLevel(); if (useAttributes) { this.maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); } else { this.maxHealth = player.getMaxHealth(); } this.health = player.getHealth(); this.gamemode = player.getGameMode(); this.level = player.getLevel(); this.saturationLevel = player.getSaturation(); this.potionEffects = player.getActivePotionEffects(); this.fallDistance = player.getFallDistance(); this.fireTicks = player.getFireTicks(); this.maxAir = player.getMaximumAir(); this.remainingAir = player.getRemainingAir(); this.bankBalance = bankBalance; this.balance = balance; }
Example 10
Source File: PWIPlayer.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
PWIPlayer(Player player, Group group, double bankBalance, double balance, boolean useAttributes) { this.uuid = player.getUniqueId(); this.name = player.getName(); this.location = player.getLocation(); this.group = group; this.saved = false; this.armor = player.getInventory().getArmorContents(); this.enderChest = player.getEnderChest().getContents(); this.inventory = player.getInventory().getContents(); this.canFly = player.getAllowFlight(); this.displayName = player.getDisplayName(); this.exhaustion = player.getExhaustion(); this.experience = player.getExp(); this.isFlying = player.isFlying(); this.foodLevel = player.getFoodLevel(); if (useAttributes) { this.maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); } else { this.maxHealth = player.getMaxHealth(); } this.health = player.getHealth(); this.gamemode = player.getGameMode(); this.level = player.getLevel(); this.saturationLevel = player.getSaturation(); this.potionEffects = player.getActivePotionEffects(); this.fallDistance = player.getFallDistance(); this.fireTicks = player.getFireTicks(); this.maxAir = player.getMaximumAir(); this.remainingAir = player.getRemainingAir(); this.bankBalance = bankBalance; this.balance = balance; }
Example 11
Source File: PlayerTickTask.java From GriefDefender with MIT License | 4 votes |
@Override public void run() { for (World world : Bukkit.getServer().getWorlds()) { for (Player player : world.getPlayers()) { if (player.isDead()) { continue; } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); // send queued visuals int count = 0; final Iterator<BlockSnapshot> iterator = playerData.queuedVisuals.iterator(); while (iterator.hasNext()) { final BlockSnapshot snapshot = iterator.next(); if (count > GriefDefenderPlugin.getGlobalConfig().getConfig().visual.clientVisualsPerTick) { break; } NMSUtil.getInstance().sendBlockChange(player, snapshot); iterator.remove(); count++; } // chat capture playerData.updateRecordChat(); // health regen if (world.getFullTime() % 100 == 0L) { final GameMode gameMode = player.getGameMode(); // Handle player health regen if (gameMode != GameMode.CREATIVE && gameMode != GameMode.SPECTATOR && GDOptions.isOptionEnabled(Options.PLAYER_HEALTH_REGEN)) { final double maxHealth = player.getMaxHealth(); if (player.getHealth() < maxHealth) { final double regenAmount = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), playerData.getSubject(), Options.PLAYER_HEALTH_REGEN, claim); if (regenAmount > 0) { final double newHealth = player.getHealth() + regenAmount; if (newHealth > maxHealth) { player.setHealth(maxHealth); } else { player.setHealth(newHealth); } } } } } // teleport delay if (world.getFullTime() % 20 == 0L) { if (playerData.teleportDelay > 0) { final int delay = playerData.teleportDelay - 1; if (delay == 0) { playerData.teleportDelay = 0; player.teleport(playerData.teleportLocation); playerData.teleportLocation = null; playerData.teleportSourceLocation = null; continue; } TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.TELEPORT_DELAY_NOTICE, ImmutableMap.of("delay", TextComponent.of(delay, TextColor.GOLD)))); playerData.teleportDelay = delay; } } } } }