calmdev0499
πŸ“Ž 1 file 18,351 chars
πŸ“„
pasted-code-1789917009692.txt
txt 1117 lines
β–Ά
# CUSTOM SERVER OPTIONS

## Complete Minecraft Paper Plugin Specification

Build a **complete, production-ready Minecraft Paper plugin** called:

**CustomServerOptions**

This plugin is for the **Dreamlands Minecraft server**, but it must remain a **general-purpose configurable plugin**. Do NOT hard-code Dreamlands into the plugin's functionality.

This is a REAL plugin.

Do NOT build a mockup, fake system, prototype, simulated GUI, fake command execution, or demonstration.

The final project must compile into a working `.jar` that can be installed on a Paper server.

---

# 1. MAIN PURPOSE

Create a customizable **Custom Server Options** system.

The plugin allows a server owner to create clickable options that execute commands provided by other installed Minecraft plugins.

For example, if the server has:

```text
/shop
/rtp
/home
/rewards
/warp spawn
```

the owner can add those commands to CustomServerOptions without modifying the plugin's Java source code.

The plugin should act as a configurable interface for existing server commands.

---

# 2. IMPORTANT: COMMAND EXECUTION

When a player clicks an option that runs a command:

```text
PLAYER CLICKS OPTION
        ↓
CLOSE CUSTOM OPTIONS MENU
        ↓
RETURN PLAYER TO NORMAL GAMEPLAY
        ↓
EXECUTE COMMAND
        ↓
PLAYER REMAINS CONNECTED TO SERVER
```

The player must NOT:

* Disconnect
* Leave the Minecraft server
* Return to the title screen
* Reconnect
* Stay inside the GUI
* Have the GUI remain open while the command runs

The menu closes immediately, the player returns to normal gameplay, and the configured command executes normally.

Example:

```yaml
shop:
  name: "&6&lServer Shop"
  command: "shop"
```

Clicking it should effectively do:

```text
Close GUI
Player returns to gameplay
Execute /shop
```

The command must be executed through the normal Minecraft/Paper command system so that the plugin providing the command can process it.

---

# 3. AUTOMATIC PLUGIN FILE CREATION

When the plugin starts for the first time, automatically create:

```text
plugins/
└── CustomServerOptions/
    β”œβ”€β”€ config.yml
    β”œβ”€β”€ options.yml
    β”œβ”€β”€ messages.yml
    └── data/
```

The owner must NOT have to manually create these files.

Generate useful comments and examples in the configuration files.

If a configuration file is missing, safely recreate it.

Do not overwrite existing configuration unless explicitly requested.

---

# 4. options.yml

The main options should be configured through:

```text
options.yml
```

Example:

```yaml
options:

  shop:
    name: "&6&lServer Shop"
    description:
      - "&7Open the server shop."
    command: "shop"
    enabled: true
    permission: ""
    icon: "EMERALD"
    slot: 20

  rtp:
    name: "&a&lRandom Teleport"
    description:
      - "&7Teleport somewhere random."
    command: "rtp"
    enabled: true
    permission: ""
    icon: "COMPASS"
    slot: 22

  rewards:
    name: "&e&lRewards"
    description:
      - "&7Claim your available rewards."
    command: "rewards"
    enabled: true
    permission: ""
    icon: "CHEST"
    slot: 24
```

These are only examples.

The server owner must be able to completely change, remove, or add options.

---

# 5. CUSTOM OPTION NAMES

This is extremely important.

The displayed name must be completely separate from the command.

Example:

```yaml
shop:
  name: "&5&lDreamlands Market"
  command: "shop"
```

The player sees:

```text
Dreamlands Market
```

but the plugin executes:

```text
/shop
```

Changing:

```yaml
name:
```

must NEVER change:

```yaml
command:
```

The owner should be able to rename every option from the configuration file.

Support color formatting.

Support legacy formatting such as:

```text
&a
&b
&c
&d
&e
&f
&l
&n
&o
&r
```

Where supported by the target Paper version, also support MiniMessage formatting.

---

# 6. OPTION SETTINGS

Every option should support configurable properties.

Example:

```yaml
example:
  name: "&dExample Option"

  description:
    - "&7This is an example."
    - "&8Click to use it."

  command: "example"

  enabled: true

  permission: ""

  icon: "DIAMOND"

  slot: 10

  category: "main"

  cooldown: 0

  execute-as: "PLAYER"

  sound:
    enabled: true
    type: "UI_BUTTON_CLICK"
    volume: 1.0
    pitch: 1.0
```

Support:

* Name
* Description/lore
* Command
* Enabled/disabled
* Permission
* Icon
* Slot
* Category
* Cooldown
* Execution mode
* Sound
* Command arguments
* Confirmation
* Ordering

---

# 7. COMMANDS FROM OTHER PLUGINS

The plugin must NOT hard-code commands.

The owner can enter any valid server command.

Examples:

```yaml
command: "shop"
```

```yaml
command: "rtp"
```

```yaml
command: "home"
```

```yaml
command: "rewards"
```

```yaml
command: "warp spawn"
```

```yaml
command: "kit starter"
```

The plugin should not care which plugin provides the command.

If the command exists, execute it.

If another plugin provides it, allow that plugin to handle the command normally.

---

# 8. COMMAND ARGUMENTS

Commands must support arguments.

Examples:

```yaml
command: "warp spawn"
```

```yaml
command: "kit starter"
```

```yaml
command: "home main"
```

The entire configured command after the leading slash should be treated as the command string.

The owner should NOT need to put `/` at the beginning.

Correct:

```yaml
command: "shop"
```

Not:

```yaml
command: "/shop"
```

Optionally support placeholders inside command arguments.

---

# 9. EXECUTION MODES

Support:

```yaml
execute-as: "PLAYER"
```

and:

```yaml
execute-as: "CONSOLE"
```

Default to:

```yaml
execute-as: "PLAYER"
```

For PLAYER:

* Close GUI
* Return player to gameplay
* Execute command as the player

For CONSOLE:

* Close GUI
* Return player to gameplay
* Execute configured command from the server console

If console execution requires the player's name or placeholders, support placeholders.

---

# 10. PLACEHOLDERS

Support useful built-in placeholders:

```text
%player%
%player_name%
%uuid%
%world%
```

If PlaceholderAPI is installed, integrate with it automatically.

PlaceholderAPI should be an optional/soft dependency.

The plugin must still work without PlaceholderAPI.

---

# 11. PERMISSIONS

Every option can have its own permission.

Example:

```yaml
permission: "customserveroptions.shop"
```

If empty:

```yaml
permission: ""
```

everyone can use it.

Create a configurable behavior for users without permission.

For example:

```yaml
permission-settings:
  hide-without-permission: true
```

If true:

* Hide the option.

If false:

* Show the option but prevent use.

Permission checks must actually work.

---

# 12. GUI SYSTEM

Create a real Minecraft inventory GUI for the Custom Server Options system.

Allow configuration of:

```yaml
gui:
  title: "&5&lServer Options"
  size: 54
```

The owner must be able to customize:

* Title
* Size
* Option slots
* Background/filler
* Navigation buttons
* Back button
* Icons
* Names
* Lore
* Sounds

The GUI must be functional, not decorative.

Clicking an option must perform its configured action.

---

# 13. CATEGORIES

Support categories.

Example:

```yaml
categories:

  main:
    name: "&dMain"

  economy:
    name: "&6Economy"

  social:
    name: "&bSocial"

  server:
    name: "&aServer"
```

Options can specify:

```yaml
category: "economy"
```

Categories should support:

* Name
* Description
* Icon
* Permission
* Enabled/disabled
* Slot

---

# 14. MULTIPLE PAGES

If the menu contains more options than fit on one page:

Automatically create additional pages.

Include:

* Next page
* Previous page
* Current page indicator
* Back button

Do not overlap option slots with navigation buttons.

Make all navigation positions configurable.

---

# 15. CUSTOM ICONS

Allow the owner to choose the Minecraft material used for each option.

Example:

```yaml
icon: "DIAMOND"
```

Other examples:

```yaml
icon: "CHEST"
```

```yaml
icon: "COMPASS"
```

```yaml
icon: "EMERALD"
```

Validate materials safely.

If an invalid material is configured:

* Log a clear warning
* Use a safe fallback icon
* Do not crash the server

---

# 16. SOUNDS

Support configurable sounds.

For example:

```yaml
sound:
  enabled: true
  type: "UI_BUTTON_CLICK"
  volume: 1.0
  pitch: 1.0
```

Support sounds for:

* Opening menu
* Clicking option
* Successful action
* Error
* Back
* Next page
* Previous page

Allow sounds to be disabled.

Invalid sounds must not crash the plugin.

---

# 17. CONFIRMATION SYSTEM

Allow individual options to require confirmation.

Example:

```yaml
confirmation:
  enabled: true
  title: "&cAre you sure?"
```

Display:

```text
CONFIRM
CANCEL
```

Clicking CANCEL returns to the previous menu.

Clicking CONFIRM:

1. Close confirmation GUI.
2. Return player to gameplay.
3. Execute the configured command.
4. Keep player connected to the server.

---

# 18. COOLDOWNS

Support per-option cooldowns.

Example:

```yaml
cooldown: 5
```

The player cannot activate that option again until the cooldown expires.

Use:

```yaml
cooldown: 0
```

for no cooldown.

Display a configurable message when the option is still on cooldown.

---

# 19. RELOAD COMMAND

Create:

```text
/customserveroptions reload
```

This must reload:

* config.yml
* options.yml
* messages.yml

without requiring a server restart.

Do not lose data.

---

# 20. OTHER COMMANDS

Create:

```text
/customserveroptions help
```

```text
/customserveroptions list
```

```text
/customserveroptions version
```

```text
/customserveroptions debug
```

Use an appropriate admin permission, for example:

```text
customserveroptions.admin
```

---

# 21. DEBUG COMMAND

`/customserveroptions debug` should display useful information such as:

* Plugin version
* Paper version
* Number of loaded options
* Number of categories
* Enabled options
* Disabled options
* Missing commands
* Soft dependencies
* PlaceholderAPI status

NEVER display:

* Passwords
* Tokens
* API keys
* Server secrets
* Private credentials

---

# 22. MISSING COMMAND HANDLING

If an option uses a command that does not currently exist:

DO NOT crash.

Example:

```yaml
command: "someplugincommand"
```

If the command is unavailable:

* Log a warning
* Keep the option loaded
* Do not crash
* Prevent the invalid action from causing errors

Example log:

```text
[CustomServerOptions] Warning: Command "someplugincommand" configured for option "Example" is unavailable.
```

If the plugin providing the command is installed later, the configured option should work normally.

Do not permanently mark it as broken.

---

# 23. PLUGIN COMPATIBILITY

The plugin should work alongside other Paper plugins.

It should be compatible with common systems such as:

* Economy plugins
* Shop plugins
* RTP plugins
* Home plugins
* Reward plugins
* Permission plugins
* PlaceholderAPI
* GUI plugins
* Teleport plugins
* Warp plugins

Use soft dependencies where appropriate.

Do not require unrelated plugins.

---

# 24. CONFIGURATION COMMENTS

Make the configuration files beginner-friendly.

For example:

```yaml
# The name players see.
name: "&6&lServer Shop"

# The command executed when clicked.
# Do not include the leading slash.
command: "shop"

# Set to false to hide this option.
enabled: true
```

Explain important settings with comments.

---

# 25. MESSAGES.YML

Create:

```text
messages.yml
```

Allow the owner to customize messages such as:

* No permission
* Invalid command
* Cooldown
* Reload successful
* Reload failed
* Option unavailable
* Confirmation messages
* Help messages
* Debug messages

Do not hard-code player-facing messages when they can reasonably be configurable.

---

# 26. CONFIG.YML

Use `config.yml` for global settings.

Example:

```yaml
settings:

  debug: false

  permission:
    hide-without-permission: true

  sounds:
    enabled: true

  placeholders:
    enabled: true

  command-execution:
    default-mode: "PLAYER"
```

Keep option-specific settings inside `options.yml`.

---

# 27. DATA STORAGE

Only store data that is actually required.

For example, cooldown information may be kept temporarily in memory.

Do not collect unnecessary player information.

Do not send data to external servers.

The plugin should work completely locally.

---

# 28. PERFORMANCE

The plugin must be lightweight and optimized.

Do NOT:

* Run unnecessary tasks every tick
* Constantly scan all plugins
* Constantly reload files
* Spam the console
* Perform expensive operations when unnecessary

Use efficient event handling.

Do not create memory leaks.

Clean up player-specific temporary data when players leave if necessary.

---

# 29. GUI SAFETY

Prevent players from exploiting the GUI.

For example:

* Prevent unauthorized item movement
* Prevent taking GUI items
* Prevent placing items inside the GUI
* Correctly handle clicks
* Correctly handle shift-clicks
* Correctly handle number-key clicks
* Correctly handle double-clicks
* Correctly handle drag events
* Prevent invalid inventory interactions

The GUI must not allow players to steal or manipulate menu items.

---

# 30. COMMAND SAFETY

Never allow configuration values to cause arbitrary server-side code execution.

Only use the normal Minecraft/Paper command system.

Do not dynamically compile Java code.

Do not evaluate configuration as executable code.

Validate configuration values safely.

---

# 31. PROJECT STRUCTURE

Use a clean structure similar to:

```text
CustomServerOptions/
β”œβ”€β”€ build.gradle
β”‚
β”œβ”€β”€ settings.gradle
β”‚
└── src/
    └── main/
        β”œβ”€β”€ java/
        β”‚   └── .../
        β”‚       β”œβ”€β”€ CustomServerOptions.java
        β”‚       β”‚
        β”‚       β”œβ”€β”€ commands/
        β”‚       β”œβ”€β”€ config/
        β”‚       β”œβ”€β”€ gui/
        β”‚       β”œβ”€β”€ options/
        β”‚       β”œβ”€β”€ listeners/
        β”‚       β”œβ”€β”€ integrations/
        β”‚       └── utilities/
        β”‚
        └── resources/
            β”œβ”€β”€ plugin.yml
            β”œβ”€β”€ config.yml
            β”œβ”€β”€ options.yml
            └── messages.yml
```

Use clean object-oriented architecture.

Separate:

* Configuration
* GUI
* Commands
* Option execution
* Permissions
* Integrations
* Utilities
* Event listeners

---

# 32. PAPER API

Target the Paper Minecraft version specified by the project.

Use modern supported Paper APIs where possible.

Avoid obsolete APIs when a supported replacement exists.

Keep version-dependent code isolated so the plugin can be updated later.

---

# 33. NO HARD-CODED SERVER BRANDING

The plugin may be installed on Dreamlands, but do NOT hard-code:

```text
Dreamlands
```

into the core plugin.

The owner must be able to change:

```yaml
gui:
  title: "&5&lServer Options"
```

to any server name they want.

The plugin should work on completely different Minecraft servers too.

---

# 34. EXAMPLE DEFAULT OPTIONS

Generate useful examples:

```yaml
options:

  shop:
    name: "&6&lServer Shop"
    description:
      - "&7Open the server shop."
    command: "shop"
    enabled: true
    permission: ""
    icon: "EMERALD"
    slot: 20
    category: "main"

  rtp:
    name: "&a&lRandom Teleport"
    description:
      - "&7Teleport somewhere random."
    command: "rtp"
    enabled: true
    permission: ""
    icon: "COMPASS"
    slot: 22
    category: "main"

  rewards:
    name: "&e&lRewards"
    description:
      - "&7Claim your rewards."
    command: "rewards"
    enabled: true
    permission: ""
    icon: "CHEST"
    slot: 24
    category: "main"
```

These are examples only.

Make them easy to edit or delete.

---

# 35. IMPORTANT USER EXPERIENCE

The plugin should feel like a polished server feature.

The player should be able to:

1. Open Custom Server Options.
2. See the configured options.
3. Click an option.
4. The menu closes.
5. The player returns to normal gameplay.
6. The command executes.
7. The player remains connected.

Everything should feel immediate and smooth.

---

# 36. FINAL DELIVERABLE

Provide the COMPLETE plugin project.

Include:

1. Full Java source code
2. Build configuration
3. `plugin.yml`
4. `config.yml`
5. `options.yml`
6. `messages.yml`
7. All commands
8. All permissions
9. Installation instructions
10. Configuration instructions
11. Example configurations
12. Dependency information
13. Build instructions
14. The final installable `.jar`

The final plugin must be genuinely functional.

DO NOT provide pseudocode instead of implementation.

DO NOT leave TODO placeholders for core functionality.

DO NOT fake command execution.

DO NOT fake GUI functionality.

DO NOT claim something works if it has not been implemented.

If a requested feature is technically impossible with the target Paper/server/client architecture, clearly explain the limitation and implement the closest genuinely supported alternative.

## FINAL GOAL

Create a polished, reliable, lightweight **CustomServerOptions** Paper plugin that lets server owners build their own custom server-options menus entirely through configuration files.

The owner should be able to install other plugins and simply add their commands to `options.yml`.

The owner should be able to change the **display name independently from the command**.

And when a player clicks an option:

**MENU CLOSES β†’ PLAYER RETURNS TO GAMEPLAY β†’ COMMAND EXECUTES β†’ PLAYER STAYS ON SERVER.**
Kodari AI
KodariSep 20 at 3:14 pm 2
CustomServerOptions
A configurable Paper plugin that creates a clickable inventory GUI menu for server commands. Server owners define options in YAML files with display names, descriptions, commands, permissions, icons, slots, categories, cooldowns, and execution modes. Players open the menu, click an option, the GUI closes, and the configured command executes through the normal command system. Supports multiple pages, categories, confirmation dialogs, sounds, placeholders, and PlaceholderAPI integration. Includes reload, help, list, version, and debug commands with admin permissions. Automatically generates configuration files on first run and handles missing commands gracefully without crashing.

Created the complete CustomServerOptions Paper plugin project.

Key features included:

  • Configurable inventory GUI with pagination

  • Custom option names, icons, lore, categories, slots, ordering, permissions, cooldowns, sounds, and confirmation

  • PLAYER and CONSOLE command execution modes

  • Built-in placeholders and optional PlaceholderAPI support

  • Safe GUI click, drag, shift-click, and item movement handling

  • /customserveroptions open

  • /customserveroptions reload

  • /customserveroptions help

  • /customserveroptions list

  • /customserveroptions version

  • /customserveroptions debug

  • Automatic creation of config.yml, options.yml, messages.yml, and data/

  • Missing configuration file recovery

  • Legacy & color formatting

  • Paper 1.21.4 and Java 21 build configuration

Build with:

Shell
./gradlew build

Install the generated JAR from:

Plain Text
build/libs/CustomServerOptions-1.0.0.jar

Place it in the server’s plugins/ folder, start the server once, then configure the generated files under:

Plain Text
plugins/CustomServerOptions/
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
settings.gradle
Code
21 1,231
src/main/java/com/kodari/customserveroptions/CustomServerOptions.java
package com.kodari.customserveroptions;

import com.kodari.customserveroptions.commands.CustomServerOptionsCommand;
import com.kodari.customserveroptions.config.ConfigurationManager;
import com.kodari.customserveroptions.gui.OptionsGuiManager;
import com.kodari.customserveroptions.options.OptionManager;
import com.kodari.customserveroptions.services.CommandExecutorService;
import com.kodari.customserveroptions.services.CooldownManager;
import com.kodari.customserveroptions.services.PlaceholderService;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class CustomServerOptions extends JavaPlugin {
    private ConfigurationManager configurationManager;
    private OptionManager optionManager;
    private CooldownManager cooldownManager;
    private PlaceholderService placeholderService;
    private CommandExecutorService commandExecutorService;
    private OptionsGuiManager guiManager;

    @Override
    public void onEnable() {
        getDataFolder().mkdirs();
        new java.io.File(getDataFolder(), "data").mkdirs();

        configurationManager = new ConfigurationManager(this);
        optionManager = new OptionManager(this, configurationManager);
        optionManager.reload();
        cooldownManager = new CooldownManager();
        placeholderService = new PlaceholderService(this, configurationManager);
        commandExecutorService = new CommandExecutorService(this, placeholderService, configurationManager);
        guiManager = new OptionsGuiManager(this, configurationManager, optionManager, cooldownManager, commandExecutorService);
        Bukkit.getPluginManager().registerEvents(guiManager, this);

        CustomServerOptionsCommand command = new CustomServerOptionsCommand(this);
        if (getCommand("customserveroptions") != null) {
            getCommand("customserveroptions").setExecutor(command);
            getCommand("customserveroptions").setTabCompleter(command);
        }
    }

    public void reloadPlugin() {
        configurationManager.reload();
        optionManager.reload();
    }

    public ConfigurationManager getConfigurationManager() {
        return configurationManager;
    }

    public OptionManager getOptionManager() {
        return optionManager;
    }

    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    public OptionsGuiManager getGuiManager() {
        return guiManager;
    }
}