Rytec Legendary

Create a comprehensive, production-ready Paper 1.21.11 Minecraft plugin in Java named "ZylosClans" (Main class: com.zylos.clans.ZylosClans) that implements an in-depth clan management, chat routing, permission-editable core ranks, and reciprocal alliance friendly-fire system utilizing Paper's native Dialog API. The plugin must support plain-text clan names (no colors), overhead nametag suffix appending without interfering with TAB below-name stats, Vault economy integration, and rich multi-dialog navigation.

  1. PLUGIN NAMING & CONFIGURATION ARCHITECTURE:
  • Official Plugin Name: ZylosClans
  • Package & Main Class: com.zylos.clans.ZylosClans
  • Database Storage: Persistent local SQLite or MySQL storage under plugins/ZylosClans/data/ to record clans, recruitment modes (Public / Invite-Only), core rank permission overrides, player-to-clan linkages, allies, Vault balances, and friendly-fire states.
  • config.yml:

- min_clan_name_length: 2 - max_clan_name_length: 5 - allow_colors: false (Strictly strip/block MiniMessage tags and legacy color codes in clan names) - max_members_per_clan: 20 - max_allies: 5 (Configurable maximum alliance limit per clan) - creation_cost: 0.0 (Vault economy cost to found a clan) - nametag_format: "<gray>[<small_caps_clan>]</gray>" (Appended directly to the right of the player's overhead nametag, coexisting cleanly with any existing below-name stats plugins)

  • messages.yml: MiniMessage/RGB formatted notifications, chat formats, invitation alerts, error states, and broadcast messages.
  • sounds.yml: Configurable sound keys, volume, and pitch for:

- menu_open - clan_created - member_joined - rank_changed - button_click - error_beep

  1. COMMANDS, CHAT ROUTING & PLACEHOLDERS:
  • /clan (Aliases: /clans, /guild, /zylosclans): Opens the main clan dialog menu (or prompts to create/browse public clans if unaligned).
  • /clan create <name>: Founds a new clan with a plain-text name (2-5 characters, no separate tag).
  • /clan invite <player>: Sends a direct invitation to another player (requires the sender's rank to have INVITE permission).
  • /clan join <name>: Joins a public clan directly or accepts an active invite.
  • /clan chat [message]:

- If <message> is provided: Sends a one-off message to clan chat without changing active chat channels. - If <message> is omitted: Toggles persistent Clan Chat mode ON/OFF (routes normal chat directly to clan chat; disables Ally Chat toggle if active). - Format: [<bold><rank></bold>] <player>: <message>

  • /clan allychat [message]:

- If <message> is provided: Sends a one-off message to ally chat without changing active chat channels. - If <message> is omitted: Toggles persistent Ally Chat mode ON/OFF (routes normal chat directly to ally chat; disables Clan Chat toggle if active). - Format: [<bold><clan_name></bold>] [<rank>] <player>: <message>

  • /clan reload: Reloads all configuration files and data caches. Requires permission zylosclans.admin.
  • PlaceholderAPI & Overhead Nametag Display:

- %zylosclans_clan%: Outputs the player's raw clan name (e.g., ASC or ASCx, or empty string if unaligned) for scoreboards. - Overhead Nametag: Appends <gray>[ᴀꜱᴄ]</gray> (converting clan name characters into Unicode Small Caps) to the right of the player's overhead nametag, preserving existing below-name stats displays.

  1. CORE RANKS & CONFIGURABLE PERMISSIONS:
  • Default Ranks: Member, Veteran, Co-Leader, Leader (additional custom ranks can be added in configuration files).
  • Default Permission Matrix:

- Member: Can execute /clan deposit <amount> only. - Veteran: Can execute /clan deposit <amount> only. - Co-Leader: Full permissions by default, including vault withdrawals (VAULT_WITHDRAW), inviting, kicking, and managing settings/allies. - Leader: Absolute permissions, including rank permission editing and clan disbanding.

  • Rank Permission Editor Dialog: Leaders or members with MANAGE_RANKS permission can open a feature-rich dialog menu to toggle granular permissions for each core rank.
  1. FEATURE-RICH NATIVE DIALOG FLOW:

UNALIGNED PLAYER MENU (/clan when not in a clan)

  • Title: "ZylosClans - Join or Create" with a banner/shield sprite.
  • Content & Buttons:

- "Create a Clan" Button: Opens a clean Dialog text input form asking for the clan name (2-5 plain characters). - "Browse Public Clans" Button: Opens a scrollable Dialog list of all clans currently set to "Public", showing member count and a 1-click "Join Clan" button. - "Close" Button.

MAIN CLAN DASHBOARD (/clan when in a clan)

  • Title: Displayed as "<clan_name> - Clan Hub" accompanied by <sprite:"minecraft:blocks":"minecraft:blocks/beacon">.
  • Overview Body: Displays Clan Name, Recruitment Status (Public or Invite-Only), Member Count, Shared Vault Balance, Player Rank, and Friendly-Fire status toggles.
  • Interactive Dialog Sub-Menus:

1. Roster & Member Management Dialog: - Lists all online and offline members sorted by rank hierarchy. Each entry shows the member's player head sprite, username, Online/Offline status, and assigned rank. - Clicking any member (if viewer has permission) opens a Member Action Dialog with buttons to change rank, kick member, or transfer leadership. 2. Rank Permissions Manager Dialog (Leader / Authorized Roles): - Lists core ranks (Member, Veteran, Co-Leader, Leader) and allows editing their permission toggles (e.g., enabling vault withdrawals for Veterans). 3. Clan Vault Dialog: - Displays the shared clan balance with interactive "Deposit" and "Withdraw" Dialog input prompts (Withdraw restricted by VAULT_WITHDRAW permission). 4. Alliances Dialog: - Lists current allied clans (up to the max_allies limit) with "Break Alliance" options, plus a "Request Alliance" input dialog. 5. Clan Settings & Friendly Fire Dialog: - Interactive toggle button switching recruitment between Public and Invite-Only. - Clan Friendly Fire Toggle: Enables or disables PvP damage between members of the same clan. - Ally Friendly Fire Toggle: Enables or disables PvP damage toward allied clans. (Note: Damage between two allied clans is only enabled if both clans have ally friendly-fire toggled ON). - "Leave Clan" button (or "Disband Clan" confirmation dialog for the Leader).

  • Bottom Action Button: "Close" button to exit the UI session.
  1. INVITATION & COMBAT RULES:
  • Clan Invitations: Executing /clan invite <player> sends the target a rich chat component with an interactive [ Accept Invite ] button. Accepting adds them to the clan without popping open the clan dialog menu automatically.
  • Friendly-Fire Enforcement:

- Same-clan PvP is controlled by the clan's internal friendly-fire setting. - Inter-clan alliance PvP is strictly reciprocal: damage is allowed only if Clan A AND Clan B both have ally friendly-fire enabled.

  1. TEXT FORMATTING & ITALICS FIX:
  • Force-disable italics across all dialog buttons, titles, roster names, rank badges, and lore text (<!italic> in MiniMessage or Component.decoration(TextDecoration.ITALIC, false)).
Kodari AI
KodariNov 12 at 2:01 am 55
ZylosClans
A comprehensive Paper 1.21.11 clan management plugin with SQLite/MySQL storage, Vault economy integration, and Paper's native Dialog API. Features plain-text clan names (2-5 chars), configurable core ranks with granular permission toggles, clan/ally chat routing with persistent modes, reciprocal alliance friendly-fire enforcement, overhead nametag suffix appending using Unicode Small Caps, and rich multi-dialog navigation including clan creation, public clan browsing, member roster management, rank permission editor, shared vault, alliances, and settings menus. Includes PlaceholderAPI support, MiniMessage formatting, configurable sounds, and full configuration reload capability.
  1. Build persistent clans, ranks, vaults, invitations, alliances, and friendly-fire rules.

  2. Add commands, chat routing, placeholders, nametags, and configurable messages and sounds.

  3. Create the native Paper dialog flows for clan management.

Created ZylosClans for Paper 1.21.11 with native dialogs, SQLite persistence, clan chat, editable ranks, vaults, alliances, and reciprocal friendly fire.

  • Data is stored in plugins/ZylosClans/data/clans.db.

  • Vault and an economy provider are required for paid creation and vault transactions; PlaceholderAPI is optional.

  • Invitations and alliance requests expire and reset on reload or restart. Disbanding requires an empty vault.

  • Below-name scoreboard objectives are untouched, though other plugins managing nametag teams may compete over suffixes.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
settings.gradle
Code
24 3,129
src/main/java/com/zylos/clans/ZylosClans.java
package com.zylos.clans;

import com.zylos.clans.command.ClanCommand;
import com.zylos.clans.dialog.ClanDialogs;
import com.zylos.clans.hook.ClanExpansion;
import com.zylos.clans.listener.PlayerListener;
import com.zylos.clans.service.ClanChat;
import com.zylos.clans.service.ClanService;
import com.zylos.clans.service.EconomyBridge;
import com.zylos.clans.service.NameTagService;
import com.zylos.clans.service.RankRegistry;
import com.zylos.clans.service.VaultEconomy;
import com.zylos.clans.storage.ClanStorage;
import com.zylos.clans.util.Text;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Objects;
import java.util.logging.Level;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class ZylosClans extends JavaPlugin {
    @Getter private RankRegistry ranks;
    @Getter private ClanStorage storage;
    @Getter private ClanService clans;
    @Getter private ClanChat clanChat;
    @Getter private NameTagService nameTags;
    @Getter private ClanDialogs dialogs;
    private FileConfiguration messages;
    private FileConfiguration sounds;
    private Runnable expansionCleanup;

    @Override
    public void onEnable() {
        try {
            saveDefaultConfig();
            if (!new File(getDataFolder(), "messages.yml").exists()) {
                saveResource("messages.yml", false);
            }
            if (!new File(getDataFolder(), "sounds.yml").exists()) {
                saveResource("sounds.yml", false);
            }
            loadAuxiliaryConfigurations();
            ranks = new RankRegistry(this);
            ranks.reload();
            storage = new ClanStorage(this);
            EconomyBridge economy = Bukkit.getPluginManager().isPluginEnabled("Vault")
                ? new VaultEconomy(this) : EconomyBridge.unavailable();
            clans = new ClanService(this, storage, ranks, economy);
            clans.reload();
            clanChat = new ClanChat(this, storage);
            clanChat.reload();
            nameTags = new NameTagService(this);
            dialogs = new ClanDialogs(this);
            ClanCommand executor = new ClanCommand(this);
            PluginCommand command = Objects.requireNonNull(getCommand("clan"), "clan command is missing from plugin.yml");
            command.setExecutor(executor);
            command.setTabCompleter(executor);
            getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
            if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
                ClanExpansion expansion = new ClanExpansion(this);
                if (expansion.register()) {
                    expansionCleanup = expansion::unregister;
                } else {
                    getLogger().warning("PlaceholderAPI rejected the ZylosClans expansion.");
                }
            }
            nameTags.start();
            for (Player online : Bukkit.getOnlinePlayers()) {
                clans.onJoin(online);
            }
        } catch (Exception | LinkageError ex) {
            getLogger().log(Level.SEVERE, "Could not enable ZylosClans", ex);
            getServer().getPluginManager().disablePlugin(this);
        }
    }

    @Override
    public void onDisable() {
        if (nameTags != null) {
            nameTags.stop();
        }
        if (expansionCleanup != null) {
            expansionCleanup.run();
        }
        if (storage != null) {
            try {
                storage.close();
            } catch (SQLException ex) {
                getLogger().log(Level.SEVERE, "Could not close the clan database", ex);
            }
        }
    }

    public boolean reloadAll() {
        try {
            reloadConfig();
            loadAuxiliaryConfigurations();
            ranks.reload();
            clans.reload();
            clanChat.reload();
            nameTags.refresh();
            return true;
        } catch (Exception ex) {
            getLogger().log(Level.SEVERE, "Could not reload ZylosClans", ex);
            return false;
        }
    }

    private void loadAuxiliaryConfigurations() throws IOException, InvalidConfigurationException {
        YamlConfiguration newMessages = new YamlConfiguration();
        YamlConfiguration newSounds = new YamlConfiguration();
        newMessages.load(new File(getDataFolder(), "messages.yml"));
        newSounds.load(new File(getDataFolder(), "sounds.yml"));
        messages = newMessages;
        sounds = newSounds;
    }

    public Component rawMessage(String key, String... replacements) {
        String template = messages.getString(key, "<red>Missing message: " + key + "</red>");
        try {
            return Text.render(template, replacements);
        } catch (RuntimeException ex) {
            getLogger().warning("Invalid MiniMessage in messages.yml for " + key + ": " + ex.getMessage());
            return Text.text(template);
        }
    }

    public Component message(String key, String... replacements) {
        return rawMessage("prefix").append(rawMessage(key, replacements));
    }

    public void send(CommandSender recipient, String key, String... replacements) {
        recipient.sendMessage(message(key, replacements));
    }

    public void play(Player player, String key) {
        String sound = sounds.getString(key + ".sound", "");
        if (sound == null || sound.isBlank()) {
            return;
        }
        double configuredVolume = sounds.getDouble(key + ".volume", 1.0);
        double configuredPitch = sounds.getDouble(key + ".pitch", 1.0);
        if (!Double.isFinite(configuredVolume) || !Double.isFinite(configuredPitch)) {
            return;
        }
        float volume = (float) Math.max(0.0, Math.min(10.0, configuredVolume));
        float pitch = (float) Math.max(0.5, Math.min(2.0, configuredPitch));
        player.playSound(player.getLocation(), sound, volume, pitch);
    }
}