-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a tags configuration with a new system for checking colors and …
…gradients
- Loading branch information
1 parent
9cd6c45
commit 3a9fead
Showing
16 changed files
with
354 additions
and
36 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
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
35 changes: 35 additions & 0 deletions
35
HypeGradients-API/src/test/java/me/doublenico/hypegradients/api/chat/ChatGradientTest.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,35 @@ | ||
package me.doublenico.hypegradients.api.chat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ChatGradientTest { | ||
|
||
@Test | ||
void testFirstRegexCase() { | ||
String regex = ".+?((?:(?=#[a-fA-F\\d]{6}[;\\]].)#[a-fA-F\\d]{6}[^\\]]?)+)](.+?)\\[\\/gradient\\]"; | ||
String test = "[gradient:#ff0000;#00ff00;#0000ff]Hello World![/gradient]"; | ||
assertTrue(test.matches(regex)); | ||
} | ||
|
||
@Test | ||
void testSecondRegexCase() { | ||
String regex = ".+?((?:(?=#[a-fA-F\\d]{6}[;\\}].)#[a-fA-F\\d]{6}[^\\}]?)+)}(.+?)\\{\\/beep\\}"; | ||
String test = "{beep:#ff0000;#00ff00;#0000ff}Hello World!{/beep}"; | ||
assertTrue(test.matches(regex)); | ||
} | ||
|
||
@Test | ||
void testThirdRegexCase() { | ||
String prefix = "<gradient:"; | ||
String prefixEnd = "]"; | ||
String separator = ";"; | ||
String suffix = "<\\/gradient>"; | ||
String regex = prefix + "((?:(?=#[a-fA-F\\d]{6}[" + separator + "\\" + prefixEnd + "].)#[a-fA-F\\d]{6}[^\\" + prefixEnd + "]?)+)" + prefixEnd + "(.+?)" + suffix; | ||
String test = "<gradient:#ff0000;#00ff00;#0000ff]Hello World!</gradient>"; | ||
assertTrue(test.matches(regex)); | ||
} | ||
|
||
|
||
} |
106 changes: 106 additions & 0 deletions
106
HypeGradients-API/src/test/java/me/doublenico/hypegradients/api/chat/ColorChatTest.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,106 @@ | ||
package me.doublenico.hypegradients.api.chat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class ColorChatTest { | ||
|
||
@Test | ||
void testFirstChatTag() { | ||
String message = "<red>"; | ||
String tag = message.replace("<", "").replace(">", ""); | ||
assertEquals("red", tag); | ||
} | ||
|
||
@Test | ||
void testSecondChatTag() { | ||
String message = "<red>"; | ||
String hex = "#ff0000"; | ||
String tag = message.replace("<", "").replace(">", "").replace("red", hex); | ||
assertEquals("#ff0000", tag); | ||
} | ||
|
||
@Test | ||
void testThirdChatTag() { | ||
String message = "<color:red>"; | ||
String hex = "#ff0000"; | ||
String tag = message.replace("<color:", "").replace(">", "").replace("red", hex); | ||
assertEquals("#ff0000", tag); | ||
} | ||
|
||
@Test | ||
void testFourthChatTag() { | ||
String message = "<color:red>"; | ||
String prefix = "<color:"; | ||
String suffix = ">"; | ||
String hex = "#ff0000"; | ||
String tag = message.replace(prefix, "").replace(suffix, "").replace("red", hex); | ||
assertEquals("#ff0000", tag); | ||
} | ||
|
||
@Test | ||
void testFifthChatTag() { | ||
String message = "~red"; | ||
String prefix = "~"; | ||
String suffix = ""; | ||
String hex = "#ff0000"; | ||
String tag = message.replace(prefix, "").replace(suffix, "").replace("red", hex); | ||
assertEquals("#ff0000", tag); | ||
} | ||
|
||
@Test | ||
void testSixthChatTag() { | ||
String configValue = "<%tag%>"; | ||
String message = configValue.replace("%tag%", "red"); | ||
String prefix = message.substring(0, 1); | ||
String suffix = message.substring(message.length() - 1); | ||
String tag = message.replace(prefix, "").replace(suffix, ""); | ||
assertEquals("red", tag); | ||
} | ||
|
||
@Test | ||
void testSeventhChatTag() { | ||
String message = "[color:%tag%]"; | ||
String tag = "%tag%"; | ||
String regexPattern = "(.*)\\" + tag + "(.*)"; | ||
|
||
Pattern pattern = Pattern.compile(regexPattern); | ||
|
||
Matcher matcher = pattern.matcher(message); | ||
|
||
if (matcher.find()) { | ||
String prefix = matcher.group(1); | ||
String suffix = matcher.group(2); | ||
|
||
assertEquals("[color:", prefix); | ||
assertEquals("]", suffix); | ||
return; | ||
} | ||
System.out.println("No match found"); | ||
} | ||
|
||
@Test | ||
void testEighthColorTag() { | ||
String message = "[%tag%]"; | ||
String tag = "%tag%"; | ||
String regexPattern = "(.*)" + tag + "(.*)"; | ||
|
||
Pattern pattern = Pattern.compile(regexPattern); | ||
|
||
Matcher matcher = pattern.matcher(message); | ||
|
||
if (matcher.find()) { | ||
String prefix = matcher.group(1); | ||
String suffix = matcher.group(2); | ||
|
||
assertEquals("[", prefix); | ||
assertEquals("]", suffix); | ||
return; | ||
} | ||
System.out.println("No match found"); | ||
} | ||
} |
Oops, something went wrong.