Java Code Examples for org.bukkit.event.entity.EntityRegainHealthEvent#getEntity()
The following examples show how to use
org.bukkit.event.entity.EntityRegainHealthEvent#getEntity() .
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: DeathListener.java From Civs with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onFoodHeal(EntityRegainHealthEvent event) { if (event.getRegainReason() != EntityRegainHealthEvent.RegainReason.SATIATED || ConfigManager.getInstance().getFoodHealInCombat()) { return; } if (!(event.getEntity() instanceof Player)) { return; } Player player = (Player) event.getEntity(); Civilian civilian = CivilianManager.getInstance().getCivilian(player.getUniqueId()); if (!civilian.isInCombat()) { return; } event.setCancelled(true); }
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: PercentHealthObjectiveModule.java From UHC with MIT License | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void on(EntityRegainHealthEvent event) { final Entity entity = event.getEntity(); if (!(entity instanceof Player)) { return; } // If the event was cancelled, another plugin may have edited the health // Update instantly with the current health final Player player = (Player) entity; if (event.isCancelled()) { updatePlayer(player); return; } // Calculate new health based on regen amount instead of waiting for one tick final double oldHealth = player.getHealth(); final double healAmount = event.getAmount(); final double newHealth = Math.min(oldHealth + healAmount, player.getMaxHealth()); updatePlayer(player, newHealth); }
Example 4
Source File: RegainHealth.java From MarriageMaster with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onHeal(EntityRegainHealthEvent event) { if(event.getEntity() instanceof Player) { MarriagePlayer player = plugin.getPlayerData((Player) event.getEntity()); if(player.isMarried()) { Marriage marriage = player.getNearestPartnerMarriageData(); if(marriage != null && marriage.inRangeSquared(range)) { BonusHealEvent bonusHealEvent = new BonusHealEvent(player, marriage, event.getAmount() * multiplier, event.getRegainReason()); plugin.getServer().getPluginManager().callEvent(bonusHealEvent); if(!bonusHealEvent.isCancelled()) { event.setAmount(bonusHealEvent.getAmount()); } } } } }
Example 5
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 6
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 7
Source File: IndicatorListener.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityRegainHealth(EntityRegainHealthEvent event) { if (Settings.INDICATOR_ENABLE.getValue("gainHealth")) { if ((event.getEntity() instanceof Player && Settings.INDICATOR_SHOW_FOR_PLAYERS.getValue("gainHealth")) || Settings.INDICATOR_SHOW_FOR_MOBS.getValue("gainHealth")) { Location l = event.getEntity().getLocation().clone(); l.setY(l.getY() + Settings.INDICATOR_Y_OFFSET.getValue("gainHealth")); HoloAPI.getManager().createSimpleHologram(l, Settings.INDICATOR_TIME_VISIBLE.getValue("gainHealth"), true, Settings.INDICATOR_FORMAT.getValue("gainHealth", "default") + "+" + event.getAmount() + " " + HEART_CHARACTER); } } }
Example 8
Source File: UHPluginListener.java From KTP with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityRegainHealth(final EntityRegainHealthEvent ev) { if (ev.getRegainReason() == RegainReason.SATIATED) ev.setCancelled(true); if (ev.getEntity() instanceof Player) { Bukkit.getScheduler().runTaskLater(this.p, new BukkitRunnable() { @Override public void run() { p.updatePlayerListName((Player)ev.getEntity()); } }, 1L); } }
Example 9
Source File: ObserverModule.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onViewingEntityRegainHealth(EntityRegainHealthEvent event) { if (event.getEntity() instanceof Player) { refreshView(event.getEntity().getUniqueId()); } }