Make .replace require a TextReplacementConfig
This commit is contained in:
parent
5b06049265
commit
7ef9b4a64a
|
|
@ -87,7 +87,12 @@ public class ChatFilter {
|
|||
while (matcher.find()) {
|
||||
String group = matcher.group(); // todo debug
|
||||
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);
|
||||
while (matcher.find()) {
|
||||
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;
|
||||
}
|
||||
|
||||
public void replace(String match, String replace) {
|
||||
text = text
|
||||
.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 void replace(TextReplacementConfig textReplacementConfig) {
|
||||
text = text.replaceText(textReplacementConfig);
|
||||
}
|
||||
|
||||
public String string() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user