Develop a clans plugin named "Gracc Clans" for Minecraft version 1.21.1 that allows players to create clans using the command /clan create. The plugin should feature customizable clan colors, a hierarchy with designated leaders and members, and support for displaying clan information through placeholders for nametags and scoreboards. Ensure that the plugin maintains a clean codebase and includes essential functionalities like clan chat, member management, and permission settings, similar to the Better Teams plugin.
Planning class dependencies before writing:
GraccClans→ holdsClanManager,FileStorageClanManager→ usesClan,ClanPlayer,ClanRole,FileStorageClan→@Data, stores members, color, tag, leader UUIDClanPlayer→@Data, stores UUID, clan name, roleClanRole→ enum LEADER / MEMBERClanCommand→ usesClanManager,MessageUtilClanChatListener→ usesClanManagerPlaceholderHook→ usesClanManagerFileStorage→ usesClan,ClanPlayer,ClanRoleMessageUtil→ static utility
Now I have everything needed. Let me build the full plugin:
Now I need to wire MessageUtil into GraccClans and update the main class to expose it:
GraccClans Clans plugin is complete. Here’s a summary of everything built:
GraccClans— main plugin class withFileStorage,ClanManager,MessageUtilfields and@GetterClan/ClanPlayer/ClanRole/PendingInvite— data models with Lombok annotationsClanManager— full business logic: create, disband, invite, accept/deny, kick, leave, color, tag, transfer leadership, clan chat messagingFileStorage— per-clan YAML files indata/clans/and per-player YAML indata/players/, full load/save/delete operationsMessageUtil— centralized message formatting with prefix support and placeholder replacementClanColors— 16 named color options mapped to&codesClanCommand— full/clancommand with 13 subcommands and tab-completionClanChatListener— intercepts chat for players with clan chat toggled onClanPlayerListener— resets clan chat state on disconnectClansPlaceholderExpansion— 10 PAPI placeholders (%graccclans_clan_name%,%graccclans_clan_tag_formatted%,%graccclans_clan_prefix%, etc.) for use in nametags and scoreboards
Can I update some things
Of course! What would you like to update or change?
First of all as you can see in clan prefix idk why I write theduo but it only registered the I want to register atleast 6 words and create 6 words clan and also one thing that is when I did the prefix thing it already has brackets with placeholder please delete all brackets with placeholder I only the prefix name or name of the clan
Let me read all the relevant files first.
Now let me read the placeholder and listener files to find where the prefix is displayed in chat.
I can see both issues clearly:
Multi-word clan names —
handleCreateonly readsargs[1](one word), andisValidNameregex[a-zA-Z0-9_]+blocks spaces entirelyBrackets in placeholder —
clan_prefixandclan_tag_formattedboth hardcode"[" + clan.getTag() + "]"
Here’s what changed:
Multi-word names:
handleCreatenow joins all words after/clan createinto one name (e.g./clan create The Duo→"The Duo"),isValidNamenow allows spaces and enforces a max of 6 words (configurable viamax-clan-name-wordsin config), andmax-clan-name-lengthis raised to 48 to accommodate longer namesNo more brackets in placeholders:
%graccclans_clan_prefix%now returns just the colored clan name (e.g.TheDuo), and%graccclans_clan_tag_formatted%returns just the colored tag with no[ ]wrapping
Not only that the prefix also gets only 3 words shown in tab or in nametag
Let me read the relevant files first.
Let me read the remaining files.
The issue is clear:
The plugin has no scoreboard team implementation, so nametags/tab use nothing from this plugin directly
When TAB plugin uses
%graccclans_clan_prefix%it returns the full clan name, but Minecraft scoreboard team prefixes are capped at 16 characters pre-1.13, causing truncation — which at&b+ color + name cuts off visually at ~3 wordsThe fix: implement a proper
ClanTeamManagerusing scoreboard teams with the formatted tag (short, designed for this), refresh on all clan state changes (join, leave, disband, kick, login)
Now I have everything I need. Here’s the plan:
Create
ClanTeamManagerthat manages one Bukkit scoreboard team per clan, setting the prefix tocolorCode + "[" + tag + "] "— well under the 16-char pre-1.13 limitRegister team on clan creation, refresh prefix on color/tag change, remove player on leave/kick/disband, assign on login
Wire into
GraccClans,ClanManager, andClanPlayerListener
Now patch GraccClans to add the manager field and load all teams after clans are loaded:
Now patch ClanPlayerListener to handle PlayerJoinEvent and assign the scoreboard team:
Now patch ClanManager to call clanTeamManager on every mutation — create, disband, accept invite, kick, leave, color, tag, transfer leadership:
What changed: Added ClanTeamManager which creates one main-scoreboard team per clan (named gc_<clanname>, max 16 chars, safe on all versions) with prefix [color][TAG] — only 10–12
Actually I mean this look I have created a clan name grass but it only shows the gra
Let me read the relevant files to find where the clan tag is being truncated.
Found the bug. In Clan.java, the constructor auto-generates the tag using only the first 3 characters of the name, so “grass” → “GRA”. It should use up to 5 characters (matching the max-tag-length config default).
The default tag generation now uses up to 5 characters (matching max-tag-length), so a clan named “grass” will show [GRASS] instead of [GRA]. Existing clans with saved tags are unaffected — only newly created clans get the corrected default.
Download
Here’s a full breakdown of your GraccClans plugin:
📦 Project Structure
GraccClans/
├── build.gradle
├── src/main/
│ ├── java/com/graccnetwork/clans/
│ │ ├── GraccClans.java ← Main plugin class
│ │ ├── commands/
│ │ │ └── ClanCommand.java ← All /clan subcommands + tab completion
│ │ ├── listeners/
│ │ │ ├── ClanChatListener.java ← Intercepts chat for clan chat mode
│ │ │ └── ClanPlayerListener.java ← Join/quit handling
│ │ ├── managers/
│ │ │ ├── ClanManager.java ← Core logic (create, disband, invite, etc.)
│ │ │ ├── ClanTeamManager.java ← Scoreboard team/prefix management
│ │ │ └── MessageUtil.java ← Config-based messaging utility
│ │ ├── model/
│ │ │ ├── Clan.java ← Clan data model
│ │ │ ├── ClanPlayer.java ← Per-player clan state
│ │ │ ├── ClanRole.java ← LEADER / MEMBER enum
│ │ │ └── PendingInvite.java ← Invite with expiry
│ │ ├── placeholders/
│ │ │ └── ClansPlaceholderExpansion.java ← PlaceholderAPI integration
│ │ ├── storage/
│ │ │ └── FileStorage.java ← YAML flat-file persistence
│ │ └── util/
│ │ └── ClanColors.java ← Color name → &code mapping
│ └── resources/
│ ├── plugin.yml
│ └── config.yml
✅ Features
Feature | Details |
|---|---|
Clan creation | /clan create <name> — name up to 48 chars, up to 6 words, alphanumeric + spaces |
Disband | Leader only; notifies all members and deletes all data |
Invite / Accept / Deny | Timed invites (configurable, default 60s); auto-expire via scheduler |
Kick | Leader can kick online or offline members |
Leave | Members only — leaders must disband or transfer first |
Clan info | Shows tag, leader, color, full member list with role colors |
Clan list | Lists all clans with tag, name, and member count |
Clan chat | Toggle with /clan chat; persists across sessions (off on quit) |
Color | 16 named colors (e.g. aqua, gold) mapped to & codes |
Tag | 2–5 alphanumeric characters; forced uppercase |
Transfer leadership | /clan setleader <player> — swaps LEADER/MEMBER roles |
Scoreboard prefix | Clan tag + color shown in tab/nametags via main scoreboard teams |
PlaceholderAPI | 10 placeholders: %graccclans_clan_name%, _tag%, _color%, _role%, etc. |
Flat-file storage | Individual YAML files per clan ( data/clans/) and player ( data/players/) |
Tab completion | Context-aware for all subcommands |
Config messages | Every message is configurable in config.yml under messages: |
🔧 Commands
Command | Permission | Description |
|---|---|---|
/clan create <name> | graccclans.clan.create | Create a new clan |
/clan disband | graccclans.clan.disband | Disband your clan (leader only) |
/clan invite <player> | graccclans.clan.invite | Invite a player (leader only) |
/clan accept | — | Accept a pending invite |
/clan deny | — | Deny a pending invite |
/clan kick <player> | graccclans.clan.kick | Kick a member (leader only) |
/clan leave | graccclans.clan.leave | Leave your clan |
/clan info [clan] | graccclans.clan.info | View clan info |
/clan list | graccclans.clan.list | List all clans |
/clan chat | graccclans.clan.chat | Toggle clan chat mode |
/clan color <name> | graccclans.clan.color | Set clan color (leader only) |
/clan tag <tag> | graccclans.clan.tag | Set clan tag (leader only) |
/clan setleader <player> | graccclans.clan.setleader | Transfer leadership |
📌 PlaceholderAPI Placeholders
Placeholder | Returns |
|---|---|
%graccclans_clan_name% | Raw clan name |
%graccclans_clan_tag% | Raw tag |
%graccclans_clan_color% | Translated color char |
%graccclans_clan_tag_formatted% | Color + tag |
%graccclans_clan_name_formatted% | Color + name |
%graccclans_clan_role% | Leader or Member |
%graccclans_clan_leader% | Leader’s name |
%graccclans_clan_size% | Member count |
%graccclans_clan_prefix% | Color + name + reset |
%graccclans_in_clan% | true / false |
⚙️ Build
./gradlew jar
Requires Java 21, targets Spigot 1.21.1. Output jar is in build/libs/. No shading needed — only compile-only deps (Spigot, PAPI, Lombok).
How should I download the new jar
Since this is a Gradle project, you build the jar using the Gradle wrapper from your project’s root directory:
On Windows:
gradlew build
On Mac/Linux:
./gradlew build
The compiled jar will be output to:
build/libs/
Common tips:
If you get a permission denied on Mac/Linux, run
chmod +x gradlewfirstUse
gradlew clean buildto do a fresh build and avoid stale cache issuesIf you’re using an IDE like IntelliJ, you can also open the Gradle panel on the right side and double-click Tasks → build → build
Drop the jar into your server’s plugins/ folder and restart (or use a plugin manager like /reload — though a full restart is always safer).
Inwas wondering why is there a space between the clan prefix and when we /clan info it shows half the name of the clan in tag
Let me read the relevant files to find the source of both issues.
Let me also read the placeholder and config files.
I can see both issues clearly now:
Space in prefix: The
clan_prefixplaceholder returnsclan.getName() + " &r"— that trailing space before&rlands inside the brackets when your TAB config wraps it like[%graccclans_clan_prefix%], producing[duo ]instead of[duo].Half the name in
/clan infotag display: Your TAB config is using%graccclans_clan_prefix%(which returns the full clan name) instead of%graccclans_clan_tag%. For “Redemption” it shows the entire name inside the tag brackets. If a name is long enough it can get cut off by TAB’s character limits, showing only half.
Fix: remove the trailing space from clan_prefix, and add a properly-formatted clan_tag_bracket placeholder so you have a clean option for TAB.
Now in your TAB plugin config, swap whichever placeholder wraps in brackets to use %graccclans_clan_tag_bracket% instead of %graccclans_clan_prefix% or [%graccclans_clan_name%]. For example:
%graccclans_clan_tag_bracket% %player_name%
This will render as [DUO] Velox1ty instead of [Redemption ] etc.
Summary of what was wrong and what changed:
clan_prefixwas returningname + " &r"— the space before&rlanded inside the[…]your TAB format added, causing[duo ]The full clan name was leaking into the tag display because
clan_prefixreturns the name, not the short tag — long names got visually cut off by TAB’s character limit (looked like “half the name”)Fixed
clan_prefixto remove the trailing space, and added a new%graccclans_clan_tag_bracket%placeholder that correctly returns[TAG](color-coded, short tag, no stray spaces) for use in TAB
Set the default color of the clan created firstly to gray who ever create a clan the first color should be gray not aqua
Changed the default colorCode in the Clan constructor from &b (aqua) to &7 (gray), so every newly created clan will start with a gray color.
That's it thankyou
Got it! I have the full project structure for GraccClans loaded. Whenever you’re ready, just let me know what you’d like to add, fix, or change.
package com.graccnetwork.clans;
import com.graccnetwork.clans.commands.ClanCommand;
import com.graccnetwork.clans.listeners.ClanChatListener;
import com.graccnetwork.clans.listeners.ClanPlayerListener;
import com.graccnetwork.clans.managers.ClanManager;
import com.graccnetwork.clans.managers.ClanTeamManager;
import com.graccnetwork.clans.managers.MessageUtil;
import com.graccnetwork.clans.placeholders.ClansPlaceholderExpansion;
import com.graccnetwork.clans.storage.FileStorage;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class GraccClans extends JavaPlugin {
private FileStorage fileStorage;
private ClanManager clanManager;
private MessageUtil messageUtil;
private ClanTeamManager clanTeamManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.messageUtil = new MessageUtil(this);
this.fileStorage = new FileStorage(this);
this.clanManager = new ClanManager(this);
clanManager.loadAll();
this.clanTeamManager = new ClanTeamManager(this);
clanTeamManager.loadAll();
getCommand("clan").setExecutor(new ClanCommand(this));
getCommand("clan").setTabCompleter(new ClanCommand(this));
Bukkit.getPluginManager().registerEvents(new ClanChatListener(this), this);
Bukkit.getPluginManager().registerEvents(new ClanPlayerListener(this), this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new ClansPlaceholderExpansion(this).register();
getLogger().info("PlaceholderAPI hooked successfully.");
}
getLogger().info("GraccClans enabled successfully.");
}
@Override
public void onDisable() {
if (clanManager != null) {
clanManager.saveAll();
}
getLogger().info("GraccClans disabled.");
}
}