Fixed Hunger/Food setting Closes #119

This commit is contained in:
Eric Stokes 2011-09-28 19:56:41 -06:00
parent ea6e94d99d
commit d97bbfb1b1
6 changed files with 4 additions and 19 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -126,6 +126,7 @@ public class InfoCommand extends MultiverseCommand {
message = new ArrayList<FancyText>();
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));

View File

@ -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 {

View File

@ -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