notvisiongg_.

"Create a plugin named MaceControl. This plugin should prevent the Mace from being stored in any type of container, including chests, barrels, Ender Chests, item frames, or any similar storage. If a player tries to store the Mace in any container, it should be blocked.

Additionally, the plugin should display the current Mace holder’s name in a boss bar for all players, like: ‘The current Mace owner is ’."

Kodari AI
KodariApr 12 at 1:55 pm 9,058 (v2)

I’ll create a plugin that prevents Mace storage in containers and displays the current holder’s name in a boss bar.

MaceControl
Prevents the Mace weapon from being stored in any container (chests, barrels, ender chests, item frames, etc.). Displays a real-time boss bar showing the current Mace holder's name to all online players. Features automatic tracking of Mace possession and seamless boss bar updates when ownership changes or when no player holds the Mace.

Plugin created successfully!

The MaceControl plugin includes:

  • Container prevention: Blocks Mace storage in chests, barrels, ender chests, item frames, armor stands, etc.

  • Boss bar display: Shows current Mace holder’s name to all players in real-time

  • Automatic tracking: Scans all online players every second to detect Mace possession

  • Bypass permission: macecontrol.bypass for admins

  • Reload command: /macecontrol reload to refresh configuration

The plugin uses XSeries for cross-version compatibility and will work from 1.21+ (when the Mace was introduced). All features are configurable via config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 566
src/main/java/com/macecontrol/MaceControl.java
package com.macecontrol;

import com.macecontrol.config.ConfigManager;
import com.macecontrol.listeners.ContainerListener;
import com.macecontrol.manager.BossBarManager;
import com.macecontrol.manager.MaceTrackerManager;
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 MaceControl extends JavaPlugin {
    
    private ConfigManager configManager;
    private BossBarManager bossBarManager;
    private MaceTrackerManager maceTrackerManager;
    private ContainerListener containerListener;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.bossBarManager = new BossBarManager(this);
        this.maceTrackerManager = new MaceTrackerManager(this);
        this.containerListener = new ContainerListener(this);
        
        Bukkit.getPluginManager().registerEvents(containerListener, this);
        
        this.maceTrackerManager.startTracking();
        
        getLogger().info("MaceControl has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.maceTrackerManager != null) {
            this.maceTrackerManager.stopTracking();
        }
        if (this.bossBarManager != null) {
            this.bossBarManager.shutdown();
        }
        getLogger().info("MaceControl has been disabled!");
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("macecontrol")) {
            if (!sender.hasPermission("macecontrol.admin")) {
                sender.sendMessage(formatMessage("&cYou don't have permission to use this command!"));
                return true;
            }
            
            if (args.length == 0 || !args[0].equalsIgnoreCase("reload")) {
                sender.sendMessage(formatMessage("&eUsage: /macecontrol reload"));
                return true;
            }
            
            reloadConfig();
            this.configManager = new ConfigManager(this);
            this.bossBarManager.reload();
            this.maceTrackerManager.reload();
            
            sender.sendMessage(formatMessage(configManager.getMessage("reload")));
            return true;
        }
        return false;
    }
    
    public String formatMessage(String message) {
        return message.replace("&", "§");
    }
}