goldencampp
📎 1 file 2,950 chars
📄
pasted-code-1785145250044.txt
txt 147 lines
▶
Create a Minecraft Paper Plugin for Minecraft Java 1.21.1 using Java and the latest Paper API.

Plugin Name

Tiny King's Sword

The plugin must be production-ready, optimized for SMP servers, fully configurable, and compatible with Paper 1.21.1.

Custom Sword

Create one unique custom Netherite Sword called Tiny King's Sword.

Properties:

Unbreakable
Enchantment Glow
Cannot be repaired
Cannot be renamed into another custom sword
Must contain a unique PersistentDataContainer tag
Custom Name
Custom Lore
Cannot be duplicated through any exploit
Default Enchantments
Sharpness VI
Looting III
Unbreaking III
Mending
Fire Aspect II
Sweeping Edge III
Holding Effects

Whenever the sword is held in the Main Hand:

Player size becomes approximately the same as a Baby Villager (smallest possible using the Paper API).
Speed III
Jump Boost II
Fire Resistance
Maximum Health becomes 15 Hearts (30 HP) while holding the sword.

When the sword leaves the player's Main Hand:

Player immediately returns to normal size.
Remove Speed.
Remove Jump Boost.
Remove Fire Resistance.
Restore normal maximum health (10 hearts).
Crafting Recipe

The sword should have a shaped crafting recipe.

Required ingredients:

1× Mace
1× Dragon Egg
1× Nether Star
1× Netherite Block
1× Netherite Sword
2× Diamond Blocks (each in a different slot, not stacked together)
2× Totems of Undying (each in a different slot, not stacked together)

The recipe layout should use separate slots for the two Diamond Blocks and the two Totems.

Players should be able to view the recipe using:

/recipe

or the normal recipe book if possible.

Only One Sword

This sword must be craftable only once on the entire server.

After someone crafts it:

Disable the recipe forever.
Save this permanently.
Restarting the server must NOT reset it.

Even if:

the sword is lost,
thrown away,
burned,
deleted,
or the owner dies,

another sword must never be craftable.

Undestroyable Sword

The sword must never be destroyed.

If dropped into:

Lava
Fire
Cactus
Void
Explosion
Despawn timer

it must survive.

If it falls into the Void, instead of disappearing:

Instantly teleport the sword to the world's spawn location.

The sword should never despawn, regardless of how long it remains on the ground.

Security

Prevent:

Item duplication
Recipe duplication
Fake copies using commands
Fake copies using anvils
Fake copies using NBT editors (as much as possible)

Only the original sword should function.

Config

Everything should be configurable inside config.yml:

Effects
Health
Enchantments
Display Name
Lore
Messages
Sounds
Files Required

Generate complete project including:

Full Java Source Code
plugin.yml
config.yml
README
All listeners
Managers
Utility classes

The project should compile without errors in IntelliJ IDEA using Maven or Gradle and follow clean coding practices.

The final plugin should be optimized for multiplayer SMP servers with minimal lag and no memory leaks.
Kodari AI
KodariJul 27 at 9:46 am 17
TinyKingsSword
Tiny King's Sword is a production-ready Paper 1.21.1 SMP plugin that adds one permanently claimable custom Netherite sword. It provides configurable display text, enchantments, holding effects, health and player scaling, a nine-ingredient shaped recipe, recipe-book and GUI viewing, persistent one-time crafting state, protected dropped-item recovery from fire, lava, explosions, cactus, despawn and the void, plus safeguards against anvil changes, mending, recipe duplication and unauthorized copies.
  1. Create the Gradle Paper project metadata and server resources.

  2. Implement persistent claim state, authenticated sword construction, configurable recipes, and recipe viewing.

  3. Add holding-effect management and all crafting, inventory, item-protection, and lifecycle listeners.

  4. Document setup, configuration, commands, and the unavoidable limits of NBT-copy prevention.

qarner

Created the TinyKingsSword Paper 1.21.1 plugin project with:

  • Persistent one-time sword claim state

  • Configurable sword name, lore, enchantments, effects, scaling, health, messages, sounds, and recipe

  • Protected dropped sword recovery from fire, lava, cactus, explosions, despawn, and void

  • Recipe-book registration and /recipe GUI

  • Anvil, smithing, mending, and crafting safeguards

  • Gradle build configuration and README documentation

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
17 1,162
src/main/java/com/kodari/tinykingsword/TinyKingsSwordPlugin.java
package com.kodari.tinykingsword;

import com.kodari.tinykingsword.command.RecipeCommand;
import com.kodari.tinykingsword.listener.RecipeViewListener;
import com.kodari.tinykingsword.listener.SwordListener;
import com.kodari.tinykingsword.manager.RecipeManager;
import com.kodari.tinykingsword.manager.SwordDataManager;
import com.kodari.tinykingsword.manager.SwordEffectManager;
import com.kodari.tinykingsword.util.SwordItemFactory;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

public final class TinyKingsSwordPlugin extends JavaPlugin {
    private SwordDataManager dataManager;
    private SwordItemFactory itemFactory;
    private RecipeManager recipeManager;
    private SwordEffectManager effectManager;
    private BukkitTask effectTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.dataManager = new SwordDataManager(this);
        this.itemFactory = new SwordItemFactory(this, dataManager);
        this.recipeManager = new RecipeManager(this, dataManager, itemFactory);
        this.recipeManager.register();

        this.effectManager = new SwordEffectManager(this, itemFactory);
        this.effectTask = Bukkit.getScheduler().runTaskTimer(this, effectManager::tick, 1L, 5L);

        Bukkit.getPluginManager().registerEvents(
                new SwordListener(this, itemFactory, dataManager, recipeManager, effectManager), this);
        Bukkit.getPluginManager().registerEvents(new RecipeViewListener(), this);

        if (getCommand("recipe") != null) {
            getCommand("recipe").setExecutor(new RecipeCommand(this, recipeManager));
        }

        for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
            recipeManager.discoverFor(player);
        }
    }

    @Override
    public void onDisable() {
        if (effectTask != null) {
            effectTask.cancel();
        }
        if (effectManager != null) {
            effectManager.shutdown();
        }
        if (dataManager != null) {
            dataManager.save();
        }
    }

    public SwordDataManager getDataManager() {
        return dataManager;
    }

    public SwordItemFactory getItemFactory() {
        return itemFactory;
    }

    public RecipeManager getRecipeManager() {
        return recipeManager;
    }

    public SwordEffectManager getEffectManager() {
        return effectManager;
    }
}