當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityRegainHealthEvent.getEntity方法代碼示例

本文整理匯總了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);
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:27,代碼來源:RegenModule.java

示例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());
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:9,代碼來源:ViewInventoryMatchModule.java

示例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());
        }
    }

}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:20,代碼來源:FightListener.java

示例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;
		}
	}
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:20,代碼來源:Party.java

示例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);
  }
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:22,代碼來源:EntityListener.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:mrsheepsheep,項目名稱:Tint-Health,代碼行數:17,代碼來源:PlayerListener.java

示例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);
		}
	}
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:26,代碼來源:PlayerListener.java

示例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;
		}
	}
}
 
開發者ID:tatanpoker09,項目名稱:TCMinigames,代碼行數:21,代碼來源:PlayerListener.java

示例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);
		}
	}
	
}
 
開發者ID:SugarCaney,項目名稱:FoodBalance,代碼行數:26,代碼來源:RegenListener.java

示例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);
				}
			}
		}
	}
}
 
開發者ID:WeaselBuilds,項目名稱:WeaselsWalls,代碼行數:17,代碼來源:FoodRegen.java

示例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);
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:11,代碼來源:DetectionListener.java

示例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);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DynamicAC,代碼行數:15,代碼來源:PlayerListener.java

示例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);
}
 
開發者ID:gvlfm78,項目名稱:BukkitOldCombatMechanics,代碼行數:35,代碼來源:ModulePlayerRegen.java

示例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);
		}
	}
}
 
開發者ID:lj2000lj,項目名稱:BeeLogin,代碼行數:12,代碼來源:EventCanceler.java

示例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);
    }
}
 
開發者ID:SettingDust,項目名稱:Lore-Attributes-Reloaded,代碼行數:14,代碼來源:LoreEvents.java


注:本文中的org.bukkit.event.entity.EntityRegainHealthEvent.getEntity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。