How to heal a player to max health?

So, I’m really new to plugin development, and I’ve learned that youtube tutorials are somewhat outdated already. Some things I’ve figured out, but the getMaxHealth() method no longer works. What can I use instead?

Line of code:
DataTransactionResult res = target.offer(target.getHealthData().setHealth(target.getHealthData().getMaxHealth()));

Only the “getMaxHealth()” part has a red line under it.

How about making it simpler to read:

target.offer(Keys.HEALTH, target.get(Keys.MAX_HEALTH).get());
1 Like

Heh, thank you =) I’m still really new to coding in general, so I need to learn things slowly. Your fix however, still seems to cause an error at the last “.get”.
Error: The method get() is undefined for the type Key< MutableBoundedValue< Double>>

Any suggestion?

Did you copy the code correctly? maybe you missed a bracket.

I think it’s correct

DataTransactionResult res = target.offer(Keys.HEALTH, target.get(Keys.MAX_HEALTH.get()));

That’s the new line of code. The last “.get” has a red line under it.

Yep, brackets are wrong. Should be:

Oh god, I feel so dumb now lol. Thank you so much ^^