Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ch.njol.util.coll.CollectionUtils;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.chat.BaseComponent;
import java.util.Arrays;

@Name("Text Of")
@Description({
Expand Down Expand Up @@ -53,14 +54,14 @@ public class ExprTextOf extends SimplePropertyExpression<Object, String> {
public Class<?> @Nullable [] acceptChange(ChangeMode mode) {
return switch (mode) {
case RESET -> CollectionUtils.array();
case SET -> CollectionUtils.array(String.class);
case SET -> CollectionUtils.array(String[].class);
default -> null;
};
}

@Override
public void change(Event event, Object @Nullable [] delta, ChangeMode mode) {
String value = delta == null ? null : (String) delta[0];
String value = delta == null ? null : String.join("\n", Arrays.copyOf(delta, delta.length, String[].class));
for (Object object : getExpr().getArray(event)) {
if (!(object instanceof TextDisplay textDisplay))
continue;
Expand Down
11 changes: 11 additions & 0 deletions src/test/skript/tests/syntaxes/expressions/ExprTextOf.sk
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ test "text of text displays":
assert text of {_td} is "" with "failed to reset text"

delete entity within {_td}
spawn text display at test-location:
set {_multilineTest} to entity
set text of {_multilineTest} to "test", "testing" and "hello!!!"
assert text of {_multilineTest} is "test%nl%testing%nl%hello!!!" with "multiple lines with list1 set"
set {_line::1} to "hi!"
set {_line::2} to "i am"
set {_line::3} to "skripting..."
set text of {_multilineTest} to {_line::*}
assert text of {_multilineTest} is "hi!%nl%i am%nl%skripting..." with "multiple lines with list2 set"

delete entity within {_multilineTest}