Joins the elements of the provided array into a single Text - * containing the provided list of elements.
- * - *No delimiter is added before or after the list. - * Null objects or empty strings within the array are represented by - * empty strings.
- * - *- * StringUtils.join(null, *) = null - * StringUtils.join([], *) = "" - * StringUtils.join([null], *) = "" - * StringUtils.join(["a", "b", "c"], ';') = "a;b;c" - * StringUtils.join(["a", "b", "c"], null) = "abc" - * StringUtils.join([null, "", "a"], ';') = ";;a" - *- * - * @param array the array of values to join together, may be null - * @param separator the separator character to use - * @return the joined String,
null
if null array input
- * @since 2.0
- */
- public static Text join(Text[] array, Text separator) {
+
+ public static MutableText deepCopy(Text text) {
+ if (text.getSiblings().isEmpty()) {
+ return text.copy();
+ }
+
+ var siblings = text.getSiblings();
+ var newSiblings = siblings.stream()
+ .map(TextUtil::deepCopy)
+ .toList();
+ siblings.clear();
+ siblings.addAll(newSiblings);
+ return text.copy();
+ }
+
+ /**
+ * Joins the elements of the provided array into a single Text + * containing the provided list of elements.
+ * + *No delimiter is added before or after the list. + * Null objects or empty strings within the array are represented by + * empty strings.
+ * + *+ * StringUtils.join(null, *) = null + * StringUtils.join([], *) = "" + * StringUtils.join([null], *) = "" + * StringUtils.join(["a", "b", "c"], ';') = "a;b;c" + * StringUtils.join(["a", "b", "c"], null) = "abc" + * StringUtils.join([null, "", "a"], ';') = ";;a" + *+ * + * @param array the array of values to join together, may be null + * @param separator the separator character to use + * @return the joined String,
null
if null array input
+ * @since 2.0
+ */
+ public static MutableText join(Text[] array, Text separator) {
if (array == null) {
- return null;
- }
+ return null;
+ }
return join(array, separator, 0, array.length);
}
- public static Text join(Collection* Heavily referenced from * https://github.com/javachaos/randomteleport/blob/master/src/main/java/net.ethermod/commands/RandomTeleportCommand.java + *
+ *+ * Additionally, tons of optimization tips & examples provided by @Wesley1808 on GitHub: + * https://github.com/Wesley1808/ServerCore/issues/16 + *
*/ - +@SuppressWarnings("checkstyle:all") public class RandomTeleportCommand implements Command