Ganor
📎 1 file 1,785 chars
📄
pasted-code-1791907425086.txt
txt 30 lines
▶
EndSword

Features
Custom End Sword: Add a legendary sword called §5End Sword with a purple name, enchanted glow, and custom lore.
Crafting Recipe: Create a custom crafting recipe using Netherite Swords, Ender Pearls, and End Crystals.
Ender Slash: Right-click to launch a purple energy wave that damages enemies.
Teleport Ability: Right-click while sneaking to teleport a short distance toward the direction the player is facing.
Void Strike: Every few hits, summon purple particles and deal bonus damage to the target.
Ender Explosion: Sneak and right-click to create a small explosion of End particles that damages nearby enemies without destroying blocks.
Cooldown System: Add configurable cooldowns for every ability.
Custom Sounds: Use Enderman teleport, Ender Dragon, and Ender Chest sounds for abilities.
Particles: Use purple dust, portal particles, dragon breath, and end rod particles.
Permissions: Add permissions such as endsword.use, endsword.give, and endsword.admin.
Commands:
/endsword give  — Give a player the End Sword.
/endsword reload — Reload the plugin configuration.
Configuration: Store damage, cooldowns, ability range, crafting ingredients, and messages in config.yml.
Anti-Exploit Protection: Prevent players from duplicating the sword and ensure abilities work only with the genuine custom sword.
Compatibility: Use the Paper API and Java. Keep the Minecraft version configurable or specify the target version before implementation.
Technical Requirements
Generate the complete, working plugin source code, including:

Main Java plugin class
Event listeners
Ability management system
Custom item identification using PersistentDataContainer
plugin.yml
config.yml
Maven pom.xml
Installation and compilation instructions
Kodari AI
KodariOct 13 at 4:07 pm 2
EndSword
EndSword is a Paper plugin that adds a legendary custom sword with four unique abilities. The sword features an enchanted purple appearance with custom lore and a crafting recipe using Netherite Swords, Ender Pearls, and End Crystals. Right-click triggers Ender Slash, launching a purple energy wave; sneaking and right-clicking teleports the player forward or creates an Ender Explosion. Every few hits activates Void Strike with bonus damage and particles. The plugin includes configurable cooldowns, custom sounds, particle effects, permissions, and commands for giving the sword and reloading the configuration. Anti-exploit protection uses PersistentDataContainer to verify authentic swords, preventing duplication and ensuring abilities only work with genuine items.
  1. Build the End Sword item, recipe, and configurable abilities with PDC-based identification.

  2. Add commands, permissions, cooldowns, and Paper plugin metadata.

  3. Add a Maven build targeting Paper 1.20.4 / Java 17.

Created EndSword for Paper 1.20.4 / Java 17, including configurable damage, cooldowns, ranges, crafting recipe, messages, commands, and PDC-based item identification.

Sneak + right-click air teleports; sneak + right-click a block triggers the explosion. Normal right-click launches the Ender Slash.

To compile in Kodari, click Compile in the top bar (or ⋮ → Compile Project on phone), then click Compile in the window. Download the resulting JAR and place it in your Paper server’s plugins folder, then restart the server. The project also includes the requested pom.xml.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
7 608
src/main/java/com/kodari/endsword/EndSwordPlugin.java
package com.kodari.endsword;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public final class EndSwordPlugin extends JavaPlugin {
    private NamespacedKey recipeKey;
    private EndSwordItem endSwordItem;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        recipeKey = new NamespacedKey(this, "end_sword");
        endSwordItem = new EndSwordItem(this);

        getServer().getPluginManager().registerEvents(new EndSwordListener(this, endSwordItem), this);
        EndSwordCommand command = new EndSwordCommand(this, endSwordItem);
        getCommand("endsword").setExecutor(command);
        getCommand("endsword").setTabCompleter(command);
        registerCraftingRecipe();
    }

    public void reloadSettings() {
        reloadConfig();
        registerCraftingRecipe();
    }

    private void registerCraftingRecipe() {
        Bukkit.removeRecipe(recipeKey);

        List<String> rows = getConfig().getStringList("recipe.rows");
        if (rows.isEmpty() || rows.size() > 3) {
            getLogger().warning("The End Sword recipe must have between one and three rows.");
            return;
        }

        int rowWidth = rows.get(0).length();
        if (rowWidth < 1 || rowWidth > 3 || rows.stream().anyMatch(row -> row.length() != rowWidth)) {
            getLogger().warning("The End Sword recipe rows must have the same width, between one and three characters.");
            return;
        }

        ConfigurationSection ingredients = getConfig().getConfigurationSection("recipe.ingredients");
        if (ingredients == null) {
            getLogger().warning("The End Sword recipe has no ingredient mappings.");
            return;
        }

        Set<Character> requiredSymbols = new HashSet<>();
        for (String row : rows) {
            for (char symbol : row.toCharArray()) {
                if (symbol != ' ') {
                    requiredSymbols.add(symbol);
                }
            }
        }

        ShapedRecipe recipe = new ShapedRecipe(recipeKey, endSwordItem.create());
        recipe.shape(rows.toArray(new String[0]));
        Set<Character> mappedSymbols = new HashSet<>();
        for (String symbolName : ingredients.getKeys(false)) {
            if (symbolName.length() != 1) {
                continue;
            }
            char symbol = symbolName.charAt(0);
            String materialName = ingredients.getString(symbolName);
            if (materialName == null) {
                continue;
            }
            Material material = XMaterial.matchXMaterial(materialName)
                    .map(XMaterial::parseMaterial)
                    .orElse(null);
            if (material != null && requiredSymbols.contains(symbol)) {
                recipe.setIngredient(symbol, material);
                mappedSymbols.add(symbol);
            }
        }

        if (!mappedSymbols.containsAll(requiredSymbols)) {
            getLogger().warning("The End Sword recipe is missing a valid material for one or more symbols.");
            return;
        }
        Bukkit.addRecipe(recipe);
    }

    public EndSwordItem getEndSwordItem() {
        return endSwordItem;
    }
}