From 186c7d1933a4cc9941a4003e7f96a9deff0e755c Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 29 Nov 2020 00:07:20 -0500 Subject: [PATCH] Revert "Merge branch 'dev' into feature/permissions-see-tent-chat" This reverts commit 3097a5583d8f1e2ba01899f60b14870e72492131, reversing changes made to 523bc9c8610670cb6932a1d69c4681a28ac56235. --- sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql | 2 +- sqlupdates/2_4_0_TO_2_4_5.sql | 3 ++ .../interactions/InteractionOneWayGate.java | 1 - .../habbohotel/permissions/Permission.java | 1 + .../com/eu/habbo/habbohotel/rooms/Room.java | 37 +++++++++++++++---- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 sqlupdates/2_4_0_TO_2_4_5.sql diff --git a/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql b/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql index 78ce8842..4e5a5206 100644 --- a/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql +++ b/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql @@ -1,2 +1,2 @@ -- Recycler value fix -INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8'); \ No newline at end of file +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8'); diff --git a/sqlupdates/2_4_0_TO_2_4_5.sql b/sqlupdates/2_4_0_TO_2_4_5.sql new file mode 100644 index 00000000..97cedc4f --- /dev/null +++ b/sqlupdates/2_4_0_TO_2_4_5.sql @@ -0,0 +1,3 @@ +-- Permissions to see tent chat +ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent'); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index 01257bea..6a26e6cb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -81,7 +81,6 @@ public class InteractionOneWayGate extends HabboItem { if (unit == null) return; - if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) { if (!currentLocation.hasUnits()) { List onSuccess = new ArrayList(); diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java b/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java index 5dfdd12f..469f9072 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java @@ -6,6 +6,7 @@ public class Permission { public static String ACC_EMPTY_OTHERS = "acc_empty_others"; public static String ACC_ENABLE_OTHERS = "acc_enable_others"; public static String ACC_SEE_WHISPERS = "acc_see_whispers"; + public static String ACC_SEE_TENTCHAT = "acc_see_tentchat"; public static String ACC_SUPERWIRED = "acc_superwired"; public static String ACC_SUPPORTTOOL = "acc_supporttool"; public static String ACC_UNKICKABLE = "acc_unkickable"; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 517b38b8..16926f18 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3130,7 +3130,7 @@ public class Room implements Comparable, ISerialize, Runnable { ServerMessage prefixMessage = null; if (Emulator.getPluginManager().isRegistered(UsernameTalkEvent.class, true)) { - UsernameTalkEvent usernameTalkEvent = (UsernameTalkEvent) Emulator.getPluginManager().fireEvent(new UsernameTalkEvent(habbo, roomChatMessage, chatType)); + UsernameTalkEvent usernameTalkEvent = Emulator.getPluginManager().fireEvent(new UsernameTalkEvent(habbo, roomChatMessage, chatType)); if (usernameTalkEvent.hasCustomComposer()) { prefixMessage = usernameTalkEvent.getCustomComposer(); } @@ -3141,7 +3141,7 @@ public class Room implements Comparable, ISerialize, Runnable { } ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null; - Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); + Rectangle tentRectangle = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$",""); @@ -3187,7 +3187,7 @@ public class Room implements Comparable, ISerialize, Runnable { if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance || h.equals(habbo) || this.hasRights(h) || - noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { if (prefixMessage != null && !h.getHabboStats().preferOldChat) { h.getClient().sendResponse(prefixMessage); @@ -3197,13 +3197,19 @@ public class Room implements Comparable, ISerialize, Runnable { h.getClient().sendResponse(clearPrefixMessage); } } + continue; } + // Staff should be able to see the tent chat anyhow + showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); } } else if (chatType == RoomChatType.SHOUT) { ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose(); for (Habbo h : this.getHabbos()) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + // Show the message + // If the receiving Habbo has not ignored the sending Habbo + // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { if (prefixMessage != null && !h.getHabboStats().preferOldChat) { h.getClient().sendResponse(prefixMessage); } @@ -3211,7 +3217,10 @@ public class Room implements Comparable, ISerialize, Runnable { if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { h.getClient().sendResponse(clearPrefixMessage); } + continue; } + // Staff should be able to see the tent chat anyhow, even when not in the same tent + showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); } } @@ -3263,11 +3272,25 @@ public class Room implements Comparable, ISerialize, Runnable { } } } - } } } + /** + * Sends the given message to the receiving Habbo if the Habbo has the ACC_SEE_TENTCHAT permission and is not within the tent + * @param receivingHabbo The receiving Habbo + * @param roomChatMessage The message to receive + * @param tentRectangle The whole tent area from where the sending Habbo is saying something + */ + private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) { + if (receivingHabbo != null && receivingHabbo.hasPermission(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentLocation())) { + RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); + staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage()); + final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose(); + receivingHabbo.getClient().sendResponse(staffMessage); + } + } + public THashSet getLockedTiles() { THashSet lockedTiles = new THashSet<>(); @@ -4420,7 +4443,7 @@ public class Room implements Comparable, ISerialize, Runnable { double height = tile.getStackHeight(); if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { - FurnitureBuildheightEvent event = (FurnitureBuildheightEvent) Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height)); + FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height)); if (event.hasChangedHeight()) { height = event.getUpdatedHeight(); } @@ -4548,7 +4571,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { - FurnitureBuildheightEvent event = (FurnitureBuildheightEvent) Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); + FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); if (event.hasChangedHeight()) { height = event.getUpdatedHeight(); }