Skip to content

Commit 7f6e3b9

Browse files
author
boiscljo
committed
Fix autoformatting and add testing
1 parent 37f470c commit 7f6e3b9

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

src/main/java/com/iridium/iridiumcolorapi/IridiumColorAPI.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class IridiumColorAPI {
3535
*/
3636
private static final boolean SUPPORTS_RGB = VERSION >= 16;
3737

38-
private static final List<String> SPECIAL_COLORS = Arrays.asList("&l", "&n", "&o", "&k", "&m", "§l", "§n", "§o",
39-
"§k", "§m");
38+
private static final List<String> SPECIAL_COLORS = Arrays.asList("&l", "&n", "&o", "&k", "&m", "§l", "§n", "§o", "§k", "§m");
4039

4140
/**
4241
* Cached result of all legacy colors.
@@ -66,8 +65,7 @@ public class IridiumColorAPI {
6665
*
6766
* @since 1.0.2
6867
*/
69-
private static final List<Pattern> PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(),
70-
new RainbowPattern());
68+
private static final List<Pattern> PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern());
7169

7270
/**
7371
* Processes a string to add color to it.
@@ -250,8 +248,7 @@ private static ChatColor[] createGradient(@Nonnull Color start, @Nonnull Color e
250248
};
251249

252250
for (int i = 0; i < step; i++) {
253-
Color color = new Color(start.getRed() + ((stepR * i) * direction[0]),
254-
start.getGreen() + ((stepG * i) * direction[1]), start.getBlue() + ((stepB * i) * direction[2]));
251+
Color color = new Color(start.getRed() + ((stepR * i) * direction[0]), start.getGreen() + ((stepG * i) * direction[1]), start.getBlue() + ((stepB * i) * direction[2]));
255252
if (SUPPORTS_RGB) {
256253
colors[i] = ChatColor.of(color);
257254
} else {
@@ -274,9 +271,7 @@ private static ChatColor getClosestColor(Color color) {
274271
double nearestDistance = Integer.MAX_VALUE;
275272

276273
for (Color constantColor : COLORS.keySet()) {
277-
double distance = Math.pow(color.getRed() - constantColor.getRed(), 2)
278-
+ Math.pow(color.getGreen() - constantColor.getGreen(), 2)
279-
+ Math.pow(color.getBlue() - constantColor.getBlue(), 2);
274+
double distance = Math.pow(color.getRed() - constantColor.getRed(), 2) + Math.pow(color.getGreen() - constantColor.getGreen(), 2) + Math.pow(color.getBlue() - constantColor.getBlue(), 2);
280275
if (nearestDistance > distance) {
281276
nearestColor = constantColor;
282277
nearestDistance = distance;
@@ -308,8 +303,7 @@ private static int getVersion() {
308303

309304
// 1.13.2, 1.14.4, etc...
310305
int lastDot = version.lastIndexOf('.');
311-
if (version.indexOf('.') != lastDot)
312-
version = version.substring(0, lastDot);
306+
if (version.indexOf('.') != lastDot) version = version.substring(0, lastDot);
313307

314308
return Integer.parseInt(version.substring(2));
315309
}

src/test/java/com/iridium/iridiumcolorapi/IridiumColorAPITest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static void setup() {
2626
@Test
2727
void process() {
2828
assertEquals("§x§1§2§3§4§5§6Test", IridiumColorAPI.process("<SOLID:123456>Test"));
29+
assertEquals("§x§1§2§3§4§5§6Te§kst", IridiumColorAPI.process("<SOLID:123456>Te&kst"));
2930
assertEquals("§x§2§c§0§8§b§a§lT§x§1§e§3§3§a§f§le§x§1§0§5§e§a§4§ls§x§0§2§8§9§9§9§lt", IridiumColorAPI.process("<GRADIENT:2C08BA>&lTest</GRADIENT:028A97>"));
3031
assertEquals("§x§f§f§0§0§0§0§lT§x§8§0§f§f§0§0§le§x§0§0§f§f§f§f§ls§x§8§0§0§0§f§f§lt", IridiumColorAPI.process("<RAINBOW1>&lTest</RAINBOW>"));
3132
assertEquals("§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*§x§1§2§3§4§5§6*", IridiumColorAPI.process("<GRADIENT:123456>******************************************************************************************************************************************************************************************************</GRADIENT:ABCDEF>"));

0 commit comments

Comments
 (0)