samutana

Create a plugin for minecraft smp version 1.21.11 and make it a admin plugin where a player has to be added in this admin plugin and he can not use creative or any gamemove swipe he can just do /whitelist add while not having to be operator

Kodari AI
KodariApr 18 at 6:12 pm 5,389 (v2)

I’ll create a restricted admin plugin where designated players can run /whitelist add without OP but are locked to survival gamemode.

AdminGuard
A controlled admin plugin for SMP servers. Server owners can designate non-OP admins who gain permission to run /whitelist add commands (executed via console internally) without any operator privileges. These admins are strictly prevented from switching gamemodes — any attempt to enter creative, spectator, or adventure mode is blocked and cancelled. Admins are managed via /adminguard add/remove/list, restricted to OPs and console only.

Plan:

  • AdminGuardPlugin — main plugin, registers commands and listeners, holds AdminManager

  • AdminManager — stores admin UUIDs in a YAML file, exposes add/remove/isAdmin methods

  • AdminCommandExecutor — handles /adminguard add|remove|list, OP/console only

  • GuardListener — intercepts PlayerCommandPreprocessEvent for /whitelist add relay and PlayerGameModeChangeEvent to block gamemode swaps

Here’s what was built:

  • AdminManager — persists admin UUIDs to admins.yml, with addAdmin, removeAdmin, and isAdmin methods

  • AdminCommandExecutor — /adminguard add|remove|list restricted to OPs and console only

  • GuardListener — cancels any gamemode change attempt (via event + command interception for /gamemode, /gm, /gmc, /gms, etc.) for registered admins, and intercepts /whitelist add <name> and dispatches it as the console so no OP is needed

  • Restricted admins receive chat feedback on all actions and restrictions

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 354
src/main/java/com/adminguard/AdminGuardPlugin.java
package com.adminguard;

import com.adminguard.command.AdminCommandExecutor;
import com.adminguard.listener.GuardListener;
import com.adminguard.manager.AdminManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class AdminGuardPlugin extends JavaPlugin {

    @Getter
    private AdminManager adminManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.adminManager = new AdminManager(this);
        getCommand("adminguard").setExecutor(new AdminCommandExecutor(this));
        getServer().getPluginManager().registerEvents(new GuardListener(this), this);
        getLogger().info("AdminGuard enabled.");
    }

    @Override
    public void onDisable() {
        if (adminManager != null) {
            adminManager.save();
        }
        getLogger().info("AdminGuard disabled.");
    }
}