Skip to content

Bug Report: Invalid NamespacedKey Causes InventoryClickEvent Failure #1101

@Blacklaegend

Description

@Blacklaegend

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:

  1. 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)

  2. Affected code location:
    • Method: AbstractVerImplCmn1.getDamage() (Line 212)

    • Code snippet:
    // Current problematic call:
    NamespacedKey.minecraft("generic.attackDamage");

Reproduction Steps:

  1. Install BedWars1058 v25.3 on Paper 1.21.1+ server
  2. Add any shop item using ATTACK_DAMAGE attribute to shops.yml
  3. Have player purchase the item
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions