Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Colors #7276

Open
wants to merge 13 commits into
base: dev/feature
Choose a base branch
from
Prev Previous commit
Next Next commit
Requested Changes
  • Loading branch information
TheAbsolutionism committed Dec 26, 2024
commit a66af3f9710f7e217cd36c8dacc41cbea7380fde
11 changes: 3 additions & 8 deletions src/main/java/ch/njol/skript/expressions/ExprStringColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.SyntaxStringBuilder;
import ch.njol.skript.util.Color;
import ch.njol.skript.util.ColorRGB;
import ch.njol.skript.util.SkriptColor;
import ch.njol.util.Kleenean;
import ch.njol.util.coll.CollectionUtils;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -71,13 +71,8 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
}

@Override
public Class<Object> getReturnType() {
return Object.class;
}

@Override
public Class<?>[] possibleReturnTypes() {
return CollectionUtils.array(String.class, SkriptColor.class, ColorRGB.class);
TheAbsolutionism marked this conversation as resolved.
Show resolved Hide resolved
public Class<?> getReturnType() {
return getCodes ? String.class : Color.class;
}

@Override
Expand Down
17 changes: 12 additions & 5 deletions src/test/skript/tests/syntaxes/expressions/ExprStringColors.sk
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
test "string colors":
set {_colors::*} to "&a", "&b", "&c", "<#ff0000>", "<#03d7fc>" and "<#48ff05>"
set {_string} to join {_colors::*}
set {_colorcodes::*} to "&a", "&b", "&c", "<#ff0000>", "<#03d7fc>" and "<#48ff05>"
set {_colors::*} to light green, light cyan, pink, rgb(255, 0, 0), rgb(3, 215, 252) and rgb(72, 255, 5)
set {_string} to join {_colorcodes::*}

loop the string color codes of {_string}:
assert {_colors::*} contains loop-value with "Unexpected Color"
assert {_colorcodes::*} contains loop-value with "Unexpected Color Code"

assert the first string color code of {_string} is {_colors::1} with "First string color does not match"
assert the last string color code of {_string} is {_colors::6} with "Last string color does not match"
assert the first string color code of {_string} is {_colorcodes::1} with "First string color code does not match"
assert the last string color code of {_string} is {_colorcodes::6} with "Last string color code does not match"

loop the string colors of {_string}:
assert {_colors::*} contains loop-value with "Unexpected Color: %loop-value%"

assert the first string color of {_string} is {_colors::1} with "First string color does not match"
assert the last string color of {_string} is {_colors::6} with "Last string color does not match"
Loading