I'm censoring the chat. Censorship works, but the plugin replaces the word, even if this word does not need to be blocked.
For example:
Blocking the word "port"
The plugin blocks as follows: Tele****ing
What check should I add to this method to make it work? swearList() this is the get method for the config.yml
For example:
Blocking the word "port"
The plugin blocks as follows: Tele****ing
What check should I add to this method to make it work? swearList() this is the get method for the config.yml
private String returnCorrected(String str) {
JsonObject jsonObject = (new JsonParser()).parse(str).getAsJsonObject();
JsonArray element = jsonObject.get("extra").getAsJsonArray();
for (JsonElement objects : element) {
if (objects instanceof JsonObject) {
JsonObject actual = (JsonObject)objects;
String text = actual.get("text").getAsString();
for (String badWord : swearList()) {
if (badWord.getChars();)
if (text.contains(badWord)) {
String repeat = StringUtils.repeat("*", badWord.length());
text = text.replace(badWord, repeat);
}
}
actual.addProperty("text", text);
}
}
return jsonObject.toString();
}
Last edited: