-
Notifications
You must be signed in to change notification settings - Fork 249
Description
Bug Report: Invalid NamespacedKey Causes InventoryClickEvent Failure
Title:
IllegalArgumentException when accessing attribute keys due to invalid generic.attackDamage identifier
Environment:
• Server Core: Paper 1.21.1-R0.1-SNAPSHOT
• Plugin Version: BedWars1058 v25.3 (bedwars-plugin-25.3.jar)
• Java Version: JDK 17+ (based on stack trace)
Description:
When players click on shop items involving weapon damage calculations, the plugin throws an IllegalArgumentException due to an invalid NamespacedKey format (generic.attackDamage). The error interrupts InventoryClickEvent handling.
Relevant Stack Trace:
java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: generic.attackDamage
at org.bukkit.NamespacedKey.(NamespacedKey.java:87)
at org.bukkit.NamespacedKey.minecraft(NamespacedKey.java:181)
at com.andrei1058.mc.bedwars.AbstractVerImplCmn1.getDamage(AbstractVerImplCmn1.java:212)
at com.andrei1058.bedwars.shop.main.BuyItem.give(BuyItem.java:258)
... [truncated] ...
Cause Analysis:
-
generic.attackDamage violates Minecraft's NamespacedKey rules ([a-z0-9/._-]):
• Contains uppercase D (disallowed)• Uses dots which require lowercase neighbors (attack.damage valid, but attackDamage invalid)
-
Affected code location:
• Method: AbstractVerImplCmn1.getDamage() (Line 212)• Code snippet:
// Current problematic call:
NamespacedKey.minecraft("generic.attackDamage");
Reproduction Steps:
- Install BedWars1058 v25.3 on Paper 1.21.1+ server
- Add any shop item using ATTACK_DAMAGE attribute to shops.yml
- Have player purchase the item
- Observe error in console
Proposed Fix:
// Replace in AbstractVerImplCmn1.getDamage():
// OLD: NamespacedKey.minecraft("generic.attackDamage");
// NEW (1.13+ compatible):
NamespacedKey.minecraft("generic.attack_damage");
Version-Specific Notes:
• Correct attribute keys for modern Minecraft versions:
// 1.13+: "generic.attack_damage"
// 1.8-1.12: "generic.attackDamage" // Note: Only usable on legacy versions
• Recommended implementation:
String key = (serverVersion >= 1.13) ?
"generic.attack_damage" : "generic.attackDamage";
Impact:
Blocks all shop transactions involving weapon damage attributes on servers running Minecraft 1.13 or newer.
References:
• https://minecraft.wiki/w/Attribute
• https://jd.papermc.io/paper/1.21/org/bukkit/NamespacedKey.html