Solved Hunger loss multiplier - get amount of food level change

Discussion in 'Spigot Plugin Development' started by joeleoli, Jun 25, 2016.

  1. I'm trying to make an easy configuration to setup game modes across my servers by using a core plugin with many options you can choose from.

    I'm trying to make it so you can change how hunger works, such as losing hunger faster, eating food adds specific hunger back, if its disabled, etc...

    The thing I'm stuck on is the FoodLevelChangeEvent and getting how much hunger has been lost when this event was called so I can make this multiplier work.

    Code:
    Code (Text):
    public class FoodLevelChange implements Listener {

        @EventHandler
        public void onFoodLevelChange(FoodLevelChangeEvent event) {
            if(Core.config.getConfig().getBoolean("settings.hunger.enabled")) {
                if(Core.config.getConfig().getInt("settings.hunger.loss-multiplier") == 0) {
                    return;
                }
             
                event.setFoodLevel(event.getFoodLevel() - (GET AMOUNT LOST * Core.config.getConfig().getInt("settings.hunger.loss-multiplier")));
            }
        }
     
    }
     
  2. When you lose food (vanilla, that is) you always lose 0.5 food level.
     
  3. Yes but I need to be able to get their food level before they lose it and then set their food level to 0.5 times the multiplier.
     
  4. Current + 0.5?