mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 15:36:27 +01:00
Apply wordfilter on more user-input fields #1679
This commit is contained in:
parent
3d0330742b
commit
2cac6175eb
@ -2,11 +2,11 @@ package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.messenger.Message;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.outgoing.friends.NewConsoleMessageComposer;
|
||||
import com.eu.habbo.plugin.events.users.UserTriggerWordFilterEvent;
|
||||
import gnu.trove.iterator.hash.TObjectHashIterator;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -42,7 +42,7 @@ public class WordFilter {
|
||||
}
|
||||
|
||||
public synchronized void reload() {
|
||||
if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled"))
|
||||
if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true))
|
||||
return;
|
||||
|
||||
this.autoReportWords.clear();
|
||||
@ -125,28 +125,22 @@ public class WordFilter {
|
||||
|
||||
public String filter(String message, Habbo habbo) {
|
||||
String filteredMessage = message;
|
||||
if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) || habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
|
||||
return message;
|
||||
}
|
||||
if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) {
|
||||
filteredMessage = this.normalise(filteredMessage);
|
||||
}
|
||||
|
||||
TObjectHashIterator iterator = this.words.iterator();
|
||||
|
||||
boolean foundShit = false;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
WordFilterWord word = (WordFilterWord) iterator.next();
|
||||
|
||||
if (StringUtils.containsIgnoreCase(filteredMessage, word.getKey())) {
|
||||
for (WordFilterWord word : this.words) {
|
||||
if (StringUtils.containsIgnoreCase(message, word.getKey())) {
|
||||
if (habbo != null) {
|
||||
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
|
||||
continue;
|
||||
}
|
||||
filteredMessage = filteredMessage.replace("(?i)" + word.getKey(), word.getReplacement());
|
||||
filteredMessage = message.replaceAll("(?i)" + word.getKey(), word.getReplacement());
|
||||
foundShit = true;
|
||||
|
||||
if (habbo != null && word.getMuteTime() > 0) {
|
||||
habbo.mute(word.getMuteTime(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable {
|
||||
}
|
||||
}
|
||||
|
||||
if (Emulator.getConfig().getBoolean("hotel.wordfilter.enabled") && Emulator.getConfig().getBoolean("hotel.wordfilter.rooms")) {
|
||||
if (Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) && Emulator.getConfig().getBoolean("hotel.wordfilter.rooms")) {
|
||||
if (!this.habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
|
||||
if (!Emulator.getGameEnvironment().getWordFilter().autoReportCheck(this)) {
|
||||
if (!Emulator.getGameEnvironment().getWordFilter().hideMessageCheck(this.message)) {
|
||||
|
@ -13,13 +13,15 @@ public class ApproveNameEvent extends MessageHandler {
|
||||
public void handle() {
|
||||
String petName = this.packet.readString();
|
||||
|
||||
if (petName.length() < PET_NAME_LENGTH_MINIMUM) {
|
||||
if (Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) && !Emulator.getGameEnvironment().getWordFilter().filter(petName, this.client.getHabbo()).equals(petName)){
|
||||
this.client.sendResponse(new ApproveNameMessageComposer(ApproveNameMessageComposer.FORBIDDEN_WORDS, petName));
|
||||
} else if (petName.length() < PET_NAME_LENGTH_MINIMUM) {
|
||||
this.client.sendResponse(new ApproveNameMessageComposer(ApproveNameMessageComposer.NAME_TO_SHORT, PET_NAME_LENGTH_MINIMUM + ""));
|
||||
} else if (petName.length() > PET_NAME_LENGTH_MAXIMUM) {
|
||||
this.client.sendResponse(new ApproveNameMessageComposer(ApproveNameMessageComposer.NAME_TO_LONG, PET_NAME_LENGTH_MAXIMUM + ""));
|
||||
} else if (!StringUtils.isAlphanumeric(petName)) {
|
||||
this.client.sendResponse(new ApproveNameMessageComposer(ApproveNameMessageComposer.FORBIDDEN_CHAR, petName));
|
||||
} else {
|
||||
} else {
|
||||
this.client.sendResponse(new ApproveNameMessageComposer(ApproveNameMessageComposer.NAME_OK, petName));
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler {
|
||||
int itemId = this.packet.readInt();
|
||||
String extraData = this.packet.readString();
|
||||
String username = this.packet.readString();
|
||||
String message = this.packet.readString();
|
||||
String message = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
int spriteId = this.packet.readInt();
|
||||
int color = this.packet.readInt();
|
||||
int ribbonId = this.packet.readInt();
|
||||
|
@ -20,8 +20,9 @@ public class CreateGuildEvent extends GuildBadgeEvent {
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
String name = this.packet.readString();
|
||||
String description = this.packet.readString();
|
||||
String name = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
String description = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
|
||||
|
||||
if(name.length() > 29 || description.length() > 254)
|
||||
return;
|
||||
|
@ -24,8 +24,8 @@ public class PostMessageEvent extends MessageHandler {
|
||||
public void handle() throws Exception {
|
||||
int guildId = this.packet.readInt();
|
||||
int threadId = this.packet.readInt();
|
||||
String subject = this.packet.readString();
|
||||
String message = this.packet.readString();
|
||||
String subject = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
String message = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class SetItemDataEvent extends MessageHandler {
|
||||
public void handle() {
|
||||
int itemId = this.packet.readInt();
|
||||
String color = this.packet.readString();
|
||||
String text = this.packet.readString().replace(((char) 9) + "", "");
|
||||
String text = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString().replace(((char) 9) + "", ""), this.client.getHabbo());
|
||||
|
||||
if (text.length() > Emulator.getConfig().getInt("postit.charlimit")) {
|
||||
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.sticky.size").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%amount%", text.length() + "").replace("%limit%", Emulator.getConfig().getInt("postit.charlimit") + ""));
|
||||
|
@ -9,7 +9,9 @@ import com.eu.habbo.plugin.events.users.UserSavedMottoEvent;
|
||||
public class ChangeMottoEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() {
|
||||
String motto = this.packet.readString();
|
||||
|
||||
String motto = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||
|
||||
UserSavedMottoEvent event = new UserSavedMottoEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getMotto(), motto);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
motto = event.getNewMotto();
|
||||
|
Loading…
Reference in New Issue
Block a user