kansies_

Please make a

📎 1 file 2,171 chars
📄
pasted-code-1780553556807.txt
txt 123 lines
▶
Create a Minecraft Paper/Spigot plugin for Minecraft Java Edition 1.21.11 called UnbreakableGear.

Goal

Prevent durability loss on all items that normally have durability. Any item that can lose durability in vanilla Minecraft should become completely unbreakable.

Requirements
Armor

Prevent durability loss for:

Leather Helmet
Leather Chestplate
Leather Leggings
Leather Boots
Chainmail Helmet
Chainmail Chestplate
Chainmail Leggings
Chainmail Boots
Iron Helmet
Iron Chestplate
Iron Leggings
Iron Boots
Golden Helmet
Golden Chestplate
Golden Leggings
Golden Boots
Diamond Helmet
Diamond Chestplate
Diamond Leggings
Diamond Boots
Netherite Helmet
Netherite Chestplate
Netherite Leggings
Netherite Boots
Turtle Helmet
Tools

Prevent durability loss for:

Wooden Pickaxe
Stone Pickaxe
Iron Pickaxe
Golden Pickaxe
Diamond Pickaxe
Netherite Pickaxe
Wooden Axe
Stone Axe
Iron Axe
Golden Axe
Diamond Axe
Netherite Axe
Wooden Shovel
Stone Shovel
Iron Shovel
Golden Shovel
Diamond Shovel
Netherite Shovel
Wooden Hoe
Stone Hoe
Iron Hoe
Golden Hoe
Diamond Hoe
Netherite Hoe
Weapons

Prevent durability loss for:

Wooden Sword
Stone Sword
Iron Sword
Golden Sword
Diamond Sword
Netherite Sword
Trident
Mace
Ranged Weapons

Prevent durability loss for:

Bow
Crossbow
Utility Items

Prevent durability loss for:

Fishing Rod
Shears
Flint and Steel
Shield
Elytra
Brush
Carrot on a Stick
Warped Fungus on a Stick
Durability Events To Block

The plugin must prevent durability loss from:

Mining blocks
Breaking blocks
Attacking mobs
Attacking players
Taking damage while wearing armor
Shield blocking
Bow shooting
Crossbow shooting
Trident throwing
Mace attacks
Elytra flying
Fishing rod usage
Shearing entities
Flint and Steel usage
Brush usage
Carrot on a Stick boosting
Warped Fungus on a Stick boosting
Any other vanilla durability reduction mechanic
Implementation
Use Paper API 1.21.11.
Listen to all relevant durability-related events.
Cancel durability damage whenever possible.
Support items added in Minecraft 1.21, including the Mace.
Ensure compatibility with enchanted items.
Preserve NBT data, custom names, lore, enchantments, attributes, trims, and custom model data.
Kodari AI
KodariJun 4 at 6:15 am 4
UnbreakableGear
A lightweight Paper/Spigot plugin for Minecraft 1.21.1 that prevents all durability loss on items. Covers every durable item — armor, tools, weapons, ranged weapons, and utility items. Listens to PlayerItemDamageEvent to cancel all durability reduction from mining, combat, elytra flying, fishing, shearing, flint-and-steel, and every other vanilla mechanic. Fully preserves NBT data, enchantments, trims, and custom model data.

Two files needed: a single event listener that cancels PlayerItemDamageEvent (which Paper fires for every source of item durability loss), plus boilerplate.

How it works: PlayerItemDamageEvent is the single Paper/Spigot event that fires for every source of item durability damage — mining, combat, armor hits, elytra, fishing, shearing, trident throws, crossbow shots, mace swings, flint-and-steel, brush, carrot/fungus-on-a-stick boosts, shield blocking, all of it. Cancelling it at LOWEST priority (before other plugins can re-open it) with ignoreCancelled = false ensures complete coverage. No item whitelist is needed — the event only fires for items with durability, so non-durable items are never touched. NBT, enchantments, trims, and custom model data are preserved because the item is never modified.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 62
src/main/java/com/kodari/unbreakablegear/UnbreakableGear.java
package com.kodari.unbreakablegear;

import org.bukkit.plugin.java.JavaPlugin;

public class UnbreakableGear extends JavaPlugin {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new DurabilityListener(), this);
        getLogger().info("UnbreakableGear enabled — all durable items are now unbreakable.");
    }

    @Override
    public void onDisable() {
        getLogger().info("UnbreakableGear disabled.");
    }
}