Arcturus-Community/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java

38 lines
1.2 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.messages.incoming.rooms;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.incoming.MessageHandler;
2019-05-26 20:14:53 +02:00
public class RoomWordFilterModifyEvent extends MessageHandler {
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public void handle() throws Exception {
final int roomId = this.packet.readInt();
final boolean add = this.packet.readBoolean();
2018-07-06 15:30:00 +02:00
String word = this.packet.readString();
2019-05-26 20:14:53 +02:00
if (word.length() > 25) {
2018-07-06 15:30:00 +02:00
word = word.substring(0, 24);
}
// Get current room of user.
final Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
if (room == null || room.getId() != roomId) {
return;
}
// Check if owner.
if (!room.isOwner(this.client.getHabbo())) {
ScripterManager.scripterDetected(this.client, String.format("User (%s) tried to change wordfilter for a not owned room.", this.client.getHabbo().getHabboInfo().getUsername()));
return;
}
2018-07-06 15:30:00 +02:00
// Modify word filter.
if (add) {
room.addToWordFilter(word);
} else {
room.removeFromWordFilter(word);
2018-07-06 15:30:00 +02:00
}
}
}