本文整理匯總了Java中org.bukkit.event.entity.EntityRegainHealthEvent.getAmount方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityRegainHealthEvent.getAmount方法的具體用法?Java EntityRegainHealthEvent.getAmount怎麽用?Java EntityRegainHealthEvent.getAmount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityRegainHealthEvent
的用法示例。
在下文中一共展示了EntityRegainHealthEvent.getAmount方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onHeal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
protected void onHeal(EntityRegainHealthEvent e) {
if (isEnabled()) {
if (!plugin.fade) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
if (plugin.functions.isTintEnabled(p)) {
Damageable d = (Damageable) p;
double heal = e.getAmount();
int health = (int) (d.getHealth() + heal);
plugin.functions.sendBorder(p, health);
}
}
}
}
}
示例2: onHealthRegain
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHealthRegain(final EntityRegainHealthEvent event){
double regainAmountTicker = event.getAmount();
Deque<DamageData> damagers = getDamageInformationDeque(event.getEntity().getUniqueId());
while(regainAmountTicker > 0 && damagers.size() > 0){
DamageData leastRecentDamage = damagers.getLast();
if(leastRecentDamage.getDamageAmount() > regainAmountTicker){
// Remove damage attribution from a specific source
leastRecentDamage.regen += regainAmountTicker;
regainAmountTicker = 0;
}else if(Utilities.equals(leastRecentDamage.getDamageAmount(), regainAmountTicker)){
// Just enough to remove the damage source
damagers.removeLast();
regainAmountTicker = 0;
}else{
// Damage amount of source is less than regain amount ticker, therefore we remove the last damage source and we decrement the regainer ticker
regainAmountTicker -= damagers.removeLast().getDamageAmount();
}
}
}
示例3: onHealthRegen
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGH)
public void onHealthRegen(EntityRegainHealthEvent e){
if(e.getEntity() instanceof Player){
Player p = (Player) e.getEntity();
Game g = GameManager.getInstance().getGame(p);
if(g != null){
if(g.gs == GameStage.Lobby || g.gs == GameStage.Build){
if(e.getAmount() != 20D){
e.setAmount(20D);
}
}
}
}
}
示例4: applyHealthRegen
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void applyHealthRegen(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
return;
}
if (((event.getEntity() instanceof Player)) &&
(event.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED)) {
event.setAmount(event.getAmount() + LoreAttributes.loreManager.getRegenBonus((LivingEntity) event.getEntity()));
if (event.getAmount() <= 0.0D)
event.setCancelled(true);
}
}
示例5: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityRegainHealth(EntityRegainHealthEvent event)
{
if (event.isCancelled() || event.getAmount() <= 0.0D)
return;
Entity entity = event.getEntity();
if (entity instanceof LivingEntity)
{
plugin.getHealthBarHandler().updateHealth((LivingEntity) entity);
}
}