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

Commit

Permalink
add ampersand color helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 9, 2018
1 parent 99aefe3 commit cc8f50a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -15,6 +15,7 @@ public class AmpersandTagBase extends AbstractTagBase {
// @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.
// @Note You can use an empty input modifier - like <&[]> - to get the raw color code symbol.
// -->

@Override
Expand All @@ -29,6 +30,9 @@ public AbstractTagObject handle(TagData data) {
return null;
}
String c = data.getNextModifier().toString();
if (c.length() == 0) {
return new TextTag(String.valueOf(Denizen2Sponge.colorChar)).handle(data.shrink());
}
StringBuilder res = new StringBuilder(c.length() * 2);
for (int i = 0; i < c.length(); i++) {
String sub = c.substring(i, i + 1);
Expand Down
Expand Up @@ -61,6 +61,16 @@ public String getName() {
handlers.put("for_old_colors", (dat, obj) -> new FormattedTextTag(
TextSerializers.formattingCode(Denizen2Sponge.colorChar).deserialize((dat.getNextModifier().toString()))));
// <--[tag]
// @Since 0.5.0
// @Name TextsBaseTag.for_ampersand_colors[<TextTag>]
// @Updated 2018/06/09
// @Group Text Formatting
// @ReturnType FormattedTextTag
// @Returns the ampersand colored text as a FormattedTextTag.
// -->
handlers.put("for_ampersand_colors", (dat, obj) -> new FormattedTextTag(
TextSerializers.formattingCode('&').deserialize((dat.getNextModifier().toString()))));
// <--[tag]
// @Since 0.3.0
// @Name TextsBaseTag.for_input[<MapTag>]
// @Updated 2016/09/21
Expand Down

0 comments on commit cc8f50a

Please sign in to comment.