Skplayz444 Skplayz444

Act as an expert Minecraft Paper plugin developer. Create a fully functional God Netherite Sword plugin for Paper 1.21.x.

The weapon must be obtained using a command: "/godweapon". It must be a special custom ability weapon, not a normal Netherite Sword. Keep its vanilla Netherite Sword appearance.

Ability 1: Right-click to fire a Warden-style Sonic Boom, dealing damage like the real Warden Sonic Boom. Every right-click must work without cooldown or usage limits.

Ability 2: SHIFT + Left-click activates Sharpness 1000 damage for that attack only, capable of one-shotting enemies. No other enchantments.

Normal left-click attacks must remain normal. Only SHIFT + Left-click activates Ability 2.

Provide complete, build-ready Java source code, "plugin.yml", and all required files. Ensure "/godweapon" gives the special sword and both abilities work correctly. Do not add any other enchantments or change the vanilla sword texture.

Kodari AI
KodariOct 27 at 11:39 pm 1
GodNetheriteWeapon
A Paper 1.21.x plugin granting a special Netherite Sword via /godweapon command. Right-click fires Warden-style Sonic Boom projectiles with no cooldown, dealing Warden-equivalent damage. Sneak-left-click triggers a one-hit-kill Sharpness 1000 attack for that strike only. Normal attacks remain vanilla; no extra enchantments or texture changes are applied.
  • Create the Gradle build and Paper plugin descriptor.

  • Add the command-driven custom sword with persistent weapon identity.

  • Implement armor-bypassing Warden Sonic Boom and shift-left-click-only high damage.

Created the Paper 1.21.x GodWeapon project with /godweapon, a vanilla-appearance Netherite Sword, unlimited Warden Sonic Boom right-clicks using sonic-boom damage, and a 1,000-damage shift-left-click attack. The special abilities use a persistent item marker; the sword has no enchantments.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 205
src/main/java/com/kodari/godweapon/GodWeaponPlugin.java
package com.kodari.godweapon;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
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.player.PlayerInteractEvent;
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.util.Vector;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public final class GodWeaponPlugin extends JavaPlugin implements Listener {
    private static final double SONIC_BOOM_DAMAGE = 10.0;
    private static final double SONIC_BOOM_RANGE = 15.0;
    private static final double SHARP_ATTACK_DAMAGE = 1000.0;

    private final Set<UUID> chargedAttacks = new HashSet<>();
    private NamespacedKey weaponKey;

    @Override
    public void onEnable() {
        weaponKey = new NamespacedKey(this, "god_weapon");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("godweapon").setExecutor((sender, command, label, args) -> {
            if (!(sender instanceof Player player)) {
                sender.sendMessage("This command can only be used by a player.");
                return true;
            }

            giveWeapon(player);
            return true;
        });
    }

    private void giveWeapon(Player player) {
        ItemStack sword = XMaterial.matchXMaterial("NETHERITE_SWORD")
                .map(XMaterial::parseItem)
                .orElse(null);
        if (sword == null) {
            player.sendMessage(ChatColor.RED + "Could not create the God Netherite Sword.");
            return;
        }

        ItemMeta meta = sword.getItemMeta();
        if (meta == null) {
            player.sendMessage(ChatColor.RED + "Could not create the God Netherite Sword.");
            return;
        }

        meta.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD + "God Netherite Sword");
        meta.setLore(java.util.List.of(
                ChatColor.GRAY + "Right-click: Sonic Boom",
                ChatColor.GRAY + "Shift + left-click: devastating strike"
        ));
        meta.getPersistentDataContainer().set(weaponKey, PersistentDataType.BYTE, (byte) 1);
        sword.setItemMeta(meta);

        for (ItemStack leftover : player.getInventory().addItem(sword).values()) {
            player.getWorld().dropItemNaturally(player.getLocation(), leftover);
        }
        player.sendMessage(ChatColor.GREEN + "You received the God Netherite Sword.");
    }

    private boolean isGodWeapon(ItemStack item) {
        if (item == null || item.getType().isAir() || !item.hasItemMeta()) {
            return false;
        }
        return item.getItemMeta().getPersistentDataContainer().has(weaponKey, PersistentDataType.BYTE);
    }

    @EventHandler
    public void onWeaponInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND) {
            return;
        }

        Player player = event.getPlayer();
        if (!isGodWeapon(player.getInventory().getItemInMainHand())) {
            return;
        }

        Action action = event.getAction();
        if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
            event.setCancelled(true);
            fireSonicBoom(player);
            return;
        }

        if (player.isSneaking() && (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK)) {
            UUID playerId = player.getUniqueId();
            chargedAttacks.add(playerId);
            Bukkit.getScheduler().runTask(this, () -> chargedAttacks.remove(playerId));
        }
    }

    private void fireSonicBoom(Player player) {
        Vector direction = player.getEyeLocation().getDirection().normalize();
        Location end = player.getEyeLocation().clone().add(direction.clone().multiply(SONIC_BOOM_RANGE));
        LivingEntity target = findSonicBoomTarget(player, direction);
        Location effectLocation = target == null
                ? end
                : target.getLocation().add(0, target.getHeight() * 0.5, 0);

        XParticle.of("SONIC_BOOM").ifPresent(particle ->
                player.getWorld().spawnParticle(particle.get(), effectLocation, 1));
        XSound.matchXSound("ENTITY_WARDEN_SONIC_BOOM").ifPresent(sound -> sound.play(player));

        if (target != null && target.isValid() && !target.isDead()) {
            DamageSource source = DamageSource.builder(DamageType.SONIC_BOOM)
                    .withCausingEntity(player)
                    .withDirectEntity(player)
                    .build();
            target.damage(SONIC_BOOM_DAMAGE, source);
        }
    }

    private LivingEntity findSonicBoomTarget(Player player, Vector direction) {
        Location origin = player.getEyeLocation();
        for (double distance = 1.0; distance <= SONIC_BOOM_RANGE; distance += 0.5) {
            Location point = origin.clone().add(direction.clone().multiply(distance));
            LivingEntity closest = null;
            double closestDistance = Double.MAX_VALUE;

            for (Entity entity : player.getWorld().getNearbyEntities(point, 0.65, 0.65, 0.65)) {
                if (!(entity instanceof LivingEntity living) || entity.equals(player) || living.isDead()) {
                    continue;
                }
                double distanceSquared = entity.getLocation().distanceSquared(point);
                if (distanceSquared < closestDistance) {
                    closest = living;
                    closestDistance = distanceSquared;
                }
            }

            if (closest != null) {
                return closest;
            }
        }
        return null;
    }

    @EventHandler
    public void onChargedAttack(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player player)
                || !(event.getEntity() instanceof LivingEntity)
                || !chargedAttacks.remove(player.getUniqueId())
                || !isGodWeapon(player.getInventory().getItemInMainHand())) {
            return;
        }

        event.setDamage(SHARP_ATTACK_DAMAGE);
    }
}