From a4beae1e7dcbf1f5f9ce97ab53705e0b78bc3e07 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 18 Nov 2020 18:47:26 +0100 Subject: [PATCH 1/2] Fixed wired condition trigger on furni issue #907 --- .../WiredConditionTriggerOnFurni.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index 56d54325..e2d446af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -4,7 +4,6 @@ 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.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; @@ -33,15 +32,34 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) return false; + if (roomUnit == null) + return false; this.refresh(); if (this.items.isEmpty()) return false; - THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); - return this.items.stream().anyMatch(itemsAtUser::contains); + /* + * 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles. + * 2. If a Habbo IS walking we have to check if the very first tile in the walking path since the startlocation + * is one of the selected items + * */ + if (!roomUnit.isWalking()) { + THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); + return this.items.stream().anyMatch(itemsAtUser::contains); + } else { + RoomTile firstTileInPath = room.getLayout() + .findPath(roomUnit.getStartLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit) + .peek(); + + return this.items + .stream() + .anyMatch(conditionItem -> conditionItem + .getOccupyingTiles(room.getLayout()) + .contains(firstTileInPath) + ); + } } @Override @@ -64,7 +82,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { String[] data = set.getString("wired_data").split(";"); for (String s : data) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item != null) { this.items.add(item); From 703a2e8659ef95343f2b71e043c30f28d3896251 Mon Sep 17 00:00:00 2001 From: Remco Date: Thu, 19 Nov 2020 14:04:38 +0100 Subject: [PATCH 2/2] Fixed a leftover bug --- .../wired/conditions/WiredConditionTriggerOnFurni.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index e2d446af..5dcfb9cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -42,17 +42,19 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { /* * 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles. - * 2. If a Habbo IS walking we have to check if the very first tile in the walking path since the startlocation - * is one of the selected items + * 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items * */ if (!roomUnit.isWalking()) { THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); return this.items.stream().anyMatch(itemsAtUser::contains); } else { RoomTile firstTileInPath = room.getLayout() - .findPath(roomUnit.getStartLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit) + .findPath(roomUnit.getCurrentLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit) .peek(); + if (firstTileInPath == null) + return false; + return this.items .stream() .anyMatch(conditionItem -> conditionItem