From 6615588b34bd95c711f3da3e5a5459f21873c8b5 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Sun, 7 Jun 2020 04:36:15 +0200 Subject: [PATCH] Fixes wordfilter permission checks (#670). --- .../rooms/RoomWordFilterModifyEvent.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java index 287a28f0..be680d50 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomWordFilterModifyEvent.java @@ -1,28 +1,37 @@ package com.eu.habbo.messages.incoming.rooms; -import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; public class RoomWordFilterModifyEvent extends MessageHandler { @Override public void handle() throws Exception { - int roomId = this.packet.readInt(); - boolean add = this.packet.readBoolean(); + final int roomId = this.packet.readInt(); + final boolean add = this.packet.readBoolean(); String word = this.packet.readString(); if (word.length() > 25) { word = word.substring(0, 24); } - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + // Get current room of user. + final Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + if (room == null || room.getId() != roomId) { + return; + } - if (room != null) { - if (add) { - room.addToWordFilter(word); - } else { - room.removeFromWordFilter(word); - } + // 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; + } + + // Modify word filter. + if (add) { + room.addToWordFilter(word); + } else { + room.removeFromWordFilter(word); } } }