kamblebhavesh850-eng

Develop a stackable totems plugin that allows players to stack multiple totems of undying up to a configurable limit in their inventory. Include options for permission nodes, stack size customization, and an optional message system to inform players when they receive or use a totem.

Kodari AI
KodariApr 22 at 4:51 am 6,052 (v2)

I’ll create a stackable totems plugin that allows players to stack totems of undying with configurable limits and messaging.

StackableTotems
A plugin that enables players to stack multiple totems of undying up to a configurable limit. Features include permission-based stacking control, customizable stack sizes, automatic inventory stacking, and an optional message system to inform players when they receive or consume totems. Perfect for survival servers looking to improve inventory management while maintaining game balance.

All files created! The plugin includes:

Core Features:

  • Totems stack up to configurable limit (default 64)

  • Automatic stacking when picking up totems

  • Stack consolidation when clicking in inventory

  • Proper totem consumption (reduces stack by 1 when used)

  • Permission-based stacking control

  • Configurable messages for all totem interactions

  • Reload command for runtime configuration changes

Technical Highlights:

  • Uses XMaterial for cross-version Material.TOTEM_OF_UNDYING compatibility

  • Listens to EntityResurrectEvent to handle totem consumption from stacks

  • Listens to EntityPickupItemEvent for automatic inventory stacking

  • Listens to InventoryClickEvent for manual stack consolidation

  • Lombok @Getter for clean manager access

  • Legacy color code support (&a, &e, etc.)

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 317
src/main/java/com/stackabletotems/StackableTotems.java
package com.stackabletotems;

import com.stackabletotems.config.ConfigManager;
import com.stackabletotems.listeners.TotemListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class StackableTotems extends JavaPlugin {
    
    private ConfigManager configManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        
        Bukkit.getPluginManager().registerEvents(new TotemListener(this), this);
        
        getLogger().info("StackableTotems has been enabled!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("StackableTotems has been disabled!");
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("stackabletotems")) {
            if (!sender.hasPermission("stackabletotems.admin")) {
                sender.sendMessage(configManager.getMessage("no-permission"));
                return true;
            }
            
            if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                reloadConfig();
                configManager.reload();
                sender.sendMessage(configManager.getMessage("reload-success"));
                return true;
            }
            
            sender.sendMessage("§6StackableTotems §7v" + getDescription().getVersion());
            sender.sendMessage("§7Use §e/stackabletotems reload §7to reload config");
            return true;
        }
        return false;
    }
}