dhh.justin_
📎 1 file 3,136 chars
📄
pasted-code-1777190982135.txt
txt 149 lines
▶
Create a professional Minecraft plugin named "CursedxMods" for Spigot/Paper servers.

MAIN GOAL:
Detect and store player client type (especially Fabric users) when they join, and allow admins (OP only) to inspect this data using a INVENTORY GUI menu.

COMPATIBILITY:
- Must support Minecraft versions 1.18 to 1.21.1
- Use Spigot/Paper API only (no Fabric server required)

CORE FEATURES:

1. PLAYER JOIN DETECTION
- On PlayerJoinEvent:
  - Detect client brand using plugin messaging channel "minecraft:brand"
  - Identify:
    - Fabric (fabric / fabric-loader)
    - Forge
    - Vanilla
    - Lunar / other clients
  - Store:
    - UUID
    - Name
    - Client brand
    - IsFabric (true/false)
    - Join timestamp

2. FABRIC CHANNEL DETECTION
- Listen to PlayerRegisterChannelEvent
- Detect channels starting with "fabric"
- Save all detected channels per player
- If found → mark player as Fabric user

3. DATA STORAGE
- Use players.yml

Structure:
players:
  :
    name: ""
    client: ""
    fabric: true/false
    channels:
      - channel1
    last_join: timestamp

4. COMMAND SYSTEM

Command:
  /mods inspect 

ACCESS CONTROL:
- ONLY allow players with OP (player.isOp() == true)
- If non-OP tries:
  Send: "You do not have permission to use this command."

5. INVENTORY GUI MENU SYSTEM (IMPORTANT)

- When command is executed:
  Open a INVENTORY GUI (Inventory-based menu)

INVENTORY GUI TITLE:
  "CursedxMods Inspector"

SIZE:
  27 slots

CONTENT:
- Player Head (slot 13):
  - Display Name: Player name
  - Lore:
    - Client: 
    - Fabric: Yes/No
    - Last Seen: 
Kodari AI
KodariApr 26 at 8:11 am 9,657 (v2)
CursedxMods
A Spigot/Paper plugin for detecting and inspecting player client types (Fabric, Forge, Vanilla, Lunar, etc.) on join via plugin messaging channels. Stores UUID, name, client brand, fabric status, detected channels, and last join timestamp in players.yml. OP-only commands open an inventory GUI inspector showing player head, detected channels, and client info. Supports Minecraft 1.18–1.21.1 with async saving and in-memory caching.

Plan:

  • GUI framework: InventoryHandler, InventoryButton, InventoryGUI, GUIManager, GUIListener

  • Data: PlayerData (Lombok), DataManager (YAML + memory cache)

  • Listeners: JoinListener (brand channel), ChannelListener (fabric channel detection)

  • Command: ModsCommand → opens InspectGUI

  • Main: CursedxMods wires everything together

What was created:

  • GUI framework — InventoryHandler, InventoryButton, InventoryGUI, GUIManager, GUIListener (standard reusable pattern)

  • PlayerData — Lombok-backed data class storing UUID, name, client brand, fabric flag, channels list, and timestamp

  • DataManager — Loads/saves players.yml with in-memory ConcurrentHashMap cache; async saves on join/quit, sync save on shutdown

  • JoinListener — Registers minecraft:brand incoming channel per player on join, parses the VarInt-prefixed UTF-8 brand string, sets client type and fabric flag

  • ChannelListener — Listens to PlayerRegisterChannelEvent, logs channels (if log-channels: true), marks Fabric if any channel starts with "fabric"

  • InspectGUI — 27-slot GUI with player head (slot 13), book for channels (slot 11), redstone for client info (slot 15), barrier close button (slot 22), and gray glass pane filler

  • ModsCommand — OP-only /mods inspect <player> and /mods reload with tab completion

  • CursedxMods — Main plugin, wires all components together, registers the minecraft:brand channel globally on enable

Kodari can make mistakes. Review important code before using.
Files
src
Code
15 718
src/main/java/com/cursedxmods/CursedxMods.java
package com.cursedxmods;

import com.cursedxmods.command.ModsCommand;
import com.cursedxmods.data.DataManager;
import com.cursedxmods.inventory.gui.GUIListener;
import com.cursedxmods.inventory.gui.GUIManager;
import com.cursedxmods.listener.ChannelListener;
import com.cursedxmods.listener.JoinListener;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class CursedxMods extends JavaPlugin {
    @Getter
    private DataManager dataManager;
    @Getter
    private GUIManager guiManager;

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

        this.dataManager = new DataManager(this);
        this.guiManager = new GUIManager();

        // Register messaging channel for client brand detection
        getServer().getMessenger().registerIncomingPluginChannel(this, "minecraft:brand", (channel, player, message) -> {});

        // Register listeners
        getServer().getPluginManager().registerEvents(new JoinListener(this), this);
        getServer().getPluginManager().registerEvents(new ChannelListener(this), this);
        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);

        // Register command
        ModsCommand modsCommand = new ModsCommand(this);
        getCommand("mods").setExecutor(modsCommand);
        getCommand("mods").setTabCompleter(modsCommand);

        getLogger().info("CursedxMods enabled successfully.");
    }

    @Override
    public void onDisable() {
        if (dataManager != null) {
            dataManager.saveSync();
        }
        getServer().getMessenger().unregisterIncomingPluginChannel(this, "minecraft:brand");
        getLogger().info("CursedxMods disabled. Data saved.");
    }
}