Bukkit/Bukkit — pull request #372 by xZise (2011-10-10 15:06:39+00:00)
Title: Methods to apply exhaustion on your own

I added two methods to player to handle the hunger stuff more smooth. For example if you want that users have to “pay” for a teleportation with hunger it is easily possible with both methods.

`Player.getTotalExhaustion()` gets the total exhaustion of a player. For example if the total exhaustion is 100 the player could walk 10 km and will then have no hunger level/saturation level left.

`Player.exhaust(float)` exhausts a specific value from the player. This method is very useful if you need to exhaust values larger than 4. Instead of changing the `exhaustion` field directly this will apply instantly. For example if you set exhaustion to 8 it will need two ticks to apply completely, because it will reduce the exhaustion only by 4 in each tick. `Player.exhaust(float)` instead will recalculate all values with one call and already on the next tick the player won't be healed/starve.

You could exhaust at maximum the value of getTotalExhaustion() but you will instantly starve.

Both could be done by outside of CraftBukkit, but then it is impossible to change the hunger behavior without breaking the plugins.

Fabian