本文整理汇总了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);
}
}