itzcyrian

can you make a plugin that has a axe with the attack speed of a sword and does 1.25 more damage

Kodari AI
KodariFri at 12:43 pm 1
SwiftAxe
A Minecraft plugin that adds a custom axe item with sword-like attack speed and increased damage. The plugin modifies the axe's base attributes, setting attack speed to match a sword (1.6) while adding 1.25 extra damage points. Players receive the custom axe via a command, and the plugin applies persistent attribute modifiers to ensure consistent combat performance. The axe retains its durability and enchantability while offering a unique combat alternative to traditional swords.
  • Add /battleaxe to give a diamond axe with sword attack speed.

  • Set its damage to 1.25 points above a normal diamond axe.

Use /battleaxe to receive a diamond axe with sword attack speed and 1.25 extra damage. The command is available to operators by default.

itzcyrian

make it netherite

Kodari AI
KodariFri at 12:44 pm 1

The battle axe is now netherite, with sword attack speed and 1.25 extra damage over a normal netherite axe.

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 56
src/main/java/com/kodari/battleaxe/BattleAxePlugin.java
package com.kodari.battleaxe;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public final class BattleAxePlugin extends JavaPlugin {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }
        Player player = (Player) sender;
        if (!player.hasPermission("battleaxe.give")) {
            player.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
            return true;
        }
        ItemStack axe = XMaterial.matchXMaterial("NETHERITE_AXE").map(XMaterial::parseItem).orElse(null);
        Attribute damage = XAttribute.of("attack_damage").map(XAttribute::get).orElse(null);
        Attribute speed = XAttribute.of("attack_speed").map(XAttribute::get).orElse(null);
        if (axe == null || damage == null || speed == null) {
            player.sendMessage(ChatColor.RED + "The battle axe is not supported on this server version.");
            return true;
        }
        ItemMeta meta = axe.getItemMeta();
        meta.setDisplayName(ChatColor.GOLD + "Battle Axe");
        meta.addAttributeModifier(damage, XAttribute.createModifier("battleaxe:damage", 10.25, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND));
        meta.addAttributeModifier(speed, XAttribute.createModifier("battleaxe:speed", -2.4, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND));
        axe.setItemMeta(meta);
        player.getInventory().addItem(axe).values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item));
        player.sendMessage(ChatColor.GREEN + "You received a battle axe.");
        return true;
    }
}