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