diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-30 17:59:50 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-30 17:59:50 -0400 |
commit | 88ff7afb7e6ab60f384e571d378b76f52ed3dfbd (patch) | |
tree | c16612751b621064b434922945820cc6cea794f7 /src/test/java | |
parent | 4fe76a3341356390fa5a4012c83062ca00bd5635 (diff) | |
download | Skyblocker-88ff7afb7e6ab60f384e571d378b76f52ed3dfbd.tar.gz Skyblocker-88ff7afb7e6ab60f384e571d378b76f52ed3dfbd.tar.bz2 Skyblocker-88ff7afb7e6ab60f384e571d378b76f52ed3dfbd.zip |
Make filters ignore formatting codes
The formatting codes caused a mess in longer regexes and are fragile if
Hypixel changes them or moves fully to Text components. Hypixel also
added emblems that display in dark purple and light blue which were
obviously incompatible due to the hardcoded formatting codes.
Diffstat (limited to 'src/test/java')
3 files changed, 57 insertions, 10 deletions
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/filters/AdFilterTest.java b/src/test/java/de/hysky/skyblocker/skyblock/filters/AdFilterTest.java index 3eec1cd9..9f788cac 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/filters/AdFilterTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/filters/AdFilterTest.java @@ -15,47 +15,47 @@ class AdFilterTest extends ChatPatternListenerTest<AdFilter> { @Test void noRank() { - assertMatches("§8[§a86§8] §7Advertiser§7: advertisement"); + assertMatches("[86] Advertiser: advertisement"); } @Test void vip() { - assertMatches("§8[§b280§8] §a[VIP] Advertiser§f: advertisement"); + assertMatches("[280] [VIP] Advertiser: advertisement"); } @Test void mvp() { - assertMatches("§8[§d256§8] §6§l⚡ §b[MVP§c+§b] Advertiser§f: advertisement"); + assertMatches("[256] ⚡ [MVP+] Advertiser: advertisement"); } @Test void plusPlus() { - assertMatches("§8[§6222§8] §6[MVP§c++§6] Advertiser§f: advertisement"); + assertMatches("[222] [MVP++] Advertiser: advertisement"); } @Test void capturesMessage() { - assertGroup("§8[§c325§8] §b[MVP§c+§b] b2dderr§f: buying prismapump", 2, "buying prismapump"); + assertGroup("[325] [MVP+] b2dderr: buying prismapump", 2, "buying prismapump"); } @Test void simpleAd() { - assertFilters("§8[§e320§8] §b[MVP§c+§b] b2dderr§f: buying prismapump"); + assertFilters("[320] [MVP+] b2dderr: buying prismapump"); } @Test void uppercaseAd() { - assertFilters("§8[§f70§8] §a[VIP] Tecnoisnoob§f: SELLING REJUVENATE 5 Book on ah!"); + assertFilters("[70] [VIP] Tecnoisnoob: SELLING REJUVENATE 5 Book on ah!"); } @Test void characterSpam() { - assertFilters("§8[§9144§8] §a[VIP] Benyyy_§f: Hey, Visit my Island, i spent lots of time to build it! I also made donate room! <<<<<<<<<<<<<<<<<<<"); + assertFilters("[144] [VIP] Benyyy_: Hey, Visit my Island, i spent lots of time to build it! I also made donate room! <<<<<<<<<<<<<<<<<<<"); } @Test void notAd() { - Matcher matcher = listener.pattern.matcher("§8[§6200§8] §a[VIP] NotMatching§f: This message shouldn't match!"); + Matcher matcher = listener.pattern.matcher("[200] [VIP] NotMatching: This message shouldn't match!"); assertTrue(matcher.matches()); assertFalse(listener.onMatch(null, matcher)); } diff --git a/src/test/java/de/hysky/skyblocker/skyblock/filters/AutopetFilterTest.java b/src/test/java/de/hysky/skyblocker/skyblock/filters/AutopetFilterTest.java index 846acbb8..0e578082 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/filters/AutopetFilterTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/filters/AutopetFilterTest.java @@ -10,6 +10,6 @@ class AutopetFilterTest extends ChatPatternListenerTest<AutopetFilter> { @Test void testAutopet() { - assertMatches("§cAutopet §eequipped your §7[Lvl 85] §6Tiger§e! §a§lVIEW RULE"); + assertMatches("Autopet equipped your [Lvl 85] Tiger! VIEW RULE"); } }
\ No newline at end of file diff --git a/src/test/java/de/hysky/skyblocker/skyblock/filters/ShowOffFilterTest.java b/src/test/java/de/hysky/skyblocker/skyblock/filters/ShowOffFilterTest.java new file mode 100644 index 00000000..d510274c --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/filters/ShowOffFilterTest.java @@ -0,0 +1,47 @@ +package de.hysky.skyblocker.skyblock.filters; + +import org.junit.jupiter.api.Test; + +import de.hysky.skyblocker.utils.chat.ChatPatternListenerTest; + +public class ShowOffFilterTest extends ChatPatternListenerTest<ShowOffFilter> { + + public ShowOffFilterTest() { + super(new ShowOffFilter()); + } + + @Test + void holding() { + assertMatches("[290] ⚡ [MVP+] Player is holding [Withered Dark Claymore ✪✪✪✪✪➎]"); + } + + @Test + void wearing() { + assertMatches("[290] ⚡ [MVP+] Player is wearing [Ancient Storm's Chestplate ✪✪✪✪✪➎]"); + } + + @Test + void isFriendsWith() { + assertMatches("[290] [MVP+] Player is friends with a [[Lvl 200] Golden Dragon]"); + } + + @Test + void has() { + assertMatches("[290] ⚡ [MVP+] Player has [Withered Hyperion ✪✪✪✪✪]"); + } + + @Test + void noLevelOrEmblem() { + assertMatches("[MVP+] Player is holding [Mithril Drill SX-R226]"); + } + + @Test + void noRank() { + assertMatches("[290] ⚡ Player is holding [Oak Leaves]"); + } + + @Test + void noLevelOrEmblemOrRank() { + assertMatches("Player is holding [Nether Star]"); + } +} |