mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-23 02:55:52 +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();
|
Player p = (Player) event.getEntity();
|
||||||
MVWorld w = this.plugin.getWorldManager().getMVWorld(p.getWorld().getName());
|
MVWorld w = this.plugin.getWorldManager().getMVWorld(p.getWorld().getName());
|
||||||
if(w != null && !w.getHunger()) {
|
if(w != null && !w.getHunger()) {
|
||||||
// If the world has hunger set to false, do not let the level change
|
// If the world has hunger set to false, do not let the level go down
|
||||||
event.setFoodLevel(20);
|
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 fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
|
||||||
MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||||
event.setCancelled(checkWorldPermissions(fromWorld, toWorld, event.getPlayer()));
|
event.setCancelled(checkWorldPermissions(fromWorld, toWorld, event.getPlayer()));
|
||||||
if (toWorld != null && !toWorld.getHunger() && fromWorld != null && fromWorld.getHunger() && !event.isCancelled()) {
|
// Dunno If I like these... @fernferret
|
||||||
// If to has hunger, and from doesn't, save the hunger
|
// if (toWorld != null && !toWorld.getHunger() && fromWorld != null && fromWorld.getHunger() && !event.isCancelled()) {
|
||||||
this.plugin.getPlayerSession(event.getPlayer()).setCachedHunger();
|
// // 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
|
// else if (toWorld != null && toWorld.getHunger() && fromWorld != null && !fromWorld.getHunger() && !event.isCancelled()) {
|
||||||
event.getPlayer().setFoodLevel(this.plugin.getPlayerSession(event.getPlayer()).getCachedHunger());
|
// // If from has hunger, and to doesn't, restore the hunger
|
||||||
}
|
// event.getPlayer().setFoodLevel(this.plugin.getPlayerSession(event.getPlayer()).getCachedHunger());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user