halogamer
📎 1 file 6,687 chars
📄
pasted-code-1791816903894.txt
txt 112 lines
▶
Make me a fully functional Minecraft plugin for Paper 1.21.11 that adds a complete team and alliance system with custom double-chest GUIs. Make sure every feature works properly and that all team data saves after server restarts.

**Team Creation**

- Allow any player to use `/team create` to create their own team.
- When a player uses `/team create`, open a custom GUI that allows them to enter a team name. They must enter a valid name before the team can be created.
- Do not allow players to create a team without a name or join multiple teams at once.
- Automatically make the player who creates the team its owner.
- Give every team a unique name and prevent duplicate team names.
- After creating a team, automatically open its custom double-chest GUI.

**Team GUI**

Create a custom 54-slot double-chest GUI for each team. Make it look clean and organized, with clickable items representing different options.

The GUI should include:
- Team information and team name.
- Team members displayed using their Minecraft player heads.
- An option to invite players.
- An option to view pending invitations.
- An option to manage team members.
- An option to view allied teams.
- An option to send alliance requests.
- An option to leave the team.
- An option to disband the team (team owner only).

Make every option functional. Players must not be able to take items from the GUI, place items inside it, or exploit it using shift-clicking, number keys, or inventory dragging.

**Team Commands and Invitations**

- `/team` — Open the team GUI and view team information.
- `/team create` — Start the team creation process.
- `/team invite ` — Invite a player to the team.
- `/team accept ` — Accept a team invitation.
- `/team deny ` — Decline a team invitation.
- `/team leave` — Leave the current team.
- `/team kick ` — Kick a member (owner or authorized staff only).
- `/team info ` — View team information.
- `/team transfer ` — Transfer team ownership.
- `/team disband` — Disband the team (owner only).

Players should receive clear messages when they are invited, accept or decline an invitation, leave a team, or get kicked. Prevent expired, duplicate, and invalid invitations.

**Team Names Next to Player Names**

- Display each player's team name next to their username in the Minecraft tab list.
- Display the team name next to their username above their head during normal gameplay.
- Use a clean format such as `[TeamName] PlayerName`.
- Update the formatting automatically whenever someone joins a team, leaves a team, changes their name display, or gets kicked.
- Players who are not in a team should keep their normal username display.
- Make sure this works for both online and offline team members when their data is loaded.

**Alliance System**

Add a complete alliance system that lets separate teams become allies.

- Add an alliance option to the team GUI.
- Add `/ally request ` to request an alliance with the team of the specified player.
- If the target player is not in a team, display an appropriate error message.
- Send alliance requests to the target team's owner or authorized members.
- Allow the receiving team to accept or decline alliance requests.
- Add `/ally accept `, `/ally deny `, `/ally list`, and `/ally remove `.
- Display allied teams in the team GUI, including their team names.
- Allow authorized members to manage alliances through the GUI.
- Prevent teams from allying with themselves, sending duplicate requests, or creating duplicate alliances.
- If a team is disbanded, clean up its alliance relationships and pending requests.

**Team and Ally PvP Protection**

This is one of the most important parts of the plugin.

- Team members cannot damage or kill other members of their own team.
- Allied teams cannot damage or kill each other's members.
- Protection must work in both directions.
- Block melee attacks, swords, axes, bows, crossbows, tridents, projectiles, and other player-caused damage.
- Correctly identify the original shooter of arrows and other projectiles so players cannot bypass protection using ranged attacks.
- Make sure explosions or other indirect player-caused attacks cannot bypass the protection when the responsible attacker can be identified.
- Cancel the damage completely so protected players do not lose health.
- Do not interfere with normal PvP between players who are not teammates or allies.
- Ensure that team and alliance protection works consistently after reconnecting or restarting the server.

**Permissions and Restrictions**

- Any player can create and manage their own team, subject to team ownership rules.
- Only team owners or authorized members can invite players, kick members, disband teams, transfer ownership, or manage alliances.
- Prevent unauthorized players from using team management commands.
- Validate all player names and team names.
- Prevent players from joining another team while already in a team.
- Handle team ownership correctly if the owner leaves or transfers ownership.
- Display helpful error messages whenever a command cannot be completed.

**Data Saving and Configuration**

- Save team names, owners, members, invitations, alliances, and pending alliance requests.
- Store the data in persistent files so it survives server restarts and reloads.
- Add a configuration file for settings such as team size limits, invitation expiration, team name length, and name formatting.
- Ensure all data is loaded safely when the plugin starts.
- Avoid data loss when players disconnect, teams change, or the server shuts down.

**Technical Requirements**

- Build the plugin specifically for Paper 1.21.11.
- Use reliable Bukkit/Paper APIs and proper event listeners.
- Include a valid `plugin.yml` or equivalent supported plugin metadata, all required source files, and a working build configuration.
- Register every command and tab completion correctly.
- Avoid deprecated or incompatible methods where possible.
- Make sure the plugin compiles without errors and does not produce console errors during normal operation.
- Do not leave any commands, GUI buttons, or features unfinished.

Before finishing, test the team creation process, invitations, GUI interactions, team name displays, alliance requests, ownership permissions, data persistence, and all friendly-fire protection scenarios.

The final result must be a working `.jar` plugin that I can put directly into my server's `plugins` folder, along with the source code and any setup instructions needed to use it.
Kodari AI
KodariOct 12 at 3:01 pm 3
TeamAllianceSystem
A comprehensive Minecraft Paper plugin implementing a full team and alliance management system with custom double-chest GUIs. Players create teams via interactive GUI, manage members through player-head displays, send invitations and alliance requests, and access team controls. Features persistent data storage for teams, members, invitations, and alliances across restarts. Includes tab-list and nametag team name formatting, friendly-fire protection between teammates and allies with projectile tracking, configurable settings for team limits and invitation expiration, and complete command suite with tab completion and permission checks.
  1. Add the Paper 1.21.11 build metadata and plugin configuration.

  2. Implement persistent team, invitation, role, alliance, and display management.

  3. Add team/alliance commands, creation/chat flow, GUIs, and friendly-fire protection.

Implemented the Paper 1.21.11 team and alliance plugin with chat-based team naming, 54-slot team menus, invitations, manager roles, ownership transfer, alliances, saved data, name formatting, and friendly-fire protection for direct, projectile, TNT, and area-effect-cloud damage. Team data and pending requests persist in plugins/TeamAlliance/teams.yml; settings are in config.yml.

Use /team create, then click the name-entry item and type a name in chat. Team managers can invite or kick members and manage alliances; only the owner can transfer ownership or disband. Alliance commands include /ally request, /ally accept, /ally deny, /ally list, and /ally remove.

To get the jar in Kodari: click Compile in the desktop top bar, or ⋮ → Compile Project on mobile; click Compile in the window, then Download when it succeeds. I haven’t run a live Paper server session, so the gameplay scenarios haven’t been runtime-tested here.

halogamer

make it so you can do the ally without being on a team

Kodari AI
KodariOct 12 at 3:03 pm 1

An alliance is between two teams, so /ally request <player> currently needs your team as the requesting side. If you’re not on a team, there’s no team to ally on your behalf.

Do you want solo players to be able to create or join a team automatically for alliances, or should they be able to manage alliances for an existing team without being a member?

halogamer

its not letting people invite players to there team with /team or the gui please fix it and make it so that we can have non team allys

Kodari AI
KodariOct 12 at 3:24 pm 2
  1. Fix team invitations from /team and the GUI.

  2. Add alliance requests for solo players and keep them distinct from team-to-team alliances.

  1. Solo alliances: /ally request, accept, deny, list, and remove will support player-to-player allies when both players are teamless. These alliances will persist and receive the same friendly-fire protection; team alliances stay as they are.

  1. Fixed invitations: /team invite <player> and the GUI now use the online inviter’s name consistently, so the recipient gets a usable /team accept <player> command.

  2. Added personal alliances for two players who are both teamless. Use /ally request <player>, /ally accept <player>, /ally deny <player>, /ally list, and /ally remove <player>. Personal alliances and pending requests are saved, and personal allies are protected from each other’s PvP. Team alliances remain unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
9 1,443
src/main/java/com/kodari/teamalliance/TeamAlliancePlugin.java
package com.kodari.teamalliance;

import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class TeamAlliancePlugin extends JavaPlugin {
    private TeamManager teamManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        teamManager = new TeamManager(this);
        TeamGUI gui = new TeamGUI(this, teamManager);
        TeamCommand commands = new TeamCommand(teamManager, gui);
        Bukkit.getPluginManager().registerEvents(gui, this);
        Bukkit.getPluginManager().registerEvents(new CombatListener(teamManager), this);

        PluginCommand teamCommand = getCommand("team");
        PluginCommand allyCommand = getCommand("ally");
        if (teamCommand == null || allyCommand == null) {
            getLogger().severe("The team and ally commands must be declared in plugin.yml.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        teamCommand.setExecutor(commands);
        teamCommand.setTabCompleter(commands);
        allyCommand.setExecutor(commands);
        allyCommand.setTabCompleter(commands);

        Bukkit.getPluginManager().registerEvents(new org.bukkit.event.Listener() {
            @org.bukkit.event.EventHandler
            public void onJoin(org.bukkit.event.player.PlayerJoinEvent event) {
                Bukkit.getScheduler().runTask(TeamAlliancePlugin.this, () -> teamManager.updateMemberName(event.getPlayer()));
            }
        }, this);
        teamManager.refreshDisplays();
    }

    @Override
    public void onDisable() {
        if (teamManager != null) teamManager.save();
    }

    public TeamManager getTeamManager() {
        return teamManager;
    }
}