sensei_wu_gaming

Make a plugin, that lets me become immortal (leaving me on half of a heart), but when holding a totem, it ignores it Commands are /immortal {PLAYERNAME} to become immortal, and /mortal {PLAYERNAME} to become back mortal For Paper 1.21.11

Kodari AI
KodariSep 5 at 9:19 am 1
ImmortalToggle
ImmortalToggle is a Paper 1.21.11 plugin that grants players immortality by locking their health at half a heart. Admins use /immortal {PLAYERNAME} to make a player immortal and /mortal {PLAYERNAME} to revert them. Immortal players cannot die from damage, but the plugin ignores totems of undying, preventing totem consumption while immortal. The plugin tracks immortal players persistently, applies damage cancellation, and ensures health stays at half a heart. It includes permission checks, command tab completion, and configurable messages for seamless server administration.

Created the Paper 1.21.11 plugin with:

  • /immortal <PLAYERNAME> — keeps the player at half a heart.

  • /mortal <PLAYERNAME> — restores normal mortality.

  • Totems are ignored for immortal players.

  • Immortal player UUIDs persist in config.yml.

  • Online-player tab completion.

  • immortal.manage permission, defaulting to server operators.

sensei_wu_gaming

ok, so when im immortal, i can lose a totem, but cant die, right?

Kodari AI
KodariSep 5 at 9:20 am 1

No—the current implementation is intended to not consume the totem at all while the player is immortal.

Immortal players remain at half a heart, damage is prevented, and a held Totem of Undying is ignored rather than activated or lost. Once /mortal <PLAYERNAME> is used, normal totem behavior returns.

sensei_wu_gaming

make it so when im immortal i can lose totems, but cant die

Kodari AI
KodariSep 5 at 9:21 am 1
  • Update immortal damage handling so lethal damage can trigger and consume a held totem.

  • Keep the player alive at half a heart after the totem activation, while still preventing death without a totem.

  • Preserve the existing commands and persistence behavior.

Updated. Immortal players now:

  • Stay at half a heart when damaged.

  • Allow lethal damage to activate a held totem.

  • Consume the totem normally from the main hand or off-hand.

  • Survive without a totem because lethal damage is cancelled.

  • No longer have totem resurrection cancelled while immortal.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 238
src/main/java/com/kodari/immortal/ImmortalPlugin.java
package com.kodari.immortal;

import java.util.Objects;
import org.bukkit.plugin.java.JavaPlugin;

public final class ImmortalPlugin extends JavaPlugin {

    private ImmortalManager immortalManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        immortalManager = new ImmortalManager(this);
        immortalManager.load();

        ImmortalCommand command = new ImmortalCommand(immortalManager);
        Objects.requireNonNull(getCommand("immortal")).setExecutor(command);
        Objects.requireNonNull(getCommand("immortal")).setTabCompleter(command);
        Objects.requireNonNull(getCommand("mortal")).setExecutor(command);
        Objects.requireNonNull(getCommand("mortal")).setTabCompleter(command);

        getServer().getPluginManager().registerEvents(new ImmortalListener(immortalManager), this);
    }

    public ImmortalManager getImmortalManager() {
        return immortalManager;
    }
}