From e79c3b2bb83e8d7064acae0e03828012cbb65c6e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 13 Sep 2020 15:36:42 +0100 Subject: [PATCH] Added support for registering enchantment aliases without reflection --- .../src/com/earth2me/essentials/Enchantments.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/Enchantments.java b/Essentials/src/com/earth2me/essentials/Enchantments.java index 33bb8d29d3b..d01b8d2579e 100644 --- a/Essentials/src/com/earth2me/essentials/Enchantments.java +++ b/Essentials/src/com/earth2me/essentials/Enchantments.java @@ -295,4 +295,18 @@ public static Set> entrySet() { public static Set keySet() { return ENCHANTMENTS.keySet(); } + + public static void registerEnchantment(String name, Enchantment enchantment) { + if(ENCHANTMENTS.containsKey(name) || ALIASENCHANTMENTS.containsKey(name)) + return; + + ENCHANTMENTS.put(name, enchantment); + } + + public static void registerAlias(String name, Enchantment enchantment) { + if(ENCHANTMENTS.containsKey(name) || ALIASENCHANTMENTS.containsKey(name) || !ENCHANTMENTS.containsValue(enchantment)) + return; + + ALIASENCHANTMENTS.put(name, enchantment); + } }