1.21.11
π
pasted-code-1787726482092.txt
txt
69 lines
βΆ
Create a Paper 1.21.11 plugin that adds a stack-based dash system for a spear.
### Spear Dash
* The dash ability is only available when the player is holding a spear that has the **Dash enchantment**.
* If the spear does not have the **Dash enchantment**, the dash ability must not work.
* The Dash enchantment is the requirement for activating the ability.
### Dash Stack System
* The dash uses a stack-based charge system instead of a normal cooldown.
* Maximum dash stacks: **5**.
* Each time the player uses the dash, consume **1 stack**.
* Every **15 seconds**, regenerate **1 stack**.
* Stacks must never exceed the maximum of 5.
* If the player has 0 stacks, the dash cannot be activated.
* The 15-second regeneration timer should continue independently for each player.
* When a player reaches 5 stacks, no additional stacks should be generated until they spend a stack.
* When a stack is consumed, the regeneration timer should begin counting toward the next stack.
* The system must correctly persist and handle each player's current stack count.
### Stack Indicator
* Display the current dash stacks as an on-screen indicator.
* **Only display the stack indicator when the player is currently holding a spear with the Dash enchantment.**
* If the player switches to another item, switches to a spear without the Dash enchantment, or otherwise no longer has a valid Dash spear equipped, hide the indicator immediately.
* When the player switches back to a valid Dash-enchanted spear, show the current stack count again.
* The indicator should clearly show the current number of stacks out of the maximum, for example:
**Dash: 5/5**
**Dash: 4/5**
**Dash: 3/5**
* Do not show the indicator permanently when the player is not using a valid Dash-enchanted spear.
### Complete Removal of Mending
* **Completely remove the Mending enchantment from this server.**
* Players must not be able to obtain Mending through any normal or custom method.
* Prevent Mending from appearing in:
* Enchanting Tables
* Villager trades
* Loot tables
* Fishing
* Generated chest loot
* Any other vanilla method that can provide enchanted items or enchanted books
* If an item or enchanted book containing Mending is obtained through any method, automatically remove the Mending enchantment.
* If a player attempts to add Mending to an item using an Anvil, prevent it from being applied.
* If a player somehow obtains an item or book with Mending through commands, plugins, world imports, or other external methods, the plugin should remove Mending from it.
* The plugin should continuously prevent Mending from being used or reintroduced.
* Do not remove or modify any other enchantments.
* Existing items containing Mending should also have Mending removed when detected.
### Important Requirements
* Use the actual enchantment on the spear to determine whether the ability is available. Do not rely only on the item's display name or lore.
* Store the player's stack data safely using their UUID.
* Prevent exploits such as gaining more than 5 stacks.
* The system must work correctly after death, respawn, item switching, and reconnecting to the server.
* Make all important values configurable in `config.yml`, including:
* Maximum stacks
* Stack regeneration interval
* Dash distance/strength
* Indicator format
* Mending removal settings
* The plugin must be optimized and should not create unnecessary repeating tasks for every player.
* Make the implementation compatible with **Paper 1.21.11**.
* Provide all required Java source files, `plugin.yml`, and `config.yml`.
Create the Paper 1.21.11 Gradle project and plugin metadata.
Add the UUID-backed dash stack manager, spear/enchantment checks, action-bar indicator, and global regeneration task.
Add comprehensive Mending filtering, event listeners, persistence, and configurable defaults.
Created the complete Paper 1.21.11 plugin.
Added Gradle project setup,
plugin.yml, and configurableconfig.yml.Implemented UUID-based dash stacks with:
Configurable maximum stacks
Independent per-player regeneration timers
Persistent storage in
data.ymlRight-click activation
Velocity-based dash movement
Action-bar stack indicator shown only with a valid enchanted spear
Added automatic loading, saving, reconnect, death, respawn, and item-switch handling.
Added comprehensive Mending removal for:
Enchanting tables
Villager trades
Loot generation
Fishing
Anvils
Smithing and grindstones
Inventory transfers
Drops, pickups, mob drops, and spawned items
Existing player inventories and ender chests
The configured enchantment defaults to
minecraft:dash; if unavailable on Paper 1.21.11, it falls back to the vanilla spear enchantmentminecraft:lunge.
DO NOT DO IT ON TRIDENT IT MUST BE A SPEAR
Replace the invalid single
SPEARmaterial check with the real 1.21.11 spear item IDs.Keep the requirement tied to the configured registered enchantment, while explicitly excluding tridents.
Set the default Paper 1.21.11 spear dash enchantment to
minecraft:lunge.
Updated the dash requirement to use actual spear materials only:
Supports wooden, stone, copper, iron, golden, diamond, and netherite spears.
Explicitly excludes tridents.
Requires the actual configured enchantment on the spear.
Changed the default enchantment to
minecraft:lungefor Paper/Minecraft 1.21.11.
μ§κΈ νλ¨μλ μ λ¨λλ° μΉ΄μ΄νΈκ° μμ€μ΄λ¬, μ’ν΄λ¦μΌλ‘ λμ¬ν΄λ countκ° -1 λμ§μμ.
μ’ν΄λ¦ λμ μ΄λ²€νΈμ μ€ν μ°¨κ° νλ¦μ νμΈν©λλ€.
μ€μ λμκ° μ±κ³΅ν κ²½μ°μλ§ μ€νμ μ°¨κ°νλλ‘ μμ ν©λλ€.
μ΄λ²€νΈ λ±λ‘ λ° μ€μ κ° μ¬μ©κΉμ§ ν¨κ» λ§μΆ₯λλ€.
μ’ν΄λ¦ λμλ‘ μμ νμ΅λλ€.
μ΄μ λ€μ κ²½μ°μλ§ λμκ° μ€νλκ³ μΉ΄μ΄νΈκ° 1 κ°μν©λλ€.
μ’ν΄λ¦ μ
λ©μΈ μμ μ€μ Spearκ° μμ λ
Spearμ μ€μ λ Dash enchantmentκ° μμ λ
λ¨μ μ€νμ΄ 1κ° μ΄μμΌ λ
μ°ν΄λ¦μμλ λ μ΄μ λμκ° μ€νλμ§ μμ΅λλ€.
μ§κΈ κ³μ 5/5λ§ λ¨κ³ μ’ν΄λ¦μΌλ‘ λμ¬μΈμ²ΈνΈλ₯Ό λ°λν΄λ 4/5κ° λμ§μμ,κ·Έλ¦¬κ³ 0/5κ° λλ©΄ 1κ° μ°°λκΉμ§λ λμ¬ λͺ»μ°κ² λ§μλ¨μ§? μ°½μ μ λ€κ³ μμ΄λ 15μ΄λ§λ€ μ€ν νλμ© μΆ©μ λκ² νκ³ .
μ’ν΄λ¦ λμκ° μ€μ λ‘ μ€νμ μ°¨κ°νλμ§μ νμ κ°±μ νλ¦μ μμ ν©λλ€.
μ€νμ΄
0/5μ΄λ©΄ 1κ°κ° μ¬μμ±λ λκΉμ§ λμλ₯Ό μ°¨λ¨ν©λλ€.μ ν¨ν μ°½μ λ€κ³ μμ§ μμλ νλ μ΄μ΄λ³ 15μ΄ μ¬μμ±μ κ³μλλλ‘ νμΈνκ³ λ³΄μν©λλ€.
μμ νμ΅λλ€.
ignoreCancelled = trueλ₯Ό μ κ±°ν΄ λ€λ₯Έ μ΄λ²€νΈμ μν΄ μ·¨μλ μ’ν΄λ¦ μ΄λ²€νΈλ λμ μ²λ¦¬κ° λλλ‘ λ³κ²½νμ΅λλ€.μ΄μ μ ν¨ν Spear + Dash μΈμ²ΈνΈμ΄κ³ μ€νμ΄ 1κ° μ΄μμ΄λ©΄ μ’ν΄λ¦ μ:
λμ μ€ν
μ€ν
1κ°μνλ¨ νμ μ¦μ κ°±μ
μ€νμ΄
0/5μ΄λ©΄ λμκ° μ€νλμ§ μμ΅λλ€.15μ΄ ν
1κ°κ° μΆ©μ λ λκΉμ§ κ³μ μ¬μ©ν μ μμ΅λλ€.Spearλ₯Ό λ€κ³ μμ§ μμλ μ¨λΌμΈ μνλΌλ©΄ μ€ν μ¬μμ± νμ΄λ¨Έλ κ³μ μλν©λλ€.
μ΅λ μ€ν
5/5λ₯Ό μ΄κ³Όνμ§ μμ΅λλ€.
0/5μ¬λ κ³μ μ¨μ§
μμΈμ νλ¬κ·ΈμΈ μ€ν μ°¨κ°κ³Ό λ³κ°λ‘ μ€μ μ°½μ μΈμ²ΈνΈ λμμ΄ κ³μ μ²λ¦¬λ μ μλ νλ¦μ λλ€.
Dash μΈμ²ΈνΈκ° μλ μ€μ Spearμ μ’ν΄λ¦ μ΄λ²€νΈλ₯Ό νλ¬κ·ΈμΈμ΄ μ§μ μ²λ¦¬ν©λλ€.
μ€νμ΄
0μ΄λ©΄ μ΄λ²€νΈλ₯Ό μ·¨μν΄ λ°λλΌ λμ¬λ μ€νλμ§ μκ² ν©λλ€.λμ¬ μ±κ³΅ μμλ μ΄λ²€νΈλ₯Ό μ·¨μν΄ ν λ²μ ν΄λ¦μΌλ‘ μ°ν λμ¬κ° λ°μνμ§ μκ² ν©λλ€.
μμ νμ΅λλ€.
μ’ν΄λ¦ κ°μ§λ₯Ό
PlayerAnimationEventμ μ€μ ν νλλ₯΄κΈ° μ΄λ²€νΈλ‘ λ³κ²½νμ΅λλ€.μ ν¨ν μΈμ²ΈνΈ μ°½μ λ€κ³ μμ λ:
μ€νμ΄
1 μ΄μμ΄λ©΄ λμ¬ μ€ν ν1μ°¨κ°μ€νμ΄
0μ΄λ©΄ λμ¬ μ€ν μ°¨λ¨
νλ¬κ·ΈμΈμ΄ μ²λ¦¬ν ν νλλ₯΄κΈ° μ΄λ²€νΈλ₯Ό μ·¨μν΄μ, μ€νμ΄ μμ΄λ λ°λλΌ μΈμ²ΈνΈκ° μ°ν μ€νλμ§ μλλ‘ νμ΅λλ€.
μ΄μ
0/5μνμμλ λ€μ μ€νμ΄ μΆ©μ λ λκΉμ§ λμ¬ν μ μμ΅λλ€.
If the dash stack count is 0/5, the player must not be able to use the dash.
The dash can only be used when the current stack count is at least 1. After using the dash, consume 1 stack. For example:
* 5/5 β can dash β 4/5 * 1/5 β can dash β 0/5 * 0/5 β cannot dash * 0/5 β after 15 seconds β 1/5 β can dash again
Make sure there is absolutely no way to activate the dash while the stack count is 0.
λͺ¨λ μ’ν΄λ¦ κ²½λ‘μμ μ ν¨ν μ°½μ κΈ°λ³Έ μΈμ²ΈνΈ λ°λμ μ°¨λ¨ν©λλ€.
νλ¬κ·ΈμΈ λμλ μ€νμ΄
1 μ΄μμΌ λλ§ μ€ννκ³ μ±κ³΅ μ μ νν 1κ° μ°¨κ°ν©λλ€.κ°μ ν΄λ¦μμ μνΈμμ© μ΄λ²€νΈμ ν νλλ₯΄κΈ° μ΄λ²€νΈκ° μ€λ³΅ μ²λ¦¬λμ§ μλλ‘ λ§μ΅λλ€.
μμ νμ΅λλ€.
0/5μμλ νλ¬κ·ΈμΈ λμκ° μ λ μ€νλμ§ μμ΅λλ€.μ ν¨ν μ€νΌμ΄λ₯Ό λ€κ³ μ’ν΄λ¦νλ©΄:
μ€νμ΄
1 μ΄μ: λμ μ€ν ν1μ°¨κ°μ€νμ΄
0: λμ μ€ν μ°¨λ¨
μ ν¨ν μ€νΌμ΄μ μ’ν΄λ¦ μ΄λ²€νΈ μ체λ₯Ό μ·¨μν΄ κΈ°λ³Έ μΈμ²ΈνΈ λμμΌλ‘ μ°ννλ κ²λ λ§μμ΅λλ€.
κ°μ ν΄λ¦μμ
PlayerInteractEventμPlayerAnimationEventκ° μ€λ³΅μΌλ‘ λμλ₯Ό μ€ννμ§ μλλ‘ 100ms μ€λ³΅ λ°©μ§ μ²λ¦¬λ₯Ό μΆκ°νμ΅λλ€.νΈλΌμ΄λνΈλ κ³μ λμμμ μ μΈλ©λλ€.
μ€νΌμ΄λ₯Ό λ€κ³ μμ§ μμλ κΈ°μ‘΄μ²λΌ 15μ΄λ§λ€ μ€νμ΄ μΆ©μ λ©λλ€.
μ΅λ μ€νμ μ€μ κ°μ λμ§ μμ΅λλ€.
μμ λκ±° λ§μ?μμ§ μ μ© μλ¬λλ° μμ§λ 0/5μμ μ¨μ§
λ§μ΅λλ€. μ΄μ μμ λ§μΌλ‘λ Paperμ μ€μ μ°½ Lunge λ°λ κ²½λ‘λ₯Ό μμ ν μ°¨λ¨νμ§ λͺ»νμ΅λλ€.
μ΄λ²μλ λ€μμ²λΌ μμ νμ΅λλ€.
0/5μ΄λ©΄tryDash()κ° μ¦μ μ€ν¨0/5μμ λμ λ°©ν₯ velocityκ° μ λ μ μ©λμ§ μμμ’ν΄λ¦ μ΄λ²€νΈμμ μμ΄ν μ¬μ© κ²°κ³Όλ₯Ό κ°μ λ‘
DENYμ€μ μ€νΌμ΄μ
LungeμΈμ²ΈνΈ λ°λλ μ°¨λ¨μ€νμ΄
1 μ΄μμΌ λλ§ νλ¬κ·ΈμΈ λμ μ€ν ν μ νν 1 μ°¨κ°κΈ°μ‘΄
15μ΄λ§λ€ 1μ€ν μΆ©μ λ‘μ§μ κ·Έλλ‘ μ μ§νΈλΌμ΄λνΈλ κ³μ λμ λμμμ μ μΈ
νλ¬κ·ΈμΈ jarλ₯Ό μλ‘ λΉλν΄μ μλ²μ κΈ°μ‘΄ jarλ₯Ό κ΅μ²΄νκ³ , μλ²λ₯Ό μμ ν μ¬μμν΄μΌ μ μ©λ©λλ€.
μ€νμ΄ μ€μ΄λ€μ§ μμ, λμ¬μλ¦¬κ° μλ€λ¦Ό
μμΈμ suppressVanillaDash()κ° λμ μΈμ²ΈνΈλ₯Ό λ¨Όμ μ κ±°ν λ€ tryDash()λ₯Ό νΈμΆν΄μ, tryDash() λ΄λΆμ μ ν¨ μ°½ κ²μ¬μμ μ€ν¨νλ νλ¦μ
λλ€. ν΄λΉ μ κ±° λ‘μ§μ μμ κ³ , μ±κ³΅ μ μ€ν μ°¨κ°κ³Ό λμ μ¬μ΄λλ₯Ό μ§μ μ²λ¦¬νκ² μ΅λλ€.
μμ νμ΅λλ€.
μμΈ: μΈμ²ΈνΈλ₯Ό μμλ‘ μ κ±°νλ
suppressVanillaDash()κ° λ¨Όμ μ€νλμ΄tryDash()μ μ ν¨ μ°½ κ²μ¬λ₯Ό ν΅κ³Όνμ§ λͺ»νκ³ μμμ΅λλ€.ν΄λΉ λ‘μ§μ μ κ±°νμ΅λλ€.
μ΄μ μ μ νλ¦μ λ€μκ³Ό κ°μ΅λλ€.
5/5β λμ μ€ν β4/51/5β λμ μ€ν β0/50/5β λμ λΆκ°
λμ μ±κ³΅ μ
ENTITY_PLAYER_ATTACK_SWEEPμ¬μ΄λκ° μ¬μλ©λλ€.μ¬μ΄λλ
config.ymlμdash.soundμμ λ³κ²½ν μ μμ΅λλ€.
μλ²μ μ νλ¬κ·ΈμΈ JARμ κ΅μ²΄ν λ€ μμ ν μ¬μμν΄μΌ μ μ©λ©λλ€.
μ°ν΄λ¦μ΄ μλ¨
μ°ν΄λ¦ μ΄λ²€νΈκ° μ·¨μλκΈ°λ§ νκ³ λμ νΈμΆμ μ’ν΄λ¦μλ§ μ°κ²°λμ΄ μμμ΅λλ€. μ°ν΄λ¦ 곡μ€/λΈλ‘ ν΄λ¦λ λμΌν μ€ν κ²μ¬μ λμ μ€ν κ²½λ‘λ₯Ό νλλ‘ μμ ν©λλ€.
μ°ν΄λ¦ λμκ° λ€μ μλνλλ‘ μμ νμ΅λλ€.
μ°ν΄λ¦ 곡μ€:
RIGHT_CLICK_AIRμ°ν΄λ¦ λΈλ‘:
RIGHT_CLICK_BLOCKμ’ν΄λ¦λ κΈ°μ‘΄μ²λΌ μ μ§
λͺ¨λ κ²½μ°
tryDash()λ₯Ό ν΅ν΄ μ€νμ νμΈνλ―λ‘:1/5β λμ ν0/50/5β λμ λΆκ°
λμ μ±κ³΅ μ μ€ν μ°¨κ° λ° μ€μ λ λμ μ¬μ΄λ μ¬μ
μ JARλ‘ κ΅μ²΄ν λ€ μλ²λ₯Ό μ¬μμν΄μΌ μ μ©λ©λλ€.
μ°ν΄λ¦ λμ¬λ νμ§λ§λΌ
μ°ν΄λ¦ λμλ₯Ό μ κ±°νμ΅λλ€.
RIGHT_CLICK_AIRRIGHT_CLICK_BLOCK
λ κ²½μ° λͺ¨λ λμλ₯Ό μ€ννμ§ μκ³ μμ΄ν μ¬μ©λ§ μ°¨λ¨ν©λλ€. μ’ν΄λ¦ λμλ§ μ μ§λ©λλ€.
μ JARλ‘ κ΅μ²΄ν λ€ μλ²λ₯Ό μ¬μμν΄μΌ μ μ©λ©λλ€.
μ’ν΄λ¦ νμλ κ·Έλ₯ λμ§ μΈμ²ΈνΈ λμ§νκ³ , μ°ν΄λ¦μ μλνμ§ μμ(λμ¬λ§κ³ κ·Έλ₯ μλ μ°ν΄λ¦ νμλμ κΈ°λ₯) κ·Έλ¦¬κ³ 0/5μμ μ¨μ§λ λ²κ·Έ μμ§λ μλ€ μ’ κ³ μ³λΌ
μ’ν΄λ¦κ³Ό μ°ν΄λ¦ μ΄λ²€νΈ μ²λ¦¬ νλ¦μ νμΈν©λλ€.
μ’ν΄λ¦μ λμ§ μΈμ²ΈνΈ κ²½λ‘λ§ νμ©νκ³ , μ°ν΄λ¦μ λμ λ‘μ§μμ μμ ν μ μΈν©λλ€.
0/5μμ λ°λλΌ/μΈμ²ΈνΈ μ°ν λ°λμ΄ λΆκ°λ₯νλλ‘ μ€ν κ²μ¬μ μ΄λ²€νΈ μ°¨λ¨ μμλ₯Ό λ°λ‘μ‘μ΅λλ€.
νμ¬ μ½λλ μ’ν΄λ¦ ν λ²μ PlayerInteractEventμ ν νλλ₯΄κΈ° μ΄λ²€νΈκ° ν¨κ» μ²λ¦¬λκ³ , νλ¬κ·ΈμΈμ΄ μ§μ μλλ₯Ό μ μ©νλ ꡬ쑰λΌμ λ°λλΌ λμ§κ³Ό μ€ν μ²λ¦¬κ° μΆ©λν©λλ€. μ’ν΄λ¦ μ΄λ²€νΈ νλλ§ μ€ν μ°¨κ° κΈ°μ€μΌλ‘ μ¬μ©νκ³ , μ±κ³΅ μ μ΄λ²€νΈλ₯Ό μ·¨μνμ§ μμ μΈμ²ΈνΈμ μλ λμ§μ μ€ννκ² κ³ μΉκ² μ΅λλ€. 0μ€νμΌ λλ§ μμ΄ν
μ¬μ©μ κ±°λΆν©λλ€.μμ νμ΅λλ€.
μ’ν΄λ¦: μ€νμ΄
1κ° μ΄μμΌ λλ§ νλ¬κ·ΈμΈ λμ μ€ν ν μ νν 1κ° μ°¨κ°5/5 β 4/51/5 β 0/50/5 β λμ λΆκ°
μ°ν΄λ¦: λμ λ‘μ§μ μ ν κ΄μ¬νμ§ μμΌλ©°, μλ μ°ν΄λ¦ κΈ°λ₯ κ·Έλλ‘ μλ
λμ μ±κ³΅ μ μ€μ λ λμ μ¬μ΄λλ μ¬μ
μ’ν΄λ¦ μ΄λ²€νΈμ ν νλλ₯΄κΈ° μ΄λ²€νΈμ μ€λ³΅ μ°¨κ°/μ€λ³΅ μ€νμ μ κ±°
μ€νμ΄
0/5μΌ λλ μ’ν΄λ¦ μ΄λ²€νΈλ₯Ό μ·¨μν΄ μΈμ²ΈνΈ μ°ν λ°λλ μ°¨λ¨
μ JARλ‘ κ΅μ²΄νκ³ μλ²λ₯Ό μμ ν μ¬μμν΄μΌ μ μ©λ©λλ€.
package com.kodari.speardash;
import com.kodari.speardash.dash.DashListener;
import com.kodari.speardash.dash.DashManager;
import com.kodari.speardash.mending.MendingListener;
import com.kodari.speardash.mending.MendingSanitizer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class SpearDashPlugin extends JavaPlugin {
private DashManager dashManager;
private MendingSanitizer mendingSanitizer;
@Override
public void onEnable() {
saveDefaultConfig();
this.dashManager = new DashManager(this);
this.mendingSanitizer = new MendingSanitizer(this);
Bukkit.getPluginManager().registerEvents(new DashListener(dashManager), this);
if (mendingSanitizer.isEnabled()) {
Bukkit.getPluginManager().registerEvents(new MendingListener(mendingSanitizer), this);
mendingSanitizer.start();
}
}
@Override
public void onDisable() {
if (mendingSanitizer != null) {
mendingSanitizer.stop();
}
if (dashManager != null) {
dashManager.stop();
}
}
}