-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/io/github/divios/jtext/parsers/legacyColorParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.divios.jtext.parsers; | ||
|
||
import net.md_5.bungee.api.ChatColor; | ||
|
||
public class legacyColorParser { | ||
|
||
public String parse(String s) { | ||
return ChatColor.translateAlternateColorCodes('&', s); | ||
} | ||
|
||
public String unparse(String s) { | ||
char[] array = s.toCharArray(); | ||
for (int i = 0; i < array.length - 1; i++) { | ||
if (array[i] == ChatColor.COLOR_CHAR && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(array[i + 1]) != -1) { | ||
array[i] = '&'; | ||
array[i + 1] = Character.toLowerCase(array[i + 1]); | ||
} | ||
} | ||
return new String(array); | ||
} | ||
|
||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/io/github/divios/jtext/parsers/legacyColorsParser.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package parsers; | ||
|
||
import io.github.divios.jtext.parsers.legacyColorParser; | ||
import org.bukkit.ChatColor; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class legacyColorParserText { | ||
|
||
@Test | ||
public void testParse() { | ||
String toParse = "&7Hello"; | ||
String parsed = new legacyColorParser().parse(toParse); | ||
String expected = ChatColor.COLOR_CHAR + "7Hello"; | ||
|
||
Assert.assertEquals(expected, parsed); | ||
} | ||
|
||
@Test | ||
public void testUnParse() { | ||
String toParse = ChatColor.COLOR_CHAR + "7Hello"; | ||
String parsed = new legacyColorParser().unparse(toParse); | ||
String expected = "&7Hello"; | ||
|
||
Assert.assertEquals(expected, parsed); | ||
} | ||
|
||
} |