sunchl

a 1.21.11 paper plugin.

the name of this plugin is item restrictions

/ire nomaceec this command will toggle on and off if maces will be allowed to be stored in ender chests globally

/ire set this command will toggle if the item i am currently holding (as an operator) will be a restricted item.

restricted items can not be stored in any container whatsoever, and when dropped it cant despawn or be destroyed. it can't be placed, cant burn, cant be destroyed cant be blown up or anything like that. if it somehow does get deleted, an exact replica has to be dropped at 0 200 0, still being a restricted item when recreated. you have to keep track of these items and make sure everything works well.

Kodari AI
KodariJul 2 at 4:13 pm 24

Building an item-restriction plugin with persistent tracking, container blocking, and auto-respawn logic for destroyed restricted items.

ItemRestrictions
A Paper 1.21 plugin letting operators mark held items as fully restricted: they cannot be stored in any container, placed, burned, destroyed, or blown up, and dropped copies never despawn. If a restricted item is somehow destroyed, an exact replica is automatically respawned at 0,200,0, still restricted. Also includes a global toggle to prevent Maces from being stored in Ender Chests. Commands: /ire set (mark/unmark held item) and /ire nomaceec (toggle mace-in-enderchest restriction), both requiring operator permission.

Plugin structure:

  • ItemRestrictionsPlugin wires up ConfigManager, RestrictedItemManager, command, and listeners.

  • RestrictedItemManager tags items via PersistentDataContainer, persists templates to restricted_items.yml, tracks dropped item-entity UUIDs, and runs a watcher task every 5s that respawns an exact replica at 0,200,0 if a tracked restricted item entity vanishes unexpectedly.

  • ContainerProtectionListener blocks restricted items (and Maces when nomaceec is enabled) from entering any container via clicks, drags, hopper transfers, and hopper pickups.

  • BlockProtectionListener stops restricted items from being placed as blocks.

  • ItemEntityProtectionListener prevents despawning and all damage (fire, lava, explosions, cactus, void) to dropped restricted items, teleporting void-falling ones back to safety instead of letting them vanish.

  • /ire set toggles restriction on the held item; /ire nomaceec toggles the global Mace/Ender Chest rule.

Kodari can make mistakes. Review important code before using.
Files
src
Code
9 547
src/main/java/com/kodari/itemrestrictions/ItemRestrictionsPlugin.java
package com.kodari.itemrestrictions;

import com.kodari.itemrestrictions.commands.IRECommand;
import com.kodari.itemrestrictions.listeners.BlockProtectionListener;
import com.kodari.itemrestrictions.listeners.ContainerProtectionListener;
import com.kodari.itemrestrictions.listeners.ItemEntityProtectionListener;
import com.kodari.itemrestrictions.managers.ConfigManager;
import com.kodari.itemrestrictions.managers.RestrictedItemManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class ItemRestrictionsPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private RestrictedItemManager restrictedItemManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.configManager = new ConfigManager(this);
        this.restrictedItemManager = new RestrictedItemManager(this);
        this.restrictedItemManager.load();
        this.restrictedItemManager.startWatcher();

        IRECommand ireCommand = new IRECommand(this);
        getCommand("ire").setExecutor(ireCommand);
        getCommand("ire").setTabCompleter(ireCommand);

        getServer().getPluginManager().registerEvents(new ContainerProtectionListener(this), this);
        getServer().getPluginManager().registerEvents(new BlockProtectionListener(this), this);
        getServer().getPluginManager().registerEvents(new ItemEntityProtectionListener(this), this);
    }

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