mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Don't set the hunger, only cancel the events
This commit is contained in:
parent
268b272f4d
commit
65dce752d4
@ -45,8 +45,10 @@ public class MVEntityListener extends EntityListener {
|
||||
Player p = (Player) event.getEntity();
|
||||
MVWorld w = this.plugin.getWorldManager().getMVWorld(p.getWorld().getName());
|
||||
if(w != null && !w.getHunger()) {
|
||||
// If the world has hunger set to false, do not let the level change
|
||||
event.setFoodLevel(20);
|
||||
// If the world has hunger set to false, do not let the level go down
|
||||
if(event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,14 +132,15 @@ 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()));
|
||||
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());
|
||||
}
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user