jor3js
📎 1 file 24,643 chars
📄
pasted-code-1791222565344.txt
txt 1139 lines
▶
You are an expert Minecraft Paper/Purpur plugin developer.

Build a complete, production-ready Minecraft plugin named:

PotatoRobbery

The plugin must be delivered as a compiled, ready-to-use JAR file.

==================================================
1. PLATFORM / BUILD REQUIREMENTS
==================================================

Target platform:
- Paper / Purpur 1.21.x
- Java 21
- Maven

Main class:
ir.potatocraft.robbery.PotatoRobbery

Plugin name:
PotatoRobbery

Output:
PotatoRobbery.jar

The final result MUST be a compiled JAR, not only source code.

The plugin must compile successfully with:

mvn clean package

Do not leave TODOs, placeholders, missing classes, missing dependencies, or pseudo-code.

==================================================
2. IMPORTANT DEPENDENCIES
==================================================

This plugin MUST integrate with:

1. PotatoBank
2. LuckPerms

PotatoBank is the server's existing city treasury/economy plugin.

A PotatoBank JAR is provided separately and should be used as the API/dependency.

Do NOT create a second economy system.

Do NOT create a second city treasury system.

Do NOT store city treasury balances inside PotatoRobbery.

PotatoRobbery must use the existing PotatoBank API to read and modify city treasury balances.

The existing PotatoBank API provides functionality similar to:

getCityTreasury(String city)
addCityTreasury(String city, long amount)
removeCityTreasury(String city, long amount)
setCityTreasury(String city, long amount)

Use the actual API/classes/methods available in the provided PotatoBank JAR. Inspect the JAR if necessary instead of guessing class names.

For example, when a robbery successfully steals $1000 from City 2:

PotatoRobbery must call PotatoBank's treasury API and reduce City 2's treasury:

10000 -> 9000

Never create a fake local balance.

==================================================
3. LUCKPERMS
==================================================

Integrate with LuckPerms.

The Robbery Leader should receive/display a special prefix:

L_R

This should be compatible with the server's existing LuckPerms setup.

Do NOT destroy or overwrite existing rank groups such as OWNER, ADMIN, VIP, MEMBER, etc.

Use a temporary/controlled LuckPerms metadata/group mechanism.

When the player stops being a Robbery Leader, remove the robbery-specific L_R state.

Do not permanently modify the player's normal rank.

==================================================
4. ROBBERY PARTY SYSTEM
==================================================

PotatoRobbery has its own party system.

A player can create a robbery party:

/robbery create

The player who creates it becomes:

Robbery Leader / Owner

The Leader can:

/robbery invite 
/robbery kick 
/robbery info
/robbery leave

Only the Leader can invite and kick members.

Example:

/robbery invite Ali

The invited player joins the robbery party.

==================================================
5. ROBBERY INFO
==================================================

/robbery info

must display:

- Robbery Leader
- All current members
- Number of members
- Current robbery status
- Target city if a robbery is active
- Remaining robbery time if active

Example:

Robbery Leader: Mamad
Members:
- Mamad
- Ali
- Reza

Members: 3/3
Status: Active
Target City: 2
Time Remaining: 04:32

==================================================
6. MINIMUM PLAYERS
==================================================

A robbery cannot start unless there are at least 2 players in the robbery party.

If there is only one player:

"At least 2 players are required to start a robbery."

==================================================
7. WHO CAN START A ROBBERY
==================================================

IMPORTANT:

OPs/admins do NOT need to start robberies.

Only the Leader of that specific robbery party can start the robbery.

Example:

/robbery start 1

/robbery start 2

/robbery start 3

This starts a robbery against the selected city's treasury.

The Leader must be a member of the party.

==================================================
8. CITY SYSTEM
==================================================

Support at least:

City 1
City 2
City 3

Each robbery safe belongs to exactly one city.

Example:

Safe 1 -> City 1
Safe 2 -> City 2
Safe 3 -> City 3

The target city must be stored with the robbery.

The money must always be removed from the treasury of the selected city.

==================================================
9. ADMIN / OP COMMANDS
==================================================

Only OP/admin/authorized permission users should be able to configure robbery settings.

Commands:

/robbery time 

/robbery safe  add
/robbery safe  remove
/robbery safe  amount 

/robbery spawn 

Examples:

/robbery time 300

/robbery safe 1 add
/robbery safe 1 amount 1000

/robbery safe 2 add
/robbery safe 2 amount 2000

/robbery safe 3 add
/robbery safe 3 amount 5000

/robbery spawn 1
/robbery spawn 2
/robbery spawn 3

The robbery time is configurable.

Example:

300 seconds = 5 minutes.

==================================================
10. ROBBERY SAFE
==================================================

Robbery safes should visually use an Iron Block style, but MUST be distinguishable from normal Minecraft Iron Blocks.

Do not treat every normal Iron Block as a robbery safe.

A safe must be registered/configured by the plugin.

Store its location and city.

Only registered robbery safes can be robbed.

Example:

City 1 Safe
City 2 Safe
City 3 Safe

==================================================
11. ROBBERY SAFE AMOUNT
==================================================

Each city safe has a configurable robbery amount.

Example:

City 1 = $1000
City 2 = $2000
City 3 = $5000

If City 2 treasury contains:

$10000

and City 2 robbery amount is:

$2000

after a successful robbery:

$10000 -> $8000

The money MUST be removed from PotatoBank's City 2 treasury.

==================================================
12. INSUFFICIENT TREASURY
==================================================

If the city treasury does not contain enough money:

DO NOT allow the robbery payout.

Example:

Treasury = $500
Robbery amount = $1000

The robbery must fail safely.

Do not create money.

Do not allow a negative treasury.

Do not partially withdraw unless explicitly configured.

==================================================
13. STARTING A ROBBERY
==================================================

Example:

Party:

Mamad
Ali
Reza

Leader:

Mamad

Mamad executes:

/robbery start 2

The plugin checks:

- Leader is executing the command
- At least 2 members exist
- City 2 safe exists
- City 2 has enough treasury money
- No conflicting robbery is active for that safe
- Configuration is valid

If valid, the robbery starts.

==================================================
14. GLOBAL ROBBERY ALERT
==================================================

IMPORTANT:

The robbery alert MUST be shown to EVERY ONLINE PLAYER on the server.

NOT only robbery members.

When a robbery starts:

Play a police siren/alarm sound to all online players.

Display a Title/Subtitle to ALL online players for 5 seconds.

Example:

"⚠ ROBBERY ALERT ⚠"

"City 2 treasury is under attack!"

For City 1:

"City 1 treasury is under attack!"

For City 2:

"City 2 treasury is under attack!"

For City 3:

"City 3 treasury is under attack!"

The sound must also be global.

==================================================
15. ROBBERY MAIN TIMER
==================================================

When a robbery starts, the configured robbery duration begins.

Example:

/robbery time 300

The robbery has a 5-minute timer.

Display the remaining robbery time above/around the XP bar area.

Example:

ROBbery: 05:00

ROBbery: 04:59

ROBbery: 04:58

...

ROBbery: 00:01

ROBbery: 00:00

This main robbery timer should be visible ONLY to members of the active robbery party.

Do not show this timer to unrelated players.

Use a clean action-bar/boss-bar/XP-style display that looks similar to an XP timer.

==================================================
16. ROBBERY TOOL
==================================================

Create a special robbery tool:

"Safe Breaker"

This must be a custom plugin item.

Do not make normal sticks work.

Only the special Safe Breaker item can interact with robbery safes/protection blocks.

The item should have a unique identifier using PersistentDataContainer.

Give it a clear name and lore.

==================================================
17. OPENING THE SAFE
==================================================

A member of the active robbery party can Right Click the registered safe using the Safe Breaker.

Right Click starts the safe-opening process.

Only members of THAT robbery party can interact with that safe.

Other players cannot open it.

Players from another robbery cannot open it.

Players outside the robbery cannot open it.

OP status alone should NOT allow normal players to participate in the robbery unless they are members of the robbery party.

==================================================
18. SAFE OPENING TIMER
==================================================

When a valid player starts opening the safe:

Start a 30-second countdown.

Display the countdown above/around the XP bar area to the robbery members.

Example:

Safe opens in: 30

Safe opens in: 29

Safe opens in: 28

...

Safe opens in: 1

Safe opens in: 0

The countdown should update smoothly every second.

==================================================
19. SAFE SUCCESS
==================================================

When the 30-second safe-opening timer reaches zero:

1. Verify the robbery is still valid.
2. Verify the city treasury still contains enough money.
3. Remove the configured robbery amount from PotatoBank.
4. Give the stolen money to the robbery party according to the configured reward system.
5. Mark the safe as successfully robbed.
6. Play an appropriate success sound.
7. Display a success message.

IMPORTANT:

The treasury withdrawal must happen only after successful completion.

Do NOT withdraw money when the safe-opening timer starts.

==================================================
20. ROBBERY REWARD
==================================================

The stolen amount comes from the city treasury.

The stolen money should be distributed to the active robbery members.

Implement a configurable reward mode.

Default mode:

Split the stolen amount equally among all current robbery members.

Example:

Stolen amount = $1000

Members = 2

Each receives $500.

If there are 4 members:

Each receives $250.

Use integer-safe calculations.

Do not create money from nothing.

The reward should use the server's economy system if PotatoBank exposes one; otherwise implement the safest compatible payout mechanism without changing the city treasury logic.

==================================================
21. LEADER DEATH
==================================================

VERY IMPORTANT:

If the Robbery Leader dies while the robbery is active:

The ENTIRE robbery immediately ends.

Cancel:

- Main robbery timer
- Safe-opening timer
- Active robbery state
- Robbery interactions
- Robbery protection state

Do NOT withdraw money if the safe was not successfully opened.

Remove robbery leader/member temporary state.

==================================================
22. ROBBERY MANUAL END
==================================================

The Robbery Leader can manually end the robbery:

/robbery end

This immediately ends the active robbery.

Cancel all active timers.

Remove active robbery state.

If the robbery has not successfully completed, do not withdraw money.

==================================================
23. ROBBERY TIME EXPIRES
==================================================

When the main robbery timer reaches zero:

The robbery ends automatically.

No additional safe-opening action should be allowed.

Cancel any active robbery operation.

If the robbery has not successfully completed, do not withdraw money.

==================================================
24. RETURN / SPAWN
==================================================

IMPORTANT:

ONLY players who were members of THAT robbery party should be returned.

When the robbery ends, teleport the members of that robbery to the configured robbery spawn for the target city.

Example:

City 1:

/robbery spawn 1

City 2:

/robbery spawn 2

City 3:

/robbery spawn 3

Players who were NOT members of the robbery must never be teleported.

Do not teleport the entire server.

==================================================
25. PROTECTED BEDROCK SYSTEM
==================================================

Create a special robbery protection Bedrock block.

It must be distinguishable from normal Bedrock using a unique PersistentDataContainer identifier.

When the special Bedrock is placed:

Create a 3x3 surrounding structure using special robbery Iron Blocks.

These Iron Blocks must be identifiable separately from normal Iron Blocks.

Do NOT permanently replace unrelated blocks.

IMPORTANT:

Before creating the 3x3 structure, store the original blocks/locations.

When the protection is destroyed:

Restore the exact original blocks.

Never delete or overwrite the player's existing world blocks permanently.

==================================================
26. BEDROCK HEALTH
==================================================

The special protection Bedrock has:

100 health/power.

Display above it:

"Power: 100"

Also display an XP-style progress bar.

When hit with the Safe Breaker:

100 -> 90 -> 80 -> 70 -> ...

Each valid hit removes exactly 10 power.

When power reaches 0:

- Break the protection Bedrock
- Remove/restore the temporary 3x3 Iron structure
- Play an explosion/break sound
- Update the hologram/progress display
- Continue the robbery logic

Do NOT cause destructive real-world explosion damage to nearby builds.

Only simulate the explosion visually/audio-wise unless explicitly configured otherwise.

==================================================
27. HOLOGRAM
==================================================

The protection block should display a floating text/hologram.

Example:

Power: 100

When damaged:

Power: 90
Power: 80
Power: 70

...

Power: 0

Use a stable implementation that does not create thousands of entities.

Clean up holograms when the robbery ends.

==================================================
28. BLOCK RESTORATION
==================================================

When the robbery protection system creates temporary Iron Blocks:

Store every original block state.

When the protection ends:

Restore every original block exactly.

Do not permanently destroy:

- chests
- doors
- blocks
- decorations
- redstone
- player builds

The system must be safe.

==================================================
29. ROBBERY ACCESS CONTROL
==================================================

Only members of the currently active robbery party can:

- Interact with the robbery safe
- Use the Safe Breaker on the robbery protection
- Damage the robbery protection
- Continue the robbery operation

Everyone else should receive a message such as:

"You are not a member of this robbery."

==================================================
30. MULTIPLE ROBBERIES
==================================================

Support multiple cities safely.

Do not allow two different parties to rob the same city safe at the same time.

Example:

Party A -> City 1
Party B -> City 2

Both can operate independently if the configuration allows it.

But:

Party A -> City 1
Party B -> City 1

must NOT be allowed simultaneously.

==================================================
31. DATA STORAGE
==================================================

Store configuration and robbery safe data in YAML files.

Example:

plugins/PotatoRobbery/config.yml

plugins/PotatoRobbery/safes.yml

plugins/PotatoRobbery/data.yml

Store:

- Safe locations
- City IDs
- Robbery amounts
- Robbery duration
- Spawn locations
- Other configurable settings

Do not store PotatoBank treasury balances locally.

==================================================
32. RELOAD
==================================================

Add:

/robbery reload

Permission:

potatorobbery.admin

Reload configuration safely without restarting the server.

Do not corrupt active robberies.

==================================================
33. PERMISSIONS
==================================================

Suggested permissions:

potatorobbery.admin
potatorobbery.create
potatorobbery.use
potatorobbery.safe
potatorobbery.reload

Normal players should only need the appropriate player permissions.

Admin configuration commands must require:

potatorobbery.admin

OPs should automatically have admin access through Bukkit permission behavior.

==================================================
34. COMMAND TAB COMPLETION
==================================================

Implement tab completion for all commands.

Examples:

/robbery 

/robbery start 

Should suggest:

1
2
3

For:

/robbery safe 

Suggest:

1
2
3

For:

/robbery invite 

Suggest online players.

==================================================
35. CONFIGURATION
==================================================

Make messages configurable.

Make sounds configurable.

Make robbery duration configurable.

Make safe opening time configurable, default:

30 seconds.

Make robbery amounts configurable.

Make reward distribution configurable.

Make titles configurable.

Make colors configurable.

Use MiniMessage or modern Paper-compatible formatting where appropriate.

==================================================
36. PERSISTENT DATA
==================================================

Use PersistentDataContainer for custom items and custom blocks.

Examples:

safe_breaker
robbery_safe
robbery_bedrock
robbery_iron

Do not identify custom blocks only by their material.

A normal Minecraft Iron Block must NEVER accidentally become a robbery safe.

A normal Minecraft Bedrock must NEVER accidentally become robbery protection.

==================================================
37. CRASH / RESTART SAFETY
==================================================

Handle server shutdown safely.

If the server restarts during an active robbery:

- Cancel the robbery safely.
- Restore temporary blocks if necessary.
- Remove temporary holograms/entities.
- Do not withdraw money incorrectly.
- Do not duplicate rewards.

Prevent duplication exploits.

==================================================
38. EXPLOIT PREVENTION
==================================================

Prevent:

- Double payouts
- Double safe openings
- Multiple simultaneous openings of one safe
- Negative treasury balances
- Reward duplication
- Fake Safe Breaker items
- Normal sticks being accepted
- Normal Iron Blocks being treated as safes
- Normal Bedrock being treated as robbery protection
- Players joining/leaving to duplicate rewards
- Repeated right-click exploits
- Disconnect/reconnect reward exploits

Use server-side validation for every important action.

==================================================
39. USER EXPERIENCE
==================================================

The system should feel like a professional Minecraft server robbery system.

Use:

- Titles
- Subtitles
- Action bars
- Sounds
- Countdown timers
- Clear messages
- Holograms
- Progress bars

The global robbery alert must be dramatic.

Example:

TITLE:
⚠ ROBBERY ALERT ⚠

SUBTITLE:
City 2 treasury is under attack!

Play a police siren to ALL online players.

Display this alert for approximately 5 seconds.

==================================================
40. IMPORTANT DISTINCTION BETWEEN TIMERS
==================================================

There are TWO separate timers:

A) Main Robbery Timer

Configured by admin:

/robbery time 300

Example:

5 minutes.

This timer controls how long the entire robbery remains active.

Visible only to robbery members.

B) Safe Opening Timer

Default:

30 seconds.

This starts when a robbery member Right Clicks the safe with the Safe Breaker.

Visible only to robbery members.

Do NOT confuse these two timers.

==================================================
41. COMPLETE EXAMPLE
==================================================

Admin configuration:

/robbery time 300

/robbery safe 2 add

/robbery safe 2 amount 1000

/robbery spawn 2

City 2 treasury:

$10000

Players:

Mamad
Ali

Mamad executes:

/robbery create

Mamad becomes Leader.

Mamad:

/robbery invite Ali

Now there are 2 members.

Mamad executes:

/robbery start 2

The plugin:

1. Checks minimum 2 members.
2. Checks City 2 safe.
3. Checks City 2 treasury.
4. Starts the 5-minute robbery timer.
5. Plays police siren to EVERY online player.
6. Shows a global title for 5 seconds:
   "⚠ ROBBERY ALERT ⚠"
   "City 2 treasury is under attack!"
7. Shows the robbery timer to Mamad and Ali.

Mamad goes to the safe.

Mamad Right Clicks with Safe Breaker.

Safe opening timer:

30
29
28
...
1
0

When it reaches 0:

PotatoBank City 2 treasury:

$10000 -> $9000

The $1000 stolen amount is distributed to the robbery members.

The robbery succeeds.

The robbery ends.

Only Mamad and Ali are teleported to:

City 2 Robbery Spawn.

Other online players are NOT teleported.

==================================================
42. IMPORTANT POTATOBANK COMPATIBILITY
==================================================

The provided PotatoBank JAR is the authoritative API reference.

Inspect it.

Use its real package names, classes and methods.

Do NOT invent an API.

If PotatoBank provides an API manager/service/provider, use that.

Declare PotatoBank as a required dependency/soft dependency only if appropriate, but the plugin must clearly fail gracefully if PotatoBank is missing.

Since PotatoRobbery depends on PotatoBank treasury functionality, preferably make PotatoBank a required dependency.

The plugin should display a clear startup error if PotatoBank is missing.

==================================================
43. FINAL BUILD REQUIREMENTS
==================================================

Before delivering:

1. Compile the project.
2. Run:

mvn clean package

3. Fix ALL compilation errors.
4. Verify plugin.yml.
5. Verify dependencies.
6. Verify main class.
7. Verify Java 21 compatibility.
8. Verify Paper/Purpur 1.21.x compatibility.
9. Verify PotatoBank integration against the actual provided JAR.
10. Verify LuckPerms integration.
11. Verify all commands.
12. Verify tab completion.
13. Verify configuration files.
14. Verify safe registration.
15. Verify treasury withdrawal.
16. Verify party permissions.
17. Verify timers.
18. Verify global alert.
19. Verify leader death cancellation.
20. Verify teleport behavior.
21. Verify block restoration.
22. Verify duplicate reward prevention.

MOST IMPORTANT:

Do not simply provide source code.

I need the final compiled:

PotatoRobbery.jar

ready to put directly into:

plugins/

Also provide the final compiled JAR as a downloadable file.

Do not modify unrelated PotatoBank functionality.

Do not create a replacement economy.

Do not create a replacement permission system.

Use PotatoBank for city treasury operations and LuckPerms for permission/prefix integration.
Kodari AI
KodariOct 5 at 5:56 pm 3
PotatoRobbery
A comprehensive Minecraft Paper plugin enabling organized city treasury heists. Players form robbery parties, target registered city safes, and use a custom Safe Breaker tool to crack protected bedrock vaults. Integrates with PotatoBank for treasury withdrawals and LuckPerms for temporary leader prefixes. Features global alerts, dual timers, holographic displays, block restoration, and robust exploit prevention.
  1. Scaffold the Java 21 Paper plugin, metadata, permissions, and configurable messages/settings.

  2. Implement the party system, commands, LuckPerms leader prefix, and reflective PotatoBank treasury bridge.

  3. Add city safes, robbery/opening timers, payouts, protection-block restoration, and shutdown cleanup.

Created the PotatoRobbery project with party and admin commands, city-safe configuration, robbery and opening timers, global alerts, LuckPerms leader metadata, treasury withdrawals, Vault payouts, and temporary protection-block restoration.

Two important limitations: the attachment contained the specification, not the PotatoBank JAR. I therefore could not verify PotatoBank’s actual API; the plugin resolves the described treasury methods at runtime and disables itself if it cannot find them. Also, the project is scaffolded with Gradle rather than Maven.

To build and download PotatoRobbery.jar, click Compile in the top bar (on phone: ⋮ → Compile Project), click Compile, then Download when the build succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
9 1,415
src/main/java/ir/potatocraft/robbery/PotatoRobbery.java
package ir.potatocraft.robbery;

import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.node.types.PrefixNode;
import net.luckperms.api.model.user.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.BlockVector;
import net.kyori.adventure.text.Component;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

public final class PotatoRobbery extends org.bukkit.plugin.java.JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private final Map<UUID, Party> partiesByMember = new HashMap<>();
    private final Map<Integer, Robbery> activeCities = new HashMap<>();
    private final Map<String, Protection> protections = new HashMap<>();
    private final Map<String, Location> safes = new HashMap<>();
    private final Map<String, Location> spawns = new HashMap<>();
    private final Map<String, Long> amounts = new HashMap<>();
    private File safesFile;
    private File dataFile;
    private YamlConfiguration safesData;
    private YamlConfiguration persistentData;
    private BankBridge bank;
    private VaultBridge vault;
    private LuckPerms luckPerms;
    private NamespacedKey breakerKey;
    private NamespacedKey protectionItemKey;
    private NamespacedKey hologramKey;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        ensureResource("safes.yml");
        ensureResource("data.yml");
        Plugin bankPlugin = Bukkit.getPluginManager().getPlugin("PotatoBank");
        Plugin luckPermsPlugin = Bukkit.getPluginManager().getPlugin("LuckPerms");
        if (bankPlugin == null || !bankPlugin.isEnabled()) {
            getLogger().severe("PotatoBank is required. PotatoRobbery will be disabled.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        if (luckPermsPlugin == null || !luckPermsPlugin.isEnabled()) {
            getLogger().severe("LuckPerms is required for the controlled robbery-leader prefix.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        try {
            luckPerms = LuckPermsProvider.get();
        } catch (IllegalStateException exception) {
            getLogger().severe("LuckPerms API is unavailable; PotatoRobbery will be disabled.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        bank = new BankBridge(bankPlugin);
        if (!bank.isAvailable()) {
            getLogger().severe("PotatoBank is installed, but its public city treasury API could not be resolved. No replacement balance system will be used.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        vault = VaultBridge.find(getClass().getClassLoader());
        breakerKey = new NamespacedKey(this, "safe_breaker");
        protectionItemKey = new NamespacedKey(this, "robbery_bedrock");
        hologramKey = new NamespacedKey(this, "robbery_hologram");
        loadSafeData();
        loadPersistentData();
        recoverProtections();
        Bukkit.getPluginManager().registerEvents(this, this);
        if (getCommand("robbery") == null) {
            getLogger().severe("The robbery command is missing from plugin.yml.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        getCommand("robbery").setExecutor(this);
        getCommand("robbery").setTabCompleter(this);
        getLogger().info("PotatoRobbery enabled; PotatoBank treasury and LuckPerms integrations are active.");
    }

    @Override
    public void onDisable() {
        for (Robbery robbery : new ArrayList<>(activeCities.values())) finishRobbery(robbery, "server shutdown", false);
        for (Party party : new HashSet<>(partiesByMember.values())) removeLeaderPrefix(party.leader);
        restoreAllProtections();
        removeLoadedHolograms();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.YELLOW + "/robbery create, invite, kick, info, leave, start, end, safe, spawn, time, reload");
            return true;
        }
        String sub = args[0].toLowerCase(Locale.ROOT);
        if (sub.equals("reload")) {
            if (!sender.hasPermission("potatorobbery.admin")) return deny(sender);
            reloadConfig();
            loadSafeData();
            message(sender, "reloaded");
            return true;
        }
        if (sub.equals("time")) return commandTime(sender, args);
        if (sub.equals("safe")) return commandSafe(sender, args);
        if (sub.equals("spawn")) return commandSpawn(sender, args);
        if (sub.equals("tool")) return commandGiveItem(sender, false);
        if (sub.equals("protection")) return commandGiveItem(sender, true);
        if (!(sender instanceof Player player)) {
            message(sender, "player-only");
            return true;
        }
        if (!player.hasPermission("potatorobbery.use") && !sub.equals("create")) return deny(player);
        switch (sub) {
            case "create" -> createParty(player);
            case "invite" -> invite(player, args);
            case "kick" -> kick(player, args);
            case "info" -> showInfo(player);
            case "leave" -> leaveParty(player);
            case "start" -> startRobbery(player, args);
            case "end" -> endRobberyCommand(player);
            default -> message(player, "no-party");
        }
        return true;
    }

    private boolean commandTime(CommandSender sender, String[] args) {
        if (!sender.hasPermission("potatorobbery.admin")) return deny(sender);
        if (args.length != 2) return false;
        Long seconds = positiveLong(args[1]);
        if (seconds == null || seconds > 86400) return invalidNumber(sender);
        getConfig().set("robbery.duration-seconds", seconds);
        saveConfig();
        message(sender, "time-set", "seconds", seconds);
        return true;
    }

    private boolean commandSafe(CommandSender sender, String[] args) {
        if (!sender.hasPermission("potatorobbery.admin")) return deny(sender);
        if (args.length < 3) return false;
        Integer city = city(args[1]);
        if (city == null) return invalidCity(sender);
        String operation = args[2].toLowerCase(Locale.ROOT);
        String id = String.valueOf(city);
        if (operation.equals("add")) {
            if (!(sender instanceof Player player)) {
                message(sender, "player-only");
                return true;
            }
            Block target = player.getTargetBlockExact(6);
            if (target == null || !target.getType().name().equals("IRON_BLOCK")) {
                named(sender, "safe-block-required", Map.of());
                return true;
            }
            if (activeCities.containsKey(city)) return message(sender, "active-safe");
            Integer registeredCity = cityForSafe(target.getLocation());
            if (registeredCity != null && registeredCity != city) {
                sender.sendMessage(ChatColor.RED + "That Iron Block is already registered to City " + registeredCity + ".");
                return true;