本文整理匯總了Java中org.bukkit.event.entity.EntityRegainHealthEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityRegainHealthEvent.getEntity方法的具體用法?Java EntityRegainHealthEvent.getEntity怎麽用?Java EntityRegainHealthEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityRegainHealthEvent
的用法示例。
在下文中一共展示了EntityRegainHealthEvent.getEntity方法的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);
}
示例2: 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());
}
}
示例3: 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());
}
}
}
示例4: 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;
}
}
}
示例5: 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);
}
}
示例6: 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);
}
}
}
}
}
示例7: 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);
}
}
}
示例8: 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;
}
}
}
示例9: 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);
}
}
}
示例10: 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);
}
}
}
}
}
示例11: 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);
}
示例12: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler
@SuppressWarnings("unused")
public void onEntityRegainHealth(EntityRegainHealthEvent e) {
if(!(e.getEntity() instanceof Player)) {
return;
}
Player player = (Player) e.getEntity();
if(e.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED) {
boolean hacking = DACManager.getBackend().checkRegen(player);
if(hacking) {
e.setCancelled(true);
}
}
}
示例13: onRegen
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onRegen(EntityRegainHealthEvent e) {
if (e.getEntityType() != EntityType.PLAYER || e.getRegainReason() != EntityRegainHealthEvent.RegainReason.SATIATED)
return;
final Player p = (Player) e.getEntity();
if (!isEnabled(p.getWorld())) return;
e.setCancelled(true);
long currentTime = System.currentTimeMillis() / 1000;
long lastHealTime = getLastHealTime(p);
if(currentTime - lastHealTime < module().getLong("frequency"))
return;
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
if (p.getHealth() < maxHealth) {
p.setHealth(MathHelper.clamp(p.getHealth() + module().getInt("amount"), 0.0, maxHealth));
healTimes.put(p.getUniqueId(), currentTime);
}
final float PREVIOUS_EXHAUSTION = p.getExhaustion();
final float EXHAUSTION_TO_APPLY = (float) module().getDouble("exhaustion");
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//This is because bukkit doesn't stop the exhaustion change when cancelling the event
p.setExhaustion(PREVIOUS_EXHAUSTION + EXHAUSTION_TO_APPLY);
debug("Exhaustion before: " + PREVIOUS_EXHAUSTION + " Now: " + p.getExhaustion() + " Saturation: " + p.getSaturation(), p);
},1L);
}
示例14: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (!usingBeeLoginMod)
return;
Entity entity = event.getEntity();
if (entity instanceof Player) {
if (!loginStatus.get(((Player) entity).getName().toLowerCase())) {
event.setCancelled(true);
}
}
}
示例15: 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);
}
}