vayyy_25
📎 1 file 12,823 chars
📄
pasted-code-1794664411037.txt
txt 151 lines
▶
# PROJECT: VAYYY - ULTIMATE PROFESSIONAL MINECRAFT ADMIN, GUI, TAB & SCOREBOARD PLUGIN

Act as a Lead Minecraft Plugin Developer, Software Architect, and Senior UI/UX Designer.

Your task is to design and develop a complete, production-ready, enterprise-grade Minecraft server management plugin named **Vayyy**. 

The plugin must feel like a handcrafted, bespoke, premium server operating system—**NOT** an AI-generated template. Every GUI layout, item icon choice, color code, scoreboard line, and chat message must look intentional, logical, and human-crafted.

---

## 1. CORE DEVELOPMENT & ANTI-AI QUALITY RULES

Before and during implementation:
- **Official Branding:** Plugin name, prefix, package structure (`me.vayyy.admin` or `com.vayyy.system`), and permissions (`vayyy.*`) must strictly use **Vayyy**.
- **Logical & Contextual GUI Icons (STRICT RULE):** NEVER use random, nonsensical, or ugly items for GUI buttons (e.g., NEVER use Cactus, Dirt, Sponge, or Rotten Flesh for admin menus). Every icon MUST semantically match its function:
  - *System Core / Header:* `NETHER_STAR` or `BEACON`
  - *Moderation / Ban / Kick:* `NETHERITE_AXE`, `IRON_BARS`, `ANVIL`, or `SHIELD`
  - *Mute / Chat Control:* `SCULK_SHRIEKER`, `WRITABLE_BOOK`, or `PAPER`
  - *Warn:* `BLAZE_POWDER` or `RECOVERY_COMPASS`
  - *Teleportation:* `ENDER_PEARL`, `ENDER_EYE`, or `COMPASS`
  - *Player Management:* `PLAYER_HEAD` or `TOTEM_OF_UNDYING`
  - *Server Utilities / Maintenance:* `COMPARATOR`, `REDSTONE_TORCH`, or `COMMAND_BLOCK_MINECART`
  - *Time / Weather:* `CLOCK`, `SUNFLOWER` (Day), `HEART_OF_THE_SEA` (Rain)
  - *Staff Tools / Vanish:* `SPYGLASS`, `AMETHYST_SHARD`, or `FEATHER`
  - *Confirm / Execute:* `LIME_DYE` or `EMERALD`
  - *Cancel / Close / Back:* `RED_DYE`, `BARRIER`, or `ARROW`
- **No AI Hallmarks:** Avoid robotic, repetitive lore, messy ASCII art, or chaotic rainbow colors. Keep typography crisp, symmetrical, and clean.
- **Zero Placeholders:** Every button, toggle, chat-input flow, and config option must be 100% functional.

---

## 2. VISUAL IDENTITY & "CYBER X YELLOW" GUI DESIGN SYSTEM

All GUIs across the entire plugin must share a unified **Modern Cyber x Yellow** aesthetic—sleek, dark, high-tech, and professional (not tacky).

### Color Palette (Configurable in `theme.yml` / `gui.yml`):
- **Primary Frame:** Matte Obsidian / Dark Slate (`BLACK_STAINED_GLASS_PANE` & `GRAY_STAINED_GLASS_PANE`).
- **Primary Brand Accent (Cyber Yellow):** Electric Yellow & Warm Gold (`#FCEE09`, `#FFD000`, `#FFAA00`) with `YELLOW_STAINED_GLASS_PANE` corner/header highlights.
- **Secondary Tech Accent:** Cyber Cyan (`#00F0FF`) for data readouts, coordinates, and stats.
- **Action States:** Neon Emerald (`#00E676`) for Confirm/ON, Crimson Red (`#FF2A54`) for Cancel/OFF/Danger.

### Mandatory Top Header Branding ("VAYYY"):
Every GUI window must prominently feature the **Vayyy** Cyber-Yellow header:
- **GUI Title Format:** `⚡ VAYYY ┃ SYS // `
- **Row 1 (Slots 0–8) Header Bar:**
  - Outer slots (`0, 1, 2, 6, 7, 8`): `BLACK_STAINED_GLASS_PANE` (named `▪`).
  - Accent slots (`3, 5`): `YELLOW_STAINED_GLASS_PANE` (named `<#FFD000>▪`).
  - **Slot 4 (Top Center Banner Emblem):** `NETHER_STAR` or `BEACON` named `VAYYY // SYSTEM CORE` with clean lore showing the current menu module, server TPS, and operator name.

### Item Lore Standard:
Use clean, structured HUD-style lore without clutter:
- Divider: `⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯`
- Status/Info: `▪ Status: `
- Action Prompt: `<#FCEE09>▸ Click to configure`

---

## 3. ROLE-BASED HELP COMMAND (`/vayyy help`)

Implement a smart, dynamic help system via `/vayyy help` (and `/help` alias if configured).
- **Dynamic Permission Filtering (POV System):**
  - **Non-OP / Regular Member POV:** When a regular player runs `/vayyy help`, ONLY display commands they actually have permission to use (e.g., general member commands, `/msg`, `/reply`, `/tpr`, or public info commands). Completely hide all admin, staff, and moderation commands so regular players do not see restricted tools.
  - **OP / Staff / Admin POV:** When an OP or player with `vayyy.admin` / staff permissions runs `/vayyy help`, display the **Member Commands** section PLUS a clearly separated, Cyber-Yellow styled **Admin & Moderation Commands** section showing all administrative commands they have access to.
- Support hover text and click-to-suggest command actions in chat, plus an optional `/vayyy help` interactive GUI view.

---

## 4. GUI-FIRST COMMAND ARCHITECTURE & MODERATION FLOW

### Strict Rule for Commands vs. GUIs:
1. **GUI-Triggered Commands (Mandatory):** Every administrative, moderation, server utility, and management command MUST open an interactive GUI.
   - Examples: `/vayyy` (or `/admin`), `/maintenance`, `/kick `, `/mute `, `/ban `, `/warn `, `/tp` (menu), `/time`, `/weather`, `/manage `, `/serverinfo`.
2. **Direct Execution Commands (Exceptions):** Direct player-to-player or urgent chat commands execute immediately via text without opening a GUI.
   - Examples: `/adminmsg  `, `/adminmsgall `, `/adminreply `, `/staffchat `, `/broadcast `, `/vayyy reload`, `/vayyy help`.

### Interactive Punishment Builder GUIs (`/kick`, `/mute`, `/warn`, `/ban`):
Running `/mute `, `/kick `, `/warn `, or `/ban ` MUST NOT punish the player immediately via command arguments. Instead, it opens a **Punishment Configuration GUI** for that target player containing:
- **Slot 13 (Target Head):** Shows the target player's skull, status, and past infractions.
- **Set Reason Button (`WRITABLE_BOOK`):** Clicking this closes the GUI, prompts the admin in chat (with an on-screen Title: `<#FCEE09>TYPE REASON IN CHAT` and option to type `cancel`), intercepts their next chat message silently, and automatically reopens the GUI with the new Reason displayed in the button's lore. Also support quick-select preset reasons.
- **Set Duration / Time Button (`CLOCK` - for Mute & Ban):** Opens duration presets (15m, 1h, 1d, 7d, 30d, Permanent) or custom time input, updating the GUI lore before execution.
- **Confirm & Execute Button (`EMERALD`):** Executes the punishment only when Reason (and Duration) are set, saves to database, notifies staff/target, and logs the action.
- **Cancel Button (`BARRIER`):** Aborts and returns to the previous menu.

### Additional Moderation & Utility GUIs:
- **Main Dashboard (`/vayyy` or `/admin`):** Symmetrical 54-slot GUI with 7 categories: Moderation, Teleportation, Player Management, Communication, Server Utilities, Staff Tools, Settings.
- **Maintenance Mode (`/maintenance`):** Opens a dedicated GUI with an ON/OFF toggle switch (`LIME_DYE` / `GRAY_DYE`), a button to edit the Maintenance Reason/MOTD via chat input, and a Whitelist Manager GUI.
- **Teleportation GUI (`/tp`):**
  - *Coordinate Teleport:* Interactive GUI builder where admins set X, Y, Z, and World via chat/anvil input and click Confirm.
  - *Player Teleport:* Paginated GUI of online player heads (`PLAYER_HEAD`) with lore stats; clicking teleports or opens quick TP options (`/tphere`, `/tpall`, `/back` also supported).
- **Player Management (`/manage `):** GUI with logical icons for Heal (`GOLDEN_APPLE`), Feed (`COOKED_BEEF`), Gamemode selector (`COMPASS`), Fly toggle (`FEATHER`), God mode (`TOTEM_OF_UNDYING`), Clear Inventory (`LAVA_BUCKET` with confirmation GUI), Inventory/EnderChest Inspector (`CHEST` / `ENDER_CHEST`), and Freeze (`PACKED_ICE`).
- **Environment & Server Info (`/environment`, `/serverinfo`):** GUIs for Day/Night, Weather, live TPS/RAM/Player count, and Clear Lag with confirmation.

---

## 5. PROFESSIONAL TABLIST & SCOREBOARD SYSTEM (TAB-INSPIRED)

Implement a built-in, flicker-free, high-performance **Tablist (Header/Footer + Player Sorting/Prefixes)** and **Sidebar Scoreboard** system inspired by the industry-standard `TAB` plugin.

### Tablist System:
- **Customizable Header & Footer:** Styled in the **Vayyy** Cyber x Yellow theme with animated or clean static bars, displaying server name, online count, ping, TPS, and current world.
- **Player List Formatting:** Display clean prefixes/suffixes (supporting LuckPerms via Vault/API if present, or built-in Vayyy permission groups like `ADMIN`, `STAFF`, `MEMBER`) and sort players in the Tablist by rank hierarchy.
- **Vanish Integration:** Hidden/vanished staff indicators in Tablist for fellow staff, hidden from regular players.

### Sidebar Scoreboard System:
- **Flicker-Free Rendering:** Use modern packet or team-based scoreboard updates so lines never flicker.
- **Clean Cyber x Yellow Layout:**
  - Title: `⚡ VAYYY`
  - Clean, minimal lines showing Player Name/Rank, Online Players, Ping, Server Status (or Maintenance indicator for staff), and footer website/IP.
- **Per-Player Toggle & Staff Mode:** Allow players to toggle their scoreboard (`/sb` or `/scoreboard`) and optionally show an enhanced Staff Scoreboard view when an admin is in Staff/Vanish mode.
- **100% Configurable:** Every line, title, update interval, and toggle state must be editable in `tab-scoreboard.yml`.

---

## 6. EXCLUSIVE COMMUNICATION & BROADCAST SYSTEM

- **Broadcast (`/broadcast `):** Direct command (and GUI builder option) supporting HEX, gradients, MiniMessage, sound alerts, and Title/Subtitle popups with a sleek Vayyy Cyber-Yellow layout.
- **Exclusive Admin Message (`/adminmsg  `, `/adminmsgall `, `/ar `):** Direct execution without GUI. Uses a distinct, high-priority visual box so the receiving player immediately knows an Administrator is contacting them directly.
- **Staff Chat (`/sc `):** Direct toggleable or one-off private channel for staff members.

---

## 7. COMPLETE FILE CUSTOMIZATION ARCHITECTURE (100% CONFIGURABLE)

Create a clean, well-documented, modular configuration system inside `plugins/Vayyy/` so the server owner can change ANY text, color, GUI title, item material, slot, broadcast style, or scoreboard line without touching the Java code:

1. **`config.yml`:** Core settings, storage type (SQLite default / MySQL), feature toggles, permission hierarchy, command aliases.
2. **`theme.yml` (or `messages.yml`):**
   - Global color variables (e.g., `primary-color: "#FCEE09"`, `secondary-color: "#FFAA00"`, `accent-color: "#00F0FF"`, `error-color: "#FF2A54"`).
   - Every chat message, prefix, kick/ban/mute screen template, `/vayyy help` layout (both Member POV and OP POV), and broadcast format.
3. **`gui.yml`:**
   - Every GUI title, size, border glass color, button slot, item `Material` (allowing full customization of icons), display name, and lore lines.
4. **`tab-scoreboard.yml`:**
   - Enable/disable toggles for Tablist and Scoreboard, update ticks, Header/Footer lines, Scoreboard title and lines, and rank sorting/prefix formats.
5. **`moderation.yml`:**
   - Preset reasons for Kick/Mute/Warn/Ban, preset durations, warning thresholds, and auto-punishment rules.

Include a `/vayyy reload` command (and a Reload button inside the Settings GUI) that safely reloads all YAML files, refreshes open scoreboards/tablists, and applies new colors/texts immediately without requiring a server restart.

---

## 8. PERMISSIONS, DATABASE & PERFORMANCE

- **Permissions (`vayyy.*`):** `vayyy.admin`, `vayyy.help.member` (default: true), `vayyy.help.admin` (default: op), `vayyy.moderation`, `vayyy.kick`, `vayyy.mute`, `vayyy.warn`, `vayyy.ban`, `vayyy.maintenance`, `vayyy.teleport`, `vayyy.broadcast`, `vayyy.adminmsg`, `vayyy.vanish`, `vayyy.staffchat`, `vayyy.player.manage`, `vayyy.server.manage`, `vayyy.reload`.
- **Database:** Asynchronous SQLite (and optional MySQL) storing punishments, active mutes/bans, warnings, player logs, and maintenance state using UUIDs.
- **Performance & Safety:** Thread-safe GUI handling, automatic cleanup of chat-input listeners on quit, anti-exploit inventory click cancellation, and zero main-thread lag.

---

## 9. FINAL DELIVERABLES

Deliver the complete, compilable Java project (`pom.xml` or `build.gradle`, `plugin.yml`, all Java classes, and all default YAML configuration files) and produce the compiled `.jar` file. Ensure every single feature—from `/vayyy help` POV filtering and Tab/Scoreboard rendering to the Cyber-Yellow GUI punishment builders—works flawlessly out of the box.
Kodari AI
KodariNov 14 at 1:55 pm 4
VayyyAdminSuite
Enterprise-grade Minecraft server management plugin with a unified Cyber x Yellow GUI design system. Features role-based dynamic help command with permission filtering, GUI-first moderation flows for kick/mute/warn/ban with interactive punishment builders, maintenance mode manager, teleportation GUI, player management dashboard, environment controls, exclusive admin messaging system, staff chat, and broadcast system. Includes flicker-free Tablist and Sidebar Scoreboard with per-player toggles, vanish integration, and rank sorting. Fully configurable through modular YAML files covering themes, GUI layouts, moderation presets, and tab/scoreboard settings. Uses asynchronous SQLite/MySQL storage for punishments and player logs, with complete permission hierarchy under vayyy.* and safe reload command.
  • Build the Vayyy core, permission-filtered help, moderation builders, and dashboard.

  • Add maintenance, messaging, teleport and player tools, plus configurable tab and sidebar displays.

Created the Vayyy plugin foundation with GUI moderation, maintenance, player tools, messaging, tab headers and a configurable sidebar.

The full specification is not yet complete. Missing features include SQLite/MySQL storage, coordinate teleportation, vanish, rank-sorted tab entries, and full GUI customization. The project has not been compiled or verified, and no JAR has been produced yet.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
9 342
src/main/java/me/vayyy/admin/Vayyy.java
package me.vayyy.admin;

import com.cryptomorin.xseries.XMaterial;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
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;
import java.util.function.Consumer;

public final class Vayyy extends JavaPlugin implements Listener {
    private final MiniMessage mm = MiniMessage.miniMessage();
    private final Map<UUID, Consumer<String>> inputs = new ConcurrentHashMap<>();
    private final Map<UUID, UUID> replies = new HashMap<>();
    private final Set<UUID> staffChat = new HashSet<>();
    private final Set<UUID> frozen = new HashSet<>();
    private final Set<UUID> hiddenSidebar = new HashSet<>();
    private final Map<UUID, Scoreboard> boards = new HashMap<>();
    private YamlConfiguration theme, gui, moderation, display, data;
    private File dataFile;
    private int displayTask = -1;

    @Override public void onEnable() {
        saveDefaultConfig();
        for (String file : Arrays.asList("theme.yml", "gui.yml", "moderation.yml", "tab-scoreboard.yml")) saveResource(file, false);
        dataFile = new File(getDataFolder(), "data.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        reloadFiles();
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override public void onDisable() {
        for (Player p : Bukkit.getOnlinePlayers()) if (boards.get(p.getUniqueId()) == p.getScoreboard()) p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
        saveData();
    }

    private void reloadFiles() {
        reloadConfig();
        theme = load("theme.yml"); gui = load("gui.yml"); moderation = load("moderation.yml"); display = load("tab-scoreboard.yml");
        if (displayTask != -1) Bukkit.getScheduler().cancelTask(displayTask);
        long ticks = Math.max(1, display.getLong("update-ticks", 40));
        displayTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::updateDisplays, 1L, ticks);
    }

    private YamlConfiguration load(String name) { return YamlConfiguration.loadConfiguration(new File(getDataFolder(), name)); }
    private void saveData() { try { data.save(dataFile); } catch (IOException e) { getLogger().warning("Could not save data: " + e.getMessage()); } }
    private Component text(String s) { return mm.deserialize(s); }
    private String safe(String s) { return MiniMessage.miniMessage().escapeTags(s == null ? "" : s); }
    private void send(CommandSender p, String s) { p.sendMessage(text(theme.getString("prefix", "<yellow>Vayyy</yellow> ") + s)); }
    private boolean allowed(CommandSender p, String permission) { if (p.hasPermission(permission)) return true; send(p, theme.getString("no-permission", "<red>No permission.</red>")); return false; }
    private Player online(String name) { return Bukkit.getPlayerExact(name); }
    private String rank(Player p) { return p.hasPermission("vayyy.admin") ? "ADMIN" : p.hasPermission("vayyy.staffchat") ? "STAFF" : "MEMBER"; }

    @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        String cmd = command.getName().toLowerCase(Locale.ROOT);
        if (cmd.equals("vayyy") && args.length > 0 && args[0].equalsIgnoreCase("help")) { help(sender); return true; }
        if (cmd.equals("vayyy") && args.length > 0 && args[0].equalsIgnoreCase("reload")) { if (allowed(sender, "vayyy.reload")) { reloadFiles(); send(sender, "<green>Configuration reloaded.</green>"); } return true; }
        if (cmd.equals("broadcast")) { if (allowed(sender, "vayyy.broadcast") && args.length > 0) Bukkit.broadcast(text(theme.getString("broadcast", "<yellow><message></yellow>").replace("<message>", String.join(" ", args)))); return true; }
        if (cmd.equals("staffchat")) { if (!allowed(sender, "vayyy.staffchat")) return true; if (args.length > 0) staff(sender, String.join(" ", args)); else if (sender instanceof Player) { UUID id = ((Player) sender).getUniqueId(); if (!staffChat.add(id)) { staffChat.remove(id); send(sender, "<gray>Staff chat disabled.</gray>"); } else send(sender, "<green>Staff chat enabled.</green>"); } return true; }
        if (cmd.equals("adminmsg") || cmd.equals("adminmsgall") || cmd.equals("adminreply")) { messages(sender, cmd, args); return true; }
        if (!(sender instanceof Player)) { send(sender, "<red>This command requires a player.</red>"); return true; }
        Player p = (Player) sender;
        switch (cmd) {
            case "vayyy": case "admin": if (allowed(p, "vayyy.admin")) dashboard(p); break;
            case "kick": case "mute": case "warn": case "ban":
                if (!allowed(p, "vayyy." + cmd)) break;
                if (args.length < 1) { send(p, "<gray>Usage: /" + cmd + " <player></gray>"); break; }
                OfflinePlayer target = Bukkit.getOfflinePlayerIfCached(args[0]);
                if (target == null) { send(p, "<red>Player not found in server history.</red>"); break; }
                punishment(p, new Draft(cmd, target)); break;
            case "maintenance": if (allowed(p, "vayyy.maintenance")) maintenance(p); break;
            case "tp": if (allowed(p, "vayyy.teleport")) teleportMenu(p, 0); break;
            case "manage": if (allowed(p, "vayyy.player.manage")) { Player t = args.length > 0 ? online(args[0]) : null; if (t == null) send(p, "<red>Specify an online player.</red>"); else manage(p, t); } break;
            case "environment": if (allowed(p, "vayyy.server.manage")) environment(p); break;
            case "serverinfo": if (allowed(p, "vayyy.server.manage")) serverInfo(p); break;
            case "scoreboard": if (!hiddenSidebar.add(p.getUniqueId())) { hiddenSidebar.remove(p.getUniqueId()); send(p, "<green>Sidebar enabled.</green>"); } else { Scoreboard b = boards.remove(p.getUniqueId()); if (b != null && p.getScoreboard() == b) p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); send(p, "<gray>Sidebar disabled.</gray>"); } break;
            default: break;
        }
        return true;
    }

    private void help(CommandSender s) {
        if (s.hasPermission("vayyy.help.member")) { send(s, "<yellow><bold>Member commands</bold></yellow>"); helpLine(s, "/vayyy help", "Show available commands"); helpLine(s, "/sb", "Toggle your sidebar"); helpLine(s, "/ar ", "Reply to an administrator"); }
        String[][] entries = {{"vayyy.admin", "/vayyy", "Dashboard"}, {"vayyy.kick", "/kick ", "Configure a kick"}, {"vayyy.mute", "/mute ", "Configure a mute"}, {"vayyy.warn", "/warn ", "Configure a warning"}, {"vayyy.ban", "/ban ", "Configure a ban"}, {"vayyy.maintenance", "/maintenance", "Maintenance settings"}, {"vayyy.teleport", "/tp", "Teleportation"}, {"vayyy.player.manage", "/manage ", "Player management"}, {"vayyy.server.manage", "/environment", "Environment"}, {"vayyy.server.manage", "/serverinfo", "Server status"}, {"vayyy.broadcast", "/broadcast ", "Broadcast"}, {"vayyy.adminmsg", "/adminmsg ", "Message a player"}, {"vayyy.staffchat", "/sc ", "Staff chat"}, {"vayyy.reload", "/vayyy reload", "Reload configuration"}};
        boolean header = false;
        for (String[] e : entries) if (s.hasPermission(e[0])) { if (!header) { send(s, "<yellow><bold>Admin &amp; moderation</bold></yellow>"); header = true; } helpLine(s, e[1], e[2]); }
    }
    private void helpLine(CommandSender s, String command, String description) { s.sendMessage(text("<yellow>" + safe(command) + "</yellow> <dark_gray>—</dark_gray> <gray>" + safe(description) + "</gray>").clickEvent(ClickEvent.suggestCommand(command)).hoverEvent(HoverEvent.showText(text("<gray>Click to suggest</gray>")))); }

    private void messages(CommandSender sender, String cmd, String[] args) {
        if (cmd.equals("adminreply")) { if (!(sender instanceof Player) || args.length == 0) return; UUID id = replies.get(((Player) sender).getUniqueId()); Player to = id == null ? null : Bukkit.getPlayer(id); if (to == null) { send(sender, "<red>No administrator is available to reply.</red>"); return; } send(to, "<yellow>Reply from " + safe(sender.getName()) + ":</yellow> <white>" + safe(String.join(" ", args)) + "</white>"); send(sender, "<gray>Reply sent.</gray>"); return; }
        if (!allowed(sender, "vayyy.adminmsg")) return;
        if (cmd.equals("adminmsgall")) { if (args.length == 0) return; for (Player to : Bukkit.getOnlinePlayers()) adminMessage(sender, to, String.join(" ", args)); return; }
        if (args.length < 2) { send(sender, "<gray>Usage: /adminmsg <player> <message></gray>"); return; }
        Player to = online(args[0]); if (to == null) { send(sender, "<red>Player is not online.</red>"); return; }
        adminMessage(sender, to, String.join(" ", Arrays.copyOfRange(args, 1, args.length))); send(sender, "<green>Message sent.</green>");
    }
    private void adminMessage(CommandSender from, Player to, String message) { to.sendMessage(text("<dark_gray>━━━━━━━━━━━━━━━━━━━━</dark_gray><newline><yellow><bold>ADMINISTRATOR MESSAGE</bold></yellow><newline><gray>" + safe(from.getName()) + ":</gray> <white>" + safe(message) + "</white><newline><dark_gray>━━━━━━━━━━━━━━━━━━━━</dark_gray>")); if (from instanceof Player) replies.put(to.getUniqueId(), ((Player) from).getUniqueId()); }
    private void staff(CommandSender from, String message) { for (Player p : Bukkit.getOnlinePlayers()) if (p.hasPermission("vayyy.staffchat")) send(p, "<aqua>Staff</aqua> <gray>" + safe(from.getName()) + ":</gray> <white>" + safe(message) + "</white>"); }

    private final class Menu implements InventoryHolder {
        final Inventory inventory; final Map<Integer, Runnable> actions = new HashMap<>();
        Menu(String name) { inventory = Bukkit.createInventory(this, 54, text(gui.getString("title", "<yellow>VAYYY</yellow> <menu>").replace("<menu>", safe(name)))); }
        @Override public Inventory getInventory() { return inventory; }
        void button(int slot, String material, String name, List<String> lore, Runnable action) { ItemStack item = XMaterial.matchXMaterial(material).map(XMaterial::parseItem).orElse(null); if (item == null) return; ItemMeta meta = item.getItemMeta(); meta.displayName(text(name)); List<Component> lines = new ArrayList<>(); for (String line : lore) lines.add(text(line)); meta.lore(lines); item.setItemMeta(meta); inventory.setItem(slot, item); if (action != null) actions.put(slot, action); }
        void button(int slot, String material, String name, Runnable action) { button(slot, material, name, Arrays.asList("<dark_gray>⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯</dark_gray>", "<yellow>▸ Click to open</yellow>"), action); }
    }
    private Menu menu(Player p, String name) { Menu m = new Menu(name); for (int i = 0; i < 9; i++) m.button(i, i == 3 || i == 5 ? "YELLOW_STAINED_GLASS_PANE" : "BLACK_STAINED_GLASS_PANE", "<dark_gray>▪</dark_gray>", (Runnable) null); m.button(4, "NETHER_STAR", "<yellow><bold>VAYYY // SYSTEM CORE</bold></yellow>", Arrays.asList("<gray>Module: <white>" + safe(name) + "</white>", "<gray>TPS: <aqua>" + String.format(Locale.ROOT, "%.1f", Bukkit.getTPS()[0]) + "</aqua>", "<gray>Operator: <white>" + safe(p.getName()) + "</white>"), null); return m; }
    private void open(Player p, Menu m) { p.openInventory(m.inventory); }
    @EventHandler public void click(InventoryClickEvent e) { if (!(e.getView().getTopInventory().getHolder() instanceof Menu)) return; e.setCancelled(true); if (e.getRawSlot() < 0 || e.getRawSlot() >= e.getView().getTopInventory().getSize()) return; Runnable action = ((Menu) e.getView().getTopInventory().getHolder()).actions.get(e.getRawSlot()); if (action != null) action.run(); }
    @EventHandler public void drag(InventoryDragEvent e) { if (e.getView().getTopInventory().getHolder() instanceof Menu) e.setCancelled(true); }

    private void dashboard(Player p) { Menu m = menu(p, "Dashboard");
        m.button(19, "IRON_BARS", "<yellow>Moderation</yellow>", () -> playerPicker(p, "Moderation", 0, t -> moderationMenu(p, t)));
        m.button(20, "ENDER_PEARL", "<yellow>Teleportation</yellow>", () -> { if (allowed(p, "vayyy.teleport")) teleportMenu(p, 0); });
        m.button(21, "PLAYER_HEAD", "<yellow>Player management</yellow>", () -> { if (allowed(p, "vayyy.player.manage")) playerPicker(p, "Players", 0, t -> manage(p, t)); });
        m.button(22, "WRITABLE_BOOK", "<yellow>Communication</yellow>", () -> { if (allowed(p, "vayyy.broadcast")) prompt(p, "Type a broadcast", msg -> { Bukkit.broadcast(text(theme.getString("broadcast", "<yellow><message></yellow>").replace("<message>", safe(msg)))); dashboard(p); }); });
        m.button(23, "COMPARATOR", "<yellow>Server utilities</yellow>", () -> { if (allowed(p, "vayyy.server.manage")) environment(p); });
        m.button(24, "SPYGLASS", "<yellow>Staff tools</yellow>", () -> { if (allowed(p, "vayyy.maintenance")) maintenance(p); });
        m.button(25, "REDSTONE_TORCH", "<yellow>Settings</yellow>", () -> settings(p)); open(p, m); }
    private void settings(Player p) { Menu m = menu(p, "Settings"); m.button(22, "COMPARATOR", "<yellow>Reload configuration</yellow>", () -> { if (allowed(p, "vayyy.reload")) { reloadFiles(); send(p, "<green>Configuration reloaded.</green>"); settings(p); } }); m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }
    private void playerPicker(Player p, String title, int page, Consumer<Player> action) { Menu m = menu(p, title); List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); int start = page * 28; for (int i = start; i < Math.min(start + 28, players.size()); i++) { Player target = players.get(i); int slot = 10 + ((i - start) / 7) * 9 + (i - start) % 7; m.button(slot, "PLAYER_HEAD", "<yellow>" + safe(target.getName()) + "</yellow>", Arrays.asList("<gray>World: <aqua>" + safe(target.getWorld().getName()) + "</aqua>", "<yellow>▸ Click to select</yellow>"), () -> { if (target.isOnline()) action.accept(target); else send(p, "<red>Player went offline.</red>"); }); ItemStack item = m.inventory.getItem(slot); if (item != null && item.getItemMeta() instanceof SkullMeta) { SkullMeta meta = (SkullMeta) item.getItemMeta(); meta.setOwningPlayer(target); item.setItemMeta(meta); } } if (page > 0) m.button(45, "ARROW", "<yellow>Previous</yellow>", () -> playerPicker(p, title, page - 1, action)); if (start + 28 < players.size()) m.button(53, "ARROW", "<yellow>Next</yellow>", () -> playerPicker(p, title, page + 1, action)); m.button(49, "BARRIER", "<red>Close</red>", p::closeInventory); open(p, m); }
    private void moderationMenu(Player p, Player target) { Menu m = menu(p, "Moderation: " + target.getName()); String[] types = {"kick", "mute", "warn", "ban"}; String[] icons = {"NETHERITE_AXE", "SCULK_SHRIEKER", "BLAZE_POWDER", "IRON_BARS"}; for (int i = 0; i < types.length; i++) { String type = types[i]; m.button(20 + i, icons[i], "<yellow>" + type.toUpperCase(Locale.ROOT) + "</yellow>", () -> { if (allowed(p, "vayyy." + type)) punishment(p, new Draft(type, target)); }); } m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }

    private static final class Draft { final String type; final OfflinePlayer target; String reason; String duration; Draft(String type, OfflinePlayer target) { this.type = type; this.target = target; } }
    private void punishment(Player p, Draft d) { Menu m = menu(p, d.type.toUpperCase(Locale.ROOT)); String id = d.target.getUniqueId().toString(); m.button(13, "PLAYER_HEAD", "<yellow>" + safe(d.target.getName()) + "</yellow>", Arrays.asList("<gray>Status: <white>" + (d.target.isOnline() ? "Online" : "Offline") + "</white>", "<gray>Infractions: <white>" + data.getStringList("history." + id).size() + "</white>"), null); ItemStack head = m.inventory.getItem(13); if (head != null && head.getItemMeta() instanceof SkullMeta) { SkullMeta meta = (SkullMeta) head.getItemMeta(); meta.setOwningPlayer(d.target); head.setItemMeta(meta); }
        m.button(20, "WRITABLE_BOOK", "<yellow>Reason</yellow>", Arrays.asList("<gray>Current: <white>" + safe(d.reason == null ? "Not set" : d.reason) + "</white>", "<yellow>▸ Select or type a reason</yellow>"), () -> reasons(p, d));
        if (d.type.equals("mute") || d.type.equals("ban")) m.button(24, "CLOCK", "<yellow>Duration</yellow>", Arrays.asList("<gray>Current: <white>" + safe(d.duration == null ? "Not set" : d.duration) + "</white>", "<yellow>▸ Select a duration</yellow>"), () -> durations(p, d));
        m.button(39, "EMERALD", "<green>Confirm and execute</green>", () -> execute(p, d)); m.button(41, "BARRIER", "<red>Cancel</red>", () -> dashboard(p)); open(p, m); }
    private void reasons(Player p, Draft d) { Menu m = menu(p, "Select reason"); List<String> list = moderation.getStringList("reasons"); for (int i = 0; i < Math.min(27, list.size()); i++) { String reason = list.get(i); m.button(10 + (i / 7) * 9 + i % 7, "PAPER", "<white>" + safe(reason) + "</white>", () -> { d.reason = reason; punishment(p, d); }); } m.button(49, "WRITABLE_BOOK", "<yellow>Custom reason</yellow>", () -> prompt(p, "Type reason in chat", value -> { d.reason = value; punishment(p, d); }, () -> punishment(p, d))); open(p, m); }
    private void durations(Player p, Draft d) { Menu m = menu(p, "Select duration"); List<String> list = moderation.getStringList("durations"); for (int i = 0; i < Math.min(7, list.size()); i++) { String value = list.get(i); m.button(19 + i, "CLOCK", "<yellow>" + safe(value) + "</yellow>", () -> { if (duration(value) < 0) { send(p, "<red>Invalid configured duration.</red>"); return; } d.duration = value; punishment(p, d); }); } m.button(49, "WRITABLE_BOOK", "<yellow>Custom duration</yellow>", () -> prompt(p, "Type duration: 15m, 1h, 1d or permanent", value -> { if (duration(value) < 0) send(p, "<red>Invalid duration.</red>"); else d.duration = value; punishment(p, d); }, () -> punishment(p, d))); open(p, m); }
    private long duration(String s) { if (s.equalsIgnoreCase("permanent")) return 0; try { if (!s.matches("[0-9]+[mhd]")) return -1; long amount = Long.parseLong(s.substring(0, s.length() - 1)); long factor = s.endsWith("m") ? 60000L : s.endsWith("h") ? 3600000L : 86400000L; return amount <= 0 ? -1 : Math.multiplyExact(amount, factor); } catch (ArithmeticException | NumberFormatException e) { return -1; } }
    private void execute(Player p, Draft d) { if (!allowed(p, "vayyy." + d.type)) return; if (d.reason == null || d.reason.trim().isEmpty() || ((d.type.equals("mute") || d.type.equals("ban")) && d.duration == null)) { send(p, "<red>Set the reason and required duration first.</red>"); return; } long length = d.duration == null ? 0 : duration(d.duration); if (length < 0 || (length > 0 && length > Long.MAX_VALUE - System.currentTimeMillis())) { send(p, "<red>Invalid duration.</red>"); return; } String id = d.target.getUniqueId().toString(); List<String> history = data.getStringList("history." + id); history.add(System.currentTimeMillis() + " | " + d.type + " | " + p.getName() + " | " + d.reason + " | " + (d.duration == null ? "-" : d.duration)); data.set("history." + id, history); if (d.type.equals("ban") || d.type.equals("mute")) { data.set(d.type + "." + id + ".until", length == 0 ? 0 : System.currentTimeMillis() + length); data.set(d.type + "." + id + ".reason", d.reason); } saveData(); Player target = d.target.getPlayer(); if (target != null) { if (d.type.equals("kick") || d.type.equals("ban")) target.kick(text("<yellow>Vayyy</yellow><newline><red>" + safe(d.type.toUpperCase(Locale.ROOT)) + "</red><newline><gray>Reason: <white>" + safe(d.reason) + "</white></gray>")); else send(target, "<red>" + safe(d.type.toUpperCase(Locale.ROOT)) + ":</red> <white>" + safe(d.reason) + "</white>"); } staff(p, d.type + " → " + d.target.getName() + ": " + d.reason); getLogger().info(p.getName() + " issued " + d.type + " to " + d.target.getName() + ": " + d.reason); p.closeInventory(); }
    private void prompt(Player p, String label, Consumer<String> callback) { prompt(p, label, callback, () -> dashboard(p)); }
    private void prompt(Player p, String label, Consumer<String> callback, Runnable cancel) { p.closeInventory(); p.sendTitle("§e" + label.toUpperCase(Locale.ROOT), "§7Type cancel to return", 5, 60, 10); send(p, "<yellow>" + safe(label) + "</yellow> <gray>(type cancel to return)</gray>"); inputs.put(p.getUniqueId(), value -> { if (value.equalsIgnoreCase("cancel")) cancel.run(); else callback.accept(value); }); }
    @EventHandler(priority = EventPriority.LOWEST) public void chat(AsyncPlayerChatEvent e) { Player p = e.getPlayer(); Consumer<String> input = inputs.remove(p.getUniqueId()); if (input != null) { e.setCancelled(true); String value = e.getMessage(); Bukkit.getScheduler().runTask(this, () -> { if (p.isOnline()) input.accept(value); }); return; } if (active("mute", p.getUniqueId())) { e.setCancelled(true); Bukkit.getScheduler().runTask(this, () -> send(p, "<red>You are muted.</red>")); return; } if (staffChat.contains(p.getUniqueId()) && p.hasPermission("vayyy.staffchat")) { e.setCancelled(true); String value = e.getMessage(); Bukkit.getScheduler().runTask(this, () -> staff(p, value)); } }
    private boolean active(String type, UUID id) { String path = type + "." + id; if (!data.contains(path + ".until")) return false; long until = data.getLong(path + ".until"); return until == 0 || until > System.currentTimeMillis(); }
    @EventHandler public void login(PlayerLoginEvent e) { if (getConfig().getBoolean("maintenance.enabled") && !e.getPlayer().hasPermission("vayyy.maintenance.bypass") && !e.getPlayer().isWhitelisted()) { e.disallow(PlayerLoginEvent.Result.KICK_OTHER, text("<yellow>Maintenance</yellow><newline><gray>" + safe(getConfig().getString("maintenance.reason")) + "</gray>")); return; } if (active("ban", e.getPlayer().getUniqueId())) e.disallow(PlayerLoginEvent.Result.KICK_BANNED, text("<red>Banned</red><newline><gray>Reason: " + safe(data.getString("ban." + e.getPlayer().getUniqueId() + ".reason")) + "</gray>")); }
    @EventHandler public void quit(PlayerQuitEvent e) { UUID id = e.getPlayer().getUniqueId(); inputs.remove(id); staffChat.remove(id); frozen.remove(id); boards.remove(id); replies.remove(id); }
    @EventHandler public void join(PlayerJoinEvent e) { Bukkit.getScheduler().runTask(this, this::updateDisplays); }
    @EventHandler public void move(PlayerMoveEvent e) { if (frozen.contains(e.getPlayer().getUniqueId()) && e.getTo() != null && (e.getFrom().getBlockX() != e.getTo().getBlockX() || e.getFrom().getBlockY() != e.getTo().getBlockY() || e.getFrom().getBlockZ() != e.getTo().getBlockZ())) e.setCancelled(true); }

    private void maintenance(Player p) { Menu m = menu(p, "Maintenance"); boolean enabled = getConfig().getBoolean("maintenance.enabled"); m.button(20, enabled ? "LIME_DYE" : "GRAY_DYE", "<yellow>Maintenance: " + (enabled ? "ON" : "OFF") + "</yellow>", () -> { getConfig().set("maintenance.enabled", !enabled); saveConfig(); maintenance(p); }); m.button(22, "WRITABLE_BOOK", "<yellow>Edit reason</yellow>", () -> prompt(p, "Type maintenance reason", value -> { getConfig().set("maintenance.reason", value); saveConfig(); maintenance(p); }, () -> maintenance(p))); m.button(24, "PLAYER_HEAD", "<yellow>Whitelist manager</yellow>", () -> playerPicker(p, "Toggle whitelist", 0, t -> { t.setWhitelisted(!t.isWhitelisted()); send(p, "<gray>Whitelist for " + safe(t.getName()) + ": " + t.isWhitelisted() + "</gray>"); maintenance(p); })); m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }
    private void teleportMenu(Player p, int page) { playerPicker(p, "Teleport to player", page, t -> { p.teleport(t); send(p, "<green>Teleported to " + safe(t.getName()) + ".</green>"); }); }
    private void manage(Player p, Player target) { if (!target.isOnline()) { send(p, "<red>Player is offline.</red>"); return; } Menu m = menu(p, "Manage " + target.getName()); m.button(19, "GOLDEN_APPLE", "<green>Heal</green>", () -> { target.setHealth(target.getMaxHealth()); manage(p, target); }); m.button(20, "COOKED_BEEF", "<green>Feed</green>", () -> { target.setFoodLevel(20); target.setSaturation(20); manage(p, target); }); m.button(21, "COMPASS", "<yellow>Cycle gamemode</yellow>", () -> { GameMode[] modes = GameMode.values(); target.setGameMode(modes[(target.getGameMode().ordinal() + 1) % modes.length]); manage(p, target); }); m.button(22, "FEATHER", "<yellow>Toggle flight</yellow>", () -> { target.setAllowFlight(!target.getAllowFlight()); manage(p, target); }); m.button(23, "TOTEM_OF_UNDYING", "<yellow>Toggle invulnerability</yellow>", () -> { target.setInvulnerable(!target.isInvulnerable()); manage(p, target); }); m.button(24, "LAVA_BUCKET", "<red>Clear inventory</red>", () -> confirm(p, "Clear inventory?", () -> { target.getInventory().clear(); send(p, "<green>Inventory cleared.</green>"); })); m.button(25, "PACKED_ICE", "<yellow>Toggle freeze</yellow>", () -> { if (!frozen.add(target.getUniqueId())) frozen.remove(target.getUniqueId()); manage(p, target); }); m.button(30, "CHEST", "<yellow>Inspect inventory</yellow>", () -> p.openInventory(target.getInventory())); m.button(32, "ENDER_CHEST", "<yellow>Inspect ender chest</yellow>", () -> p.openInventory(target.getEnderChest())); m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }
    private void confirm(Player p, String name, Runnable action) { Menu m = menu(p, name); m.button(21, "EMERALD", "<green>Confirm</green>", () -> { action.run(); p.closeInventory(); }); m.button(23, "BARRIER", "<red>Cancel</red>", () -> dashboard(p)); open(p, m); }
    private void environment(Player p) { Menu m = menu(p, "Environment"); World w = p.getWorld(); m.button(19, "SUNFLOWER", "<yellow>Day</yellow>", () -> { w.setTime(1000); environment(p); }); m.button(21, "CLOCK", "<yellow>Night</yellow>", () -> { w.setTime(13000); environment(p); }); m.button(23, "HEART_OF_THE_SEA", "<aqua>Toggle rain</aqua>", () -> { w.setStorm(!w.hasStorm()); environment(p); }); m.button(25, "COMPARATOR", "<yellow>Server information</yellow>", () -> serverInfo(p)); m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }
    private void serverInfo(Player p) { Menu m = menu(p, "Server information"); Runtime r = Runtime.getRuntime(); m.button(22, "COMPARATOR", "<yellow>Live server status</yellow>", Arrays.asList("<gray>TPS: <aqua>" + String.format(Locale.ROOT, "%.1f", Bukkit.getTPS()[0]) + "</aqua>", "<gray>Online: <white>" + Bukkit.getOnlinePlayers().size() + "</white>", "<gray>Memory: <white>" + (r.totalMemory() - r.freeMemory()) / 1048576 + " MB</white>"), () -> serverInfo(p)); m.button(49, "ARROW", "<red>Back</red>", () -> dashboard(p)); open(p, m); }

    private String variables(String value, Player p) { return value.replace("<player>", safe(p.getName())).replace("<rank>", rank(p)).replace("<world>", safe(p.getWorld().getName())).replace("<ping>", String.valueOf(p.getPing())).replace("<online>", String.valueOf(Bukkit.getOnlinePlayers().size())).replace("<tps>", String.format(Locale.ROOT, "%.1f", Bukkit.getTPS()[0])).replace("<status>", getConfig().getBoolean("maintenance.enabled") ? "Maintenance" : "Online"); }
    private void updateDisplays() { for (Player p : Bukkit.getOnlinePlayers()) { if (display.getBoolean("tab-enabled", true)) p.sendPlayerListHeaderAndFooter(text(variables(display.getString("header", ""), p)), text(variables(display.getString("footer", ""), p))); else p.sendPlayerListHeaderAndFooter(Component.empty(), Component.empty()); if (!display.getBoolean("scoreboard-enabled", true) || hiddenSidebar.contains(p.getUniqueId())) { Scoreboard old = boards.remove(p.getUniqueId()); if (old != null && p.getScoreboard() == old) p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); continue; } Scoreboard board = boards.computeIfAbsent(p.getUniqueId(), ignored -> Bukkit.getScoreboardManager().getNewScoreboard()); Objective objective = board.getObjective("vayyy"); if (objective == null) { objective = board.registerNewObjective("vayyy", "dummy", text(variables(display.getString("scoreboard-title", "<yellow>Vayyy</yellow>"), p))); objective.setDisplaySlot(DisplaySlot.SIDEBAR); } objective.displayName(text(variables(display.getString("scoreboard-title", "<yellow>Vayyy</yellow>"), p))); List<String> lines = display.getStringList("lines"); for (int i = 0; i < 15; i++) { String entry = "§" + Integer.toHexString(i); Team team = board.getTeam("line" + i); if (i >= lines.size()) { board.resetScores(entry); if (team != null) team.unregister(); continue; } if (team == null) { team = board.registerNewTeam("line" + i); team.addEntry(entry); } team.prefix(text(variables(lines.get(i), p))); objective.getScore(entry).setScore(15 - i); } if (p.getScoreboard() != board) p.setScoreboard(board); } }
}