diff --git a/src/main/java/com/denizenscript/denizencore/flags/AbstractFlagTracker.java b/src/main/java/com/denizenscript/denizencore/flags/AbstractFlagTracker.java index 209b9478..4e692157 100644 --- a/src/main/java/com/denizenscript/denizencore/flags/AbstractFlagTracker.java +++ b/src/main/java/com/denizenscript/denizencore/flags/AbstractFlagTracker.java @@ -112,42 +112,42 @@ public static void registerFlagHandlers(ObjectTagPro } public ElementTag doHasFlagTag(Attribute attribute) { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The has_flag[...] tag must have an input!"); return null; } - return new ElementTag(hasFlag(attribute.getContext(1))); + return new ElementTag(hasFlag(attribute.getParam())); } public ObjectTag doFlagTag(Attribute attribute) { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The flag[...] tag must have an input!"); return null; } - if (attribute.getAttributeWithoutContext(2).equals("is_expired")) { + if (attribute.getAttributeWithoutParam(2).equals("is_expired")) { Deprecations.flagIsExpiredTag.warn(attribute.context); - boolean result = !hasFlag(attribute.getContext(1)); + boolean result = !hasFlag(attribute.getParam()); attribute.fulfill(1); return new ElementTag(result); } - else if (attribute.getAttributeWithoutContext(2).equals("expiration")) { + else if (attribute.getAttributeWithoutParam(2).equals("expiration")) { Deprecations.flagExpirationTag.warn(attribute.context); - TimeTag time = getFlagExpirationTime(attribute.getContext(1)); + TimeTag time = getFlagExpirationTime(attribute.getParam()); if (time == null) { return null; } attribute.fulfill(1); return new DurationTag((time.millis() - TimeTag.now().millis()) / 1000.0); } - return getFlagValue(attribute.getContext(1)); + return getFlagValue(attribute.getParam()); } public TimeTag doFlagExpirationTag(Attribute attribute) { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The flag_expiration[...] tag must have an input!"); return null; } - return getFlagExpirationTime(attribute.getContext(1)); + return getFlagExpirationTime(attribute.getParam()); } public static Warning listFlagsTagWarning = new SlowWarning("The list_flags and flag_map tags are meant for testing/debugging only. Do not use it in scripts (ignore this warning if using for testing reasons)."); diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/CustomObjectTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/CustomObjectTag.java index aad579b7..7a520dba 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/CustomObjectTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/CustomObjectTag.java @@ -137,9 +137,9 @@ public ObjectTag specialTagProcessing(Attribute attribute) { if (res != null) { return CoreUtilities.autoAttribTyped(res, attribute.fulfill(1)); } - String taggo = attribute.getAttributeWithoutContext(1); + String taggo = attribute.getAttributeWithoutParam(1); if (container.hasPath("tags." + taggo)) { - ListTag outcomes = container.runTagScript(taggo, attribute.getContextObject(1), this, + ListTag outcomes = container.runTagScript(taggo, attribute.getParamObject(), this, attribute.getScriptEntry() != null ? attribute.getScriptEntry().entryData : DenizenCore.getImplementation().getEmptyScriptEntryData()); if (outcomes == null) { diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/DurationTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/DurationTag.java index 7871e244..b05b9a82 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/DurationTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/DurationTag.java @@ -402,11 +402,11 @@ public static void registerTags() { // returns this duration minus another. // --> tagProcessor.registerStaticTag(DurationTag.class, "sub", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag DurationTag.sub[...] must have a value."); return null; } - return new DurationTag(object.getTicks() - attribute.contextAsType(1, DurationTag.class).getTicks()); + return new DurationTag(object.getTicks() - attribute.paramAsType(DurationTag.class).getTicks()); }); // <--[tag] @@ -416,11 +416,11 @@ public static void registerTags() { // returns this duration plus another. // --> tagProcessor.registerStaticTag(DurationTag.class, "add", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag DurationTag.add[...] must have a value."); return null; } - return new DurationTag(object.getTicks() + attribute.contextAsType(1, DurationTag.class).getTicks()); + return new DurationTag(object.getTicks() + attribute.paramAsType(DurationTag.class).getTicks()); }); // <--[tag] @@ -432,10 +432,10 @@ public static void registerTags() { // Equivalent to if comparison: > // --> tagProcessor.registerStaticTag(ElementTag.class, "is_more_than", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.seconds > attribute.contextAsType(1, DurationTag.class).seconds); + return new ElementTag(object.seconds > attribute.paramAsType(DurationTag.class).seconds); }); // <--[tag] @@ -447,10 +447,10 @@ public static void registerTags() { // Equivalent to if comparison: < // --> tagProcessor.registerStaticTag(ElementTag.class, "is_less_than", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.seconds < attribute.contextAsType(1, DurationTag.class).seconds); + return new ElementTag(object.seconds < attribute.paramAsType(DurationTag.class).seconds); }); // <--[tag] @@ -462,10 +462,10 @@ public static void registerTags() { // Equivalent to if comparison: >= // --> tagProcessor.registerStaticTag(ElementTag.class, "is_more_than_or_equal_to", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.seconds >= attribute.contextAsType(1, DurationTag.class).seconds); + return new ElementTag(object.seconds >= attribute.paramAsType(DurationTag.class).seconds); }); // <--[tag] @@ -477,10 +477,10 @@ public static void registerTags() { // Equivalent to if comparison: <= // --> tagProcessor.registerStaticTag(ElementTag.class, "is_less_than_or_equal_to", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.seconds <= attribute.contextAsType(1, DurationTag.class).seconds); + return new ElementTag(object.seconds <= attribute.paramAsType(DurationTag.class).seconds); }); tagProcessor.registerTag(TimeTag.class, "time", (attribute, object) -> { diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/ElementTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/ElementTag.java index a9826289..066f260e 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/ElementTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/ElementTag.java @@ -410,10 +410,10 @@ public static void registerTags() { // Equivalent to if comparison: == // --> tagProcessor.registerStaticTag(ElementTag.class, "equals", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(CoreUtilities.equalsIgnoreCase(object.asString(), attribute.getContext(1))); + return new ElementTag(CoreUtilities.equalsIgnoreCase(object.asString(), attribute.getParam())); }); // <--[tag] @@ -425,10 +425,10 @@ public static void registerTags() { // Equivalent to if comparison: > // --> tagProcessor.registerStaticTag(ElementTag.class, "is_more_than", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getContext(1)).asBigDecimal()) > 0); + return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getParam()).asBigDecimal()) > 0); }); // <--[tag] @@ -440,10 +440,10 @@ public static void registerTags() { // Equivalent to if comparison: < // --> tagProcessor.registerStaticTag(ElementTag.class, "is_less_than", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getContext(1)).asBigDecimal()) < 0); + return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getParam()).asBigDecimal()) < 0); }); // <--[tag] @@ -455,10 +455,10 @@ public static void registerTags() { // Equivalent to if comparison: >= // --> tagProcessor.registerStaticTag(ElementTag.class, "is_more_than_or_equal_to", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getContext(1)).asBigDecimal()) >= 0); + return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getParam()).asBigDecimal()) >= 0); }); // <--[tag] @@ -470,10 +470,10 @@ public static void registerTags() { // Equivalent to if comparison: <= // --> tagProcessor.registerTag(ElementTag.class, "is_less_than_or_equal_to", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getContext(1)).asBigDecimal()) <= 0); + return new ElementTag(object.asBigDecimal().compareTo(new ElementTag(attribute.getParam()).asBigDecimal()) <= 0); }); // <--[tag] @@ -794,7 +794,7 @@ public static void registerTags() { // --> tagProcessor.registerStaticTag(ElementTag.class, "difference", (attribute, object) -> { String element = object.element; - String two = attribute.getContext(1); + String two = attribute.getParam(); return new ElementTag(CoreUtilities.getLevenshteinDistance(element, two)); }); @@ -807,7 +807,7 @@ public static void registerTags() { // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_any_case_sensitive_text", (attribute, object) -> { String element = object.element; - ListTag list = attribute.contextAsType(1, ListTag.class); + ListTag list = attribute.paramAsType(ListTag.class); for (String list_element : list) { if (element.contains(list_element)) { return new ElementTag(true); @@ -826,7 +826,7 @@ public static void registerTags() { // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_any_text", (attribute, object) -> { String element = object.element; - ListTag list = ListTag.valueOf(CoreUtilities.toLowerCase(attribute.getContext(1)), attribute.context); + ListTag list = ListTag.valueOf(CoreUtilities.toLowerCase(attribute.getParam()), attribute.context); String ellow = CoreUtilities.toLowerCase(element); for (String list_element : list) { if (ellow.contains(list_element)) { @@ -846,7 +846,7 @@ public static void registerTags() { // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_case_sensitive_text", (attribute, object) -> { String element = object.element; - String contains = attribute.getContext(1); + String contains = attribute.getParam(); if (element.contains(contains)) { return new ElementTag("true"); } @@ -866,7 +866,7 @@ public static void registerTags() { // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_text", (attribute, object) -> { String element = object.element; - String contains = attribute.getContext(1); + String contains = attribute.getParam(); if (CoreUtilities.toLowerCase(contains).startsWith("regex:")) { if (Pattern.compile(contains.substring(("regex:").length()), Pattern.CASE_INSENSITIVE).matcher(element).find()) { return new ElementTag("true"); @@ -893,7 +893,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_all_text", (attribute, object) -> { String element = object.element; - ListTag list = ListTag.valueOf(CoreUtilities.toLowerCase(attribute.getContext(1)), attribute.context); + ListTag list = ListTag.valueOf(CoreUtilities.toLowerCase(attribute.getParam()), attribute.context); String ellow = CoreUtilities.toLowerCase(element); for (String list_element : list) { if (!ellow.contains(list_element)) { @@ -913,7 +913,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_all_case_sensitive_text", (attribute, object) -> { String element = object.element; - ListTag list = attribute.contextAsType(1, ListTag.class); + ListTag list = attribute.paramAsType(ListTag.class); for (String list_element : list) { if (!element.contains(list_element)) { return new ElementTag("false"); @@ -932,7 +932,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // --> tagProcessor.registerStaticTag(ElementTag.class, "ends_with", (attribute, object) -> { return new ElementTag(CoreUtilities.toLowerCase(object.element). - endsWith(CoreUtilities.toLowerCase(attribute.getContext(1)))); + endsWith(CoreUtilities.toLowerCase(attribute.getParam()))); }, "endswith"); // <--[tag] @@ -943,10 +943,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether the element matches another element, case-sensitive. // --> tagProcessor.registerStaticTag(ElementTag.class, "equals_case_sensitive", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.element.equals(attribute.getContext(1))); + return new ElementTag(object.element.equals(attribute.getParam())); }, "equals_with_case"); // <--[tag] @@ -957,10 +957,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether the element matches some matcher text, using the system behind <@link language Advanced Script Event Matching>. // --> tagProcessor.registerStaticTag(ElementTag.class, "advanced_matches_text", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(ScriptEvent.createMatcher(attribute.getContext(1)).doesMatch(object.element)); + return new ElementTag(ScriptEvent.createMatcher(attribute.getParam()).doesMatch(object.element)); }, "advanced_matches"); // <--[tag] @@ -971,10 +971,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether the element matches a regex input. // --> tagProcessor.registerStaticTag(ElementTag.class, "regex_matches", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return new ElementTag(object.element.matches(attribute.getContext(1))); + return new ElementTag(object.element.matches(attribute.getParam())); }, "matches"); // <--[tag] @@ -987,10 +987,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example, returns '5'. // --> tagProcessor.registerTag(ElementTag.class, "regex", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1) || !attribute.hasContext(2)) { + if (!attribute.hasParam() || !attribute.hasContext(2)) { return null; } - String regex = attribute.getContext(1); + String regex = attribute.getParam(); Matcher m = Pattern.compile(regex).matcher(object.element); if (!m.matches()) { return null; @@ -1015,10 +1015,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Essentially equivalent to <@link tag ListTag.contains>, but with input order reversed. // --> tagProcessor.registerStaticTag(ElementTag.class, "is_in", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - ListTag list = attribute.contextAsType(1, ListTag.class); + ListTag list = attribute.paramAsType(ListTag.class); for (String element : list) { if (CoreUtilities.equalsIgnoreCase(element, object.asString())) { return new ElementTag(true); @@ -1058,7 +1058,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether both the element and the second element are true. // --> tagProcessor.registerStaticTag(ElementTag.class, "and", (attribute, object) -> { - return new ElementTag(object.element.equalsIgnoreCase("true") && attribute.getContext(1).equalsIgnoreCase("true")); + return new ElementTag(object.element.equalsIgnoreCase("true") && attribute.getParam().equalsIgnoreCase("true")); }); // <--[tag] @@ -1069,7 +1069,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether either the element or the second element are true. // --> tagProcessor.registerStaticTag(ElementTag.class, "or", (attribute, object) -> { - return new ElementTag(object.element.equalsIgnoreCase("true") || attribute.getContext(1).equalsIgnoreCase("true")); + return new ElementTag(object.element.equalsIgnoreCase("true") || attribute.getParam().equalsIgnoreCase("true")); }); // <--[tag] @@ -1080,7 +1080,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether the element and the second element are true and false (exclusive or). // --> tagProcessor.registerStaticTag(ElementTag.class, "xor", (attribute, object) -> { - return new ElementTag(object.element.equalsIgnoreCase("true") != attribute.getContext(1).equalsIgnoreCase("true")); + return new ElementTag(object.element.equalsIgnoreCase("true") != attribute.getParam().equalsIgnoreCase("true")); }); // <--[tag] @@ -1091,7 +1091,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns whether the element starts with a specified element. // --> tagProcessor.registerStaticTag(ElementTag.class, "starts_with", (attribute, object) -> { - return new ElementTag(CoreUtilities.toLowerCase(object.element).startsWith(CoreUtilities.toLowerCase(attribute.getContext(1)))); + return new ElementTag(CoreUtilities.toLowerCase(object.element).startsWith(CoreUtilities.toLowerCase(attribute.getParam()))); }, "startswith"); // <--[tag] @@ -1103,12 +1103,12 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns 0 if the element never occurs within the element. // --> tagProcessor.registerStaticTag(ElementTag.class, "index_of", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.index_of[...] must have a value."); return null; } return new ElementTag(CoreUtilities.toLowerCase(object.element) - .indexOf(CoreUtilities.toLowerCase(attribute.getContext(1))) + 1); + .indexOf(CoreUtilities.toLowerCase(attribute.getParam())) + 1); }); // <--[tag] @@ -1120,12 +1120,12 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns 0 if the element never occurs within the element. // --> tagProcessor.registerStaticTag(ElementTag.class, "last_index_of", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.last_index_of[...] must have a value."); return null; } return new ElementTag(CoreUtilities.toLowerCase(object.element) - .lastIndexOf(CoreUtilities.toLowerCase(attribute.getContext(1))) + 1); + .lastIndexOf(CoreUtilities.toLowerCase(attribute.getParam())) + 1); }); // <--[tag] @@ -1137,11 +1137,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns null if the index is outside the range of the element. // --> tagProcessor.registerStaticTag(ElementTag.class, "char_at", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.char_at[...] must have a value."); return null; } - int index = attribute.getIntContext(1) - 1; + int index = attribute.getIntParam() - 1; if (index < 0 || index >= object.element.length()) { return null; } @@ -1164,11 +1164,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // An input value or zero or a negative number will result in an empty element. // --> tagProcessor.registerStaticTag(ElementTag.class, "repeat", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.repeat[...] must have a value."); return null; } - int repeatTimes = attribute.getIntContext(1); + int repeatTimes = attribute.getIntParam(); StringBuilder result = new StringBuilder(object.element.length() * repeatTimes); for (int i = 0; i < repeatTimes; i++) { result.append(object.element); @@ -1186,11 +1186,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // An input value or zero or a negative number will result in an empty list. // --> tagProcessor.registerStaticTag(ListTag.class, "repeat_as_list", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.repeat_as_list[...] must have a value."); return null; } - int repeatTimes = attribute.getIntContext(1); + int repeatTimes = attribute.getIntParam(); ListTag result = new ListTag(); for (int i = 0; i < repeatTimes; i++) { result.addObject(object); @@ -1207,11 +1207,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example: abcabc .after_last[b] returns c. // --> tagProcessor.registerStaticTag(ElementTag.class, "after_last", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.after_last[...] must have a value."); return null; } - String delimiter = attribute.getContext(1); + String delimiter = attribute.getParam(); if (CoreUtilities.toLowerCase(object.element).contains(CoreUtilities.toLowerCase(delimiter))) { return new ElementTag(object.element.substring (CoreUtilities.toLowerCase(object.element).lastIndexOf(CoreUtilities.toLowerCase(delimiter)) + delimiter.length())); @@ -1230,11 +1230,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example: HelloWorld .after[Hello] returns World. // --> tagProcessor.registerStaticTag(ElementTag.class, "after", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.after[...] must have a value."); return null; } - String delimiter = attribute.getContext(1); + String delimiter = attribute.getParam(); if (CoreUtilities.toLowerCase(object.element).contains(CoreUtilities.toLowerCase(delimiter))) { return new ElementTag(object.element.substring (CoreUtilities.toLowerCase(object.element).indexOf(CoreUtilities.toLowerCase(delimiter)) + delimiter.length())); @@ -1253,11 +1253,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example: abcabc .before_last[b] returns abca. // --> tagProcessor.registerStaticTag(ElementTag.class, "before_last", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.before_last[...] must have a value."); return null; } - String delimiter = attribute.getContext(1); + String delimiter = attribute.getParam(); if (CoreUtilities.toLowerCase(object.element).contains(CoreUtilities.toLowerCase(delimiter))) { return new ElementTag(object.element.substring (0, CoreUtilities.toLowerCase(object.element).lastIndexOf(CoreUtilities.toLowerCase(delimiter)))); @@ -1276,11 +1276,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example: abcd .before[c] returns ab. // --> tagProcessor.registerStaticTag(ElementTag.class, "before", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.before[...] must have a value."); return null; } - String delimiter = attribute.getContext(1); + String delimiter = attribute.getParam(); if (CoreUtilities.toLowerCase(object.element).contains(CoreUtilities.toLowerCase(delimiter))) { return new ElementTag(object.element.substring (0, CoreUtilities.toLowerCase(object.element).indexOf(CoreUtilities.toLowerCase(delimiter)))); @@ -1308,11 +1308,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Specify firstregex: at the start of the replace element to Regex 'replaceFirst' // --> tagProcessor.registerTag(ElementTag.class, "replace_text", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.replace[...] must have a value."); return null; } - String replace = attribute.getContext(1); + String replace = attribute.getParam(); String replacement = ""; if (attribute.startsWith("with", 2)) { if (attribute.hasContext(2)) { @@ -1350,8 +1350,8 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // --> tagProcessor.registerStaticTag(ElementTag.class, "format_number", (attribute, object) -> { try { - if (attribute.hasContext(1)) { - DecimalFormat format = new DecimalFormat(attribute.getContext(1), CoreUtilities.decimalFormatSymbols); + if (attribute.hasParam()) { + DecimalFormat format = new DecimalFormat(attribute.getParam(), CoreUtilities.decimalFormatSymbols); return new ElementTag(format.format(object.asBigDecimal())); } int decimal = object.element.indexOf('.'); @@ -1418,7 +1418,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Spaces will be preferred to become newlines, unless a line does not contain any spaces. // --> tagProcessor.registerStaticTag(ElementTag.class, "split_lines", (attribute, object) -> { - int characterCount = attribute.getIntContext(1); + int characterCount = attribute.getIntParam(); return new ElementTag(CoreUtilities.splitLinesByCharacterCount(object.element, characterCount)); }); @@ -1530,14 +1530,14 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // element after the specified index. // --> tagProcessor.registerStaticTag(ElementTag.class, "substring", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.substring[...] must have a value."); return null; } - int beginning_index = new ElementTag(attribute.getContext(1).split(",")[0]).asInt() - 1; + int beginning_index = new ElementTag(attribute.getParam().split(",")[0]).asInt() - 1; int ending_index; - if (attribute.getContext(1).split(",").length > 1) { - ending_index = new ElementTag(attribute.getContext(1).split(",")[1]).asInt(); + if (attribute.getParam().split(",").length > 1) { + ending_index = new ElementTag(attribute.getParam().split(",")[1]).asInt(); } else { ending_index = object.element.length(); @@ -1578,7 +1578,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // If a split string is unspecified, splits by space. // --> tagProcessor.registerTag(ListTag.class, "split", (attribute, object) -> { // non-static due to hacked sub-tag - String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : " "); + String split_string = (attribute.hasParam() ? attribute.getParam() : " "); if (CoreUtilities.toLowerCase(split_string).startsWith("regex:")) { split_string = split_string.split(":", 2)[1]; } @@ -1619,12 +1619,12 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // by adding spaces to the left side. // --> tagProcessor.registerTag(ElementTag.class, "pad_left", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.pad_left[...] must have a value."); return null; } String with = CoreUtilities.NBSP; - int length = attribute.getIntContext(1); + int length = attribute.getIntParam(); // <--[tag] // @attribute ].with[]> @@ -1656,12 +1656,12 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // by adding spaces to the right side. // --> tagProcessor.registerTag(ElementTag.class, "pad_right", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.pad_right[...] must have a value."); return null; } String with = CoreUtilities.NBSP; - int length = attribute.getIntContext(1); + int length = attribute.getIntParam(); // <--[tag] // @attribute ].with[]> @@ -1715,7 +1715,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(Math.max(ele.asDouble(), new ElementTag(attribute.getContext(1)).asDouble())); + return new ElementTag(Math.max(ele.asDouble(), new ElementTag(attribute.getParam()).asDouble())); }); // <--[tag] @@ -1731,7 +1731,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(Math.min(ele.asDouble(), new ElementTag(attribute.getContext(1)).asDouble())); + return new ElementTag(Math.min(ele.asDouble(), new ElementTag(attribute.getParam()).asDouble())); }); // <--[tag] @@ -1747,7 +1747,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(ele.asLong() + attribute.getLongContext(1)); + return new ElementTag(ele.asLong() + attribute.getLongParam()); }); // <--[tag] @@ -1763,7 +1763,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(ele.asLong() / attribute.getLongContext(1)); + return new ElementTag(ele.asLong() / attribute.getLongParam()); }); // <--[tag] @@ -1779,7 +1779,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(ele.asLong() * attribute.getLongContext(1)); + return new ElementTag(ele.asLong() * attribute.getLongParam()); }); // <--[tag] @@ -1795,7 +1795,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + ele + "' is not a valid decimal number!"); return null; } - return new ElementTag(ele.asLong() - attribute.getLongContext(1)); + return new ElementTag(ele.asLong() - attribute.getLongParam()); }); // <--[tag] @@ -1807,7 +1807,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the element plus a number. // --> TagRunnable.ObjectInterface addRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.add[...] must have a value."); return null; } @@ -1816,10 +1816,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c return null; } try { - return new ElementTag(object.asBigDecimal().add(object.getBD(attribute.getContext(1)))); + return new ElementTag(object.asBigDecimal().add(object.getBD(attribute.getParam()))); } catch (Throwable e) { - return new ElementTag(object.asDouble() + attribute.getDoubleContext(1)); + return new ElementTag(object.asDouble() + attribute.getDoubleParam()); } }; tagProcessor.registerStaticTag(ElementTag.class, "add", addRunnable); @@ -1834,7 +1834,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the element divided by a number. // --> TagRunnable.ObjectInterface divRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.div[...] must have a value."); return null; } @@ -1843,10 +1843,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c return null; } try { - return new ElementTag(object.asBigDecimal().divide(object.getBD(attribute.getContext(1)), 64, RoundingMode.HALF_UP)); + return new ElementTag(object.asBigDecimal().divide(object.getBD(attribute.getParam()), 64, RoundingMode.HALF_UP)); } catch (Throwable e) { - return new ElementTag(object.asDouble() / attribute.getDoubleContext(1)); + return new ElementTag(object.asDouble() / attribute.getDoubleParam()); } }; tagProcessor.registerStaticTag(ElementTag.class, "div", divRunnable); @@ -1861,7 +1861,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the remainder of the element divided by a number. // --> TagRunnable.ObjectInterface modRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.mod[...] must have a value."); return null; } @@ -1872,10 +1872,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c try { // Note: "remainder" method has doc "Note that this is not the modulo operation (the result can be negative)." // however this doc is misleading - standard modulo with "%" allows negatives in the exact same situation (first parameter is negative). - return new ElementTag(object.asBigDecimal().remainder(object.getBD(attribute.getContext(1)))); + return new ElementTag(object.asBigDecimal().remainder(object.getBD(attribute.getParam()))); } catch (Throwable e) { - return new ElementTag(object.asDouble() % attribute.getDoubleContext(1)); + return new ElementTag(object.asDouble() % attribute.getDoubleParam()); } }; tagProcessor.registerStaticTag(ElementTag.class, "mod", modRunnable); @@ -1890,7 +1890,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the element multiplied by a number. // --> TagRunnable.ObjectInterface mulRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.mul[...] must have a value."); return null; } @@ -1899,10 +1899,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c return null; } try { - return new ElementTag(object.asBigDecimal().multiply(object.getBD(attribute.getContext(1)))); + return new ElementTag(object.asBigDecimal().multiply(object.getBD(attribute.getParam()))); } catch (Throwable e) { - return new ElementTag(object.asDouble() * attribute.getDoubleContext(1)); + return new ElementTag(object.asDouble() * attribute.getDoubleParam()); } }; tagProcessor.registerStaticTag(ElementTag.class, "mul", mulRunnable); @@ -1917,7 +1917,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the element minus a number. // --> TagRunnable.ObjectInterface subRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.sub[...] must have a value."); return null; } @@ -1926,10 +1926,10 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c return null; } try { - return new ElementTag(object.asBigDecimal().subtract(object.getBD(attribute.getContext(1)))); + return new ElementTag(object.asBigDecimal().subtract(object.getBD(attribute.getParam()))); } catch (Throwable e) { - return new ElementTag(object.asDouble() - attribute.getDoubleContext(1)); + return new ElementTag(object.asDouble() - attribute.getDoubleParam()); } }; tagProcessor.registerStaticTag(ElementTag.class, "sub", subRunnable); @@ -1964,7 +1964,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the logarithm of the element, with the base of the specified number. // --> tagProcessor.registerStaticTag(ElementTag.class, "log", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.log[...] must have a value."); return null; } @@ -1972,7 +1972,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - return new ElementTag(Math.log(object.asDouble()) / Math.log(attribute.getDoubleContext(1))); + return new ElementTag(Math.log(object.asDouble()) / Math.log(attribute.getDoubleParam())); }); // <--[tag] @@ -1999,7 +1999,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Returns the element to the power of a number. // --> TagRunnable.ObjectInterface powerRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.power[...] must have a value."); return null; } @@ -2007,7 +2007,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - return new ElementTag(Math.pow(object.asDouble(), attribute.getDoubleContext(1))); + return new ElementTag(Math.pow(object.asDouble(), attribute.getDoubleParam())); }; tagProcessor.registerStaticTag(ElementTag.class, "power", powerRunnable); tagProcessor.registerStaticTag(ElementTag.class, "^", powerRunnable); @@ -2066,7 +2066,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // and returns an angle in radians representing the vector of (X,Y). // --> tagProcessor.registerStaticTag(ElementTag.class, "atan2", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.atan2[...] must have a value."); return null; } @@ -2074,7 +2074,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - return new ElementTag(Math.atan2(object.asDouble(), attribute.getDoubleContext(1))); + return new ElementTag(Math.atan2(object.asDouble(), attribute.getDoubleParam())); }); // <--[tag] @@ -2211,7 +2211,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example, 0.12345 .round_to[3] returns "0.123". // --> tagProcessor.registerStaticTag(ElementTag.class, "round_to", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.round_to[...] must have a value."); return null; } @@ -2219,7 +2219,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - int ten = (int) Math.pow(10, attribute.getIntContext(1)); + int ten = (int) Math.pow(10, attribute.getIntParam()); return new ElementTag(((double) Math.round(object.asDouble() * ten)) / ten); }); @@ -2232,7 +2232,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // For example, 0.12345 .round_to_precision[0.005] returns "0.125". // --> tagProcessor.registerStaticTag(ElementTag.class, "round_to_precision", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.round_to_precision[...] must have a value."); return null; } @@ -2240,7 +2240,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - double precision = attribute.getDoubleContext(1); + double precision = attribute.getDoubleParam(); return new ElementTag(((double) Math.round(object.asDouble() / precision)) * precision); }); @@ -2252,7 +2252,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Rounds a decimal downward to the specified precision. // --> tagProcessor.registerStaticTag(ElementTag.class, "round_down_to_precision", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.round_down_to_precision[...] must have a value."); return null; } @@ -2260,7 +2260,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - double precision = attribute.getDoubleContext(1); + double precision = attribute.getDoubleParam(); return new ElementTag(Math.floor(object.asDouble() / precision) * precision); }); @@ -2272,7 +2272,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // Rounds a decimal upward to the specified precision. // --> tagProcessor.registerStaticTag(ElementTag.class, "round_up_to_precision", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.round_up_to_precision[...] must have a value."); return null; } @@ -2280,7 +2280,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c attribute.echoError("Element '" + object + "' is not a valid decimal number!"); return null; } - double precision = attribute.getDoubleContext(1); + double precision = attribute.getDoubleParam(); return new ElementTag(Math.ceil(object.asDouble() / precision) * precision); }); @@ -2431,11 +2431,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // and "alphabet1" .matches_character_set[abcdefghijklmnopqrstuvwxyz]> returns "false" because it has a "1". // --> tagProcessor.registerStaticTag(ElementTag.class, "matches_character_set", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.matches_character_set[...] must have a value."); return null; } - return new ElementTag(new AsciiMatcher(attribute.getContext(1)).isOnlyMatches(object.element)); + return new ElementTag(new AsciiMatcher(attribute.getParam()).isOnlyMatches(object.element)); }); // <--[tag] @@ -2452,11 +2452,11 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // and "alphabet1" .trim_to_character_set[abcdefghijklmnopqrstuvwxyz]> returns "alphabet" without the "1". // --> tagProcessor.registerStaticTag(ElementTag.class, "trim_to_character_set", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ElementTag.trim_to_character_set[...] must have a value."); return null; } - return new ElementTag(new AsciiMatcher(attribute.getContext(1)).trimToMatches(object.element)); + return new ElementTag(new AsciiMatcher(attribute.getParam()).trimToMatches(object.element)); }); // <--[tag] @@ -2470,7 +2470,7 @@ else if (CoreUtilities.toLowerCase(element).contains(CoreUtilities.toLowerCase(c // will return the player's name if there's a player present, or if not will return 'server', and won't show any errors from the '' tag even without a player linked. // --> tagProcessor.registerTag(ObjectTag.class, "if_true", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1) || !attribute.startsWith("if_false", 2) || !attribute.hasContext(2)) { + if (!attribute.hasParam() || !attribute.startsWith("if_false", 2) || !attribute.hasContext(2)) { attribute.echoError("ElementTag.if_true[...].if_false[...] malformed and missing at least one required part."); return null; } diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/ListTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/ListTag.java index 6c912e86..0fb5f9d8 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/ListTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/ListTag.java @@ -712,11 +712,11 @@ public static void registerTags() { // For example, a list of a|b|c|d|e|f .sub_lists[2] will return a list containing lists "a|b", "c|d", and "e|f". // --> tagProcessor.registerStaticTag(ListTag.class, "sub_lists", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("list.sub_lists[...] tag must have an input."); return null; } - int subListLength = Math.max(1, attribute.getIntContext(1)); + int subListLength = Math.max(1, attribute.getIntParam()); ListTag output = new ListTag(); ListTag building = new ListTag(); for (int i = 0; i < object.size(); i++) { @@ -757,7 +757,7 @@ public static void registerTags() { if (object.isEmpty()) { return new ElementTag(""); } - String input = attribute.getContext(1); + String input = attribute.getParam(); return new ElementTag(parseString(object, input)); }); @@ -799,8 +799,8 @@ public static void registerTags() { // --> tagProcessor.registerTag(ListTag.class, "get_sub_items", (attribute, object) -> { // non-static due to hacked sub-tag int index = -1; - if (ArgumentHelper.matchesInteger(attribute.getContext(1))) { - index = attribute.getIntContext(1) - 1; + if (ArgumentHelper.matchesInteger(attribute.getParam())) { + index = attribute.getIntParam() - 1; } // <--[tag] @@ -844,7 +844,7 @@ public static void registerTags() { if (object.isEmpty()) { return new ElementTag(""); } - ListTag input = getListFor(attribute.getContextObject(1), attribute.context); + ListTag input = getListFor(attribute.getParamObject(), attribute.context); String split = "/"; if (attribute.startsWith("split_by", 2)) { @@ -878,7 +878,7 @@ else if (input.size() > 1) { tagProcessor.registerTag(ElementTag.class, "map_find_key", (attribute, object) -> { Deprecations.listOldMapTags.warn(attribute.context); - String input = attribute.getContext(1); + String input = attribute.getParam(); String split = "/"; if (attribute.startsWith("split_by", 2)) { @@ -926,8 +926,8 @@ else if (input.size() > 1) { // --> tagProcessor.registerStaticTag(MapTag.class, "to_map", (attribute, object) -> { String symbol = "/"; - if (attribute.hasContext(1)) { - symbol = attribute.getContext(1); + if (attribute.hasParam()) { + symbol = attribute.getParam(); } MapTag map = new MapTag(); for (String entry : object) { @@ -952,7 +952,7 @@ else if (input.size() > 1) { // For example, on a list of "a|b|c|", using ".map_with[1|2|3|]" will return a MapTag of [a=1;b=2;c=3] // --> tagProcessor.registerStaticTag(MapTag.class, "map_with", (attribute, object) -> { - ListTag inputList = getListFor(attribute.getContextObject(1), attribute.context); + ListTag inputList = getListFor(attribute.getParamObject(), attribute.context); if (object.size() != inputList.size()) { attribute.echoError("List.map_with tag failed: lists must be the same size!"); return null; @@ -1005,11 +1005,11 @@ else if (input.size() > 1) { // For example: .insert[two|three].at[2] on a list of "one|four" will return "one|two|three|four". // --> tagProcessor.registerTag(ListTag.class, "insert", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.insert[...] must have a value."); return null; } - ListTag items = getListFor(attribute.getContextObject(1), attribute.context); + ListTag items = getListFor(attribute.getParamObject(), attribute.context); if (attribute.startsWith("at", 2) && attribute.hasContext(2)) { ListTag result = new ListTag(object); int index = object.parseIndex(attribute.getContext(2)); @@ -1041,11 +1041,11 @@ else if (input.size() > 1) { // For example: .set[potato|taco|hotdog].at[2] on a list of "one|two|three" will return "one|potato|taco|hotdog|three". // --> tagProcessor.registerTag(ListTag.class, "set", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.set[...] must have a value."); return null; } - ListTag items = getListFor(attribute.getContextObject(1), attribute.context); + ListTag items = getListFor(attribute.getParamObject(), attribute.context); if (attribute.startsWith("at", 2) && attribute.hasContext(2)) { ListTag result = new ListTag(object); int index = object.parseIndex(attribute.getContext(2)); @@ -1078,11 +1078,11 @@ else if (input.size() > 1) { // For example: .set_single[potato].at[2] on a list of "one|two|three" will return "one|potato|three". // --> tagProcessor.registerTag(ListTag.class, "set_single", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.set_single[...] must have a value."); return null; } - ObjectTag value = attribute.getContextObject(1); + ObjectTag value = attribute.getParamObject(); if (attribute.startsWith("at", 2) && attribute.hasContext(2)) { ListTag result = new ListTag(object); int index = object.parseIndex(attribute.getContext(2)); @@ -1115,14 +1115,14 @@ else if (input.size() > 1) { // For example: .overwrite[potato|taco|hotdog|cheeseburger].at[2] on a list of "one|two|three" will return "one|potato|taco|hotdog|cheeseburger". // --> tagProcessor.registerTag(ListTag.class, "overwrite", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.overwrite[...] must have a value."); return null; } if (object.isEmpty()) { return null; } - ListTag items = getListFor(attribute.getContextObject(1), attribute.context); + ListTag items = getListFor(attribute.getParamObject(), attribute.context); if (attribute.startsWith("at", 2) && attribute.hasContext(2)) { ListTag result = new ListTag(object); int index = object.parseIndex(attribute.getContext(2)); @@ -1157,12 +1157,12 @@ else if (input.size() > 1) { // If the value input is a list, that list becomes a list-within-a-list, still only occupying one space in the outer list. // --> tagProcessor.registerStaticTag(ListTag.class, "include_single", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.include_single[...] must have a value."); return null; } ListTag copy = new ListTag(object); - copy.addObject(attribute.getContextObject(1)); + copy.addObject(attribute.getParamObject()); return copy; }); @@ -1174,12 +1174,12 @@ else if (input.size() > 1) { // For example: .include[three|four] on a list of "one|two" will return "one|two|three|four". // --> tagProcessor.registerStaticTag(ListTag.class, "include", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.include[...] must have a value."); return null; } ListTag copy = new ListTag(object); - copy.addAll(getListFor(attribute.getContextObject(1), attribute.context)); + copy.addAll(getListFor(attribute.getParamObject(), attribute.context)); return copy; }); @@ -1191,11 +1191,11 @@ else if (input.size() > 1) { // For example: .exclude[two|four] on a list of "one|two|three|four" will return "one|three". // --> tagProcessor.registerTag(ListTag.class, "exclude", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.exclude[...] must have a value."); return null; } - ListTag exclusions = getListFor(attribute.getContextObject(1), attribute.context); + ListTag exclusions = getListFor(attribute.getParamObject(), attribute.context); int max = exclusions.size(); // <--[tag] // @attribute ]> @@ -1237,11 +1237,11 @@ else if (input.size() > 1) { // Also supports [first] and [last] values. // --> tagProcessor.registerTag(ListTag.class, "remove", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.remove[#] must have a value."); return null; } - ListTag indices = getListFor(attribute.getContextObject(1), attribute.context); + ListTag indices = getListFor(attribute.getParamObject(), attribute.context); ListTag copy = new ListTag(object); // <--[tag] @@ -1290,11 +1290,11 @@ else if (input.size() > 1) { // This will retain the list order of the list object the tag is on (so, for example "a|b|c" .shared_contents[c|b] returns "b|c"). // --> tagProcessor.registerStaticTag(ListTag.class, "shared_contents", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.shared_contents[...] must have a value."); return null; } - ListTag secondList = getListFor(attribute.getContextObject(1), attribute.context); + ListTag secondList = getListFor(attribute.getParamObject(), attribute.context); ListTag output = new ListTag(); for (String val : object) { if (secondList.containsCaseInsensitive(val) && !output.containsCaseInsensitive(val)) { @@ -1320,16 +1320,20 @@ else if (input.size() > 1) { // Specify regex: at the start of the replace element to replace elements that match the Regex. // --> tagProcessor.registerTag(ListTag.class, "replace", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag ListTag.replace[...] must have a value."); return null; } - String replace = attribute.getContext(1); + String replace = attribute.getParam(); ObjectTag replacement = null; if (attribute.startsWith("with", 2)) { - if (attribute.hasContext(2)) { - replacement = attribute.getContextObject(2); - attribute.fulfill(1); + attribute.fulfill(1); + if (attribute.hasParam()) { + replacement = attribute.getParamObject(); + } + else { + Debug.echoError("The tag ListTag.replace[...].with[...] must have a value."); + return null; } } @@ -1398,7 +1402,7 @@ else if (input.size() > 1) { // Specify more than one index to get a list of results. // --> TagRunnable.ObjectInterface getRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.get[...] must have a value."); return null; } @@ -1406,7 +1410,7 @@ else if (input.size() > 1) { attribute.echoError("Can't get from an empty list."); return null; } - ListTag indices = getListFor(attribute.getContextObject(1), attribute.context); + ListTag indices = getListFor(attribute.getParamObject(), attribute.context); if (indices.size() > 1) { ListTag results = new ListTag(); for (String index : indices) { @@ -1477,11 +1481,11 @@ else if (input.size() > 1) { // TODO: Take multiple inputs? Or a matcher? // --> tagProcessor.registerStaticTag(ListTag.class, "find_all_partial", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.find_all_partial[...] must have a value."); return null; } - String test = attribute.getContext(1).toUpperCase(); + String test = attribute.getParam().toUpperCase(); ListTag positions = new ListTag(); for (int i = 0; i < object.size(); i++) { if (object.get(i).toUpperCase().contains(test)) {// TODO: Efficiency @@ -1501,13 +1505,13 @@ else if (input.size() > 1) { // TODO: Take multiple inputs? Or a matcher? // --> tagProcessor.registerStaticTag(ListTag.class, "find_all", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.find_all[...] must have a value."); return null; } ListTag positions = new ListTag(); for (int i = 0; i < object.size(); i++) { - if (object.get(i).equalsIgnoreCase(attribute.getContext(1))) { + if (object.get(i).equalsIgnoreCase(attribute.getParam())) { positions.add(String.valueOf(i + 1)); } } @@ -1524,11 +1528,11 @@ else if (input.size() > 1) { // TODO: Take multiple inputs? Or a matcher? // --> tagProcessor.registerStaticTag(ElementTag.class, "find_partial", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.find_partial[...] must have a value."); return null; } - String test = attribute.getContext(1).toUpperCase(); + String test = attribute.getParam().toUpperCase(); for (int i = 0; i < object.size(); i++) { if (object.get(i).toUpperCase().contains(test)) { // TODO: Efficiency return new ElementTag(i + 1); @@ -1547,19 +1551,19 @@ else if (input.size() > 1) { // TODO: Take multiple inputs? Or a matcher? // --> tagProcessor.registerStaticTag(ElementTag.class, "find", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.find[...] must have a value."); return null; } for (int i = 0; i < object.size(); i++) { - if (object.get(i).equalsIgnoreCase(attribute.getContext(1))) { + if (object.get(i).equalsIgnoreCase(attribute.getParam())) { return new ElementTag(i + 1); } } // TODO: This should be find_partial or something /* for (int i = 0; i < size(); i++) { - if (get(i).toUpperCase().contains(attribute.getContext(1).toUpperCase())) + if (get(i).toUpperCase().contains(attribute.getParam().toUpperCase())) return new Element(i + 1); } */ @@ -1574,11 +1578,11 @@ else if (input.size() > 1) { // For example: a list of "one|two|two|three" .count[two] returns 2. // --> tagProcessor.registerStaticTag(ElementTag.class, "count", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ListTag.count[...] must have a value."); return null; } - String element = attribute.getContext(1); + String element = attribute.getParam(); int count = 0; for (String s : object) { if (CoreUtilities.equalsIgnoreCase(s, element)) { @@ -1675,8 +1679,8 @@ else if (input.size() > 1) { // --> tagProcessor.registerTag(ObjectTag.class, "lowest", (attribute, object) -> { String tag = null; - if (attribute.hasContext(1)) { - tag = attribute.getRawContext(1); + if (attribute.hasParam()) { + tag = attribute.getRawParam(); } Attribute subAttribute; try { @@ -1764,8 +1768,8 @@ else if (input.size() > 1) { // --> tagProcessor.registerTag(ObjectTag.class, "highest", (attribute, object) -> { String tag = null; - if (attribute.hasContext(1)) { - tag = attribute.getRawContext(1); + if (attribute.hasParam()) { + tag = attribute.getRawParam(); } Attribute subAttribute; try { @@ -1898,12 +1902,12 @@ else if (value > 0) { // For example, you might sort a list of players based on their names, via .sort_by_value[name] on the list of valid players. // --> tagProcessor.registerTag(ListTag.class, "sort_by_value", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ListTag newlist = new ListTag(object); final NaturalOrderComparator comparator = new NaturalOrderComparator(); - final String tag = attribute.getRawContext(1); + final String tag = attribute.getRawParam(); Attribute subAttribute; try { subAttribute = new Attribute(tag, attribute.getScriptEntry(), attribute.context); @@ -1936,11 +1940,11 @@ else if (value > 0) { // Non-numerical input is considered an error, and the result is not guaranteed. // --> tagProcessor.registerTag(ListTag.class, "sort_by_number", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ListTag newlist = new ListTag(object); - final String tag = attribute.getRawContext(1); + final String tag = attribute.getRawParam(); Attribute subAttribute; try { subAttribute = new Attribute(tag, attribute.getScriptEntry(), attribute.context); @@ -1996,9 +2000,9 @@ else if (value > 0) { // --> tagProcessor.registerTag(ListTag.class, "sort", (attribute, object) -> { ListTag obj = new ListTag(object); - final ProcedureScriptContainer script = (ProcedureScriptContainer) attribute.contextAsType(1, ScriptTag.class).getContainer(); + final ProcedureScriptContainer script = (ProcedureScriptContainer) attribute.paramAsType(ScriptTag.class).getContainer(); if (script == null) { - attribute.echoError("'" + attribute.getContext(1) + "' is not a valid procedure script!"); + attribute.echoError("'" + attribute.getParam() + "' is not a valid procedure script!"); return obj; } final ScriptEntry entry = attribute.getScriptEntry(); @@ -2010,8 +2014,8 @@ else if (value > 0) { // --> ListTag context = new ListTag(); if (attribute.startsWith("context", 2)) { - context = getListFor(attribute.getContextObject(2), attribute.context); attribute.fulfill(1); + context = attribute.paramAsType(ListTag.class); } final ListTag context_send = context; List list = new ArrayList<>(obj); @@ -2064,7 +2068,7 @@ else if (value > 0) { // One should generally prefer <@link tag ListTag.filter_tag>. // --> tagProcessor.registerTag(ListTag.class, "filter", (attribute, object) -> { - String tag = attribute.getRawContext(1); + String tag = attribute.getRawParam(); boolean defaultValue = tag.endsWith("||true"); if (defaultValue) { tag = tag.substring(0, tag.length() - "||true".length()); @@ -2104,7 +2108,7 @@ else if (value > 0) { // --> tagProcessor.registerTag(ListTag.class, "parse", (attribute, object) -> { ListTag newlist = new ListTag(); - String tag = attribute.getRawContext(1); + String tag = attribute.getRawParam(); String defaultValue = "null"; boolean fallback = false; if (tag.contains("||")) { @@ -2161,7 +2165,7 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // For example: a list of '1|2|3|4|5' .filter_tag[]>] returns a list of '4|5'. // --> tagProcessor.registerTag(ListTag.class, "filter_tag", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ListTag newlist = new ListTag(); @@ -2169,7 +2173,7 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { try { for (ObjectTag obj : object.objectForms) { provider.altDefs.putObject("filter_value", obj); - if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicContext(1, provider).toString(), "true")) { + if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicParam(provider).toString(), "true")) { newlist.addObject(obj); } } @@ -2190,7 +2194,7 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // For example: a list of '3|1|2' .parse_tag[]>] returns a list of 'charlie|alpha|bravo'. // --> tagProcessor.registerTag(ListTag.class, "parse_tag", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ListTag newlist = new ListTag(); @@ -2198,7 +2202,7 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { try { for (ObjectTag obj : object.objectForms) { provider.altDefs.putObject("parse_value", obj); - newlist.addObject(attribute.parseDynamicContext(1, provider)); + newlist.addObject(attribute.parseDynamicParam(provider)); } } catch (Exception ex) { @@ -2215,11 +2219,11 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // by adding entries to the left side. // --> tagProcessor.registerTag(ListTag.class, "pad_left", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ObjectTag with = new ElementTag(""); - int length = attribute.getIntContext(1); + int length = attribute.getIntParam(); // <--[tag] // @attribute ].with[]> @@ -2247,11 +2251,11 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // by adding entries to the right side. // --> tagProcessor.registerTag(ListTag.class, "pad_right", (attribute, object) -> { // non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ObjectTag with = new ElementTag(""); - int length = attribute.getIntContext(1); + int length = attribute.getIntParam(); // <--[tag] // @attribute ].with[]> @@ -2296,10 +2300,10 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // returns whether the list contains any of a list of given elements, case-sensitive. // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_any_case_sensitive", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - ListTag list = getListFor(attribute.getContextObject(1), attribute.context); + ListTag list = getListFor(attribute.getParamObject(), attribute.context); boolean state = false; full_set: for (String element : object) { @@ -2320,10 +2324,10 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // returns whether the list contains any of a list of given elements. // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_any", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - ListTag list = getListFor(attribute.getContextObject(1), attribute.context); + ListTag list = getListFor(attribute.getParamObject(), attribute.context); boolean state = false; full_set: for (String element : object) { @@ -2344,12 +2348,12 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // returns whether the list contains a given element, case-sensitive. // --> tagProcessor.registerStaticTag(ElementTag.class, "contains_case_sensitive", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } boolean state = false; for (String element : object) { - if (element.equals(attribute.getContext(1))) { + if (element.equals(attribute.getParam())) { state = true; break; } @@ -2364,10 +2368,10 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // returns whether the list contains all of the given elements. // --> tagProcessor.registerStaticTag(ElementTag.class, "contains", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - ListTag needed = getListFor(attribute.getContextObject(1), attribute.context); + ListTag needed = getListFor(attribute.getParamObject(), attribute.context); int gotten = 0; for (String check : needed) { for (String element : object) { @@ -2395,8 +2399,8 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { if (object.isEmpty()) { return null; } - if (attribute.hasContext(1)) { - int count = Integer.valueOf(attribute.getContext(1)); + if (attribute.hasParam()) { + int count = Integer.valueOf(attribute.getParam()); int times = 0; ArrayList available = new ArrayList<>(object.objectForms); ListTag toReturn = new ListTag(); @@ -2425,7 +2429,7 @@ else if (marks == 0 && c == '|' && tag.charAt(i + 1) == '|') { // You can use that tag to add an upper limit on how different the text can be. // --> tagProcessor.registerStaticTag(ElementTag.class, "closest_to", (attribute, object) -> { - return new ElementTag(CoreUtilities.getClosestOption(object, attribute.getContext(1))); + return new ElementTag(CoreUtilities.getClosestOption(object, attribute.getParam())); }); } @@ -2449,7 +2453,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) { @Override public ObjectTag specialTagProcessing(Attribute attribute) { - String attrLow = attribute.getAttributeWithoutContext(1); + String attrLow = attribute.getAttributeWithoutParam(1); if (Debug.verbose) { Debug.log("ListTag alternate attribute " + attrLow); } diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/MapTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/MapTag.java index 2c70341b..1946c5e1 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/MapTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/MapTag.java @@ -294,7 +294,7 @@ public static void registerTags() { tagProcessor.registerTag(MapTag.class, "sort_by_value", (attribute, object) -> { ArrayList> entryList = new ArrayList<>(object.map.entrySet()); final NaturalOrderComparator comparator = new NaturalOrderComparator(); - final String tag = attribute.hasContext(1) ? attribute.getRawContext(1) : null; + final String tag = attribute.hasParam() ? attribute.getRawParam() : null; Attribute subAttribute; try { subAttribute = tag == null ? null : new Attribute(tag, attribute.getScriptEntry(), attribute.context); @@ -333,7 +333,7 @@ public static void registerTags() { // For example: a map of [a=1;b=2;c=3;d=4;e=5] .filter_tag[<[filter_value].is[or_more].than[3]>] returns a list of [c=3;d=4;e=5]. // --> tagProcessor.registerTag(MapTag.class, "filter_tag", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Must have input to filter_tag[...]"); return null; } @@ -343,7 +343,7 @@ public static void registerTags() { for (Map.Entry entry : object.map.entrySet()) { provider.altDefs.putObject("filter_key", new ElementTag(entry.getKey().str)); provider.altDefs.putObject("filter_value", entry.getValue()); - if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicContext(1, provider).toString(), "true")) { + if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicParam(provider).toString(), "true")) { newMap.map.put(entry.getKey(), entry.getValue()); } } @@ -363,7 +363,7 @@ public static void registerTags() { // For example: a map of [alpha=one;bravo=two] .parse_value_tag[<[parse_value].to_uppercase>] returns a map of [alpha=ONE;bravo=TWO]. // --> tagProcessor.registerTag(MapTag.class, "parse_value_tag", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Must have input to parse_value_tag[...]"); return null; } @@ -373,7 +373,7 @@ public static void registerTags() { for (Map.Entry entry : object.map.entrySet()) { provider.altDefs.putObject("parse_key", new ElementTag(entry.getKey().str)); provider.altDefs.putObject("parse_value", entry.getValue()); - newMap.map.put(entry.getKey(), attribute.parseDynamicContext(1, provider)); + newMap.map.put(entry.getKey(), attribute.parseDynamicParam(provider)); } } catch (Exception ex) { @@ -390,12 +390,12 @@ public static void registerTags() { // If a list is given as input, returns whether the map contains all of the specified keys. // --> tagProcessor.registerStaticTag(ElementTag.class, "contains", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.contains' must have an input value."); return null; } - if (attribute.getContext(1).contains("|")) { - ListTag keyList = attribute.getContextObject(1).asType(ListTag.class, attribute.context); + if (attribute.getParam().contains("|")) { + ListTag keyList = attribute.getParamObject().asType(ListTag.class, attribute.context); boolean contains = true; for (String key : keyList) { if (object.getObject(key) == null) { @@ -405,7 +405,7 @@ public static void registerTags() { } return new ElementTag(contains); } - return new ElementTag(object.getObject(attribute.getContext(1)) != null); + return new ElementTag(object.getObject(attribute.getParam()) != null); }); // <--[tag] @@ -418,19 +418,19 @@ public static void registerTags() { // For example, on a map of [a=1;b=2;c=3], using ".get[b|c]" will return a list of "2|3". // --> tagProcessor.registerStaticTag(ObjectTag.class, "get", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.get' must have an input value."); return null; } - if (attribute.getContext(1).contains("|")) { - ListTag keyList = attribute.getContextObject(1).asType(ListTag.class, attribute.context); + if (attribute.getParam().contains("|")) { + ListTag keyList = attribute.getParamObject().asType(ListTag.class, attribute.context); ListTag valList = new ListTag(); for (String key : keyList) { valList.addObject(object.getObject(key)); } return valList; } - return object.getObject(attribute.getContext(1)); + return object.getObject(attribute.getParam()); }); // <--[tag] @@ -443,19 +443,19 @@ public static void registerTags() { // If a list is given as input, returns a list of values. // --> TagRunnable.ObjectInterface deepGetRunnable = (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.deep_get' must have an input value."); return null; } - if (attribute.getContext(1).contains("|")) { - ListTag keyList = attribute.getContextObject(1).asType(ListTag.class, attribute.context); + if (attribute.getParam().contains("|")) { + ListTag keyList = attribute.getParamObject().asType(ListTag.class, attribute.context); ListTag valList = new ListTag(); for (String key : keyList) { valList.addObject(object.getDeepObject(key)); } return valList; } - return object.getDeepObject(attribute.getContext(1)); + return object.getDeepObject(attribute.getParam()); }; tagProcessor.registerStaticTag(ObjectTag.class, "deep_get", deepGetRunnable); tagProcessor.registerStaticTag(ObjectTag.class, "", deepGetRunnable); @@ -469,11 +469,11 @@ public static void registerTags() { // Keys that aren't present in the original map will be ignored. // --> tagProcessor.registerStaticTag(MapTag.class, "get_subset", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.get_subset' must have an input value."); return null; } - ListTag keys = ListTag.getListFor(attribute.getContextObject(1), attribute.context); + ListTag keys = ListTag.getListFor(attribute.getParamObject(), attribute.context); MapTag output = new MapTag(); for (String key : keys) { StringHolder keyHolder = new StringHolder(key); @@ -496,24 +496,24 @@ public static void registerTags() { // For example, on a map of [a=1;b=2;c=3], using ".default[c].as[4]" will return [a=1;b=2;c=3]. // --> tagProcessor.registerTag(MapTag.class, "default", (attribute, object) -> { // Non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.default' must have an input value."); return null; } - String key = attribute.getContext(1); + String key = attribute.getParam(); attribute.fulfill(1); if (!attribute.matches("as")) { attribute.echoError("The tag 'MapTag.default' must be followed by '.as'."); return null; } - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.default.as' must have an input value for 'as'."); return null; } if (object.map.containsKey(new StringHolder(key))) { return object; } - ObjectTag value = attribute.getContextObject(1); + ObjectTag value = attribute.getParamObject(); MapTag result = object.duplicate(); result.putObject(key, value); return result; @@ -527,21 +527,21 @@ public static void registerTags() { // This means for example if you use "deep_with[root.leaf].as[myvalue]", you will have the key 'root' set to the value of a second MapTag (with key 'leaf' as "myvalue"). // --> tagProcessor.registerTag(MapTag.class, "deep_with", (attribute, object) -> { // Non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.deep_with' must have an input value."); return null; } - String key = attribute.getContext(1); + String key = attribute.getParam(); attribute.fulfill(1); if (!attribute.matches("as")) { attribute.echoError("The tag 'MapTag.deep_with' must be followed by '.as'."); return null; } - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.deep_with.as' must have an input value for 'as'."); return null; } - ObjectTag value = attribute.getContextObject(1); + ObjectTag value = attribute.getParamObject(); MapTag result = object.duplicate(); result.putDeepObject(key, value); return result; @@ -556,21 +556,21 @@ public static void registerTags() { // Matching keys will be overridden. For example, on a map of [a=1;b=2;c=3], using ".with[c].as[4]" will return [a=1;b=2;c=4]. // --> tagProcessor.registerTag(MapTag.class, "with", (attribute, object) -> { // Non-static due to hacked sub-tag - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.with' must have an input value."); return null; } - String key = attribute.getContext(1); + String key = attribute.getParam(); attribute.fulfill(1); if (!attribute.matches("as")) { attribute.echoError("The tag 'MapTag.with' must be followed by '.as'."); return null; } - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.with.as' must have an input value for 'as'."); return null; } - ObjectTag value = attribute.getContextObject(1); + ObjectTag value = attribute.getParamObject(); MapTag result = object.duplicate(); result.putObject(key, value); return result; @@ -602,12 +602,12 @@ public static void registerTags() { // Returns a copy of the map with the specified deep key(s) excluded. // --> tagProcessor.registerStaticTag(MapTag.class, "deep_exclude", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.deep_exclude' must have an input value."); return null; } MapTag result = object.duplicate(); - for (String key : ListTag.getListFor(attribute.getContextObject(1), attribute.context)) { + for (String key : ListTag.getListFor(attribute.getParamObject(), attribute.context)) { result.putDeepObject(key, null); } return result; @@ -621,12 +621,12 @@ public static void registerTags() { // For example, on a map of [a=1;b=2;c=3], using ".exclude[b]" will return [a=1;c=3]. // --> tagProcessor.registerStaticTag(MapTag.class, "exclude", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.exclude' must have an input value."); return null; } MapTag result = object.duplicate(); - for (String key : ListTag.getListFor(attribute.getContextObject(1), attribute.context)) { + for (String key : ListTag.getListFor(attribute.getParamObject(), attribute.context)) { result.map.remove(new StringHolder(key)); } return result; @@ -641,12 +641,12 @@ public static void registerTags() { // Matching keys will be overridden. For example, on a map of [a=1;b=2;c=3], using ".include[b=4;c=5]" will return [a=1;b=4;c=5]. // --> tagProcessor.registerStaticTag(MapTag.class, "include", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag 'MapTag.include' must have an input value."); return null; } MapTag result = object.duplicate(); - result.map.putAll(getMapFor(attribute.getContextObject(1), attribute.context).map); + result.map.putAll(getMapFor(attribute.getParamObject(), attribute.context).map); return result; }); diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/QueueTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/QueueTag.java index f8fe4df3..6c0f0734 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/QueueTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/QueueTag.java @@ -281,11 +281,11 @@ else if (object.getQueue().is_stopping) { // Returns null if the queue lacks the definition. // --> tagProcessor.registerTag(ObjectTag.class, "definition", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag QueueTag.definition[...] must have a value."); return null; } - return object.getQueue().getDefinitionObject(attribute.getContext(1)); + return object.getQueue().getDefinitionObject(attribute.getParam()); }); // <--[tag] diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/ScriptTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/ScriptTag.java index 84309ade..727a6124 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/ScriptTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/ScriptTag.java @@ -314,7 +314,7 @@ public static void registerTags() { tagProcessor.registerTag(ObjectTag.class, "constant", (attribute, object) -> { Deprecations.scriptConstantTag.warn(attribute.context); - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag ScriptTag.constant[...] must have a value."); return null; } @@ -322,7 +322,7 @@ public static void registerTags() { if (section == null) { return null; } - Object obj = section.get(attribute.getContext(1).toUpperCase()); + Object obj = section.get(attribute.getParam().toUpperCase()); if (obj == null) { return null; } @@ -351,7 +351,7 @@ public static void registerTags() { // (meaning, a tag that returns a ListTag, inside a data list, will insert a ListTag inside the returned ListTag, as you would expect). // --> tagProcessor.registerTag(ObjectTag.class, "parsed_key", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag ScriptTag.parsed_key[...] must have a value."); return null; } @@ -365,7 +365,7 @@ public static void registerTags() { Debug.echoError("Script '" + container.getName() + "' missing root section?!"); return null; } - Object obj = section.get(attribute.getContext(1).toUpperCase()); + Object obj = section.get(attribute.getParam().toUpperCase()); if (obj == null) { return null; } @@ -381,7 +381,7 @@ public static void registerTags() { // Custom keys should usually go in a 'data' script container, or under a key labeled 'data' for other script containers. // --> tagProcessor.registerStaticTag(ObjectTag.class, "data_key", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("The tag ScriptTag.data_key[...] must have a value."); return null; } @@ -395,7 +395,7 @@ public static void registerTags() { Debug.echoError("Script '" + container.getName() + "' missing root section?!"); return null; } - Object obj = section.get(attribute.getContext(1).toUpperCase()); + Object obj = section.get(attribute.getParam().toUpperCase()); if (obj == null) { return null; } @@ -410,7 +410,7 @@ public static void registerTags() { // Returns a list of all data keys within a script, with an optional starting-key. // --> tagProcessor.registerStaticTag(ListTag.class, "list_keys", (attribute, object) -> { - YamlConfiguration conf = object.getContainer().getConfigurationSection(attribute.hasContext(1) ? attribute.getContext(1) : ""); + YamlConfiguration conf = object.getContainer().getConfigurationSection(attribute.hasParam() ? attribute.getParam() : ""); if (conf == null) { return null; } @@ -424,7 +424,7 @@ public static void registerTags() { // Returns a list of all keys within a script, searching recursively, with an optional starting-key. // --> tagProcessor.registerStaticTag(ListTag.class, "list_deep_keys", (attribute, object) -> { - YamlConfiguration conf = object.getContainer().getConfigurationSection(attribute.hasContext(1) ? attribute.getContext(1) : ""); + YamlConfiguration conf = object.getContainer().getConfigurationSection(attribute.hasParam() ? attribute.getParam() : ""); if (conf == null) { return null; } diff --git a/src/main/java/com/denizenscript/denizencore/objects/core/TimeTag.java b/src/main/java/com/denizenscript/denizencore/objects/core/TimeTag.java index 5eccdb27..6c2740ae 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/core/TimeTag.java +++ b/src/main/java/com/denizenscript/denizencore/objects/core/TimeTag.java @@ -410,7 +410,7 @@ public static void registerTags() { // Zone input can be like 'UTC-5' or like 'America/New_York' // --> tagProcessor.registerStaticTag(TimeTag.class, "to_zone", (attribute, object) -> { - return new TimeTag(object.instant.withZoneSameInstant(ZoneId.of(attribute.getContext(1)))); + return new TimeTag(object.instant.withZoneSameInstant(ZoneId.of(attribute.getParam()))); }); // <--[tag] @@ -443,11 +443,11 @@ public static void registerTags() { // The minute/second/millisecond will be zeroed. // --> tagProcessor.registerStaticTag(TimeTag.class, "last_hour_of_day", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.last_hour_of_day[...] must have input."); return null; } - int hour = attribute.getIntContext(1); + int hour = attribute.getIntParam(); int todayHour = object.hour(); TimeTag result = new TimeTag(object.year(), object.month(), object.day(), 0, 0, 0, 0, object.instant.getOffset()); if (hour > todayHour) { @@ -466,11 +466,11 @@ public static void registerTags() { // The minute/second/millisecond will be zeroed. // --> tagProcessor.registerStaticTag(TimeTag.class, "next_hour_of_day", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.next_hour_of_day[...] must have input."); return null; } - int hour = attribute.getIntContext(1); + int hour = attribute.getIntParam(); int todayHour = object.hour(); TimeTag result = new TimeTag(object.year(), object.month(), object.day(), 0, 0, 0, 0, object.instant.getOffset()); if (hour <= todayHour) { @@ -487,16 +487,16 @@ public static void registerTags() { // The hour/minute/second/millisecond will be zeroed. // --> tagProcessor.registerStaticTag(TimeTag.class, "last_day_of_week", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.last_day_of_week[...] must have input."); return null; } DayOfWeek day; try { - day = DayOfWeek.valueOf(attribute.getContext(1).toUpperCase()); + day = DayOfWeek.valueOf(attribute.getParam().toUpperCase()); } catch (IllegalArgumentException ex) { - attribute.echoError("'" + attribute.getContext(1) + "' is not a valid day-of-week."); + attribute.echoError("'" + attribute.getParam() + "' is not a valid day-of-week."); return null; } ZonedDateTime time = object.instant; @@ -515,16 +515,16 @@ public static void registerTags() { // The hour/minute/second/millisecond will be zeroed. // --> tagProcessor.registerStaticTag(TimeTag.class, "next_day_of_week", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.next_day_of_week[...] must have input."); return null; } DayOfWeek day; try { - day = DayOfWeek.valueOf(attribute.getContext(1).toUpperCase()); + day = DayOfWeek.valueOf(attribute.getParam().toUpperCase()); } catch (IllegalArgumentException ex) { - attribute.echoError("'" + attribute.getContext(1) + "' is not a valid day-of-week."); + attribute.echoError("'" + attribute.getParam() + "' is not a valid day-of-week."); return null; } ZonedDateTime time = object.instant; @@ -546,11 +546,11 @@ public static void registerTags() { // Be careful with inputs of 29/30/31, as only some months contain those days. // --> tagProcessor.registerStaticTag(TimeTag.class, "last_day_of_month", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.last_day_of_month[...] must have input."); return null; } - int day = attribute.getIntContext(1); + int day = attribute.getIntParam(); if (day < 1 || day > 31) { return null; } @@ -578,11 +578,11 @@ public static void registerTags() { // Be careful with inputs of 29/30/31, as only some months contain those days. // --> tagProcessor.registerStaticTag(TimeTag.class, "next_day_of_month", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("time.next_day_of_month[...] must have input."); return null; } - int day = attribute.getIntContext(1); + int day = attribute.getIntParam(); if (day < 1 || day > 31) { return null; } @@ -637,11 +637,11 @@ public static void registerTags() { // For example, a TimeTag on Monday, '.add[1d]', will return a time on Tuesday. // --> tagProcessor.registerStaticTag(TimeTag.class, "add", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag TimeTag.add[...] must have an input."); return null; } - DurationTag toAdd = attribute.contextAsType(1, DurationTag.class); + DurationTag toAdd = attribute.paramAsType(DurationTag.class); return new TimeTag(object.millis() + toAdd.getMillis(), object.instant.getZone()); }); @@ -653,11 +653,11 @@ public static void registerTags() { // For example, a TimeTag on Monday, '.sub[1d]', will return a time on Sunday. // --> tagProcessor.registerStaticTag(TimeTag.class, "sub", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag TimeTag.sub[...] must have an input."); return null; } - DurationTag toSub = attribute.contextAsType(1, DurationTag.class); + DurationTag toSub = attribute.paramAsType(DurationTag.class); return new TimeTag(object.millis() - toSub.getMillis(), object.instant.getZone()); }); @@ -685,11 +685,11 @@ public static void registerTags() { // For example, a time on Monday, .duration_since[a time on Sunday], will return '1d'. // --> tagProcessor.registerStaticTag(DurationTag.class, "duration_since", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag TimeTag.duration_since[...] must have an input."); return null; } - TimeTag toSub = attribute.contextAsType(1, TimeTag.class); + TimeTag toSub = attribute.paramAsType(TimeTag.class); return new DurationTag((object.millis() - toSub.millis()) / 1000.0); }); @@ -700,11 +700,11 @@ public static void registerTags() { // Returns true if this time object comes after the input time value, or false if it's before (or equal). // --> tagProcessor.registerStaticTag(ElementTag.class, "is_after", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag TimeTag.is_after[...] must have an input."); return null; } - TimeTag toCompare = attribute.contextAsType(1, TimeTag.class); + TimeTag toCompare = attribute.paramAsType(TimeTag.class); return new ElementTag(object.millis() > toCompare.millis()); }); @@ -715,11 +715,11 @@ public static void registerTags() { // Returns true if this time object comes before the input time value, or false if it's after (or equal). // --> tagProcessor.registerStaticTag(ElementTag.class, "is_before", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("The tag TimeTag.is_before[...] must have an input."); return null; } - TimeTag toCompare = attribute.contextAsType(1, TimeTag.class); + TimeTag toCompare = attribute.paramAsType(TimeTag.class); return new ElementTag(object.millis() < toCompare.millis()); }); @@ -733,7 +733,7 @@ public static void registerTags() { // There are a variety of additional symbols accepted, as listed under "Patterns for Formatting and Parsing" on <@link url https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html>. // --> tagProcessor.registerStaticTag(ElementTag.class, "format", (attribute, object) -> { - return new ElementTag(object.format(attribute.hasContext(1) ? attribute.getContext(1) : null)); + return new ElementTag(object.format(attribute.hasParam() ? attribute.getParam() : null)); }); tagProcessor.registerTag(DurationTag.class, "duration_compat", (attribute, object) -> { diff --git a/src/main/java/com/denizenscript/denizencore/objects/properties/PropertyParser.java b/src/main/java/com/denizenscript/denizencore/objects/properties/PropertyParser.java index 796ca190..3b242f2f 100644 --- a/src/main/java/com/denizenscript/denizencore/objects/properties/PropertyParser.java +++ b/src/main/java/com/denizenscript/denizencore/objects/properties/PropertyParser.java @@ -305,11 +305,11 @@ public static void registerPropertyTagHandlers(Class t // Consider using <@link tag PropertyHolderObject.with_single> instead. // --> processor.registerTag(type, "with", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } T instance = (T) object.duplicate(); - List properties = ObjectFetcher.separateProperties("[" + attribute.getContext(1) + "]"); + List properties = ObjectFetcher.separateProperties("[" + attribute.getParam() + "]"); for (int i = 1; i < properties.size(); i++) { List data = CoreUtilities.split(properties.get(i), '=', 2); if (data.size() != 2) { @@ -331,13 +331,13 @@ public static void registerPropertyTagHandlers(Class t // This avoids the risk of escaping issues. // --> processor.registerTag(type, "with_single", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } T instance = (T) object.duplicate(); - List data = CoreUtilities.split(attribute.getContext(1), '=', 2); + List data = CoreUtilities.split(attribute.getParam(), '=', 2); if (data.size() != 2) { - Debug.echoError("Invalid property string '" + attribute.getContext(1) + "'!"); + Debug.echoError("Invalid property string '" + attribute.getParam() + "'!"); } else { instance.safeApplyProperty(new Mechanism(data.get(0), new ElementTag(data.get(1)), attribute.context)); @@ -353,10 +353,10 @@ public static void registerPropertyTagHandlers(Class t // Returns a copy of the object with the MapTag of mechanism adjustments applied. // --> processor.registerTag(type, "with_map", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - MapTag properties = attribute.contextAsType(1, MapTag.class); + MapTag properties = attribute.paramAsType(MapTag.class); T instance = (T) object.duplicate(); for (Map.Entry pair : properties.map.entrySet()) { instance.safeApplyProperty(new Mechanism(pair.getKey().low, pair.getValue(), attribute.context)); @@ -373,10 +373,10 @@ public static void registerPropertyTagHandlers(Class t // This does not necessarily mean it has a valid current value, just that it's supported at all. // --> processor.registerTag(ElementTag.class, "supports", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - String propertyName = attribute.getContext(1); + String propertyName = attribute.getParam(); ClassPropertiesInfo properties = propertiesByClass.get(object.getObjectTagClass()); if (properties == null) { return new ElementTag(false); diff --git a/src/main/java/com/denizenscript/denizencore/scripts/commands/file/YamlCommand.java b/src/main/java/com/denizenscript/denizencore/scripts/commands/file/YamlCommand.java index 8c4246a3..efd17e50 100644 --- a/src/main/java/com/denizenscript/denizencore/scripts/commands/file/YamlCommand.java +++ b/src/main/java/com/denizenscript/denizencore/scripts/commands/file/YamlCommand.java @@ -746,7 +746,7 @@ public void Set(YamlConfiguration yaml, int index, String key, Object value, Ele } public ObjectTag yamlTagProcess(Attribute attribute) { - String id = attribute.hasContext(1) ? CoreUtilities.toLowerCase(attribute.getContext(1)) : null; + String id = attribute.hasParam() ? CoreUtilities.toLowerCase(attribute.getParam()) : null; attribute.fulfill(1); // <--[tag] @@ -777,8 +777,8 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // Returns true if the file has the specified path. // Otherwise, returns false. // --> - if (attribute.startsWith("contains") && attribute.hasContext(1)) { - return new ElementTag(yaml.contains(attribute.getContext(1))); + if (attribute.startsWith("contains") && attribute.hasParam()) { + return new ElementTag(yaml.contains(attribute.getParam())); } // <--[tag] @@ -787,8 +787,8 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // @description // Returns true if the specified path results in a list. // --> - if (attribute.startsWith("is_list") && attribute.hasContext(1)) { - return new ElementTag(yaml.isList(attribute.getContext(1))); + if (attribute.startsWith("is_list") && attribute.hasParam()) { + return new ElementTag(yaml.isList(attribute.getParam())); } // <--[tag] @@ -800,8 +800,8 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // (meaning, a tag that returns a ListTag, inside a data list, will insert a ListTag inside the returned ListTag, as you would expect). // Generally, prefer to use <@link tag yaml.read>. // --> - if (attribute.startsWith("parsed_key") && attribute.hasContext(1)) { - Object obj = yaml.get(attribute.getContext(1)); + if (attribute.startsWith("parsed_key") && attribute.hasParam()) { + Object obj = yaml.get(attribute.getParam()); if (obj == null) { return null; } @@ -814,8 +814,8 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // @description // Returns the value from a data key on the YAML document as an ElementTag, ListTag, or MapTag. // --> - if (attribute.startsWith("read") && attribute.hasContext(1)) { - Object obj = yaml.get(attribute.getContext(1)); + if (attribute.startsWith("read") && attribute.hasParam()) { + Object obj = yaml.get(attribute.getParam()); if (obj == null) { return null; } @@ -829,9 +829,9 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // Returns a ListTag of all the keys at the path and all subpaths. // Use empty path input to represent the root of the yaml document tree. // --> - if (attribute.startsWith("list_deep_keys") && attribute.hasContext(1)) { + if (attribute.startsWith("list_deep_keys") && attribute.hasParam()) { Set keys; - String path = attribute.getContext(1); + String path = attribute.getParam(); if (path != null && path.length() > 0) { YamlConfiguration section = yaml.getConfigurationSection(path); if (section == null) { @@ -858,9 +858,9 @@ public ObjectTag yamlTagProcess(Attribute attribute) { // Returns a ListTag of all the keys at the path (and not sub-keys). // Use empty path input to represent the root of the yaml document tree. // --> - if (attribute.startsWith("list_keys") && attribute.hasContext(1)) { + if (attribute.startsWith("list_keys") && attribute.hasParam()) { Set keys; - String path = attribute.getContext(1); + String path = attribute.getParam(); if (path != null && path.length() > 0) { YamlConfiguration section = yaml.getConfigurationSection(path); if (section == null) { diff --git a/src/main/java/com/denizenscript/denizencore/tags/Attribute.java b/src/main/java/com/denizenscript/denizencore/tags/Attribute.java index 49cf081b..d870d753 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/Attribute.java +++ b/src/main/java/com/denizenscript/denizencore/tags/Attribute.java @@ -19,9 +19,9 @@ public static class AttributeComponent { public final String key; - public final String context; + public final String rawParam; - public ParseableTag contextParsed; + public ParseableTag paramParsed; public ObjectTagProcessor.TagData data; @@ -29,19 +29,19 @@ public AttributeComponent(String inp) { if (inp.endsWith("]") && CoreUtilities.contains(inp, '[')) { int ind = inp.indexOf('['); rawKey = inp.substring(0, ind); - context = inp.substring(ind + 1, inp.length() - 1); + rawParam = inp.substring(ind + 1, inp.length() - 1); } else { rawKey = inp; - context = null; + rawParam = null; } key = CoreUtilities.toLowerCase(rawKey); } @Override public String toString() { - if (context != null) { - return key + "[" + context + "]"; + if (rawParam != null) { + return key + "[" + rawParam + "]"; } return key; } @@ -193,14 +193,14 @@ public Attribute(String attributes, ScriptEntry scriptEntry, TagContext context) } } - public boolean matches(String string) { + public final boolean matches(String string) { if (fulfilled >= attributes.length) { return false; } return attributes[fulfilled].key.equals(string); } - public boolean startsWith(String string) { + public final boolean startsWith(String string) { if (fulfilled >= attributes.length) { return false; } @@ -233,15 +233,15 @@ public boolean startsWith(String string) { return false; } - public boolean startsWith(String string, int attribute) { - return CoreUtilities.toLowerCase(getAttributeWithoutContext(attribute)).equals(string); + public final boolean startsWith(String string, int attribute) { + return CoreUtilities.toLowerCase(getAttributeWithoutParam(attribute)).equals(string); } - public boolean isComplete() { + public final boolean isComplete() { return fulfilled >= attributes.length; } - public Attribute fulfill(int attributes) { + public final Attribute fulfill(int attributes) { hadManualFulfill = true; resetErrorTrack(); if (filled != null) { @@ -275,12 +275,27 @@ public final void trackLastTagFailure() { } } - public boolean hasContext(int attribute) { + public final boolean hasParam() { + if (fulfilled >= attributes.length) { + return false; + } + if (attributes[fulfilled].rawParam != null) { + return true; + } + if (Debug.verbose) { + Debug.log("Attribute " + fulfilled + " is missing param, hasParamFailed"); + } + hasContextFailed = true; + return false; + } + + @Deprecated + public final boolean hasContext(int attribute) { attribute += fulfilled - 1; if (attribute < 0 || attribute >= attributes.length) { return false; } - if (attributes[attribute].context != null) { + if (attributes[attribute].rawParam != null) { return true; } if (Debug.verbose) { @@ -341,16 +356,15 @@ public void removeDefinition(String definition) { } } - public String getRawContext(int attribute) { - attribute += fulfilled - 1; - if (attribute < 0 || attribute >= attributes.length) { + public final String getRawParam() { + if (fulfilled >= attributes.length) { return null; } - return attributes[attribute].context; + return attributes[fulfilled].rawParam; } - public ObjectTag parseDynamicContext(int attribute, OverridingDefinitionProvider customProvider) { - String inp = getRawContext(attribute); + public final ObjectTag parseDynamicParam(OverridingDefinitionProvider customProvider) { + String inp = getRawParam(); if (inp == null) { return null; } @@ -364,7 +378,16 @@ public ObjectTag parseDynamicContext(int attribute, OverridingDefinitionProvider } } - public T contextAsType(int attribute, Class dClass) { + public final T paramAsType(Class dClass) { + ObjectTag contextObj = getParamObject(); + if (contextObj == null) { + return null; + } + return CoreUtilities.asType(contextObj, dClass, context); + } + + @Deprecated + public final T contextAsType(int attribute, Class dClass) { ObjectTag contextObj = getContextObject(attribute); if (contextObj == null) { return null; @@ -372,7 +395,11 @@ public T contextAsType(int attribute, Class dClass) { return CoreUtilities.asType(contextObj, dClass, context); } - public ObjectTag getContextObject(int attribute) { + public final ObjectTag getParamObject() { + return getContextObject(1); // TODO + } + + public final ObjectTag getContextObject(int attribute) { attribute += fulfilled - 1; if (attribute < 0 || attribute >= attributes.length) { return null; @@ -382,25 +409,38 @@ public ObjectTag getContextObject(int attribute) { return tagged; } AttributeComponent component = attributes[attribute]; - if (component.contextParsed == null) { - String inp = attributes[attribute].context; + if (component.paramParsed == null) { + String inp = attributes[attribute].rawParam; if (inp == null) { return null; } - component.contextParsed = TagManager.parseTextToTag(component.context, context); + component.paramParsed = TagManager.parseTextToTag(component.rawParam, context); } - if (component.contextParsed == null) { + if (component.paramParsed == null) { return null; } - tagged = component.contextParsed.parse(context); + tagged = component.paramParsed.parse(context); contexts[attribute] = tagged; return tagged; } - public String getContext(int attribute) { + public final String getParam() { + return CoreUtilities.stringifyNullPass(getParamObject()); + } + + @Deprecated + public final String getContext(int attribute) { return CoreUtilities.stringifyNullPass(getContextObject(attribute)); } + public final ElementTag getParamElement() { + ObjectTag obj = getParamObject(); + if (obj == null) { + return null; + } + return obj.asType(ElementTag.class, context); + } + private boolean hadAlternative = false; // <--[language] @@ -464,10 +504,10 @@ public String getContext(int attribute) { static { fallbackTags.put("if_null", new TagManager.TagBaseData("if_null", ObjectTag.class, (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - return attribute.getContextObject(1); + return attribute.getParamObject(); }, false)); fallbackTags.put("exists", new TagManager.TagBaseData("exists", ElementTag.class, (attribute) -> { return new ElementTag(false); @@ -501,21 +541,26 @@ public void setHadAlternative(boolean hadAlternative) { } } - public long getLongContext(int attribute) { + public final long getLongParam() { try { - if (hasContext(attribute)) { - return Long.parseLong(getContext(attribute)); + if (hasParam()) { + return Long.parseLong(getParam()); } } catch (Exception ex) { if (!hasAlternative()) { - Debug.echoError("Tag <" + toString() + "> has invalid input - expected a number, got '" + getContext(attribute) + "'...: " + ex.getMessage()); + Debug.echoError("Tag <" + toString() + "> has invalid input - expected a number, got '" + getParam() + "'...: " + ex.getMessage()); } } return 0; } - public int getIntContext(int attribute) { + public final int getIntParam() { + return getIntContext(1); // TODO + } + + @Deprecated + public final int getIntContext(int attribute) { try { if (hasContext(attribute)) { return Integer.parseInt(getContext(attribute)); @@ -529,6 +574,11 @@ public int getIntContext(int attribute) { return 0; } + public final double getDoubleParam() { + return getDoubleContext(1); // TODO + } + + @Deprecated public double getDoubleContext(int attribute) { try { if (hasContext(attribute)) { @@ -563,7 +613,7 @@ public String getAttribute(int num) { return attributes[num].toString(); } - public String getAttributeWithoutContext(int num) { + public String getAttributeWithoutParam(int num) { num += fulfilled - 1; if (num < 0 || num >= attributes.length) { return ""; @@ -630,8 +680,8 @@ public String toString() { if (contexts[i] != null) { sb.append("[").append(contexts[i]).append("]."); } - else if (attributes[i].context != null) { - sb.append("[").append(filled == null || filled[i] != 3 ? "" : "").append(attributes[i].context).append("]."); + else if (attributes[i].rawParam != null) { + sb.append("[").append(filled == null || filled[i] != 3 ? "" : "").append(attributes[i].rawParam).append("]."); } else { sb.append("."); diff --git a/src/main/java/com/denizenscript/denizencore/tags/ObjectTagProcessor.java b/src/main/java/com/denizenscript/denizencore/tags/ObjectTagProcessor.java index 83534a50..c5288abc 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/ObjectTagProcessor.java +++ b/src/main/java/com/denizenscript/denizencore/tags/ObjectTagProcessor.java @@ -79,21 +79,21 @@ public void generateCoreTags() { // Returns the 'determine' result of a procedure script, passing this object in as the context value. // --> registerTag(ObjectTag.class, "proc", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } ScriptTag script; String path = null; - if (attribute.getContext(1).indexOf('.') > 0) { - String[] split = attribute.getContext(1).split("\\.", 2); + if (attribute.getParam().indexOf('.') > 0) { + String[] split = attribute.getParam().split("\\.", 2); path = split[1]; script = ScriptTag.valueOf(split[0], attribute.context); } else { - script = attribute.contextAsType(1, ScriptTag.class); + script = attribute.paramAsType(ScriptTag.class); } if (script == null) { - attribute.echoError("Missing script for procedure script tag '" + attribute.getContext(1) + "'!"); + attribute.echoError("Missing script for procedure script tag '" + attribute.getParam() + "'!"); return null; } if (!(script.getContainer() instanceof ProcedureScriptContainer)) { @@ -136,7 +136,7 @@ public void generateCoreTags() { // This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden. // --> registerTag(ObjectTag.class, "if_null", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } return object; @@ -177,10 +177,10 @@ public void generateCoreTags() { // Consider also <@link tag ObjectTag.null_if_tag>. // --> registerTag(ObjectTag.class, "null_if", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } - String tag = attribute.getContext(1); + String tag = attribute.getParam(); boolean defaultValue = tag.endsWith("||true"); if (defaultValue) { tag = tag.substring(0, tag.length() - "||true".length()); @@ -213,12 +213,12 @@ public void generateCoreTags() { // Consider also <@link tag ObjectTag.null_if_tag>. // --> registerTag(ObjectTag.class, "null_if_tag", (attribute, object) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return null; } Attribute.OverridingDefinitionProvider provider = new Attribute.OverridingDefinitionProvider(attribute.context.definitionProvider); provider.altDefs.putObject("null_if_value", object); - if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicContext(1, provider).toString(), "true")) { + if (CoreUtilities.equalsIgnoreCase(attribute.parseDynamicParam(provider).toString(), "true")) { return null; } return object; @@ -245,15 +245,15 @@ public void generateCoreTags() { // Returns the outcome of the comparable, either true or false. For information on operators, see <@link language operator>. // Equivalent to <@link tag ObjectTag.is[].to[]> // --> - if (attribute.hasContext(1) && (attribute.startsWith("to", 2) || attribute.startsWith("than", 2)) && attribute.hasContext(2)) { + if (attribute.hasParam() && (attribute.startsWith("to", 2) || attribute.startsWith("than", 2)) && attribute.hasContext(2)) { boolean negative = false; String operator; - if (attribute.getContext(1).startsWith("!")) { - operator = attribute.getContext(1).substring(1); + if (attribute.getParam().startsWith("!")) { + operator = attribute.getParam().substring(1); negative = true; } else { - operator = attribute.getContext(1); + operator = attribute.getParam(); } attribute = attribute.fulfill(1); Comparable.Operator comparableOperator = Comparable.getOperatorFor(operator); @@ -261,7 +261,7 @@ public void generateCoreTags() { attribute.echoError("Unknown operator '" + operator + "'."); return null; } - return new ElementTag(Comparable.compare(object, attribute.getContextObject(1), comparableOperator, negative, attribute.context)); + return new ElementTag(Comparable.compare(object, attribute.getParamObject(), comparableOperator, negative, attribute.context)); } return null; }); diff --git a/src/main/java/com/denizenscript/denizencore/tags/ReplaceableTagEvent.java b/src/main/java/com/denizenscript/denizencore/tags/ReplaceableTagEvent.java index 52a81972..89f46ea5 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/ReplaceableTagEvent.java +++ b/src/main/java/com/denizenscript/denizencore/tags/ReplaceableTagEvent.java @@ -196,7 +196,7 @@ public boolean matches(String... tagNames) { } public String getName() { - return core_attributes.getAttributeWithoutContext(1); + return core_attributes.getAttributeWithoutParam(1); } @Deprecated @@ -221,7 +221,7 @@ public ObjectTag getAlternative() { core_attributes.filled[core_attributes.fulfilled] = 2; } core_attributes.fulfilled = index; - alternateBase = Attribute.fallbackTags.get(core_attributes.getAttributeWithoutContext(1)); + alternateBase = Attribute.fallbackTags.get(core_attributes.getAttributeWithoutParam(1)); return TagManager.readSingleTagObjectNoDebug(context, this); } if (mainRef.alternative != null) { diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ContextTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ContextTagBase.java index 789ebf13..abfe6e6d 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ContextTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ContextTagBase.java @@ -37,7 +37,7 @@ public void contextTags(ReplaceableTagEvent event) { if (event.matches("c")) { Deprecations.contextShorthand.warn(event.getScriptEntry()); } - String contextName = attribute.getAttributeWithoutContext(2); + String contextName = attribute.getAttributeWithoutParam(2); ObjectTag obj = event.getAttributes().context.contextSource.getContext(contextName); if (obj != null) { event.setReplacedObject(CoreUtilities.autoAttrib(obj, attribute.fulfill(2))); @@ -54,14 +54,14 @@ public void savedEntryTags(ReplaceableTagEvent event) { return; } Attribute attribute = event.getAttributes(); - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return; } if (event.matches("e")) { Deprecations.entryShorthand.warn(event.getScriptEntry()); } if (event.getScriptEntry().getResidingQueue() != null) { - String id = attribute.getContext(1); + String id = attribute.getParam(); ScriptEntry held = event.getScriptEntry().getResidingQueue().getHeldScriptEntry(id); if (held == null) { if (!event.hasAlternative()) { @@ -69,7 +69,7 @@ public void savedEntryTags(ReplaceableTagEvent event) { } } else { - String attrib = CoreUtilities.toLowerCase(attribute.getAttributeWithoutContext(2)); + String attrib = CoreUtilities.toLowerCase(attribute.getAttributeWithoutParam(2)); ObjectTag got = held.getObjectTag(attrib); if (got == null) { if (!event.hasAlternative()) { diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/CustomTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/CustomTagBase.java index 342031bb..ec427e75 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/CustomTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/CustomTagBase.java @@ -15,11 +15,11 @@ public CustomTagBase() { // Refer to <@link ObjectType CustomObjectTag>. // --> TagManager.registerTagHandler(CustomObjectTag.class, "custom_object", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Custom_Object tag base must have input."); return null; } - return CustomObjectTag.valueOf(attribute.getContext(1), attribute.context); + return CustomObjectTag.valueOf(attribute.getParam(), attribute.context); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/DefinitionTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/DefinitionTagBase.java index a3c0290f..c7a7c2c8 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/DefinitionTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/DefinitionTagBase.java @@ -20,11 +20,11 @@ public DefinitionTagBase() { // In most usages, the tag name is left blank, like "<[defhere]>". // --> TagRunnable.BaseInterface defTag = (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { Debug.echoError("Invalid definition tag, no context specified!"); return null; } - String defName = attribute.getContext(1); + String defName = attribute.getParam(); DefinitionProvider definitionProvider = attribute.context.definitionProvider; if (definitionProvider == null) { Debug.echoError("No definitions are provided in this tag's context!"); diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/DurationTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/DurationTagBase.java index 82d3fcfb..56be2291 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/DurationTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/DurationTagBase.java @@ -15,11 +15,11 @@ public DurationTagBase() { // Refer to <@link ObjectType DurationTag>. // --> TagManager.registerTagHandler(DurationTag.class, "duration", (attribute) -> { // non-static because there is a randomized constructor option - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Duration tag base must have input."); return null; } - return DurationTag.valueOf(attribute.getContext(1), attribute.context); + return DurationTag.valueOf(attribute.getParam(), attribute.context); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ElementTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ElementTagBase.java index 325aa8a7..ccf55bdc 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ElementTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ElementTagBase.java @@ -15,11 +15,11 @@ public ElementTagBase() { // Refer to <@link objecttype ElementTag>. // --> TagManager.registerStaticTagBaseHandler(ElementTag.class, "element", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Element tag base must have input."); return null; } - return new ElementTag(attribute.getContext(1)); + return new ElementTag(attribute.getParam()); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ListSingleTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ListSingleTagBase.java index 21f509ee..28471ca2 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ListSingleTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ListSingleTagBase.java @@ -15,12 +15,12 @@ public ListSingleTagBase() { // This is primarily useful for creating lists-within-lists. // --> TagManager.registerStaticTagBaseHandler(ListTag.class, "list_single", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("List_Single tag base must have input."); return null; } ListTag list = new ListTag(); - list.addObject(attribute.getContextObject(1)); + list.addObject(attribute.getParamObject()); return list; }); } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ListTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ListTagBase.java index 723e7ede..2c7d7782 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ListTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ListTagBase.java @@ -16,10 +16,10 @@ public ListTagBase() { // Refer to <@link ObjectType ListTag>. // --> TagManager.registerStaticTagBaseHandler(ListTag.class, "list", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return new ListTag(); } - return ListTag.getListFor(attribute.getContextObject(1), attribute.context); + return ListTag.getListFor(attribute.getParamObject(), attribute.context); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/MapTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/MapTagBase.java index 6a6b25e2..f9ff6cda 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/MapTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/MapTagBase.java @@ -17,10 +17,10 @@ public MapTagBase() { // For example: // --> TagManager.registerStaticTagBaseHandler(MapTag.class, "map", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return new MapTag(); } - return MapTag.getMapFor(attribute.getContextObject(1), attribute.context); + return MapTag.getMapFor(attribute.getParamObject(), attribute.context); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ProcedureScriptTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ProcedureScriptTagBase.java index ca9a86c1..1a3809be 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ProcedureScriptTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ProcedureScriptTagBase.java @@ -39,14 +39,14 @@ public void procedureTag(ReplaceableTagEvent event) { Attribute attribute = event.getAttributes(); ScriptTag script; String path = null; - if (attribute.hasContext(1)) { - if (attribute.getContext(1).indexOf('.') > 0) { - String[] split = attribute.getContext(1).split("\\.", 2); + if (attribute.hasParam()) { + if (attribute.getParam().indexOf('.') > 0) { + String[] split = attribute.getParam().split("\\.", 2); path = split[1]; script = ScriptTag.valueOf(split[0], attribute.context); } else { - script = attribute.contextAsType(1, ScriptTag.class); + script = attribute.paramAsType(ScriptTag.class); } } else { @@ -54,7 +54,7 @@ public void procedureTag(ReplaceableTagEvent event) { return; } if (script == null) { - attribute.echoError("Missing script for procedure script tag '" + attribute.getContext(1) + "'!"); + attribute.echoError("Missing script for procedure script tag '" + attribute.getParam() + "'!"); return; } if (!(script.getContainer() instanceof ProcedureScriptContainer)) { diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/QueueTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/QueueTagBase.java index b53fe321..8b0672b3 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/QueueTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/QueueTagBase.java @@ -57,8 +57,8 @@ public void queueTag(ReplaceableTagEvent event) { return; } // Modern tag: - if (attribute.hasContext(1)) { - QueueTag queue = attribute.contextAsType(1, QueueTag.class); + if (attribute.hasParam()) { + QueueTag queue = attribute.paramAsType(QueueTag.class); if (queue == null) { return; } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/ScriptTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/ScriptTagBase.java index 45ca6f61..6a68b439 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/ScriptTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/ScriptTagBase.java @@ -17,10 +17,10 @@ public ScriptTagBase() { // --> TagManager.registerStaticTagBaseHandler(ScriptTag.class, "script", (attribute) -> { ScriptTag script = null; - if (attribute.hasContext(1)) { - script = attribute.contextAsType(1, ScriptTag.class); + if (attribute.hasParam()) { + script = attribute.paramAsType(ScriptTag.class); if (script == null) { - attribute.echoError("Script '" + attribute.getContext(1) + "' does not exist."); + attribute.echoError("Script '" + attribute.getParam() + "' does not exist."); return null; } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/TernaryTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/TernaryTagBase.java index ce7e616a..2f340a53 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/TernaryTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/TernaryTagBase.java @@ -37,11 +37,11 @@ public void ternaryTag(ReplaceableTagEvent event) { Attribute attribute = event.getAttributes(); // Fallback if nothing to evaluate - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { return; } - String result = attribute.getContext(1); + String result = attribute.getParam(); if (result.equalsIgnoreCase("true")) { ObjectTag passValue; diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/TimeTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/TimeTagBase.java index a3f2e733..2589f88e 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/TimeTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/TimeTagBase.java @@ -15,11 +15,11 @@ public TimeTagBase() { // Refer to <@link ObjectType TimeTag>. // --> TagManager.registerStaticTagBaseHandler(TimeTag.class, "time", (attribute) -> { - if (!attribute.hasContext(1)) { + if (!attribute.hasParam()) { attribute.echoError("Time tag base must have input."); return null; } - return TimeTag.valueOf(attribute.getContext(1), attribute.context); + return TimeTag.valueOf(attribute.getParam(), attribute.context); }); } } diff --git a/src/main/java/com/denizenscript/denizencore/tags/core/UtilTagBase.java b/src/main/java/com/denizenscript/denizencore/tags/core/UtilTagBase.java index 5704a3ff..2eb32047 100644 --- a/src/main/java/com/denizenscript/denizencore/tags/core/UtilTagBase.java +++ b/src/main/java/com/denizenscript/denizencore/tags/core/UtilTagBase.java @@ -51,12 +51,12 @@ public void utilTag(ReplaceableTagEvent event) { // For example: random.int[1].to[3] could return 1, 2, or 3. // --> if (attribute.startsWith("int")) { - String stc = attribute.getContext(1); + String stc = attribute.getParam(); attribute = attribute.fulfill(1); if (attribute.startsWith("to")) { - if (ArgumentHelper.matchesInteger(stc) && ArgumentHelper.matchesInteger(attribute.getContext(1))) { + if (ArgumentHelper.matchesInteger(stc) && ArgumentHelper.matchesInteger(attribute.getParam())) { int min = Integer.parseInt(stc); - int max = attribute.getIntContext(1); + int max = attribute.getIntParam(); // in case the first number is larger than the second, reverse them if (min > max) { @@ -80,13 +80,13 @@ public void utilTag(ReplaceableTagEvent event) { // For example: random.decimal[1].to[2] could return 1.5, 1.75, or a massive number of other options. // --> if (attribute.startsWith("decimal") - && attribute.hasContext(1)) { - String stc = attribute.getContext(1); + && attribute.hasParam()) { + String stc = attribute.getParam(); attribute = attribute.fulfill(1); if (attribute.startsWith("to")) { - if (ArgumentHelper.matchesDouble(stc) && ArgumentHelper.matchesDouble(attribute.getContext(1))) { + if (ArgumentHelper.matchesDouble(stc) && ArgumentHelper.matchesDouble(attribute.getParam())) { double min = Double.parseDouble(stc); - double max = Double.parseDouble(attribute.getContext(1)); + double max = Double.parseDouble(attribute.getParam()); // in case the first number is larger than the second, reverse them if (min > max) { @@ -156,7 +156,7 @@ else if (attribute.startsWith("uuid")) { // --> else if (attribute.startsWith("duuid")) { int size = QueueWordList.FinalWordList.size(); - String id = (attribute.hasContext(1) ? attribute.getContext(1) : "DUUID") + "_" + String id = (attribute.hasParam() ? attribute.getParam() : "DUUID") + "_" + QueueWordList.FinalWordList.get(CoreUtilities.getRandom().nextInt(size)) + QueueWordList.FinalWordList.get(CoreUtilities.getRandom().nextInt(size)) + QueueWordList.FinalWordList.get(CoreUtilities.getRandom().nextInt(size)); @@ -172,8 +172,8 @@ else if (attribute.startsWith("duuid")) { // Note that you should NEVER use this as the input to a "foreach" command. Instead, use "repeat". // In most cases, there's a better way to do what you're trying to accomplish than using this tag. // --> - if (attribute.startsWith("list_numbers_to") && attribute.hasContext(1)) { - int to = attribute.getIntContext(1); + if (attribute.startsWith("list_numbers_to") && attribute.hasParam()) { + int to = attribute.getIntParam(); ListTag result = new ListTag(); for (int i = 1; i <= to; i++) { result.add(String.valueOf(i)); @@ -187,8 +187,8 @@ else if (attribute.startsWith("duuid")) { // @description // Returns a list of the specified size where each entry is blank (zero characters long). // --> - if (attribute.startsWith("empty_list_entries") && attribute.hasContext(1)) { - int to = attribute.getIntContext(1); + if (attribute.startsWith("empty_list_entries") && attribute.hasParam()) { + int to = attribute.getIntParam(); ListTag result = new ListTag(); for (int i = 1; i <= to; i++) { result.add(""); @@ -308,9 +308,9 @@ else if (attribute.startsWith("list_tag_bases")) { event.setReplacedObject(CoreUtilities.autoAttrib(result, attribute.fulfill(1))); } - else if (attribute.matches("time_at") && attribute.hasContext(1)) { + else if (attribute.matches("time_at") && attribute.hasParam()) { Deprecations.timeTagRewrite.warn(attribute.context); - String[] dateComponents = attribute.getContext(1).split(" "); + String[] dateComponents = attribute.getParam().split(" "); String[] ymd = dateComponents[0].split("/"); int year = Integer.parseInt(ymd[0]); int month = Integer.parseInt(ymd[1]) - 1; @@ -407,13 +407,13 @@ else if (attribute.startsWith("formatted_zone")) { } } else if (attribute.startsWith("format") - && attribute.hasContext(1)) { + && attribute.hasParam()) { try { - format.applyPattern(attribute.getContext(1)); + format.applyPattern(attribute.getParam()); event.setReplacedObject(CoreUtilities.autoAttrib(new ElementTag(format.format(currentDate)), attribute.fulfill(1))); } catch (Exception ex) { - Debug.echoError("Error: invalid pattern '" + attribute.getContext(1) + "'"); + Debug.echoError("Error: invalid pattern '" + attribute.getParam() + "'"); Debug.echoError(ex); } } @@ -430,8 +430,8 @@ else if (attribute.startsWith("format") // @description // Parses the input YAML or JSON text into a MapTag. // --> - else if (attribute.matches("parse_yaml") && attribute.hasContext(1)) { - ObjectTag tagForm = CoreUtilities.objectToTagForm(YamlConfiguration.load(attribute.getContext(1)).contents, attribute.context); + else if (attribute.matches("parse_yaml") && attribute.hasParam()) { + ObjectTag tagForm = CoreUtilities.objectToTagForm(YamlConfiguration.load(attribute.getParam()).contents, attribute.context); event.setReplacedObject(CoreUtilities.autoAttrib(tagForm, attribute.fulfill(1))); } diff --git a/src/main/java/com/denizenscript/denizencore/utilities/CoreUtilities.java b/src/main/java/com/denizenscript/denizencore/utilities/CoreUtilities.java index ec362127..4ee4fe47 100644 --- a/src/main/java/com/denizenscript/denizencore/utilities/CoreUtilities.java +++ b/src/main/java/com/denizenscript/denizencore/utilities/CoreUtilities.java @@ -259,13 +259,13 @@ public static ObjectTag autoPropertyTagObject(ObjectTag object, Attribute attrib if (properties == null) { return null; } - String tagName = attribute.getAttributeWithoutContext(1); + String tagName = attribute.getAttributeWithoutParam(1); PropertyParser.PropertyGetter specificGetter = properties.propertiesByTag.get(tagName); if (specificGetter != null) { Property prop = specificGetter.get(object); if (prop == null) { String propName = properties.propertyNamesByTag.get(tagName); - attribute.seemingSuccesses.add(attribute.getAttributeWithoutContext(1) + " - property " + propName + " matched, but is not valid for the object."); + attribute.seemingSuccesses.add(attribute.getAttributeWithoutParam(1) + " - property " + propName + " matched, but is not valid for the object."); return null; } return prop.getObjectAttribute(attribute); diff --git a/src/main/java/com/denizenscript/denizencore/utilities/codegen/TagCodeGenerator.java b/src/main/java/com/denizenscript/denizencore/utilities/codegen/TagCodeGenerator.java index 3afd39ce..d11f01fe 100644 --- a/src/main/java/com/denizenscript/denizencore/utilities/codegen/TagCodeGenerator.java +++ b/src/main/java/com/denizenscript/denizencore/utilities/codegen/TagCodeGenerator.java @@ -16,16 +16,16 @@ public class TagCodeGenerator { public static String FULFILL_ONE_RUN_DESCRIPTOR = "(L" + CodeGenUtil.OBJECT_TAG_PATH + ";)V"; public static boolean hasStaticContext(Attribute.AttributeComponent component, TagContext genContext) { - if (component.context == null) { + if (component.rawParam == null) { return true; } - if (component.contextParsed == null) { - component.contextParsed = TagManager.parseTextToTag(component.context, genContext); - if (component.contextParsed == null) { + if (component.paramParsed == null) { + component.paramParsed = TagManager.parseTextToTag(component.rawParam, genContext); + if (component.paramParsed == null) { return false; } } - return !component.contextParsed.hasTag; + return !component.paramParsed.hasTag; } public static TagRunnable.BaseInterface generatePartialTag(TagManager.ParseableTagPiece toParse, TagContext genContext) {