DiscordSRV

DiscordSRV

86.8k Downloads

doNotSendActsAsWhitelist not works properly as expected

shikendon opened this issue ยท 2 comments

commented

boolean doNotSendActsAsWhitelist = DiscordSRV.config().getBoolean("DiscordConsoleChannelDoNotSendPhrasesActsAsWhitelist");
for (String phrase : DiscordSRV.config().getStringList("DiscordConsoleChannelDoNotSendPhrases"))
if (line.contains(phrase) == !doNotSendActsAsWhitelist) return;

In whitelist case, it means the line need to contain all phrases of the array.

Example:

Boolean doNotSendActsAsWhitelist = true;
String line = "shikendon lost connection: Timed out";
String[] phrases = new String[]{"Timed out", "Whatever"};

for (String phrase : phrases)
    if (line.contains(phrase) == !doNotSendActsAsWhitelist) return;
System.out.println(line); // Unreachable

Expected:

// import java.util.Arrays;

Boolean doNotSendActsAsWhitelist = true;
String line = "shikendon lost connection: Timed out";
String[] phrases = new String[]{"Timed out", "Whatever"};

if (Arrays.stream(phrases).parallel().anyMatch(line::contains) == !doNotSendActsAsWhitelist) return;

System.out.println(line); // shikendon lost connection: Timed out

Message should be send when line contains any phrases of whitelist.

commented

merged with v1.16.5

commented

You can make a PR for this if you want but DiscordSRV v1 isnโ€™t under active development anymore.