Joshua Cozad

make a mace plugin that has a small dash when you right click and if you miss a hit you have a 1 minute cooldown for the mace and everytime you hit someone with the mace you gain one dash that you can use with a crafting recipie of 64 copper blocks 64 iron blocks 1 heavy core and 64 breeze rods

Kodari AI
KodariOct 3 at 10:06 pm 1
MaceDashCombat
A Minecraft plugin introducing a powerful mace weapon with dash mechanics. Right-clicking triggers a short forward dash. Missing a hit applies a 60-second cooldown. Each successful hit grants one dash charge. The mace is crafted using 64 copper blocks, 64 iron blocks, 1 heavy core, and 64 breeze rods. Dash charges persist until used, rewarding aggressive combat playstyles.

[Generation stopped]

Joshua Cozad

Can you make a mace plugin that has small dashes when you right click and you get the dashes everytime you mace someone from more than 5 blocks high and it takes 1 dragon egg in the middle of the crafting menu 4 netherite ingots in each corner and 16 diamonds in the middle of each side and the mace has density 2 and breach 2

Kodari AI
KodariOct 5 at 7:28 pm 1

Created MaceDashCombat with a custom mace enchanted with Density II and Breach II. Its recipe uses a dragon egg in the center, netherite ingots in the corners, and 16 diamonds in each of the four side slots.

A mace hit while falling more than 5 blocks grants a dash charge; right-click spends one for a short dash. I also retained the one-minute cooldown for a missed swing from your earlier request.

Joshua Cozad

make it so the dash is equivalent to riptide 1 and you can dash in any direction

Kodari AI
KodariOct 5 at 9:49 pm 1
  1. Replace the horizontal dash with a full 3D launch at Riptide I strength (1.5), following the player’s look direction.

Updated the dash to launch at Riptide I strength (1.5) in the player’s full look direction, including upward and downward.

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 249
src/main/java/com/kodari/macedash/MaceDashPlugin.java
package com.kodari.macedash;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

public final class MaceDashPlugin extends JavaPlugin implements Listener {
    private static final long MISS_COOLDOWN_MILLIS = 60_000L;
    private static final int MISS_CHECK_TICKS = 2;
    private static final int REQUIRED_FALL_DISTANCE = 5;

    private final Map<UUID, Integer> pendingSwings = new HashMap<>();
    private final Map<UUID, Long> missCooldowns = new HashMap<>();
    private NamespacedKey customMaceKey;
    private NamespacedKey dashChargesKey;
    private NamespacedKey recipeKey;
    private int swingSequence;

    @Override
    public void onEnable() {
        customMaceKey = new NamespacedKey(this, "dash_mace");
        dashChargesKey = new NamespacedKey(this, "dash_charges");
        recipeKey = new NamespacedKey(this, "dash_mace_recipe");
        Bukkit.getPluginManager().registerEvents(this, this);
        registerRecipe();
    }

    private void registerRecipe() {
        ItemStack result = createMace();
        ShapedRecipe recipe = new ShapedRecipe(recipeKey, result);
        recipe.shape("NDN", "DED", "NDN");
        recipe.setIngredient('N', material("NETHERITE_INGOT"));
        recipe.setIngredient('D', material("DIAMOND"));
        recipe.setIngredient('E', material("DRAGON_EGG"));
        Bukkit.addRecipe(recipe);
    }

    @EventHandler
    public void onPrepareCraft(PrepareItemCraftEvent event) {
        if (!isMaceRecipe(event.getRecipe())) {
            return;
        }
        event.getInventory().setResult(hasRecipeIngredients(event.getInventory().getMatrix()) ? createMace() : null);
    }

    @EventHandler
    public void onCraft(CraftItemEvent event) {
        if (!isMaceRecipe(event.getRecipe()) || !hasRecipeIngredients(event.getInventory().getMatrix())) {
            return;
        }

        event.setCancelled(true);
        CraftingInventory inventory = event.getInventory();
        ItemStack[] matrix = inventory.getMatrix();
        for (int slot : new int[]{0, 2, 6, 8}) {
            consume(matrix[slot], 1);
        }
        for (int slot : new int[]{1, 3, 5, 7}) {
            consume(matrix[slot], 16);
        }
        consume(matrix[4], 1);
        inventory.setMatrix(matrix);
        inventory.setResult(null);

        Player player = (Player) event.getWhoClicked();
        Map<Integer, ItemStack> leftovers = player.getInventory().addItem(createMace());
        leftovers.values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item));
        player.updateInventory();
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (!"HAND".equals(event.getHand().name())) {
            return;
        }

        ItemStack item = event.getItem();
        if (!isCustomMace(item)) {
            return;
        }

        String action = event.getAction().name();
        if (action.startsWith("RIGHT_CLICK")) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            if (isOnMissCooldown(player.getUniqueId())) {
                return;
            }

            int charges = getDashCharges(item);
            if (charges <= 0) {
                return;
            }

            setDashCharges(item, charges - 1);
            Vector direction = player.getLocation().getDirection().normalize().multiply(1.5);
            player.setVelocity(direction);
            return;
        }

        if (action.startsWith("LEFT_CLICK") && !isOnMissCooldown(event.getPlayer().getUniqueId())) {
            scheduleMissCheck(event.getPlayer());
        }
    }

    @EventHandler
    public void onMaceHit(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player player) || !isCustomMace(player.getInventory().getItemInMainHand())) {
            return;
        }

        if (isOnMissCooldown(player.getUniqueId())) {
            event.setCancelled(true);
            return;
        }

        pendingSwings.remove(player.getUniqueId());
        if (player.getFallDistance() > REQUIRED_FALL_DISTANCE) {
            ItemStack mace = player.getInventory().getItemInMainHand();
            setDashCharges(mace, getDashCharges(mace) + 1);
            player.sendMessage("§aMace hit! You gained a dash charge.");
        }
    }

    private void scheduleMissCheck(Player player) {
        UUID playerId = player.getUniqueId();
        int swingId = ++swingSequence;
        pendingSwings.put(playerId, swingId);
        Bukkit.getScheduler().runTaskLater(this, () -> {
            if (!Objects.equals(pendingSwings.get(playerId), swingId)) {
                return;
            }
            pendingSwings.remove(playerId);
            long expiry = System.currentTimeMillis() + MISS_COOLDOWN_MILLIS;
            missCooldowns.put(playerId, expiry);
            player.setCooldown(material("MACE"), (int) (MISS_COOLDOWN_MILLIS / 50L));
            player.sendMessage("§cMissed! Your mace is on cooldown for 1 minute.");
        }, MISS_CHECK_TICKS);
    }

    private boolean isOnMissCooldown(UUID playerId) {
        Long expiry = missCooldowns.get(playerId);
        if (expiry == null) {
            return false;
        }
        if (expiry <= System.currentTimeMillis()) {
            missCooldowns.remove(playerId);
            return false;
        }
        return true;
    }

    private boolean isMaceRecipe(org.bukkit.inventory.Recipe recipe) {
        return recipe instanceof ShapedRecipe shaped && shaped.getKey().equals(recipeKey);
    }

    private boolean hasRecipeIngredients(ItemStack[] matrix) {
        if (matrix.length != 9) {
            return false;
        }
        for (int slot = 0; slot < matrix.length; slot++) {
            String required = switch (slot) {
                case 0, 2, 6, 8 -> "NETHERITE_INGOT";
                case 1, 3, 5, 7 -> "DIAMOND";
                case 4 -> "DRAGON_EGG";
                default -> throw new IllegalStateException("Unexpected crafting slot");
            };
            int requiredAmount = (slot == 1 || slot == 3 || slot == 5 || slot == 7) ? 16 : 1;
            ItemStack ingredient = matrix[slot];
            if (ingredient == null || ingredient.getAmount() < requiredAmount
                    || !XMaterial.matchXMaterial(ingredient.getType()).name().equals(required)) {
                return false;
            }
        }
        return true;
    }

    private void consume(ItemStack item, int amount) {