CUTE KING

Can you make it?

📎 1 file 21,552 chars
📄
FalconXTeams_Plugin_Prompt.txt
txt 1743 lines
▶
🦅 FALCONX TEAMS — FULL PRODUCTION-READY PLUGIN PROMPT

Create a complete, production-ready Minecraft team plugin called FalconX Teams for FalconX Network.

The plugin must be designed for Paper 1.21.x, Java 21, and work correctly with Java Edition and Bedrock Edition through Geyser/Floodgate.

---

1. PLUGIN IDENTITY

Plugin Name: FalconX Teams
Display Name: "ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"
JAR Name: "FalconXTeams.jar"
Package: "in.falconx.teams"
Minecraft: Paper 1.21.x
Java: Java 21
Network: FalconX Network

The plugin must be lightweight, secure, optimized and production-ready.

---

2. MAIN COMMAND

Main command:

"/team"

Aliases:

"/teams"

"/t"

The command system must have proper tab completion and permission checking.

---

3. TEAM CREATION

Command:

"/team create "

Example:

"/team create FalconX"

The player becomes the Team Owner.

Every team must contain:

- Unique team ID
- Team name
- Team tag
- Owner
- Officers
- Members
- Description
- Team color
- Member limit
- Team home
- Team ender chest
- Team warp
- Team settings
- Creation timestamp

Prevent duplicate team names.

Team names must be case-insensitive.

---

4. TEAM NAME VALIDATION

Configurable:

- Minimum length
- Maximum length
- Allowed characters
- Blocked words
- Duplicate-name protection
- Unicode restrictions
- Color-code restrictions

Example:

"FalconX"

and:

"falconx"

must be treated as the same team.

Never allow malicious input to reach commands, GUIs or database queries.

---

5. TEAM ROLES

👑 OWNER

The owner has complete control over the team.

Owner can:

- Invite players
- Accept requests
- Kick members
- Promote members
- Demote officers
- Change team name
- Change team tag
- Change description
- Change team color
- Change team settings
- Enable/disable team PvP
- Manage team warp
- Manage team ender chest
- Transfer ownership
- Disband team

⭐ OFFICER

Configurable permissions.

Default:

- Invite players
- Accept join requests
- Kick regular members
- View team information
- Use team management features

Officers cannot:

- Transfer ownership
- Disband the team
- Change owner-only settings
- Change team PvP unless explicitly granted permission

👤 MEMBER

Members can:

- View team information
- Use team chat
- Use team ender chest
- Use team warp
- Use team home
- View members
- Leave the team

---

6. TEAM INVITATIONS

Command:

"/team invite "

Send an invitation.

Example:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

"Vexron invited you to join FalconX."

Buttons:

"[ ACCEPT ] [ DENY ]"

Commands:

"/team accept"

"/team deny"

Features:

- Invitation expiration
- Invitation cooldown
- Duplicate-invitation protection
- Team-full protection
- Cannot invite someone already in a team
- Configurable offline-player invitations
- Pending invitation limit

---

7. JOIN REQUESTS

Command:

"/team request "

Players can request to join a team if requests are enabled.

Owner/officers receive:

"ShadowX wants to join FalconX."

Buttons:

"[ ACCEPT ] [ DENY ]"

Commands:

"/team requests"

"/team accept "

"/team deny "

Support:

- Request expiration
- Request cooldown
- Public/private teams
- Maximum pending requests

---

8. TEAM CHAT — IMPORTANT SPECIAL SYSTEM

Implement a two-state team chat toggle.

Command:

"/team chat"

First use

When the player runs:

"/team chat"

their chat switches to TEAM CHAT MODE.

Display:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

"Team chat enabled. Your messages will only be sent to your teammates."

Now when they type:

"Enemy at spawn"

ONLY their team members receive:

"[TEAM] Vexron: Enemy at spawn"

The message must NOT appear in public chat.

Second use

When the player runs:

"/team chat"

again:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

"Team chat disabled. Your messages will now be sent to public chat."

Now:

"Enemy at spawn"

goes to normal public chat.

Important

The plugin must remember each player's current chat mode while they are online.

A player should also be able to use:

"/tc "

to send one message directly to team chat without changing their current chat mode.

Example:

"/tc Enemy near base"

→ only teammates receive it.

The team chat system must never leak private team messages into public chat.

---

9. TEAM CHAT FORMATTING

Configurable format:

"[TEAM] %player%: %message%"

Example:

"[TEAM] Vexron: Enemy coming."

Use MiniMessage or another modern formatting system.

Support:

- Team color
- Player name
- Team tag
- Message
- Role

---

10. TEAM PVP SYSTEM

Every team has a Team PvP setting.

Default:

"OFF"

When Team PvP is OFF:

Teammates cannot damage each other.

Example:

"You cannot attack your teammate while Team PvP is disabled."

When Team PvP is ON:

Teammates CAN damage each other.

---

11. TEAM PVP GUI — OWNER ONLY

Team PvP must be controlled through the team management GUI.

Only the Team Owner can change this setting by default.

GUI item:

"⚔ Team PvP"

When OFF:

"Status: OFF"

"Click to enable Team PvP."

When ON:

"Status: ON"

"Click to disable Team PvP."

When the owner clicks it, update immediately.

Example:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

"Team PvP has been enabled."

or:

"Team PvP has been disabled."

Important security rule

Normal members must never be able to change this setting.

Officers also cannot change it unless an administrator explicitly gives them permission.

Server administrators can override the setting.

---

12. TEAM HOME

Commands:

"/team sethome"

"/team home"

"/team delhome"

Shared team teleport location.

Features:

- Teleport delay
- Cooldown
- Combat restriction
- Movement cancellation
- Damage cancellation
- World restrictions
- Permission bypass
- Configurable number of homes

Example:

"Teleporting to team home in 5 seconds..."

If player moves:

"Teleport cancelled because you moved."

If player is in combat:

"You cannot use team home while in combat."

---

13. TEAM WARP — NEW FEATURE

Teams can create shared warps.

Command:

"/team setwarp "

Example:

"/team setwarp base"

Then:

"/team warp base"

teleports the team member to that warp.

Command:

"/team delwarp "

List:

"/team warps"

Example:

"Available Team Warps:"

"• base"

"• farm"

"• shop"

"• pvp"

Warp permissions

Configurable permissions:

- Owner can create/delete warps
- Officers can create/delete warps
- Members can only use warps

Allow the server administrator to configure the maximum number of team warps.

Example:

"max-warps: 3"

Warp safety

Team warp must support:

- Teleport delay
- Cooldown
- Combat restriction
- Movement cancellation
- World blacklist
- Safe-location checking

Never allow team warps to become an easy combat escape.

---

14. TEAM ENDER CHEST

Command:

"/team echest"

Create a shared team Ender Chest storage system.

Every member of the team accesses the same storage.

Example:

Vexron puts an item inside.

Rolex_07 runs:

"/team echest"

and can see the same items.

Important

This must NOT use the player's normal Minecraft Ender Chest.

Each team gets its own separate persistent storage.

Example:

Team:

"FalconX"

has:

"FalconX Team Ender Chest"

Another team:

"Shadow"

has:

"Shadow Team Ender Chest"

They must be completely separate.

Permissions

Configurable:

- Who can open it
- Who can deposit
- Who can withdraw
- Owner-only management
- Officer access

Default:

All team members can use it.

Storage

Store team Ender Chest contents persistently.

Do not lose contents after:

- Server restart
- Player disconnect
- Plugin reload
- Team member leaving

When a team is disbanded, administrator configuration determines whether the storage:

- Is deleted
- Is backed up
- Is dropped
- Is preserved for administrators

Default should be safe and avoid accidental item loss.

---

15. TEAM STORAGE SECURITY

Prevent:

- Unauthorized access
- Inventory duplication
- Shift-click exploits
- Double-click exploits
- Drag exploits
- GUI manipulation
- Race conditions
- Item duplication during server shutdown

Validate all inventory interactions server-side.

Save storage safely.

---

16. TEAM INFORMATION

Command:

"/team info"

or:

"/team info "

Display:

"╔════ ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs ════╗"

"Team: FalconX"

"Tag: [FAL]"

"Owner: Vexron"

"Members: 8/10"

"Online: 5"

"Team PvP: OFF"

"Warps: 3"

"Team Home: Set"

"Description: Official PvP Team"

"╚══════════════════════╝"

---

17. TEAM MEMBER LIST

Command:

"/team members"

Display:

- Owner
- Officers
- Members
- Online/offline status
- Member count

Example:

"👑 Vexron — Owner — Online"

"⭐ Rolex_07 — Officer — Online"

"👤 ShadowX — Member — Offline"

---

18. TEAM LIST

Command:

"/team list"

Pagination:

"/team list 2"

Display:

- Team name
- Tag
- Owner
- Members
- Online members
- Public/private status

---

19. TEAM TAG

Command:

"/team tag "

Example:

"/team tag FAL"

Display:

"[FAL] Vexron"

Features:

- Maximum length
- Minimum length
- Allowed characters
- Duplicate-tag prevention
- Formatting restrictions
- PlaceholderAPI support

---

20. TEAM COLOR

Command:

"/team color "

Or use the GUI.

Only authorized team members can change it according to configuration.

---

21. TEAM DESCRIPTION

Command:

"/team description "

Example:

"/team description Official FalconX PvP Team"

Configurable maximum length.

---

22. TEAM GUI

Create a modern inventory GUI named:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

Main GUI should contain:

👥 Members

View team members.

📊 Team Info

View complete team information.

📨 Invitations

Manage invitations.

📋 Join Requests

Accept/deny requests.

💬 Team Chat

Show current chat mode.

🏠 Team Home

Teleport to team home.

📦 Team Ender Chest

Open "/team echest".

🌀 Team Warps

View available team warps.

⚔ Team PvP

Owner-only toggle.

🎨 Team Color

Change team color if permitted.

🏷 Team Tag

Manage team tag.

📝 Description

Manage description.

⚙ Settings

Team settings.

🚪 Leave Team

Leave team.

🗑 Disband Team

Owner-only.

---

23. TEAM WARP GUI

Create a dedicated warp GUI.

Example:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs — WARPS"

Items:

"🏠 Base"

"🌾 Farm"

"🛒 Shop"

Clicking a warp teleports the player.

Owner/officers can have management controls:

"Create"

"Edit"

"Delete"

---

24. TEAM E-CHEST GUI

The "/team echest" command should directly open the team's shared storage.

GUI must look similar to a normal chest inventory but be clearly identified as:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs — Team Storage"

The storage size should be configurable.

Possible sizes:

- 27 slots
- 54 slots

Default:

"54"

---

25. MEMBER MANAGEMENT

Commands:

"/team kick "

"/team promote "

"/team demote "

"/team transfer "

"/team leave"

"/team disband"

Proper permission checks are mandatory.

---

26. OWNERSHIP TRANSFER

Command:

"/team transfer "

Require confirmation.

Example:

"⚠ Transfer FalconX ownership to Rolex_07?"

"/team transfer confirm"

After confirmation:

- New player becomes Owner
- Old owner becomes Member or Officer
- Notify all members

---

27. TEAM DISBAND

Command:

"/team disband"

Require confirmation.

Example:

"⚠ This permanently deletes FalconX."

"Type /team disband confirm"

Handle team storage safely according to configuration.

Delete:

- Team data
- Members
- Homes
- Warps
- Invitations
- Requests

---

28. TEAM LEAVE

Command:

"/team leave"

Require confirmation if configured.

Owner cannot leave without:

- Transferring ownership
  OR
- Disbanding the team

---

29. TEAM SETTINGS

Include:

- Public/private
- Join requests
- Friendly fire / Team PvP
- Team home
- Team warps
- Team storage
- Invitation permissions
- Officer permissions
- Member limit
- Team visibility

---

30. COMBAT PROTECTION

The plugin must support combat restrictions.

During combat, configurable commands/features can be blocked:

- "/team home"
- "/team warp"
- "/team sethome"
- "/team setwarp"

Example:

"You cannot use this team teleport while in combat."

Provide hooks for external combat plugins.

---

31. MEMBER LIMIT

Default:

"10"

Configurable.

Permission-based limits:

"falconxteams.limit.15"

Example:

Default:

"10 players"

VIP permission:

"15 players"

Do not allow players to bypass limits.

---

32. PLACEHOLDERAPI

Support placeholders such as:

"%falconxteams_name%"

"%falconxteams_tag%"

"%falconxteams_owner%"

"%falconxteams_members%"

"%falconxteams_online%"

"%falconxteams_role%"

"%falconxteams_description%"

"%falconxteams_has_team%"

"%falconxteams_pvp%"

"%falconxteams_chat_mode%"

"%falconxteams_warps%"

Use with:

- TAB
- Scoreboards
- Chat
- Nametags
- Holograms

---

33. JAVA + BEDROCK

Fully support:

- Java Edition
- Geyser
- Floodgate
- Bedrock players

Java and Bedrock players must share exactly the same team system.

Team data must not depend on Java-only player behavior.

---

34. DATABASE

Support:

SQLite

Required.

MySQL/MariaDB

Optional but recommended.

Store:

- Teams
- Members
- Roles
- Settings
- Homes
- Warps
- Team storage
- Invitations
- Requests
- Metadata

Use asynchronous database operations where appropriate.

Never perform expensive database queries on the main thread.

---

35. TEAM STORAGE DATABASE DESIGN

Team Ender Chest contents must be stored safely.

Each team's storage must have a unique identifier.

Never accidentally share storage between teams.

When saving item data:

- Validate item data
- Handle corrupted data safely
- Handle server shutdown
- Handle plugin reload
- Handle concurrent access

---

36. CONFIG.YML

Create a complete configuration.

Example:

team:
  max-name-length: 16
  min-name-length: 3
  default-member-limit: 10

pvp:
  default: false
  owner-only-toggle: true

chat:
  enabled: true
  command-toggle: true

home:
  enabled: true
  teleport-delay: 5
  cooldown: 60
  blocked-in-combat: true

warps:
  enabled: true
  max-warps: 3
  teleport-delay: 5
  cooldown: 30
  blocked-in-combat: true

echest:
  enabled: true
  size: 54

invitations:
  expiration: 120
  cooldown: 30

requests:
  expiration: 120
  cooldown: 30

gui:
  enabled: true

Every important option must be configurable.

---

37. MESSAGES.YML

ALL player-facing messages must be stored in:

"messages.yml"

Never hard-code player messages.

Include messages for:

- Team created
- Team deleted
- Team full
- Invalid name
- No permission
- No team
- Already in team
- Invitation
- Invitation accepted
- Invitation denied
- Join request
- Request accepted
- Request denied
- Team chat enabled
- Team chat disabled
- Team PvP enabled
- Team PvP disabled
- Team home
- Team warp
- Team Ender Chest
- Combat restriction
- Kick
- Promote
- Demote
- Ownership transfer
- Leave
- Disband
- Errors

Support MiniMessage.

---

38. COMMANDS

Implement:

"/team"

"/team create "

"/team invite "

"/team accept"

"/team deny"

"/team request "

"/team requests"

"/team info [team]"

"/team list [page]"

"/team members"

"/team chat"

"/team " if desired

"/tc "

"/team home"

"/team sethome"

"/team delhome"

"/team warp "

"/team warps"

"/team setwarp "

"/team delwarp "

"/team echest"

"/team kick "

"/team promote "

"/team demote "

"/team transfer "

"/team tag "

"/team color "

"/team description "

"/team settings"

"/team leave"

"/team disband"

"/team reload"

---

39. ADMIN COMMANDS

Create:

"/teamadmin"

Alias:

"/ta"

Commands:

"/teamadmin reload"

"/teamadmin info "

"/teamadmin list"

"/teamadmin delete "

"/teamadmin kick "

"/teamadmin forcejoin  "

"/teamadmin forceleave "

"/teamadmin setlimit  "

"/teamadmin setpvp  "

"/teamadmin storage "

Admins must be able to resolve team problems without directly editing database files.

---

40. PERMISSIONS

Create:

"falconxteams.team.create"

"falconxteams.team.invite"

"falconxteams.team.manage"

"falconxteams.team.chat"

"falconxteams.team.home"

"falconxteams.team.warp"

"falconxteams.team.echest"

"falconxteams.team.pvp"

"falconxteams.team.admin"

"falconxteams.admin"

"falconxteams.spy"

"falconxteams.reload"

"falconxteams.bypass.cooldown"

"falconxteams.bypass.combat"

"falconxteams.bypass.limit"

---

41. ANTI-ABUSE

Protect against:

- Team spam
- Invitation spam
- Request spam
- Duplicate team names
- Duplicate team tags
- GUI exploits
- Inventory exploits
- Team-storage duplication
- Teleport abuse
- Combat escape
- Permission bypass
- Member-limit bypass
- Malicious team names
- Malicious descriptions
- Concurrent database updates

---

42. PERFORMANCE

The plugin must be optimized for a real server.

Requirements:

- No unnecessary repeating tasks
- No constant database polling
- Async database operations
- Efficient caching
- Efficient team lookups
- Minimal event overhead
- No memory leaks
- Proper cache cleanup
- Safe shutdown

It should support hundreds of players and many teams without significant TPS impact.

---

43. API

Provide a public API for other FalconX plugins.

API methods should allow:

- Get team
- Get player's team
- Check teammates
- Get owner
- Get role
- Get members
- Create team
- Delete team
- Add member
- Remove member
- Change role
- Check Team PvP
- Access team settings

Events:

"TeamCreateEvent"

"TeamDeleteEvent"

"TeamJoinEvent"

"TeamLeaveEvent"

"TeamInviteEvent"

"TeamKickEvent"

"TeamPromoteEvent"

"TeamDemoteEvent"

"TeamTransferEvent"

"TeamPvPChangeEvent"

"TeamWarpCreateEvent"

"TeamWarpDeleteEvent"

---

44. PLUGIN INTEGRATIONS

Support:

- PlaceholderAPI
- LuckPerms
- Geyser
- Floodgate
- TAB
- Combat plugins
- Chat plugins
- Scoreboard plugins

Optional dependencies must not crash the plugin if unavailable.

---

45. RELOAD

Command:

"/team reload"

Reload configuration safely.

Do not use Bukkit's unsafe global "/reload".

Do not reload database connections incorrectly.

---

46. LOGGING

Console examples:

"[FalconX Teams] Plugin enabled successfully."

"[FalconX Teams] Loaded 42 teams."

"[FalconX Teams] SQLite database connected."

Errors must provide useful diagnostic information.

Do not spam the console.

---

47. TAB COMPLETION

Implement smart tab completion.

Examples:

"/team invite "

→ online players

"/team kick "

→ team members

"/team warp "

→ team warps

"/team info "

→ team names

"/team promote "

→ eligible members

Only show valid suggestions.

---

48. ERROR HANDLING

Gracefully handle:

- Invalid arguments
- Missing team
- Missing player
- No permission
- Team full
- Already in team
- Player already invited
- Request expired
- Team not found
- Combat restriction
- Cooldown
- Database failure
- Invalid GUI action
- Invalid storage state

Never expose Java stack traces to players.

---

49. SECURITY

All actions must be validated server-side.

Never trust:

- GUI clicks
- Client inventory actions
- Command input
- Player-provided team names
- Player-provided descriptions
- Player-provided warp names

Protect against race conditions when:

- Two players join simultaneously
- Two players accept the same request
- Two players change team settings
- Multiple players access Team Ender Chest

---

50. DOCUMENTATION

Include a complete README.

Document:

- Installation
- Requirements
- Commands
- Permissions
- Configuration
- Messages
- GUI
- PlaceholderAPI
- Database
- Geyser/Floodgate
- Team storage
- Team warps
- Team PvP
- API
- Troubleshooting

---

51. PROJECT STRUCTURE

Use clean architecture.

Example:

FalconXTeams/
├── src/main/java/
│   └── in/falconx/teams/
│       ├── FalconXTeams.java
│       ├── command/
│       ├── team/
│       ├── storage/
│       ├── database/
│       ├── gui/
│       ├── listener/
│       ├── placeholder/
│       ├── api/
│       ├── integration/
│       └── util/
│
├── src/main/resources/
│   ├── plugin.yml
│   ├── config.yml
│   ├── messages.yml
│   └── gui.yml
│
└── pom.xml

---

52. BUILD

Use:

Java 21

Maven

Target modern Paper 1.21.x.

The project must compile successfully.

Run:

"mvn clean package"

The final file must be:

"FalconXTeams.jar"

Output:

"target/FalconXTeams.jar"

Fix ALL compilation errors before delivery.

---

53. COMPLETE TESTING

Before declaring the plugin complete, test:

Team system

- Create team
- Rename team
- Delete team
- Leave team
- Transfer ownership

Members

- Invite
- Accept
- Deny
- Request
- Kick
- Promote
- Demote

Chat

- Team chat toggle
- Public chat toggle
- "/tc"
- Private message isolation

PvP

- PvP OFF
- PvP ON
- Owner-only GUI control
- Permission bypass
- Admin override

Home

- Set
- Delete
- Teleport
- Cooldown
- Combat restriction
- Movement cancellation

Warps

- Create
- Delete
- List
- Teleport
- Multiple warps
- Permissions
- Combat restrictions

Team Ender Chest

- Open
- Deposit
- Withdraw
- Persistence
- Multiple teams
- Server restart
- Plugin reload
- Duplication testing
- Concurrent access

GUI

- Every button
- Permissions
- Invalid clicks
- Bedrock compatibility

Database

- Server restart
- Plugin restart
- Data persistence
- Error recovery

Security

- Permission bypass
- GUI exploits
- Inventory exploits
- Race conditions
- Malicious input

Fix every discovered bug before release.

---

54. FINAL REQUIREMENT

Do NOT create a simple demonstration plugin.

Create a complete professional team-management platform called:

"ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs"

It must be suitable for a real FalconX Network Minecraft server.

The plugin must be:

Fast ⚡

Secure 🔐

Modern 🎨

Configurable ⚙️

PvP-friendly ⚔️

Java + Bedrock compatible 🌍

Database-backed 💾

GUI-based 🖥️

API-ready 🔌

and production-ready.
Kodari AI
KodariSep 4 at 7:22 am 4
FalconXTeams
A comprehensive team management platform for Paper 1.21.x servers with Java 21 support. Features team creation with validation, role-based permissions (Owner/Officer/Member), invitation and join request systems, two-state team chat toggle with /tc command, configurable Team PvP with owner-only GUI control, team homes with teleport delays and combat restrictions, multiple team warps, persistent shared team Ender Chest storage, modern inventory GUIs, SQLite/MySQL database storage, PlaceholderAPI integration, Geyser/Floodgate Bedrock support, comprehensive admin commands, and a public API with events. Includes anti-abuse protections, async database operations, efficient caching, and full configuration through config.yml and messages.yml with MiniMessage formatting.
  1. Create the Maven/Paper project resources and configuration.

  2. Implement the team model, SQLite persistence, invitations/requests, roles, warps, homes, storage, and chat state.

  3. Add commands, admin commands, GUI interactions, teleport/combat protection, and event listeners.

  4. Add PlaceholderAPI support and a public API/event surface.

Created the FalconX Teams Maven project with:

  • Paper 1.21.x / Java 21 setup

  • SQLite-backed team persistence

  • Team creation, membership, roles, invitations, requests, warps, homes, storage, PvP, and chat

  • /team, /teams, /t, /tc, and /teamadmin commands

  • GUI menus and shared team storage

  • Teleport delays, cooldowns, movement cancellation, and combat restrictions

  • PlaceholderAPI expansion

  • Public team API and Bukkit events

  • Configurable config.yml, messages.yml, and gui.yml

  • Plugin manifest and README

  • Maven output configured as target/FalconXTeams.jar

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
36 726
src/main/java/in/falconx/teams/FalconXTeams.java
package in.falconx.teams;

import in.falconx.teams.chat.ChatManager;
import in.falconx.teams.command.TeamAdminCommand;
import in.falconx.teams.command.TeamCommand;
import in.falconx.teams.config.ConfigService;
import in.falconx.teams.config.MessageService;
import in.falconx.teams.database.Database;
import in.falconx.teams.gui.TeamGui;
import in.falconx.teams.listener.TeamListener;
import in.falconx.teams.placeholder.FalconXPlaceholderExpansion;
import in.falconx.teams.team.Team;
import in.falconx.teams.team.TeamManager;
import in.falconx.teams.teleport.TeleportService;
import java.util.Objects;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;

public final class FalconXTeams extends JavaPlugin {
    private ConfigService config; private MessageService messages; private Database database; private TeamManager teams; private ChatManager chat; private TeleportService teleports; private TeamGui gui;
    @Override public void onEnable(){saveDefaultConfig();saveResource("messages.yml",false);saveResource("gui.yml",false);config=new ConfigService(this);messages=new MessageService(this);database=new Database(this);try{database.connect();}catch(Exception ex){getLogger().severe("SQLite connection failed: "+ex.getMessage());getServer().getPluginManager().disablePlugin(this);return;}teams=new TeamManager(this,database);teams.load();chat=new ChatManager(this);teleports=new TeleportService(this);gui=new TeamGui(this);TeamCommand command=new TeamCommand(this);Objects.requireNonNull(getCommand("team")).setExecutor(command);Objects.requireNonNull(getCommand("team")).setTabCompleter(command);Objects.requireNonNull(getCommand("tc")).setExecutor(command);Objects.requireNonNull(getCommand("teamadmin")).setExecutor(new TeamAdminCommand(this));Bukkit.getPluginManager().registerEvents(new TeamListener(this),this);if(Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI"))new FalconXPlaceholderExpansion(this).register();getLogger().info("Plugin enabled successfully.");}
    @Override public void onDisable(){if(database!=null)database.close();}
    public ConfigService config(){return config;} public MessageService messages(){return messages;} public TeamManager teams(){return teams;} public ChatManager chat(){return chat;} public TeleportService teleports(){return teleports;} public TeamGui gui(){return gui;} public org.bukkit.configuration.file.FileConfiguration getMessages(){return loadConfigFile("messages.yml");} public org.bukkit.configuration.file.FileConfiguration getGui(){return loadConfigFile("gui.yml");}
    private org.bukkit.configuration.file.FileConfiguration loadConfigFile(String file){java.io.File f=new java.io.File(getDataFolder(),file);return org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(f);}
    public void reloadPlugin(){reloadConfig();}
    public void openStorage(Player player,Team team){if(!player.hasPermission("falconxteams.team.echest")){messages.send(player,"no-permission");return;}int size=config.getInt("echest.size",54);if(size!=27&&size!=54)size=54;Inventory inv=Bukkit.createInventory(new TeamGui.StorageHolder(team.getId()),size,messages.parse(getGui().getString("storage-title","ꜰᴀʟᴄᴏɴx ᴛᴇᴀᴍs — Team Storage")));inv.setContents(java.util.Arrays.copyOf(team.getStorage(),size));player.openInventory(inv);}
}