From d97bbfb1b1d24f7d8fd7a6c99548f2ea8ade1a3d Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Wed, 28 Sep 2011 19:56:41 -0600 Subject: [PATCH] Fixed Hunger/Food setting Closes #119 --- .../com/onarandombox/MultiverseCore/MVPlayerSession.java | 8 -------- .../java/com/onarandombox/MultiverseCore/MVWorld.java | 2 +- .../com/onarandombox/MultiverseCore/MultiverseCore.java | 1 + .../MultiverseCore/commands/InfoCommand.java | 1 + .../MultiverseCore/commands/ModifyCommand.java | 2 +- .../MultiverseCore/listeners/MVPlayerListener.java | 9 --------- 6 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVPlayerSession.java b/src/main/java/com/onarandombox/MultiverseCore/MVPlayerSession.java index def86ec9..15fdac12 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVPlayerSession.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVPlayerSession.java @@ -20,7 +20,6 @@ public class MVPlayerSession { private Long messageLast = 0L; // Timestamp for the Players last Alert Message. private Configuration config; // Configuration file to find out Cooldown Timers. - private int cachedHunger = 20; public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) { this.player = player; @@ -48,11 +47,4 @@ public class MVPlayerSession { return false; } } - - public void setCachedHunger() { - this.cachedHunger = this.player.getFoodLevel(); - } - public int getCachedHunger() { - return this.cachedHunger; - } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index 7ca5d4d3..a40e4f81 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -380,7 +380,7 @@ public class MVWorld { this.setMonsters(value); } else if (name.equalsIgnoreCase("memory") || name.equalsIgnoreCase("spawnmemory")) { this.setSpawnInMemory(value); - } else if (name.equalsIgnoreCase("hunger")) { + } else if ((name.equalsIgnoreCase("hunger")) || (name.equalsIgnoreCase("food"))){ this.setHunger(value); }else if (name.equalsIgnoreCase("weather") || name.equalsIgnoreCase("storm")) { this.setEnableWeather(value); diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 922323fb..880b2dff 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -208,6 +208,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow fake PVP pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning. + pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGE, this.entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this); pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java index 8fbf311f..9b484f19 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/InfoCommand.java @@ -126,6 +126,7 @@ public class InfoCommand extends MultiverseCommand { message = new ArrayList(); message.add(new FancyHeader("More World Settings", colors)); message.add(new FancyMessage("Weather: ", world.getWeatherEnabled() + "", colors)); + message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors)); message.add(new FancyMessage("Keep spawn in memory: ", world.getKeepSpawnInMemory() + "", colors)); message.add(new FancyHeader("PVP Settings", colors)); message.add(new FancyMessage("Multiverse Setting: ", world.getPvp().toString(), colors)); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java index b0ee8990..0b26177e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java @@ -27,7 +27,7 @@ enum Action { // Color == Aliascolor enum SetProperties { - alias, animals, monsters, pvp, scaling, aliascolor, color, respawn, currency, curr, price, scale, spawnmemory, memory, weather, storm, gamemode, mode, hunger + alias, animals, monsters, pvp, scaling, aliascolor, color, respawn, currency, curr, price, scale, spawnmemory, memory, weather, storm, gamemode, mode, hunger, food } public class ModifyCommand extends MultiverseCommand { diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index e8c53116..92055540 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -136,15 +136,6 @@ public class MVPlayerListener extends PlayerListener { MVWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName()); MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); event.setCancelled(checkWorldPermissions(fromWorld, toWorld, event.getPlayer())); - // Dunno If I like these... @fernferret -// if (toWorld != null && !toWorld.getHunger() && fromWorld != null && fromWorld.getHunger() && !event.isCancelled()) { -// // If to has hunger, and from doesn't, save the hunger -// this.plugin.getPlayerSession(event.getPlayer()).setCachedHunger(); -// } -// else if (toWorld != null && toWorld.getHunger() && fromWorld != null && !fromWorld.getHunger() && !event.isCancelled()) { -// // If from has hunger, and to doesn't, restore the hunger -// event.getPlayer().setFoodLevel(this.plugin.getPlayerSession(event.getPlayer()).getCachedHunger()); -// } } @Override