Nalla Yt

make a minecraft server plugin for 26.3 where ElrixNite never loses Operator using /op even if anyne do /deop elrixnite once the elrixnite join the server it get automatic op and make plugin and send me

Kodari AI
KodariNov 4 at 11:57 am 1
ElrixNiteGuard
A Minecraft server plugin for version 1.26.3 that ensures the player named ElrixNite permanently retains Operator status. The plugin intercepts all /deop commands targeting ElrixNite and prevents them from taking effect. Upon server startup and whenever ElrixNite joins the server, the plugin automatically grants Operator privileges. The plugin also monitors for any attempts to remove Operator status through commands or external plugins, immediately re-granting Operator if detected. It provides a simple configuration file to customize the protected player name and enable/disable automatic re-oping. The plugin uses event listeners to handle PlayerJoinEvent and command execution, ensuring ElrixNite always maintains full administrative access regardless of any deop attempts.

I’ll create a Java Paper plugin that grants ElrixNite operator status on join and blocks attempts to de-op them while online.

Created the plugin. It cancels de-op attempts against ElrixNite while they’re online and grants them operator status when they join (or when the plugin enables).

To download the JAR: click Compile in the top bar (on phone: ⋮ → Compile Project), click Compile, then click Download when it succeeds. This gives ElrixNite full server-operator permissions, so use it only on a server you control.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 99
src/main/java/com/kodari/elrixoperatorlock/ElrixOperatorLock.java
package com.kodari.elrixoperatorlock;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class ElrixOperatorLock extends JavaPlugin implements Listener {
    private static final String PROTECTED_NAME = "ElrixNite";

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        for (Player player : getServer().getOnlinePlayers()) {
            ensureOperator(player);
        }
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        ensureOperator(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
        if (isDeopCommandForProtected(event.getMessage())) {
            event.setCancelled(true);
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onServerCommand(ServerCommandEvent event) {
        if (isDeopCommandForProtected(event.getCommand())) {
            event.setCancelled(true);
        }
    }

    private void ensureOperator(Player player) {
        if (isProtected(player) && !player.isOp()) {
            player.setOp(true);
        }
    }

    private boolean isProtected(Player player) {
        return PROTECTED_NAME.equalsIgnoreCase(player.getName());
    }

    private boolean isDeopCommandForProtected(String commandLine) {
        String[] arguments = commandLine.trim().split("\\s+");
        if (arguments.length < 2) {
            return false;
        }

        String command = arguments[0];
        if (command.startsWith("/")) {
            command = command.substring(1);
        }
        int namespaceSeparator = command.lastIndexOf(':');
        if (namespaceSeparator >= 0) {
            command = command.substring(namespaceSeparator + 1);
        }

        return command.equalsIgnoreCase("deop") && arguments[1].equalsIgnoreCase(PROTECTED_NAME);
    }
}