本文整理匯總了Java中org.bukkit.event.entity.FoodLevelChangeEvent.setFoodLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java FoodLevelChangeEvent.setFoodLevel方法的具體用法?Java FoodLevelChangeEvent.setFoodLevel怎麽用?Java FoodLevelChangeEvent.setFoodLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.FoodLevelChangeEvent
的用法示例。
在下文中一共展示了FoodLevelChangeEvent.setFoodLevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
Game game = Skywars.getInstance().getGame(player);
if (game != null && game.getGamePlayer(player) != null) {
GamePlayer gamePlayer = game.getGamePlayer(player);
if (!(game.isState(Game.GameState.ACTIVE) || game.isState(Game.GameState.DEATHMATCH))) {
if (gamePlayer.isTeamClass()) {
if (gamePlayer.getTeam().isPlayer(player)) {
event.setFoodLevel(25);
event.setCancelled(true);
}
} else {
if (gamePlayer.getPlayer() == player) {
event.setFoodLevel(25);
event.setCancelled(true);
}
}
}
}
}
}
示例2: onPlayerHunger
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
private void onPlayerHunger(FoodLevelChangeEvent event) {
if (!(event.getEntity() instanceof Player))
return;
Player p = (Player)event.getEntity();
IArenaPlayer player = ArenaPlayer.get(p);
if (player == null)
return;
IArena arena = player.getArena();
if (arena == null)
return;
// get settings
IContextSettings settings = player.getContextSettings();
if (settings == null)
return;
// prevent hunger
if (!settings.isHungerEnabled()) {
event.setFoodLevel(20);
event.setCancelled(true);
}
}
示例3: onFoodRegen
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGH)
public void onFoodRegen(FoodLevelChangeEvent 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.getFoodLevel() != 20){
e.setFoodLevel(20);
}
}
}
}
}
示例4: onHunger
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onHunger(FoodLevelChangeEvent event) {
if (isSpectating((Player) event.getEntity())) {
event.setCancelled(true);
event.setFoodLevel(20);
}
}
示例5: handleHungerChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleHungerChange(final FoodLevelChangeEvent event) {
if(event.getEntity() instanceof Player) {
int oldFoodLevel = ((Player) event.getEntity()).getFoodLevel();
event.setFoodLevel(oldFoodLevel);
}
}
示例6: onFood
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFood(FoodLevelChangeEvent e) {
KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getEntity());
if(player != null) {
if(player.getKingdom().getType() == KingdomType.GEEN) {
e.setFoodLevel(20);
}
}
}
示例7: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setFoodLevel(20);
Gamer g = Gamer.get(event.getEntity().getName());
if (g.getVariable("arena") != null) {
Arena a = (Arena) g.getVariable("arena");
if (a.getState() == ArenaState.STARTED)
return;
}
((Player) event.getEntity()).setHealth(20);
}
示例8: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (Scheduler.getState() != State.PVP) {
event.setFoodLevel(20);
event.setCancelled(true);
return;
}
}
示例9: checkFood
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOW)
public void checkFood(FoodLevelChangeEvent event)
{
Area a = getArea(new Loc(event.getEntity().getLocation(),false));
if(a != null && !a.getAllowHunger())
{
event.setFoodLevel(20);
//event.setCancelled(true);
}
}
示例10: onFeed
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFeed(FoodLevelChangeEvent e) {
if (BlockParty.onFloorPlayers.containsKey(e.getEntity().getName())) {
e.setFoodLevel(20);
}
if (BlockParty.inLobbyPlayers.containsKey(e.getEntity().getName())) {
e.setFoodLevel(20);
}
}
示例11: onHungerChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onHungerChange(FoodLevelChangeEvent event) {
MMPlayer player = MMGames.getPlugin().getPlayer(event.getEntity().getName());
if (!(player.inGame() && GameSettings.HUNGER)) {
event.setFoodLevel(20);
}
}
示例12: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (event.getEntity().getWorld().getName().equals("lobby")) {
event.setCancelled(true);
event.setFoodLevel(20);
}
}
示例13: foodControl
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void foodControl(FoodLevelChangeEvent event) {
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
int min = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath());
int max = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath());
if (event.getFoodLevel() < min) {
event.setFoodLevel(min);
}else {
event.setFoodLevel(max);
}
}
}
}
示例14: noHunger
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void noHunger(FoodLevelChangeEvent e){
e.setCancelled(true);
e.setFoodLevel(20);
}
示例15: onFoodLevelChange
import org.bukkit.event.entity.FoodLevelChangeEvent; //導入方法依賴的package包/類
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setFoodLevel(20);
if (event.getEntity() instanceof Player)
((Player) event.getEntity()).setHealth(20);
}