From 51ec413b49a22941fa3ebb2ee90e81cacdb2759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Szab=C3=B3?= Date: Fri, 15 Nov 2024 10:27:29 +0100 Subject: [PATCH] Bypass NamespacedId forced lowercasing in ItemRegistry --- .../auraskills/api/registry/NamespacedId.java | 11 +++++++++++ .../auraskills/bukkit/item/BukkitItemRegistry.java | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/dev/aurelium/auraskills/api/registry/NamespacedId.java b/api/src/main/java/dev/aurelium/auraskills/api/registry/NamespacedId.java index d48bf4625..fb2e2fcec 100644 --- a/api/src/main/java/dev/aurelium/auraskills/api/registry/NamespacedId.java +++ b/api/src/main/java/dev/aurelium/auraskills/api/registry/NamespacedId.java @@ -7,10 +7,12 @@ public class NamespacedId { public static final String AURASKILLS = "auraskills"; private final String namespace; + private final String originalKey; private final String key; private NamespacedId(String namespace, String key) { this.namespace = namespace.toLowerCase(Locale.ROOT); + this.originalKey = key; this.key = key.toLowerCase(Locale.ROOT); } @@ -33,6 +35,15 @@ public String getKey() { return key; } + /** + * Gets the original key portion of the NamespacedId, which is the key in the case it was created with. + * + * @return the original key + */ + public String getOriginalKey() { + return originalKey; + } + /** * Returns the full String representation of the NamespacedId, with a / separating the * namespace and the key. diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java index afe1ff315..e343af1fe 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/item/BukkitItemRegistry.java @@ -61,8 +61,8 @@ public ItemStack getItem(NamespacedId key) { } ExternalItemProvider provider = externalItemProviders.get(key.getNamespace()); - if(provider != null) { - return provider.getItem(key.getKey()); + if (provider != null) { + return provider.getItem(key.getOriginalKey()); } return null;