aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-02-15 15:23:50 +0000
committerolim <bobq4582@gmail.com>2024-02-15 15:23:50 +0000
commit4d0d772537648d424631a1a932780601a642b1a5 (patch)
tree9bb9cef55fd1daf3a651f5c50d6159c2fa252f53 /src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
parentb9aeadfc2fe33b60555f978c82bef0294286e92a (diff)
downloadSkyblocker-4d0d772537648d424631a1a932780601a642b1a5.tar.gz
Skyblocker-4d0d772537648d424631a1a932780601a642b1a5.tar.bz2
Skyblocker-4d0d772537648d424631a1a932780601a642b1a5.zip
make the rules acutaly work
now scans each chat message with the rules to see if they match
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
index e212b2a0..afc409ac 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
@@ -20,6 +20,7 @@ public class ChatRule {
public Boolean enabled;
public Boolean isPartialMatch;
public Boolean isRegex;
+ public Boolean isIgnoreCase;
public String filter;
public LocationOption validLocation;
@@ -38,6 +39,7 @@ public class ChatRule {
this.enabled = true;
this.isPartialMatch = false;
this.isRegex = false;
+ this.isIgnoreCase = true;
this.filter = "";
this.validLocation = LocationOption.None;
@@ -49,11 +51,12 @@ public class ChatRule {
}
- public ChatRule(String name, Boolean enabled, Boolean isPartialMatch, Boolean isRegex, String filter, LocationOption validLocation, List<ItemStack> validItems, Boolean hideMessage, Boolean showActionBar, Boolean showAnnouncement, String replaceMessage, Sound customSound) {
+ public ChatRule(String name, Boolean enabled, Boolean isPartialMatch, Boolean isRegex, Boolean isIgnoreCase, String filter, LocationOption validLocation, List<ItemStack> validItems, Boolean hideMessage, Boolean showActionBar, Boolean showAnnouncement, String replaceMessage, Sound customSound) {
this.name = name;
this.enabled = enabled;
this.isPartialMatch = isPartialMatch;
this.isRegex = isRegex;
+ this.isIgnoreCase = isIgnoreCase;
this.filter = filter;
this.validLocation = validLocation;
this.hideMessage = hideMessage;
@@ -147,26 +150,37 @@ public class ChatRule {
/**
* checks every input option and if the games state and the inputted str matches them returns true.
- * @param str the chat message to check if fits
+ * @param inputString the chat message to check if fits
* @return if the inputs are all true and the outputs should be performed
*/
- public Boolean isMatch(String str, MinecraftClient client){
+ public Boolean isMatch(String inputString){
//enabled
if (!enabled) return false;
+ //ignore case
+ String testString;
+ String testFilter;
+ if (isIgnoreCase){
+ testString = inputString.toLowerCase();
+ testFilter = filter.toLowerCase();
+ }else {
+ testString = inputString;
+ testFilter = filter;
+ }
+
//filter
- if (filter.isEmpty()) return false;
+ if (testFilter.isEmpty()) return false;
if(isRegex) {
if (isPartialMatch) {
- if (! Pattern.compile(filter).matcher(str).find()) return false;
+ if (! Pattern.compile(testFilter).matcher(testString).find()) return false;
}else {
- if (!str.matches(filter)) return false;
+ if (!testString.matches(testFilter)) return false;
}
} else{
if (isPartialMatch) {
- if (!str.contains(filter)) return false;
+ if (!testString.contains(testFilter)) return false;
}else {
- if (!filter.equals(str)) return false;
+ if (!testFilter.equals(testString)) return false;
}
}