Skplayz444 Skplayz444

Create a fully functional Minecraft Paper 1.21.x God Stone Sword plugin in Java. The weapon must look exactly like a normal vanilla STONE_SWORD, with no enchantments, custom textures, or visible custom name.

Abilities:

  1. Unlimited Lightning: While right-clicking, continuously summon lightning bolts at my crosshair target, with no usage limit. Each lightning hit must deal exactly 1 true health point (half a heart), ignoring armor.
  2. Offhand Arrow Machine: While holding the sword in the offhand, continuously shoot arrows at 4 arrows per second. Every arrow must deal exactly 1 true health point (half a heart) to any player or mob, ignoring armor.
  3. Fire Attack: Every normal left-click sword hit must ignite the target without adding the Fire Aspect enchantment.
  4. Looting 100: Every kill with this sword must receive Looting level 100 effects without visibly enchanting the sword.
  5. Lightning Block Damage: Lightning strikes must break 1–2 blocks at the impact location, with safe handling for protected regions and valuable blocks.

All abilities must work reliably on Paper servers. Use proper event handling, avoid memory leaks, and provide complete build-ready Java source code, plugin.yml, and Maven configuration. Do not use fake enchantments or change the sword's vanilla appearance.

Kodari AI
KodariOct 27 at 1:34 pm 2
GodStoneSword
Creates an invisible god-tier stone sword with no visual changes. Right-click summons unlimited lightning dealing exactly 1 true damage per strike, breaking 1-2 blocks safely. Offhand mode auto-fires 4 arrows per second dealing 1 true damage each. Left-click ignites targets without Fire Aspect. Kills grant Looting 100 effects. All abilities bypass armor while maintaining vanilla appearance.
  1. Identify the Paper 1.21 APIs for true damage, arrow identification, and loot handling.

  2. Create the Maven project, plugin descriptor, and a listener/scheduler implementation for all five abilities.

  3. Respect protection plugins through cancellable block-break events and skip valuable or tile-entity blocks.

Created the Maven project with the plugin descriptor, /godstonesword [player] command, and the sword abilities. The item keeps the vanilla stone sword appearance; temporary Looting 100 is restored after the loot calculation.

Right-click limitation: Bukkit/Paper doesn’t expose release of a right-click on a sword that has no built-in use action. The lightning stream starts on right-click and stops when the sword is switched out, or the player disconnects or dies; releasing right-click alone won’t stop it.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
4 518
src/main/java/com/kodari/godstonesword/GodStoneSwordPlugin.java
package com.kodari.godstonesword;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Map;

public final class GodStoneSwordPlugin extends JavaPlugin {
    private NamespacedKey swordKey;
    private GodStoneSwordListener listener;

    @Override
    public void onEnable() {
        swordKey = new NamespacedKey(this, "god_stone_sword");
        listener = new GodStoneSwordListener(this, swordKey);
        Bukkit.getPluginManager().registerEvents(listener, this);
        getCommand("godstonesword").setExecutor(this::giveSword);
    }

    @Override
    public void onDisable() {
        if (listener != null) {
            listener.shutdown();
        }
    }

    private boolean giveSword(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.hasPermission("godstonesword.give")) {
            sender.sendMessage("You do not have permission to use this command.");
            return true;
        }

        Player target;
        if (args.length > 0) {
            target = Bukkit.getPlayerExact(args[0]);
            if (target == null) {
                sender.sendMessage("That player is not online.");
                return true;
            }
        } else if (sender instanceof Player player) {
            target = player;
        } else {
            sender.sendMessage("Console must specify a player.");
            return true;
        }

        ItemStack sword = createSword();
        PlayerInventory inventory = target.getInventory();
        for (ItemStack leftover : inventory.addItem(sword).values()) {
            target.getWorld().dropItemNaturally(target.getLocation(), leftover);
        }
        sender.sendMessage("Gave a God Stone Sword to " + target.getName() + ".");
        return true;
    }

    ItemStack createSword() {
        ItemStack sword = XMaterial.matchXMaterial("STONE_SWORD")
                .map(XMaterial::parseItem)
                .orElse(null);
        if (sword == null) {
            throw new IllegalStateException("XSeries could not create STONE_SWORD");
        }
        ItemMeta meta = sword.getItemMeta();
        meta.getPersistentDataContainer().set(swordKey, PersistentDataType.BYTE, (byte) 1);
        sword.setItemMeta(meta);
        return sword;
    }

    boolean isGodSword(ItemStack item) {
        if (item == null || item.getType().isAir()) {
            return false;
        }
        ItemMeta meta = item.getItemMeta();
        return meta != null && meta.getPersistentDataContainer().has(swordKey, PersistentDataType.BYTE);
    }
}