Don't know if you are still having issues but it could be this.
else if (getAPIContext().localPlayer().getHealthPercent()) {
eat();
In the ELSE IF at the bottom, this just gets the Health Percent, you will need to check it against a value like such.
else if (getAPIContext().localPlayer().getHealthPercent() <= 50) {
eat();
This will check if your health is less than 50 and then call the eat() function.