Souhardya Karmakar

AdminSuite (plugin name: "souhardya protection++") provides staff administration tools, conservative movement and combat monitoring, ore-mining alerts and logs, and server-configured resource-pack enforcement for a Paper/Spigot server. Keep RAM consumption very low.

📎 1 file 2,546 chars
📄
pasted-code-1791462410729.txt
txt 29 lines
▶
Create a complete, single-file Java plugin for a Paper/Spigot 1.20+ Minecraft server. The plugin should be named "AdminSuite".

Include the following core systems and features:

1. PERMISSIONS & ADMIN SYSTEM
- Restrict ALL plugin commands to players/staff with the permission node "adminsuite.admin" (or OP status).
- Command: /admin - Opens a chest GUI menu displaying server status (TPS, online player count, total RAM usage) and quick toggles.
- Command: /vanish (or /v) - Toggles full staff invisibility from normal players, hides join/leave messages, and prevents physical pickup of dropped items while vanished.
- Command: /staffchat [message] (or /sc) - A dedicated internal chat channel visible only to staff members with "adminsuite.admin".
- Command: /invsee  - Allows staff to view and interact with another player's live inventory.
- Command: /freeze  - Locks a target player in place, preventing movement, command execution, and chat until unfrozen.

2. LIGHTWEIGHT MOVEMENT & COMBAT ANTI-CHEAT
- Movement Checks: Detect impossible movement speeds, fly hacks, and air-walking. Teleport offending players back to their last valid location and send an alert message to online staff.
- Reach & KillAura Checks: Check player attack distance (flag attacks exceeding 3.5 blocks) and attack frequency (cps limit). Log flagged infractions directly to staff chat with player name, ping, and check type.

3. ORE/X-RAY MONITORING SYSTEM
- Ore Mining Tracker: Log diamond, netherite, and emerald ore mining activity per player in real-time.
- Alert Threshold: If a player mines more than 10 diamond/netherite ores within 60 seconds, trigger a staff alert: "[AntiXray] Player {player} mined {count} ores in 60s! Click to /tp".
- Command: /xraylogs  - View total ores mined by a specific player along with their timestamp log.

4. SERVER RESOURCE PACK ENFORCER
- On player join, force the client to download a server resource pack via event listener player.setResourcePack(url, hash).
- If the player declines or fails to download the pack, kick them after 10 seconds with the message: "You must accept the custom resource pack to play on this server."

TECHNICAL REQUIREMENTS:
- Use clean, modern Spigot/Paper API events (AsyncPlayerChatEvent, PlayerMoveEvent, EntityDamageByEntityEvent, BlockBreakEvent, PlayerJoinEvent, PlayerResourcePackStatusEvent).
- Fully annotated with @EventHandler and registered properly in JavaPlugin onEnable().
- Provide the complete plugin.yml configuration content alongside the Java class.
Kodari AI
KodariOct 8 at 12:37 pm 14
AdminSuite
AdminSuite is a lightweight staff administration plugin providing essential moderation tools for Paper/Spigot 1.20+ servers. It includes a comprehensive permission system with /admin GUI showing server status, /vanish for invisible staff monitoring, /staffchat for private staff communication, /invsee for inventory inspection, and /freeze for player lockdown. The plugin features a lightweight anti-cheat detecting impossible movement, fly hacks, and killaura with automatic teleportation and staff alerts. An ore mining tracker monitors diamond, netherite, and emerald collection with real-time threshold alerts and /xraylogs command. Resource pack enforcement forces clients to accept server packs or face automatic kick after timeout. All systems use modern Paper API events with minimal RAM footprint.

I’m writing the three AdminSuite files now.

AdminSuite is built as one main class plus plugin.yml and config.yml.

  • Commands: /admin opens a panel with TPS, online count, memory, and vanish and alert toggles. /vanish (/v) hides you from non-staff, silences your join and quit messages, and blocks item pickup. /staffchat (/sc) messages only staff. /invsee opens the target’s live inventory. /freeze toggles a lock on movement, commands, and chat. /xraylogs shows ore totals and recent timestamps. Every command requires adminsuite.admin or OP.

  • Movement checks: speed, hover/air-walk, and fly-style checks teleport the player back to their last valid spot. Elytra, vehicles, creative, flight, levitation, teleports, damage, and riptide get grace periods.

  • Combat checks: a 3.5-block reach limit and a 20-hits-per-second CPS limit. Hits are logged to staff with name, ping, and check type. Attacks are not cancelled.

  • Ore alerts: diamond and netherite (ancient debris) mining above 10 in 60 seconds sends the staff alert with a clickable /tp.

  • Resource pack: on join the pack is sent with the SHA-1 from config.yml. A declined or failed download starts the 10-second kick.

Setup notes:

  • Set resource-pack.url and resource-pack.sha1 in config.yml. Leaving the URL empty turns enforcement off.

  • The plugin is named AdminSuite in plugin.yml because Bukkit rejects names containing +.

  • Speed, hover, and CPS thresholds are conservative starting points. Clients that spoof onGround can evade the air checks, and very fast legitimate effects such as Soul Speed may need a higher limit.

  • Per-player state is removed on quit. Ore logs are capped at 100 entries per player and live in memory, so they reset on restart.

  • AsyncPlayerChatEvent is deprecated on newer Paper builds, but it still works as you requested.

Kodari can make mistakes. Review important code before using.
Files
src
Code
3 775
src/main/java/com/example/adminsuite/AdminSuite.java
package com.example.adminsuite;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import org.bukkit.event.player.PlayerRiptideEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitTask;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public final class AdminSuite extends JavaPlugin implements Listener, CommandExecutor {

    private static final String ADMIN_PERMISSION = "adminsuite.admin";
    private static final double MAX_HORIZONTAL_SPEED = 9.0;
    private static final double SPEED_TOLERANCE = 0.6;
    private static final int HOVER_TICK_LIMIT = 25;
    private static final double REACH_LIMIT = 3.5;
    private static final int CPS_LIMIT = 20;
    private static final long ALERT_COOLDOWN_MS = 3000L;
    private static final long TELEPORT_GRACE_MS = 1500L;
    private static final long DAMAGE_GRACE_MS = 1500L;
    private static final long RIPTIDE_GRACE_MS = 3000L;
    private static final long ORE_WINDOW_MS = 60000L;
    private static final int ORE_THRESHOLD = 10;
    private static final long ORE_ALERT_COOLDOWN_MS = 30000L;
    private static final int ORE_LOG_CAP = 100;
    private static final long PACK_KICK_DELAY_TICKS = 200L;
    private static final String PACK_KICK_MESSAGE = "You must accept the custom resource pack to play on this server.";

    private final Set<UUID> vanished = ConcurrentHashMap.newKeySet();
    private final Set<UUID> frozen = ConcurrentHashMap.newKeySet();
    private final Set<UUID> alertsMuted = ConcurrentHashMap.newKeySet();
    private final Map<UUID, PlayerState> states = new HashMap<>();
    private final Map<UUID, OreStats> oreStats = new HashMap<>();
    private final Map<UUID, BukkitTask> pendingKicks = new HashMap<>();
    private String packUrl;
    private byte[] packHash;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadResourcePack();
        Bukkit.getPluginManager().registerEvents(this, this);
        for (String name : new String[]{"admin", "vanish", "staffchat", "invsee", "freeze", "xraylogs"}) {
            PluginCommand command = getCommand(name);
            if (command != null) {
                command.setExecutor(this);
            }
        }
    }

    private void loadResourcePack() {
        packUrl = null;
        packHash = null;
        String url = getConfig().getString("resource-pack.url", "").trim();
        String sha1 = getConfig().getString("resource-pack.sha1", "").trim();
        if (url.isEmpty()) {
            return;
        }
        byte[] hash = parseSha1(sha1);
        if (hash == null) {
            getLogger().warning("resource-pack.sha1 must be a 40-character hex SHA-1. Resource pack enforcement is disabled.");
            return;
        }
        packUrl = url;
        packHash = hash;
    }

    private static byte[] parseSha1(String hex) {
        if (hex.length() != 40) {
            return null;
        }
        byte[] out = new byte[20];
        for (int i = 0; i < 20; i++) {
            int high = Character.digit(hex.charAt(i * 2), 16);
            int low = Character.digit(hex.charAt(i * 2 + 1), 16);
            if (high < 0 || low < 0) {
                return null;
            }
            out[i] = (byte) ((high << 4) | low);
        }
        return out;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(color("&cThis command is for players only."));
            return true;
        }
        Player player = (Player) sender;
        if (!isStaff(player)) {
            player.sendMessage(color("&cYou do not have permission to use this command."));
            return true;
        }
        switch (command.getName().toLowerCase(Locale.ROOT)) {
            case "admin":
                openAdminPanel(player);
                break;
            case "vanish":
                toggleVanish(player);
                break;
            case "staffchat":
                handleStaffChat(player, args);
                break;
            case "invsee":
                handleInvsee(player, args);
                break;
            case "freeze":
                handleFreeze(player, args);
                break;
            case "xraylogs":
                handleXrayLogs(player, args);
                break;
            default:
                return false;
        }
        return true;
    }

    private void handleStaffChat(Player sender, String[] args) {
        if (args.length == 0) {
            sender.sendMessage(color("&cUsage: /staffchat <message>"));
            return;
        }
        String line = color("&c[StaffChat] &f" + sender.getName() + "&7: &f" + String.join(" ", args));
        for (Player online : Bukkit.getOnlinePlayers()) {
            if (isStaff(online)) {
                online.sendMessage(line);
            }
        }
    }

    private void handleInvsee(Player staff, String[] args) {
        if (args.length != 1) {
            staff.sendMessage(color("&cUsage: /invsee <player>"));
            return;
        }
        Player target = Bukkit.getPlayerExact(args[0]);
        if (target == null) {
            staff.sendMessage(color("&cPlayer &f" + args[0] + " &cis not online."));
            return;
        }
        staff.openInventory(target.getInventory());
        staff.sendMessage(color("&7Viewing &f" + target.getName() + "&7's inventory. Changes are live."));
    }

    private void handleFreeze(Player staff, String[] args) {
        if (args.length != 1) {
            staff.sendMessage(color("&cUsage: /freeze <player>"));
            return;
        }