Fix for duplicating room tags #2000

This commit is contained in:
Yordi 2024-10-15 17:17:08 +02:00
parent 0a6355996a
commit c22c7cf186

View File

@ -10,6 +10,9 @@ import com.eu.habbo.messages.outgoing.rooms.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Set;
public class RoomSettingsSaveEvent extends MessageHandler { public class RoomSettingsSaveEvent extends MessageHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(RoomSettingsSaveEvent.class); private static final Logger LOGGER = LoggerFactory.getLogger(RoomSettingsSaveEvent.class);
@ -55,6 +58,7 @@ public class RoomSettingsSaveEvent extends MessageHandler {
int usersMax = this.packet.readInt(); int usersMax = this.packet.readInt();
int categoryId = this.packet.readInt(); int categoryId = this.packet.readInt();
StringBuilder tags = new StringBuilder(); StringBuilder tags = new StringBuilder();
Set<String> uniqueTags = new HashSet<>();
int count = Math.min(this.packet.readInt(), 2); int count = Math.min(this.packet.readInt(), 2);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String tag = this.packet.readString(); String tag = this.packet.readString();
@ -63,7 +67,10 @@ public class RoomSettingsSaveEvent extends MessageHandler {
this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.TAGS_TOO_LONG, "")); this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.TAGS_TOO_LONG, ""));
return; return;
} }
tags.append(tag).append(";"); if(!uniqueTags.contains(tag)) {
uniqueTags.add(tag);
tags.append(tag).append(";");
}
} }
if (!Emulator.getGameEnvironment().getWordFilter().filter(tags.toString(), this.client.getHabbo()).equals(tags.toString())) { if (!Emulator.getGameEnvironment().getWordFilter().filter(tags.toString(), this.client.getHabbo()).equals(tags.toString())) {