What is the max number this can return ? I tried to check the apidocs but it seems they are down atm.
That was I was thinking, but it doesn't seem to work that way. PHP: if(player.getFoodLevel() != 20) {player.setFoodLevel(player.getFoodLevel() + 3);ItemStack hand = player.getItemInHand();hand.setAmount(hand.getAmount() - 1);}
I think that it returns a max of 10 because that's how many show on the food bar. I'm not sure and it doesn't show on the apidocs either. Maybe make a test plugin and spawn yourself a lot of food, eat it and then do a command for it to broadcast your food level?
I have been trying exactly that. This method i have above is always called. So i tried setFoodLevel(20); and it fills the hunger bar. It may be a bug with getFoodLevel() :/ EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Why not just run some debug tests, and have it send a message to the player telling them what their hunger is, so you can log in and see what 'getFoodLevel()' returns when you're at full ,etc.
Nothing wrong with the getFoodLevel() method its working fine for me. The max amount of food a player can have is 20.
I highly doubt something as simple as getFoodLevel() would ever be buggy. Like someone else said, just run some debug tests by sending yourself a message which contains what getFoodLevel() returns.