Ed Dhaene

can you make a grappling bow that u have at spawn and when u use it it lunges you up

Kodari AI
KodariOct 2 at 3:49 pm 1
GrapplingBowLunge
A Minecraft plugin that adds a special grappling bow available at spawn. When fired, the arrow creates a grappling effect that lunges the player upward toward the arrow's trajectory, providing a dynamic movement mechanic. The plugin includes spawn-based item distribution, arrow tracking, and velocity manipulation to simulate the grappling lunge. Players can use this bow to traverse terrain quickly, reach high areas, or perform acrobatic maneuvers. The plugin handles cooldown management to prevent spam, configurable lunge power, and ensures compatibility with standard Minecraft mechanics while delivering an exciting parkour-style gameplay enhancement.
  1. Create a Paper plugin that grants a tagged grappling bow on join and respawn.

  2. Make right-clicking it launch the player upward and forward.

Created the GrapplingBow plugin. Players receive a special bow when they join or respawn; right-clicking it launches them upward and forward.

Ed Dhaene

okay make the cooldown 5 seconds and also make it show the bow animation with an arrow withour shootting an error look for bugs and fix

Kodari AI
KodariOct 3 at 6:50 pm 1
  1. Add a 5-second cooldown and bow-use animation without spawning a projectile.

  2. Review the plugin for bugs and fix any confirmed issues.

Updated GrapplingBowPlugin.java:

  • Added a 5-second per-player cooldown.

  • Let the bow-use event proceed so players see the bow draw animation; ensures they have an arrow to draw.

  • Cancels the grappling bow’s shoot event so no arrow projectile is fired.

  • Fixed the animation bug: the original handler canceled every right-click, preventing the bow animation.

Ed Dhaene

make the anitmation like without an arrow in the inventory and make it finish the animation of the bow and after the animation let the lunge be and also make it more lunge how longer you hold the animation how futher the lungez is make it very smooth and not to fast

Kodari AI
KodariOct 3 at 7:06 pm 1
  1. Replace permanent arrow grants with a temporary, tagged arrow used only to start vanilla’s bow-draw animation, then remove it.

  2. Charge while the bow is drawn; lunge on release, scaling distance with hold time and smoothing the velocity over several ticks.

  3. Fix cleanup and cooldown edge cases so interrupted draws, disconnects, and completed launches don’t leave arrows or tasks behind.

  • The bow now charges normally; releasing it lunges you, with more charge giving a stronger lunge (up to a full draw).

  • The lunge eases in over 10 ticks instead of hitting at full speed immediately.

  • Fixed arrows and tasks being left behind when a draw is interrupted, the player dies or disconnects, or the plugin shuts down. Cooldown remains 5 seconds.

You don’t need to carry arrows: vanilla’s bow animation requires ammo, so the plugin briefly adds a tagged temporary arrow while you draw and removes it afterward.

Ed Dhaene

make it so theres like no delay after the bow shot so its instant and also say in chat when there is a message in chat there is a 5 second delay or something like that

Kodari AI
KodariOct 3 at 7:15 pm 1

The lunge now starts on the same tick the bow is released, then eases smoothly over the next ticks. Players see a chat message stating the 5-second cooldown after using it, and the remaining cooldown time if they try again too soon.

Ed Dhaene

make it so to where you look there you will get the velocity the way you look

Kodari AI
KodariOct 3 at 7:17 pm 1
  1. Use the player’s full look direction—including pitch—for the lunge target.

  2. Keep charge-based strength and the existing smooth velocity easing.

The lunge now follows your full look direction, including up and down, while keeping the charge-based strength and smooth easing.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 341
src/main/java/com/kodari/grapplingbow/GrapplingBowPlugin.java
package com.kodari.grapplingbow;

import com.cryptomorin.xseries.XMaterial;
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.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;

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

public final class GrapplingBowPlugin extends JavaPlugin implements Listener {
    private static final long COOLDOWN_NANOS = 5_000_000_000L;

    private NamespacedKey grapplingBowKey;
    private NamespacedKey temporaryArrowKey;
    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final Map<UUID, BukkitTask> chargeTasks = new HashMap<>();
    private final Map<UUID, BukkitTask> lungeTasks = new HashMap<>();

    @Override
    public void onEnable() {
        grapplingBowKey = new NamespacedKey(this, "grappling_bow");
        temporaryArrowKey = new NamespacedKey(this, "temporary_grappling_arrow");
        getServer().getPluginManager().registerEvents(this, this);

        for (Player player : getServer().getOnlinePlayers()) {
            giveGrapplingBow(player);
        }
    }

    @Override
    public void onDisable() {
        chargeTasks.values().forEach(BukkitTask::cancel);
        lungeTasks.values().forEach(BukkitTask::cancel);
        for (Player player : getServer().getOnlinePlayers()) {
            removeTemporaryArrow(player);
        }
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        giveGrapplingBow(event.getPlayer());
    }

    @EventHandler
    public void onRespawn(PlayerRespawnEvent event) {
        giveGrapplingBow(event.getPlayer());
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        UUID id = player.getUniqueId();
        cooldowns.remove(id);
        cancelTask(chargeTasks, id);
        cancelTask(lungeTasks, id);
        removeTemporaryArrow(player);
    }

    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        Player player = event.getEntity();
        UUID id = player.getUniqueId();
        cancelTask(chargeTasks, id);
        cancelTask(lungeTasks, id);
        event.getDrops().removeIf(this::isTemporaryArrow);
        removeTemporaryArrow(player);
    }

    @EventHandler
    public void onGrapplingBowUse(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND
                || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
                || !isGrapplingBow(event.getItem())) {
            return;
        }

        Player player = event.getPlayer();
        UUID id = player.getUniqueId();
        if (chargeTasks.containsKey(id)) {
            return;
        }

        long now = System.nanoTime();
        Long cooldownUntil = cooldowns.get(id);
        if (cooldownUntil != null && now < cooldownUntil) {
            event.setCancelled(true);
            long secondsRemaining = (cooldownUntil - now + 999_999_999L) / 1_000_000_000L;
            player.sendMessage("§cGrappling Bow cooldown: " + secondsRemaining + " second(s) remaining.");
            return;
        }

        if (!hasArrow(player) && !addTemporaryArrow(player)) {
            event.setCancelled(true);
            return;
        }

        cooldowns.put(id, now + COOLDOWN_NANOS);
        startChargeTracking(player);
    }

    @EventHandler
    public void onGrapplingBowShoot(EntityShootBowEvent event) {
        if (isGrapplingBow(event.getBow())) {
            event.setCancelled(true);
            if (event.getEntity() instanceof Player player) {
                UUID id = player.getUniqueId();
                cancelTask(chargeTasks, id);
                startLunge(player, event.getForce());
                getServer().getScheduler().runTask(this, () -> removeTemporaryArrow(player));
            }
        }
    }

    private void giveGrapplingBow(Player player) {
        boolean hasGrapplingBow = false;
        for (ItemStack item : player.getInventory().getContents()) {
            if (isGrapplingBow(item)) {
                hasGrapplingBow = true;
                break;
            }
        }

        if (!hasGrapplingBow) {
            ItemStack bow = XMaterial.matchXMaterial("BOW").map(XMaterial::parseItem).orElse(null);
            if (bow == null) {
                getLogger().warning("Could not create the grappling bow: BOW is unavailable.");
                return;
            }

            ItemMeta meta = bow.getItemMeta();
            if (meta == null) {
                return;
            }

            meta.setDisplayName("§6Grappling Bow");
            meta.setLore(List.of("§7Right-click to launch yourself upward!"));
            meta.getPersistentDataContainer().set(grapplingBowKey, PersistentDataType.BYTE, (byte) 1);
            bow.setItemMeta(meta);

            player.getInventory().addItem(bow).values().forEach(remaining ->
                    player.getWorld().dropItemNaturally(player.getLocation(), remaining));
        }

    }

    private boolean hasArrow(Player player) {
        for (ItemStack item : player.getInventory().getContents()) {
            if (item != null && "ARROW".equals(item.getType().name())) {
                return true;
            }
        }

        return false;
    }

    private boolean addTemporaryArrow(Player player) {
        ItemStack arrow = XMaterial.matchXMaterial("ARROW").map(XMaterial::parseItem).orElse(null);
        if (arrow == null) {
            return false;
        }

        ItemMeta meta = arrow.getItemMeta();
        if (meta == null) {
            return false;
        }
        meta.getPersistentDataContainer().set(temporaryArrowKey, PersistentDataType.BYTE, (byte) 1);
        arrow.setItemMeta(meta);

        int slot = player.getInventory().firstEmpty();
        if (slot >= 0) {
            player.getInventory().setItem(slot, arrow);
            return true;
        }

        ItemStack offHand = player.getInventory().getItemInOffHand();
        if (offHand == null || offHand.getType().isAir()) {
            player.getInventory().setItemInOffHand(arrow);
            return true;
        }
        return false;
    }