Make .replace require a TextReplacementConfig
This commit is contained in:
@@ -87,7 +87,12 @@ public class ChatFilter {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String group = matcher.group(); // todo debug
|
String group = matcher.group(); // todo debug
|
||||||
if (getExclusions().stream().noneMatch(s -> s.equalsIgnoreCase(group))) { // idk how heavy this is:/
|
if (getExclusions().stream().noneMatch(s -> s.equalsIgnoreCase(group))) { // idk how heavy this is:/
|
||||||
modifiableString.replace(group, getReplacement());
|
modifiableString.replace(
|
||||||
|
TextReplacementConfig.builder()
|
||||||
|
.matchLiteral(group)
|
||||||
|
.replacement(getReplacement())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +108,10 @@ public class ChatFilter {
|
|||||||
Matcher matcher = pattern.matcher(input);
|
Matcher matcher = pattern.matcher(input);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String group = matcher.group();
|
String group = matcher.group();
|
||||||
modifiableString.replace(group, group.substring(0, length));
|
modifiableString.replace(TextReplacementConfig.builder()
|
||||||
|
.matchLiteral(group)
|
||||||
|
.replacement(group.substring(0, length))
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,40 +19,8 @@ public class ModifiableString {
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(String match, String replace) {
|
public void replace(TextReplacementConfig textReplacementConfig) {
|
||||||
text = text
|
text = text.replaceText(textReplacementConfig);
|
||||||
.replaceText(
|
|
||||||
TextReplacementConfig.builder()
|
|
||||||
.matchLiteral(match)
|
|
||||||
.replacement(replace)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replace(Pattern match, String replace) {
|
|
||||||
text = text
|
|
||||||
.replaceText(
|
|
||||||
TextReplacementConfig.builder()
|
|
||||||
.match(match)
|
|
||||||
.replacement(replace)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replace(@RegExp String match, Component replace) {
|
|
||||||
text = text
|
|
||||||
.replaceText(
|
|
||||||
TextReplacementConfig.builder()
|
|
||||||
.matchLiteral(match)
|
|
||||||
.replacement(replace)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replace(Pattern match, Component replace) {
|
|
||||||
text = text
|
|
||||||
.replaceText(
|
|
||||||
TextReplacementConfig.builder()
|
|
||||||
.match(match)
|
|
||||||
.replacement(replace)
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String string() {
|
public String string() {
|
||||||
|
|||||||
Reference in New Issue
Block a user