Add foodLevel game rule

This commit is contained in:
Daniel Saukel 2020-04-05 15:08:03 +02:00
parent dfda93f664
commit 1928fafdfe
2 changed files with 5 additions and 1 deletions

View File

@ -77,6 +77,10 @@ public class GameRule<V> {
* The Vanilla difficulty.
*/
public static final GameRule<Difficulty> DIFFICULTY = new GameRule<>(Difficulty.class, "difficulty", Difficulty.NORMAL);
/**
* If the food levels of the players change.
*/
public static final GameRule<Boolean> FOOD_LEVEL = new GameRule<>(Boolean.class, "foodLevel", true);
/**
* If players may fly.
*/

View File

@ -217,7 +217,7 @@ public class DPlayerListener implements Listener {
public void onFoodLevelChange(FoodLevelChangeEvent event) {
GameWorld gameWorld = plugin.getGameWorld(event.getEntity().getWorld());
if (gameWorld != null) {
if (!gameWorld.isPlaying()) {
if (!gameWorld.isPlaying() || !gameWorld.getDungeon().getRules().getState(GameRule.FOOD_LEVEL)) {
event.setCancelled(true);
}
}