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


Java EntityRegainHealthEvent类代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityRegainHealthEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityRegainHealthEvent类的具体用法?Java EntityRegainHealthEvent怎么用?Java EntityRegainHealthEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onRegen

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler
public void onRegen(EntityRegainHealthEvent event) {
    if (event.getEntityType() != EntityType.PLAYER || event.getRegainReason() != EntityRegainHealthEvent.RegainReason.SATIATED) return;
    event.setCancelled(true);

    Player player = (Player) event.getEntity();
    long currentTime = System.currentTimeMillis() / 1000;

    if (currentTime - getLastHealTime(player) < 3)
        return;

    double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();

    if (player.getHealth() < maxHealth) {
        player.setHealth(clamp(player.getHealth() + 1, 0.0, maxHealth));
        healTimes.put(player.getUniqueId(), currentTime);
    }

    float exhToApply = (float) 3;

    Bukkit.getScheduler().runTaskLater(TGM.get(), () -> {
        //This is because bukkit doesn't stop the exhaustion change when cancelling the event
        player.setExhaustion(player.getExhaustion() + exhToApply);
        //debug("Exhaustion before: " + previousExh + " Now: " + p.getExhaustion() + "Saturation: " + p.getSaturation(), p);
    }, 1L);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:27,代码来源:RegenModule.java

示例2: call

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityRegainHealthEvent) {
		EntityRegainHealthEvent erhe = (EntityRegainHealthEvent) event;

		if (erhe.getRegainReason() == RegainReason.SATIATED) {
			/*
			 * Player is regenerating health because their hunger is full.
			 */

			final double health = profile.getPlayer().getHealth();

			if (!isAcceptable(health, erhe.getAmount())) {
				callback(true);
			}

			lastTime = System.currentTimeMillis();
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:21,代码来源:FastHealA.java

示例3: updateMonitoredHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:ViewInventoryMatchModule.java

示例4: onRegen

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onRegen(EntityRegainHealthEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof Player)) {
        return;
    }

    Player player = (Player) entity;
    EntityRegainHealthEvent.RegainReason reason = event.getRegainReason();
    if (reason == EntityRegainHealthEvent.RegainReason.SATIATED) {
        FightData data = FightData.getData(player);
        boolean canCheckRegeneration = CHECK_MANAGER.canCheckPlayer(player, CheckType.REGENERATION);
        if (canCheckRegeneration) {
            event.setCancelled(REGENERATION.check(player, data));
            data.setLastHealthEvent(System.currentTimeMillis());
        }
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:20,代码来源:FightListener.java

示例5: onPlayerRegen

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerRegen(EntityRegainHealthEvent e) {
	if (e.isCancelled() || !(e.getEntity() instanceof Player)) {
		return;
	}
	
	Player p = (Player) e.getEntity();
	if (leader.getPlayer().getUniqueId().equals(p.getUniqueId())) {
		updateScoreboard(leader, (int) (p.getHealth() + e.getAmount()));
		return;
	}
	if (!members.isEmpty())
	for (QuestPlayer qp : members) {
		if (qp.getPlayer().getUniqueId().equals(p.getUniqueId())) {
			updateScoreboard(qp, (int) (p.getHealth() + e.getAmount()));
			return;
		}
	}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:20,代码来源:Party.java

示例6: onRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:22,代码来源:EntityListener.java

示例7: 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);
                }
            }
        }
    }
}
 
开发者ID:mrsheepsheep,项目名称:Tint-Health,代码行数:17,代码来源:PlayerListener.java

示例8: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
/**
 * On entity regain health.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
	
	Entity entity = event.getEntity();
	Player player;
	IPlayerConfEntry entry;
	
	if(entity != null && event.getEntity() instanceof Player
			&& (event.getRegainReason() == RegainReason.REGEN
			|| event.getRegainReason() == RegainReason.SATIATED)
			&& (entry = playerConf.get((player = (Player) event.getEntity()))) != null
			&& !entry.isAdminMod()) {
	
		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(player.getLocation());
		
		if (!checkPermission(land, player, PermissionList.FOOD_HEAL.getPermissionType())) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:26,代码来源:PlayerListener.java

示例9: 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();
		}
	}
	
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:22,代码来源:Utilities.java

示例10: onHealthChange

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler
public void onHealthChange(EntityRegainHealthEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			if(event.getEntity() instanceof Player){
				if(((CircleOfBoom)Minigame.getCurrentMinigame()).isUhc()){
					event.setCancelled(true);
				}
			}
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
开发者ID:tatanpoker09,项目名称:TCMinigames,代码行数:21,代码来源:PlayerListener.java

示例11: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
	if (!(event.getEntity() instanceof Player)) {
		return;
	}
	
	if (event.getRegainReason() != RegainReason.SATIATED) {
		return;
	}
	
	Player player = (Player) event.getEntity();
	int proteinValue = plugin.getValueManager().getValue(FoodType.PROTEIN, player);
	
	Random ran = new Random();
	if (proteinValue <= -7) {
		if (ran.nextInt(2) == 0) {
			event.setCancelled(true);
		}
	} else if (proteinValue <= -6) {
		if (ran.nextInt(4) > 0) {
			event.setCancelled(true);
		}
	}
	
}
 
开发者ID:SugarCaney,项目名称:FoodBalance,代码行数:26,代码来源:RegenListener.java

示例12: onEnderDragonRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
/**
 * Handle EnderDragon regen
 *
 * @param event an EntityRegainHealthEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonRegainHealth(final EntityRegainHealthEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON && event.getRegainReason() == RegainReason.ENDER_CRYSTAL) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getEntity().getLocation().getWorld().getName()));
        if (handler != null) {
            final float rate = handler.getConfig().getEcHealthRegainRate();
            if (rate < 1.0) {
                if (RANDOM.nextFloat() >= rate) {
                    event.setCancelled(true);
                }
            } else if (rate > 1.0) {
                event.setAmount((int)(rate * event.getAmount()));
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:22,代码来源:EnderDragonListener.java

示例13: 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);
				}
			}
		}
	}
}
 
开发者ID:WeaselBuilds,项目名称:WeaselsWalls,代码行数:17,代码来源:FoodRegen.java

示例14: heal

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
public void heal(int i, EntityRegainHealthEvent.RegainReason regainReason) {
    if (this.health > 0) {
        EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
            this.setHealth(this.getHealth() + event.getAmount());
        }

        // this.getMaxHealth() -> this.maxHealth
        if (this.health > this.maxHealth) {
            this.setHealth(this.maxHealth);
            // CraftBukkit end
        }

        this.noDamageTicks = this.maxNoDamageTicks / 2;
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:19,代码来源:EntityLiving.java

示例15: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
	if (!(event.getEntity() instanceof Player)) {
		return;
	}

	final Player player = (Player) event.getEntity();

	getCheckVersion(player, CheckType.FASTHEAL, "A").call(event);
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:11,代码来源:DetectionListener.java


注:本文中的org.bukkit.event.entity.EntityRegainHealthEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。