Solved Changing a player's max health

Discussion in 'Spigot Plugin Help' started by alifezithu, Nov 25, 2021.

  1. Hello, I want to make a plugin that has custom potions I already added some I'm having an issue with one potion.

    Code (Java):
    else if (item.isSimilar(Utils.getItemManager().potionDoubleHealth)) {
                    if (player.getMaxHealth() == 20.0) {
                        player.sendMessage("You may now have * 2 health (health times 2) :)");
                        BukkitScheduler sched = Bukkit.getScheduler();
                        sched.runTaskLater(plugin, new Runnable() {
                            public void run() {
                                player.sendMessage("You may no longer have * 2 health (health times 2) :(");
                        }, 600L);
    But this doesn't work.
    I tried using the player.getAttribute() way and it didn't work either.

    Can someone help?

    Btw, I'm on 1.17
  2. what about health boost effect?
    I dont think you can change the max health
    so use health boost effect
  3. Thank you for the help!
  4. Not sure why you are doing
    Code (Text):
    Why not just do player.setHealth(40);

  5. Cause it wont work since Max health is 20
  6. Also, there's no errors on the console when I drink the potion in Minecraft.