Ayala Jameson

make it so when u get a fishing rod from creative it exactly puts it at 1 duribility so when u use it the fishing rod break and warden sonic blast fires from the sky breaking blocks and alot of damage to players in a circle

Kodari AI
KodariYesterday at 4:32 am 1
BrokenRodWardenStrike
When a player obtains a fishing rod from creative mode, its durability is set to exactly 1, causing it to break after a single use. Upon the rod breaking, a warden sonic blast effect is triggered from the sky, dealing massive damage to all players within a circular radius and breaking blocks in the affected area.
  • Set creative-obtained fishing rods to one durability.

  • Break the rod on use and trigger a damaging, block-breaking sonic blast.

Created the sonic fishing rod plugin. Creative inventory rods are set to one durability; using one breaks it and triggers a downward sonic blast, an explosion, and heavy damage to nearby players.

Ayala Jameson

When a player obtains a fishing rod from creative mode, its durability is set to exactly 1, causing it to break after a single use. Upon the rod breaking, a warden sonic blast effect is triggered from the sky, dealing massive damage to all players within a circular radius and breaking blocks in the affected area and make it like a stab shot so when u use it. it breaks in a circle going down to bedrock. and u can aim it withen 100 blocks

Kodari AI
KodariYesterday at 4:36 am 1
  • Aim the shot up to 100 blocks away.

  • Drive a circular blast from the impact point down to bedrock, with player damage and block-break protection checks.

The rod now fires an aimed sonic shot up to 100 blocks away. At impact, it damages players within a six-block radius and clears a circular shaft down to bedrock, respecting block-break cancellations from other plugins.

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

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.FluidCollisionMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.inventory.InventoryCreativeEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;

public final class SonicFishingPlugin extends JavaPlugin implements Listener {
    private static final double RADIUS = 6.0;
    private static final double DAMAGE = 30.0;
    private static final double RANGE = 100.0;

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onCreativeInventory(InventoryCreativeEvent event) {
        if (!(event.getWhoClicked() instanceof Player player)) {
            return;
        }
        getServer().getScheduler().runTask(this, () -> {
            if (!player.isOnline() || player.getGameMode() != GameMode.CREATIVE) {
                return;
            }
            for (ItemStack item : player.getInventory().getContents()) {
                setOneDurability(item);
            }
            setOneDurability(player.getItemOnCursor());
            player.updateInventory();
        });
    }

    private void setOneDurability(ItemStack item) {
        if (!isRod(item) || !(item.getItemMeta() instanceof Damageable meta)) {
            return;
        }
        meta.setDamage(item.getType().getMaxDurability() - 1);
        item.setItemMeta(meta);
    }

    private boolean isRod(ItemStack item) {
        Material rod = XMaterial.matchXMaterial("FISHING_ROD").map(XMaterial::parseMaterial).orElse(null);
        return item != null && rod != null && item.getType() == rod;
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onFish(PlayerFishEvent event) {
        if (event.getState() != PlayerFishEvent.State.FISHING) {
            return;
        }
        Player player = event.getPlayer();
        EquipmentSlot hand = event.getHand();
        if (hand == null) {
            return;
        }
        ItemStack rod = hand == EquipmentSlot.OFF_HAND
                ? player.getInventory().getItemInOffHand() : player.getInventory().getItemInMainHand();
        if (!isRod(rod) || !(rod.getItemMeta() instanceof Damageable meta)
                || meta.getDamage() < rod.getType().getMaxDurability() - 1) {
            return;
        }
        event.setCancelled(true);
        if (rod.getAmount() > 1) {
            rod.setAmount(rod.getAmount() - 1);
        } else if (hand == EquipmentSlot.OFF_HAND) {
            player.getInventory().setItemInOffHand(null);
        } else {
            player.getInventory().setItemInMainHand(null);
        }
        World world = player.getWorld();
        Location eye = player.getEyeLocation();
        Vector direction = eye.getDirection();
        RayTraceResult hit = world.rayTraceBlocks(eye, direction, RANGE, FluidCollisionMode.NEVER, true);
        Location center = hit == null ? eye.clone().add(direction.clone().multiply(RANGE))
                : hit.getHitPosition().toLocation(world);
        int top = Math.min(world.getMaxHeight() - 1, Math.max(world.getMinHeight(), center.getBlockY()));
        Material air = XMaterial.matchXMaterial("AIR").map(XMaterial::parseMaterial).orElse(null);
        Material bedrock = XMaterial.matchXMaterial("BEDROCK").map(XMaterial::parseMaterial).orElse(null);
        XParticle.of("SONIC_BOOM").ifPresent(particle -> {
            for (double distance = 0; distance <= eye.distance(center); distance += 4) {
                world.spawnParticle(particle.get(), eye.clone().add(direction.clone().multiply(distance)), 1, 0, 0, 0, 0);
            }
            for (int y = Math.min(world.getMaxHeight() - 1, top + 30); y >= top; y -= 3) {
                world.spawnParticle(particle.get(), new Location(world, center.getX(), y, center.getZ()), 1, 0, 0, 0, 0);
            }
        });
        XSound.matchXSound("ENTITY_WARDEN_SONIC_BOOM").ifPresent(sound -> sound.play(player));
        for (Player target : world.getPlayers()) {
            Location location = target.getLocation();
            double dx = location.getX() - center.getX();
            double dz = location.getZ() - center.getZ();
            if (dx * dx + dz * dz <= RADIUS * RADIUS) {
                target.damage(DAMAGE, player);
            }
        }
        if (air == null || bedrock == null) {
            return;
        }
        int minX = (int) Math.floor(center.getX() - RADIUS);
        int maxX = (int) Math.floor(center.getX() + RADIUS);
        int minZ = (int) Math.floor(center.getZ() - RADIUS);
        int maxZ = (int) Math.floor(center.getZ() + RADIUS);
        for (int x = minX; x <= maxX; x++) {
            for (int z = minZ; z <= maxZ; z++) {
                double dx = x + 0.5 - center.getX();
                double dz = z + 0.5 - center.getZ();
                if (dx * dx + dz * dz > RADIUS * RADIUS) {
                    continue;
                }
                for (int y = top; y >= world.getMinHeight(); y--) {
                    Block block = world.getBlockAt(x, y, z);
                    if (block.getType() == bedrock) {
                        break;
                    }
                    if (block.getType().isAir()) {
                        continue;
                    }
                    BlockBreakEvent breakEvent = new BlockBreakEvent(block, player);
                    getServer().getPluginManager().callEvent(breakEvent);
                    if (!breakEvent.isCancelled()) {
                        block.setType(air, false);
                    }
                }
            }
        }
    }
}