.ofxs

create plugin /settings and commands:

Kodari AI
KodariMon at 4:27 pm 1
ServerSettings
A comprehensive Minecraft plugin that provides a /settings command interface for players to manage their personal server preferences. The plugin features a GUI-based settings menu with configurable options such as player visibility, chat toggles, particle effects, sound preferences, and teleportation requests. Includes persistent data storage per player using YAML configuration, permission-based access control, and customizable messages. The settings interface supports multiple pages for organized navigation, with intuitive item icons and click handlers. Administrators can configure default settings and available options through the main config file. The plugin integrates seamlessly with existing server commands and provides a smooth, user-friendly experience for managing individual gameplay preferences.

What should each icon in the Settings menu control, and which commands besides /settings should the plugin have? The screenshot shows the layout, but not the item names or behavior.

.ofxs

add hex code support and /settings editor for admin command edit the gui settings and lore and name currenly on and off on color #00F986 off #FC0000

Kodari AI
KodariMon at 4:30 pm 4
  • Create the six-row menu from the image, with per-player on/off states.

  • Add an admin editor for item names, lore and materials, including hex colors.

Created /settings and the admin-only /settings editor. The editor changes item names, lore and materials; names and lore support #RRGGBB and &#RRGGBB colors.

The icons are currently generic, persistent on/off toggles—they don’t change gameplay behavior yet. Tell me what each setting should control to connect them.

.ofxs

and the gui settings must same in image not items can set commands the click settings like payalert

Kodari AI
KodariMon at 4:32 pm 2
  • Keep the image’s layout and let admins assign player commands to each icon.

  • Run configured commands on click; icons without commands will retain their local toggle.

The menu keeps the image layout. In /settings editor, select an icon and choose Edit click commands—for example, enter /payalert. Commands run as the clicking player.

Icons with commands no longer use the local toggle. Their displayed status won’t automatically reflect another plugin’s setting.

.ofxs

add messege.yml and config.yml add commands: example payalert and settings reload and all name menu use #00F986 small text

Kodari AI
KodariMon at 4:41 pm 4
  • Add messages.yml and an admin /settings reload command.

  • Use green small-text defaults for menu names and add /payalert as an example click command.

Added messages.yml, /settings reload, green small-text menu defaults, and a /payalert click-command example.

/payalert must be provided by another plugin. Existing config.yml files are preserved, so update them manually to use the new defaults.

.ofxs

My mean in config.yml COMMAND: 'payalert' like that example

Kodari AI
KodariMon at 4:43 pm 2

I’ll add a COMMAND: 'payalert' field for each item, while keeping existing command lists and the in-game editor working.

Added COMMAND: 'payalert' to the example item in config.yml. Existing command lists and the GUI editor still work.

.ofxs

don't items But menu settings example BOUNTY-ALERT and gui &8settings small text

Kodari AI
KodariMon at 4:45 pm 4

I’ll name settings in config.yml (for example, BOUNTY-ALERT) and make the menu title dark-gray small text.

Updated config.yml to use named settings such as BOUNTY-ALERT, and changed the menu title to &8ꜱᴇᴛᴛɪɴɢꜱ.

Existing configs keep their old items layout until you update or regenerate them.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 381
src/main/java/com/kodari/settings/SettingsPlugin.java
package com.kodari.settings;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
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.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.plugin.java.JavaPlugin;

public final class SettingsPlugin extends JavaPlugin implements Listener {
    private static final Pattern HEX = Pattern.compile("(?i)&#([0-9a-f]{6})|(?<![a-zA-Z0-9])#([0-9a-fA-F]{6})");
    private final Map<UUID, PendingEdit> pending = new ConcurrentHashMap<>();
    private File dataFile;
    private YamlConfiguration data;
    private File messagesFile;
    private YamlConfiguration messages;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("messages.yml", false);
        messagesFile = new File(getDataFolder(), "messages.yml");
        messages = YamlConfiguration.loadConfiguration(messagesFile);
        dataFile = new File(getDataFolder(), "players.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("settings.reload")) {
                send(sender, "no-permission");
                return true;
            }
            reloadConfig();
            messages = YamlConfiguration.loadConfiguration(messagesFile);
            send(sender, "reloaded");
            return true;
        }
        if (!(sender instanceof Player)) {
            send(sender, "players-only");
            return true;
        }
        Player player = (Player) sender;
        if (args.length == 0) {
            openMenu(player, false);
        } else if (args.length == 1 && args[0].equalsIgnoreCase("editor")) {
            if (!player.hasPermission("settings.editor")) {
                send(player, "no-permission");
                return true;
            }
            openMenu(player, true);
        } else {
            send(player, "usage");
        }
        return true;
    }

    private void openMenu(Player player, boolean editor) {
        MenuHolder holder = new MenuHolder(editor ? "editor" : "settings", -1);
        Inventory inventory = Bukkit.createInventory(holder, 54, color(editor ? getConfig().getString("editor-title", "#00F986ꜱᴇᴛᴛɪɴɢꜱ ᴇᴅɪᴛᴏʀ") : getConfig().getString("title", "&8ꜱᴇᴛᴛɪɴɢꜱ")));
        holder.inventory = inventory;
        ConfigurationSection items = settingsSection();
        if (items != null) {
            for (String key : items.getKeys(false)) {
                try {
                    int slot = items.getName().equals("items") ? Integer.parseInt(key) : items.getInt(key + ".slot", -1);
                    if (slot >= 0 && slot < inventory.getSize()) {
                        ItemStack item = settingItem(player, slot, editor);
                        if (item != null) inventory.setItem(slot, item);
                    }
                } catch (NumberFormatException ignored) {
                    getLogger().warning("Invalid settings slot: " + key);
                }
            }
        }
        player.openInventory(inventory);
    }

    private ConfigurationSection settingsSection() {
        ConfigurationSection old = getConfig().getConfigurationSection("items");
        return old != null ? old : getConfig().getConfigurationSection("settings");
    }

    private String settingPath(int slot) {
        ConfigurationSection section = settingsSection();
        if (section == null) return null;
        for (String key : section.getKeys(false)) {
            if (section.getName().equals("items") ? key.equals(String.valueOf(slot)) : section.getInt(key + ".slot", -1) == slot) {
                return section.getName() + "." + key;
            }
        }
        return null;
    }

    private ItemStack settingItem(Player player, int slot, boolean editor) {
        String path = settingPath(slot);
        if (path == null) return null;
        Material material = Material.matchMaterial(getConfig().getString(path + ".material", "PAPER"));
        if (material == null || !material.isItem()) return null;
        boolean enabled = data.getBoolean(player.getUniqueId() + "." + slot, true);
        String status = getConfig().getString(enabled ? "on-text" : "off-text", enabled ? "&#00F986ON" : "&#FC0000OFF");
        ItemStack item = new ItemStack(material);
        ItemMeta meta = item.getItemMeta();
        if (meta == null) return item;
        meta.setDisplayName(color(getConfig().getString(path + ".name", "Setting").replace("{status}", status)));
        List<String> lore = new ArrayList<>();
        for (String line : getConfig().getStringList(path + ".lore")) lore.add(color(line.replace("{status}", status)));
        if (editor) lore.add(color(messages.getString("editor-item-lore", "&eClick to edit this item")));
        meta.setLore(lore);
        item.setItemMeta(meta);
        return item;
    }

    private void openItemEditor(Player player, int slot) {
        MenuHolder holder = new MenuHolder("item", slot);
        Inventory inventory = Bukkit.createInventory(holder, 27, color(getConfig().getString("item-editor-title", "#00F986ᴇᴅɪᴛ ꜱᴇᴛᴛɪɴɢ {slot}").replace("{slot}", String.valueOf(slot))));
        holder.inventory = inventory;
        inventory.setItem(10, editorButton("NAME_TAG", "#00F986ᴇᴅɪᴛ ɴᴀᴍᴇ", "&7Type a name in chat."));
        inventory.setItem(12, editorButton("PAPER", "#00F986ᴇᴅɪᴛ ʟᴏʀᴇ", "&7Separate lines with | in chat."));
        inventory.setItem(14, editorButton("CHEST", "#00F986ᴇᴅɪᴛ ᴍᴀᴛᴇʀɪᴀʟ", "&7Type a material name in chat."));
        inventory.setItem(16, editorButton("ARROW", "#00F986ʙᴀᴄᴋ", "&7Return to the settings editor."));
        inventory.setItem(22, editorButton("COMMAND_BLOCK", "#00F986ᴇᴅɪᴛ ᴄʟɪᴄᴋ ᴄᴏᴍᴍᴀɴᴅꜱ", "&7Separate player commands with |; type clear to remove."));
        player.openInventory(inventory);
    }

    private ItemStack editorButton(String materialName, String name, String description) {
        Material material = Material.matchMaterial(materialName);
        ItemStack item = new ItemStack(material);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(color(name));
        meta.setLore(Arrays.asList(color(description)));
        item.setItemMeta(meta);
        return item;
    }

    @EventHandler
    public void onClick(InventoryClickEvent event) {
        if (!(event.getView().getTopInventory().getHolder() instanceof MenuHolder)) return;
        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player) || event.getRawSlot() < 0 || event.getRawSlot() >= event.getView().getTopInventory().getSize()) return;
        Player player = (Player) event.getWhoClicked();
        MenuHolder holder = (MenuHolder) event.getView().getTopInventory().getHolder();
        int slot = event.getRawSlot();
        if (!holder.type.equals("settings") && !player.hasPermission("settings.editor")) {
            player.closeInventory();
            return;
        }
        if (holder.type.equals("item")) {
            if (slot == 16) {
                openMenu(player, true);
                return;
            }
            String field = slot == 10 ? "name" : slot == 12 ? "lore" : slot == 14 ? "material" : slot == 22 ? "commands" : null;
            if (field != null) {
                pending.put(player.getUniqueId(), new PendingEdit(holder.slot, field));
                player.closeInventory();
                player.sendMessage(color(messages.getString(field.equals("commands") ? "prompt-commands" : "prompt-edit", "").replace("{field}", field)));
            }
        } else if (settingPath(slot) != null) {
            if (holder.type.equals("editor")) {
                openItemEditor(player, slot);
            } else {
                String path = settingPath(slot);
                List<String> commands = getConfig().getStringList(path + ".commands");
                String configuredCommand = getConfig().getString(path + ".COMMAND", "").trim();
                if (!configuredCommand.isEmpty()) commands.add(0, configuredCommand);
                if (!commands.isEmpty()) {
                    player.closeInventory();
                    for (String configured : commands) {
                        String command = configured.replace("{player}", player.getName()).trim();
                        if (command.startsWith("/")) command = command.substring(1).trim();
                        if (!command.isEmpty()) player.performCommand(command);
                    }
                    return;
                }