7jjas

Make a plugin that will block enchanting a mace in any way.

Kodari AI
KodariMar 29 at 1:09 am 5,970 (v2)

I’ll create a plugin that blocks enchanting maces through all methods (enchanting tables, anvils, commands, etc.).

MaceEnchantBlocker
Prevents players from enchanting maces through any method including enchanting tables, anvils, and commands. Automatically removes any enchantments found on maces in player inventories. Includes configurable messages and bypass permissions for staff members.

Plugin created! MaceEnchantBlocker prevents mace enchanting through enchanting tables, anvils, and removes any enchantments added via commands. Includes bypass permission maceenchantblocker.bypass for staff and a configurable inventory scanner that removes enchantments from maces automatically.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 304
src/main/java/com/maceenchantblocker/MaceEnchantBlocker.java
package com.maceenchantblocker;

import com.maceenchantblocker.listener.AnvilListener;
import com.maceenchantblocker.listener.EnchantListener;
import com.maceenchantblocker.manager.ConfigManager;
import com.maceenchantblocker.task.MaceCheckTask;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class MaceEnchantBlocker extends JavaPlugin {

    private ConfigManager configManager;
    private MaceCheckTask maceCheckTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        
        getServer().getPluginManager().registerEvents(new EnchantListener(this), this);
        getServer().getPluginManager().registerEvents(new AnvilListener(this), this);
        
        if (getConfig().getBoolean("remove-existing-enchantments", true)) {
            this.maceCheckTask = new MaceCheckTask(this);
            int interval = getConfig().getInt("check-interval", 100);
            this.maceCheckTask.runTaskTimer(this, 20L, interval);
        }
        
        getCommand("maceenchantblocker").setExecutor(new MaceCommand(this));
        
        getLogger().info("MaceEnchantBlocker has been enabled!");
    }

    @Override
    public void onDisable() {
        if (maceCheckTask != null) {
            maceCheckTask.cancel();
        }
        getLogger().info("MaceEnchantBlocker has been disabled!");
    }
}