I was wondering how to slowly heal people in a certain box. I want to create a certain area on my server that slowly adds hearts and hunger points to people every second they are in that area, but stop when they hit full points. Thanks
You could start a repeating task whenever a player moves into a certain area. When the task runs, you could heal and restore food at whatever rate you want. You could cancel the task for that player when they leave the area or get full health. I suppose you could perform a simple check every time the task runs to see if the player needs health, or you could check their health after the task is run, and cancel the task if needed.
Alternatively you could schedule a repeating task at the enabling of the plugin and foreach the online players, then check if the player is within a box of two Vector3s.
persudo code PHP: private $spot,$distancefunction task_construct(Location$point,numeric$distance = 3){setToSelf($point,$distance);}function task _onRun(){$lvPlayers = $spot->getLevel->getPlayers;foreach ($lvPlayers){if ($pos->dist($lvPlayer) <= $dist AND ($player->isNotFull OR $player->isFullyHeale)) $lvPlayer->healHp(0.1)->feedFood(0.1);}} some things are the things i wish i know are in PHP, some just wont work if you copy and paste it, some are just abstractions too simple and pointless to be pointed out either ways like i said again this is persudo code DO NOT TRY TO COPY IT INTO PMMP plugin warning aside that SHOULD work just register a repeating task for each points with a distance, the rate of task is the rate of healing IMO there's no reason to deregister it just to have a task to check and re register it or even worse register it onMove
that's another way of doing an area check, but i prefer passing on constructor as it feels more flexible and not just a hardcoded magicvalue