Check if habbo != null when applying wordFilter && use habbo when filtering bot texts/name

This commit is contained in:
Yordi 2023-02-03 14:35:48 +01:00 committed by yordii
parent 2897b24917
commit 495cb137c4
2 changed files with 3 additions and 3 deletions

View File

@ -125,7 +125,7 @@ public class WordFilter {
public String filter(String message, Habbo habbo) { public String filter(String message, Habbo habbo) {
String filteredMessage = message; String filteredMessage = message;
if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) || habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) { if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) || (habbo != null && habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER))) {
return message; return message;
} }
if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) { if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) {

View File

@ -71,7 +71,7 @@ public class CommandBotEvent extends MessageHandler {
count++; count++;
} }
String result = Emulator.getGameEnvironment().getWordFilter().filter(s, null); String result = Emulator.getGameEnvironment().getWordFilter().filter(s, this.client.getHabbo());
if (!result.isEmpty()) { if (!result.isEmpty()) {
if (!this.client.getHabbo().hasPermission(Permission.ACC_CHAT_NO_FILTER)) { if (!this.client.getHabbo().hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
@ -117,7 +117,7 @@ public class CommandBotEvent extends MessageHandler {
String name = this.packet.readString(); String name = this.packet.readString();
boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH || name.contains("<") || name.contains(">"); boolean invalidName = name.length() > BotManager.MAXIMUM_NAME_LENGTH || name.contains("<") || name.contains(">");
if (!invalidName) { if (!invalidName) {
String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(name, null); String filteredName = Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo());
invalidName = !name.equalsIgnoreCase(filteredName); invalidName = !name.equalsIgnoreCase(filteredName);
if (!invalidName) { if (!invalidName) {
BotSavedNameEvent nameEvent = new BotSavedNameEvent(bot, name); BotSavedNameEvent nameEvent = new BotSavedNameEvent(bot, name);