Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Improve color tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 29, 2016
1 parent 8feac11 commit 906a203
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -4,7 +4,6 @@
import com.denizenscript.denizen2core.tags.AbstractTagObject;
import com.denizenscript.denizen2core.tags.TagData;
import com.denizenscript.denizen2core.tags.objects.TextTag;
import com.denizenscript.denizen2core.utilities.CoreUtilities;
import com.denizenscript.denizen2sponge.Denizen2Sponge;

public class ColorTagBase extends AbstractTagBase {
Expand All @@ -14,6 +13,7 @@ public class ColorTagBase extends AbstractTagBase {
// @Group Sponge Helper Types
// @ReturnType TextTag
// @Returns the color code corresponding to the given symbol. Valid symbols: 0123456789 abcdef klmno r
// @Note This also supports combinations of color codes, EG "1o" for oblong text with color 1.
// -->

@Override
Expand All @@ -24,9 +24,14 @@ public String getName() {
@Override
public AbstractTagObject handle(TagData data) {
String c = data.getNextModifier().toString();
if (!"0123456789abcdefklmnorABCDEFKLMNOR".contains(c)) {
data.error.run("Invalid color code specified!");
StringBuilder res = new StringBuilder(c.length() * 2);
for (int i = 0; i < c.length(); i++) {
String sub = c.substring(i, i + 1);
if (!"0123456789abcdefklmnorABCDEFKLMNOR".contains(sub)) {
data.error.run("Invalid color code specified: " + sub);
}
res.append(Denizen2Sponge.colorChar).append(sub);
}
return new TextTag(Denizen2Sponge.colorChar + c).handle(data.shrink());
return new TextTag(res.toString()).handle(data.shrink());
}
}
Expand Up @@ -90,7 +90,7 @@ public boolean contains(UtilLocation point) {
// @Group Connected Information
// @ReturnType ListTag
// @Returns the location of all block locations in this cuboid. Optionally, specify a list of BlockType's to use.
// @Note that partially covered blocks are counted.
// @Note Partially covered blocks are counted.
// @Example "0,1,2,world" .world returns "world".
// -->
handlers.put("block_locations", (dat, obj) -> {
Expand Down

0 comments on commit 906a203

Please sign in to comment.