Basically what the title says, I use hunger as Stamina on my server, I would like a plugin that regenerates half a food bar each 2 seconds, or configurable
I will attempt to do this, Let me research what your asking first. Oh and use the proper format. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
So it always regenerates half a hunger every 2 seconds? I'll get right to it, should be easily configurable as well.
Done! Currently it is very simple; the two seconds are counted on the server, instead of being individual for each player. This is mostly because it's a small and unnoticeable trade-off for efficiency. * <Edit by Moderator: Redacted mediafire url> * Source repository I hope it works well for you! Keep in mind that in the config generated, it counts the delay in seconds. I defaulted it to 2 seconds, since that's what you asked for. Edit: Oh, by the way, it currently logs every single regeneration of hunger. I can remove this if it's a problem, it was mostly meant for debugging.
Ill test it, thanks man! It wokrs! EDIT by Moderator: merged posts, please use the edit button instead of double posting.
EternalFacepalm Just FYI for those looking back at this and a word of warning: #1 you can't reference the player object in an asynchronous thread, nor can you modify the hunger value. The plugin as is, will potentially crash out the server or cause problems. #2 don't keep debug logging enabled, you should remove the per-player log spam as it causes a bunch of unnecessary writes to the log file every single interval for any player that has used stamina.
Well, I didn't notice the crashing, and daniel isn't complaining, so I don't really see what you mean. I know I should've disabled the logging, but the guy requesting it didn't seem to have any issues with it, so I just let it be. Not everyone has WG.
EternalFacepalm - it wont necessarily be immediately noticable. But if anything else at all increases/reduces hunger while your plugin does it breaks. End of argument. The result can be a wide variety of problems, from server crash, to be as tame as invalid hunger values and the hunger change not doing anything that tic. Regardless, it's a bug. You can't modify the player object safely in any thread other than the main one.