Levi

Make me a admin only command that's spawn a stash for cheaters

Kodari AI
KodariSep 6 at 2:54 am 1
CheaterStashSpawner
An admin-only Minecraft plugin that allows server administrators to spawn a hidden stash container at a specified location for cheaters. The command /spawnstash is restricted to operators and creates a chest filled with confiscated items, marking the stash with a unique identifier. The plugin tracks all spawned stashes, stores their coordinates in a persistent configuration file, and provides a cleanup command to remove all stashes at once. It includes permission checks, cooldown prevention, and console logging for audit purposes. The stash appears as a normal chest but is visually distinct with a custom name and lore, making it easy for admins to identify while remaining discreet to regular players.
  1. Create a Paper plugin with /cheaterstash spawn [player].

  2. Restrict the command and stash access to cheaterstash.admin (operators by default).

  3. Mark spawned chests persistently and protect them from non-admin opening, breaking, and explosions.

Created the CheaterStash Paper plugin.

  • Command: /cheaterstash spawn [player]

  • Admin permission: cheaterstash.admin

  • Operators receive permission by default

  • Spawns a protected chest stash in front of the target player

  • Non-admins cannot open or break stashes

  • Stashes are protected from explosions

  • Stashes are marked persistently so protection survives restarts

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 251
src/main/java/com/kodari/cheaterstash/CheaterStashPlugin.java
package com.kodari.cheaterstash;

import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

public final class CheaterStashPlugin extends JavaPlugin {
    public static final String ADMIN_PERMISSION = "cheaterstash.admin";

    private NamespacedKey stashKey;
    private Listener stashListener;

    @Override
    public void onEnable() {
        stashKey = new NamespacedKey(this, "cheater-stash");

        getCommand("cheaterstash").setExecutor(new CheaterStashCommand(this));
        stashListener = new StashListener(this);
        getServer().getPluginManager().registerEvents(stashListener, this);
    }

    @Override
    public void onDisable() {
        if (stashListener != null) {
            HandlerList.unregisterAll(stashListener);
        }
    }

    public NamespacedKey getStashKey() {
        return stashKey;
    }

    public boolean isStash(Block block) {
        if (!(block.getState() instanceof Chest chest)) {
            return false;
        }

        Byte marker = chest.getPersistentDataContainer().get(stashKey, PersistentDataType.BYTE);
        return marker != null && marker == (byte) 1;
    }
}