From 02cb78f710025e5e4cdab2652f534777c64afe47 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 29 Dec 2020 21:54:03 +0100 Subject: [PATCH 01/14] Effect_tile interaction now keeps the effect after walkoff --- .../items/interactions/InteractionEffectTile.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java index cb8eb2ab..ac10dcc7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; @@ -7,6 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; @@ -32,7 +35,11 @@ public class InteractionEffectTile extends InteractionPressurePlate { @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - super.onWalkOff(roomUnit, room, objects); + Emulator.getThreading().run(() -> updateState(room), 100); + + if(objects != null && objects.length > 0) { + WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this}); + } } @Override From 909047010062389a0fae67f46ea238bc64d46590 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 17:33:27 +0100 Subject: [PATCH 02/14] Fireworks working like Habbo --- .../interactions/InteractionFireworks.java | 132 ++++++++++++++---- .../com/eu/habbo/habbohotel/rooms/Room.java | 8 ++ 2 files changed, 115 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 645c0d4e..bc8385c5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -5,14 +5,28 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class InteractionFireworks extends InteractionDefault { + + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class); + + private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels + private static final String STATE_CHARGED = "1"; + private static final String STATE_EXPLOSION = "2"; -public class InteractionFireworks extends HabboItem { public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -26,35 +40,103 @@ public class InteractionFireworks extends HabboItem { return false; } - @Override - public boolean isWalkable() { - return this.getBaseItem().allowWalk(); - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } - - @Override - public void serializeExtradata(ServerMessage serverMessage) { - serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); - super.serializeExtradata(serverMessage); //Design flaw ;( - } - + /** + * Checked in Habbo on 2021-01-03 + * - Fireworks should be charged to be able to detonate them + * - Habbos with Rights can detonate fireworks from anywhere in a room + * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Iteraction Switch) + * - Wired can always detonate fireworks + */ @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); + if (room == null) + return; - if (client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect) - { - AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger")); + // Wireds can always detonate fireworks if charged + if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) { + if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + super.onClick(client, room, objects); + + if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) { + this.reCharge(room); + } + } + + return; + } + + if (client == null) + return; + + // Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks + if (!this.canToggle(client.getHabbo(), room)) { + RoomTile closestTile = null; + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { + closestTile = tile; + } + } + + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + List onSuccess = new ArrayList<>(); + onSuccess.add(() -> { + try { + this.onClick(client, room, objects); + } catch (Exception e) { + e.printStackTrace(); + } + }); + + client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); + } + } + + if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + super.onClick(client, room, objects); + + if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) + { + this.reCharge(room); + AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger")); + } } } @Override public boolean allowWiredResetState() { - return true; + return false; + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + this.setExtradata(STATE_CHARGED); + } + + @Override + public boolean canToggle(Habbo habbo, Room room) { + return room.hasRights(habbo) || RoomLayout.tilesAdjecent( + room.getLayout().getTile(this.getX(), this.getY()), + habbo.getRoomUnit().getCurrentLocation() + ); + } + + private void reCharge(Room room) { + // Default = 5000, Nuclear Firework should have 10000 in its custom params according to Habbo + int explodeDuration = 5000; + if (!this.getBaseItem().getCustomParams().isEmpty()) { + try { + explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams()); + } catch (NumberFormatException e) { + LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); + } + } + + Emulator.getThreading().run(() -> { + this.setExtradata(STATE_CHARGED); + this.needsUpdate(true); + room.updateItemState(this); + }, explodeDuration); } } 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 d0704c82..7a955925 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -383,6 +383,11 @@ public class Room implements Comparable, ISerialize, Runnable { this.updateItem(item); } } + + for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) { + item.setExtradata("1"); + this.updateItem(item); + } } Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this)); @@ -2419,7 +2424,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionSnowboardSlope) { this.roomSpecialTypes.addUndefined(item); + } else if (item instanceof InteractionFireworks) { + this.roomSpecialTypes.addUndefined(item); } + } } From c7bfcf76e5c78f70fbf3c68f636d0c0ae1a0dadb Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 3 Jan 2021 17:38:49 +0100 Subject: [PATCH 03/14] Fix typo --- .../habbohotel/items/interactions/InteractionFireworks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index bc8385c5..b2255e2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -44,7 +44,7 @@ public class InteractionFireworks extends InteractionDefault { * Checked in Habbo on 2021-01-03 * - Fireworks should be charged to be able to detonate them * - Habbos with Rights can detonate fireworks from anywhere in a room - * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Iteraction Switch) + * - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Interaction Switch) * - Wired can always detonate fireworks */ @Override From 4937ac298de4f5d029e40da106bd216cab9fe5df Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:24:04 +0100 Subject: [PATCH 04/14] Added roombadge command --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 6 +++ .../habbohotel/commands/RoomBadgeCommand.java | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index b8fc2d61..23f3508b 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -114,3 +114,9 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`; -- 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'); + +-- Roombadge command +ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_massbadge', 'roombadge'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_massbadge', ':roombadge '); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java new file mode 100644 index 00000000..a2693217 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java @@ -0,0 +1,54 @@ +package com.eu.habbo.habbohotel.commands; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboBadge; +import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; +import gnu.trove.map.hash.THashMap; + +public class RoomBadgeCommand extends Command { + public RoomBadgeCommand() { + super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient == null) + return true; + + if (params.length == 2) { + String badge; + + badge = params[1]; + + if (!badge.isEmpty()) { + THashMap keys = new THashMap<>(); + keys.put("display", "BUBBLE"); + keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); + keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); + ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); + + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) { + if (habbo.isOnline()) { + if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { + HabboBadge b = BadgesComponent.createBadge(badge, habbo); + + habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); + habbo.getClient().sendResponse(message); + } + } + } + } + return true; + } + + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT); + return true; + } +} From 22efb1c925075c2827cbdb5ff9900e283c6f226e Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:34:22 +0100 Subject: [PATCH 05/14] Oop.. --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index 23f3508b..1bc01add 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -118,5 +118,5 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', -- Roombadge command ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_massbadge', 'roombadge'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_massbadge', ':roombadge '); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge '); From 8a89f7ce4d572705f4ff1f67763c616d82a9b3be Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 6 Jan 2021 20:39:30 +0100 Subject: [PATCH 06/14] Actually added the RoomBadgeCommand --- .../java/com/eu/habbo/habbohotel/commands/CommandHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index 1ec167c4..a37d9482 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -217,6 +217,7 @@ public class CommandHandler { addCommand(new LayCommand()); addCommand(new MachineBanCommand()); addCommand(new MassBadgeCommand()); + addCommand(new RoomBadgeCommand()); addCommand(new MassCreditsCommand()); addCommand(new MassGiftCommand()); addCommand(new MassPixelsCommand()); From 5981046523bd44ff09dee6e293e40db45a540985 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 10 Jan 2021 02:49:15 +0000 Subject: [PATCH 07/14] Fix issue 936 --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 2 ++ src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index b8fc2d61..21f3064c 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -101,6 +101,8 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscr INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.roomuser.idle.not_dancing.ignore.wired_idle', '0'); + -- OPTIONAL HC MIGRATION -- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP(); 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 d0704c82..512783f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1205,8 +1205,11 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().increaseIdleTimer(); if (habbo.getRoomUnit().isIdle()) { - this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); - WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); + boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE); + if (danceIsNone) + this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); + if (danceIsNone && !Emulator.getConfig().getBoolean("hotel.roomuser.idle.not_dancing.ignore.wired_idle")) + WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } } else { habbo.getRoomUnit().increaseIdleTimer(); From 35ac99b2c6c1f0622a2d09aa4a65fb1b39ebc62e Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:45:44 +0100 Subject: [PATCH 08/14] Added Apply furni to set conditions feature --- .../WiredConditionMatchStatePosition.java | 23 ++++- .../WiredConditionNotMatchStatePosition.java | 23 ++++- .../wired/effects/WiredEffectMatchFurni.java | 23 ++++- .../InteractionWiredMatchFurniSettings.java | 11 +++ .../com/eu/habbo/messages/PacketManager.java | 4 +- .../eu/habbo/messages/incoming/Incoming.java | 2 + .../WiredEffectApplySetConditionsEvent.java | 98 +++++++++++++++++++ 7 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 27c82d91..0fe350dd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -16,7 +17,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMatchStatePosition extends InteractionWiredCondition { +public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -198,4 +199,24 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } } + + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java index 48983cef..b6d7cb5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -16,7 +17,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { +public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -189,4 +190,24 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } } + + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.rotation; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index fbd374d4..aa19b878 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -24,7 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -public class WiredEffectMatchFurni extends InteractionWiredEffect { +public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; @@ -241,6 +242,26 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { } } + @Override + public THashSet getMatchFurniSettings() { + return this.settings; + } + + @Override + public boolean shouldMatchState() { + return this.state; + } + + @Override + public boolean shouldMatchRotation() { + return this.direction; + } + + @Override + public boolean shouldMatchPosition() { + return this.position; + } + static class JsonData { boolean state; boolean direction; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java new file mode 100644 index 00000000..6db447f7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java @@ -0,0 +1,11 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; +import gnu.trove.set.hash.THashSet; + +public interface InteractionWiredMatchFurniSettings { + public THashSet getMatchFurniSettings(); + public boolean shouldMatchState(); + public boolean shouldMatchRotation(); + public boolean shouldMatchPosition(); +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 00cdb987..f9b427a3 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,6 +65,7 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; +import com.eu.habbo.messages.incoming.wired.WiredEffectApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -81,7 +82,7 @@ public class PacketManager { private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); private static final List logList = new ArrayList<>(); - public static boolean DEBUG_SHOW_PACKETS = false; + public static boolean DEBUG_SHOW_PACKETS = true; public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; @@ -579,6 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); + this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredEffectApplySetConditionsEvent.class); } void registerUnknown() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 621a4775..c70b9b88 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,6 +155,8 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; + public static final int WiredEffectApplySetConditionsEvent = 3373; +// public static final int WiredEffectApplySetConditionsEvent = 495; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java new file mode 100644 index 00000000..4e8a40e2 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java @@ -0,0 +1,98 @@ +package com.eu.habbo.messages.incoming.wired; + +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; +import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class WiredEffectApplySetConditionsEvent extends MessageHandler { + + @Override + public void handle() throws Exception { + int itemId = this.packet.readInt(); + + // Executing Habbo has to be in a Room + if (!this.client.getHabbo().getRoomUnit().isInRoom()) { + this.client.sendResponse(new BubbleAlertComposer( + BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, + FurnitureMovementError.NO_RIGHTS.errorCode + )); + return; + } + + Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + + if (room != null) { + + // Executing Habbo should be able to edit wireds + if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) { + + List wireds = new ArrayList<>(); + wireds.addAll(room.getRoomSpecialTypes().getConditions()); + wireds.addAll(room.getRoomSpecialTypes().getEffects()); + + // Find the item with the given ID in the room + Optional item = wireds.stream() + .filter(wired -> wired.getId() == itemId) + .findFirst(); + + // If the item exists + if (item.isPresent()) { + HabboItem wiredItem = item.get(); + + // The item should have settings to match furni state, position and rotation + if (wiredItem instanceof InteractionWiredMatchFurniSettings) { + + InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; + + // Try to apply the set settings to each item + wired.getMatchFurniSettings().forEach(setting -> { + HabboItem matchItem = room.getHabboItem(setting.item_id); + + // Match state + if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { + if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { + matchItem.setExtradata(setting.state); + room.updateItemState(matchItem); + } + } + + RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); + double oldZ = matchItem.getZ(); + + // Match Position & Rotation + if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { + if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { + room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); + } + } + else if(wired.shouldMatchPosition()) { + boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; + RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); + int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); + + if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { + if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { + if(slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + } + } + } + } + }); + } + } + } + } + } +} From 32e7c29f84755f9076ff6ef1a58d9e1daebc0b32 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:47:26 +0100 Subject: [PATCH 09/14] Removed commented code --- src/main/java/com/eu/habbo/messages/incoming/Incoming.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index c70b9b88..dd19f4a7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -156,7 +156,6 @@ public class Incoming { public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; public static final int WiredEffectApplySetConditionsEvent = 3373; -// public static final int WiredEffectApplySetConditionsEvent = 495; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; From 2313276df067997120819fb106d2010f43c2f295 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:50:03 +0100 Subject: [PATCH 10/14] Removed debugging code --- src/main/java/com/eu/habbo/messages/PacketManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index f9b427a3..16e85a04 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -82,7 +82,7 @@ public class PacketManager { private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); private static final List logList = new ArrayList<>(); - public static boolean DEBUG_SHOW_PACKETS = true; + public static boolean DEBUG_SHOW_PACKETS = false; public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; From 53fc7ece4a34a3b49f6782f23083a0a50fd8e90e Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 20:55:09 +0100 Subject: [PATCH 11/14] Renamed event since it applies to both conditions and effects --- src/main/java/com/eu/habbo/messages/PacketManager.java | 4 ++-- ...ConditionsEvent.java => WiredApplySetConditionsEvent.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/eu/habbo/messages/incoming/wired/{WiredEffectApplySetConditionsEvent.java => WiredApplySetConditionsEvent.java} (98%) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 16e85a04..f61928d2 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,7 +65,7 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; -import com.eu.habbo.messages.incoming.wired.WiredEffectApplySetConditionsEvent; +import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -580,7 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredEffectApplySetConditionsEvent.class); + this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java similarity index 98% rename from src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java rename to src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 4e8a40e2..12676201 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -public class WiredEffectApplySetConditionsEvent extends MessageHandler { +public class WiredApplySetConditionsEvent extends MessageHandler { @Override public void handle() throws Exception { From de7c51d78a1771465094fa513451a3c178fc5963 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 22:15:20 +0100 Subject: [PATCH 12/14] Added ratelimit --- .../incoming/wired/WiredApplySetConditionsEvent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 12676201..6fac8cab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -17,6 +17,11 @@ import java.util.Optional; public class WiredApplySetConditionsEvent extends MessageHandler { + @Override + public int getRatelimit() { + return 500; + } + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); From 40914b505080add986d31bd8e6642bb5e39474a7 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 10 Jan 2021 23:10:15 +0100 Subject: [PATCH 13/14] Renamed incoming event --- src/main/java/com/eu/habbo/messages/PacketManager.java | 2 +- src/main/java/com/eu/habbo/messages/incoming/Incoming.java | 2 +- .../messages/incoming/wired/WiredApplySetConditionsEvent.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index f61928d2..edf209bb 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -580,7 +580,7 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredEffectApplySetConditionsEvent, WiredApplySetConditionsEvent.class); + this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index dd19f4a7..75223e4c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,7 +155,7 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; - public static final int WiredEffectApplySetConditionsEvent = 3373; + public static final int WiredApplySetConditionsEvent = 3373; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java index 6fac8cab..1d9266f3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java @@ -21,7 +21,7 @@ public class WiredApplySetConditionsEvent extends MessageHandler { public int getRatelimit() { return 500; } - + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); From f4869a6305370a5bbddc73fed5b85af4e466e0a4 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Jan 2021 18:04:47 -0500 Subject: [PATCH 14/14] Revert "Merge branch 'feature/packet-1094' into 'dev'" This reverts merge request !366 --- .../WiredConditionMatchStatePosition.java | 23 +--- .../WiredConditionNotMatchStatePosition.java | 23 +--- .../wired/effects/WiredEffectMatchFurni.java | 23 +--- .../InteractionWiredMatchFurniSettings.java | 11 -- .../com/eu/habbo/messages/PacketManager.java | 2 - .../eu/habbo/messages/incoming/Incoming.java | 1 - .../wired/WiredApplySetConditionsEvent.java | 103 ------------------ 7 files changed, 3 insertions(+), 183 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java delete mode 100644 src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 0fe350dd..27c82d91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -17,7 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { +public class WiredConditionMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; private THashSet settings; @@ -199,24 +198,4 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } } - - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.direction; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java index b6d7cb5e..48983cef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -17,7 +16,7 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { +public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; private THashSet settings; @@ -190,24 +189,4 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi } } } - - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.rotation; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index aa19b878..fbd374d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -25,7 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { +public class WiredEffectMatchFurni extends InteractionWiredEffect { private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; @@ -242,26 +241,6 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } } - @Override - public THashSet getMatchFurniSettings() { - return this.settings; - } - - @Override - public boolean shouldMatchState() { - return this.state; - } - - @Override - public boolean shouldMatchRotation() { - return this.direction; - } - - @Override - public boolean shouldMatchPosition() { - return this.position; - } - static class JsonData { boolean state; boolean direction; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java deleted file mode 100644 index 6db447f7..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; - -import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import gnu.trove.set.hash.THashSet; - -public interface InteractionWiredMatchFurniSettings { - public THashSet getMatchFurniSettings(); - public boolean shouldMatchState(); - public boolean shouldMatchRotation(); - public boolean shouldMatchPosition(); -} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index edf209bb..00cdb987 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -65,7 +65,6 @@ import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent; import com.eu.habbo.messages.incoming.unknown.UnknownEvent1; import com.eu.habbo.messages.incoming.users.*; import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent; -import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent; import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent; import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; @@ -580,7 +579,6 @@ public class PacketManager { this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class); this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class); this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class); - this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class); } void registerUnknown() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 75223e4c..621a4775 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -155,7 +155,6 @@ public class Incoming { public static final int RequestInventoryItemsEvent = 3150; public static final int ModToolRoomAlertEvent = 3842; public static final int WiredEffectSaveDataEvent = 2281; - public static final int WiredApplySetConditionsEvent = 3373; public static final int CheckPetNameEvent = 2109; public static final int SecureLoginEvent = 2419; public static final int BotSaveSettingsEvent = 2624; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java deleted file mode 100644 index 1d9266f3..00000000 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredApplySetConditionsEvent.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.eu.habbo.messages.incoming.wired; - -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; -import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomTileState; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class WiredApplySetConditionsEvent extends MessageHandler { - - @Override - public int getRatelimit() { - return 500; - } - - @Override - public void handle() throws Exception { - int itemId = this.packet.readInt(); - - // Executing Habbo has to be in a Room - if (!this.client.getHabbo().getRoomUnit().isInRoom()) { - this.client.sendResponse(new BubbleAlertComposer( - BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, - FurnitureMovementError.NO_RIGHTS.errorCode - )); - return; - } - - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - - if (room != null) { - - // Executing Habbo should be able to edit wireds - if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) { - - List wireds = new ArrayList<>(); - wireds.addAll(room.getRoomSpecialTypes().getConditions()); - wireds.addAll(room.getRoomSpecialTypes().getEffects()); - - // Find the item with the given ID in the room - Optional item = wireds.stream() - .filter(wired -> wired.getId() == itemId) - .findFirst(); - - // If the item exists - if (item.isPresent()) { - HabboItem wiredItem = item.get(); - - // The item should have settings to match furni state, position and rotation - if (wiredItem instanceof InteractionWiredMatchFurniSettings) { - - InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem; - - // Try to apply the set settings to each item - wired.getMatchFurniSettings().forEach(setting -> { - HabboItem matchItem = room.getHabboItem(setting.item_id); - - // Match state - if (wired.shouldMatchState() && matchItem.allowWiredResetState()) { - if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) { - matchItem.setExtradata(setting.state); - room.updateItemState(matchItem); - } - } - - RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); - double oldZ = matchItem.getZ(); - - // Match Position & Rotation - if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { - if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) { - room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true); - } - } - else if(wired.shouldMatchPosition()) { - boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation; - RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y); - int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation(); - - if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { - if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - if(slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); - } - } - } - } - }); - } - } - } - } - } -}