use of com.denizenscript.denizencore.objects.Fetchable in project Denizen-For-Bukkit by DenizenScript.
the class EnchantmentTag method valueOf.
@Fetchable("enchantment")
public static EnchantmentTag valueOf(String string, TagContext context) {
if (string == null) {
return null;
}
string = CoreUtilities.toLowerCase(string);
if (string.startsWith("enchantment@")) {
string = string.substring("enchantment@".length());
}
Enchantment ench;
NamespacedKey key = Utilities.parseNamespacedKey(string);
ench = Enchantment.getByKey(key);
if (ench == null) {
ench = Enchantment.getByName(string.toUpperCase());
}
if (ench == null) {
ench = Enchantment.getByKey(new NamespacedKey("denizen", Utilities.cleanseNamespaceID(string)));
}
if (ench == null && ScriptRegistry.containsScript(string, EnchantmentScriptContainer.class)) {
ench = ScriptRegistry.getScriptContainerAs(string, EnchantmentScriptContainer.class).enchantment;
}
if (ench == null) {
if (context == null || context.debug) {
Debug.echoError("Unknown enchantment '" + string + "'");
}
return null;
}
return new EnchantmentTag(ench);
}
Aggregations