crossik0227_38224

add an axe that when you sneak+ right click people cant hit or punch you for 6 seconds

/protectionaxe give /protectionaxe reload

Only server operators should be able to obtain the axe through the give command by default, but this should be configurable in config.yml. The axe should not be obtainable through normal plugin commands by non-OP players unless configured otherwise.

add a 45 second cooldown that is displayed in the action bar when the axe is in hand make the cooldown prefix and editable in the config so i can edit colours and more messages

Generate all necessary files including:

* Main plugin class * Command classes * Listener classes * Cooldown manager * Item manager * Utility classes * plugin.yml * config.yml

Kodari AI
KodariJul 31 at 4:25 pm 1
ProtectionAxe
A lightweight Minecraft protection plugin that provides a special Protection Axe. When a player sneaks and right-clicks another player while holding the axe, they become immune to player attacks for six seconds. The axe has a configurable 45-second cooldown shown in the action bar while held. Server operators can grant the axe with a command, reload configuration settings, customize item details, permissions, durations, cooldown text, protection messages, and color codes through config.yml.
  1. Create the main plugin lifecycle and configuration handling.

  2. Add the Protection Axe item, cooldown and protection managers.

  3. Add interaction, damage-protection, and action-bar listeners.

  4. Add /protectionaxe give and /protectionaxe reload.

  5. Add plugin.yml and customizable config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
Code
11 663
src/main/java/com/kodari/protectionaxe/ProtectionAxePlugin.java
package com.kodari.protectionaxe;

import com.kodari.protectionaxe.command.ProtectionAxeCommand;
import com.kodari.protectionaxe.listener.AxeInteractListener;
import com.kodari.protectionaxe.listener.ProtectionListener;
import com.kodari.protectionaxe.manager.CooldownManager;
import com.kodari.protectionaxe.manager.ItemManager;
import com.kodari.protectionaxe.manager.ProtectionManager;
import com.kodari.protectionaxe.task.CooldownActionBarTask;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class ProtectionAxePlugin extends JavaPlugin {

    private CooldownManager cooldownManager;
    private ProtectionManager protectionManager;
    private ItemManager itemManager;

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

        cooldownManager = new CooldownManager();
        protectionManager = new ProtectionManager();
        itemManager = new ItemManager(this);

        ProtectionAxeCommand command = new ProtectionAxeCommand(this);
        PluginCommand protectionAxeCommand = getCommand("protectionaxe");

        if (protectionAxeCommand != null) {
            protectionAxeCommand.setExecutor(command);
            protectionAxeCommand.setTabCompleter(command);
        }

        getServer().getPluginManager().registerEvents(
                new AxeInteractListener(this, itemManager, cooldownManager, protectionManager),
                this
        );
        getServer().getPluginManager().registerEvents(
                new ProtectionListener(this, protectionManager),
                this
        );

        getServer().getScheduler().runTaskTimer(
                this,
                new CooldownActionBarTask(this, itemManager, cooldownManager),
                0L,
                20L
        );
    }

    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    public ProtectionManager getProtectionManager() {
        return protectionManager;
    }

    public ItemManager getItemManager() {
        return itemManager;
    }
}