From 8cbe5129acf3b38bb1f650046c497922ef9f86db Mon Sep 17 00:00:00 2001 From: Ilany Date: Fri, 18 Sep 2020 13:35:25 +0200 Subject: [PATCH 1/3] Fixed gate bug --- .../habbohotel/items/interactions/InteractionGate.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index 5c0b3422..a6452849 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; 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.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -42,8 +43,12 @@ public class InteractionGate extends HabboItem { if (client != null && !room.hasRights(client.getHabbo()) && !isWired) return; - if (!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty()) - return; + // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't be triggered + if (!isWired) { + for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) + if (room.hasHabbosAt(tile.x, tile.y)) + return; + } if (this.getExtradata().length() == 0) this.setExtradata("0"); From 0a09ff1f41a6685d6a2b602067cd78399e7220ef Mon Sep 17 00:00:00 2001 From: Ilany Date: Fri, 18 Sep 2020 14:24:42 +0200 Subject: [PATCH 2/3] Added comments --- .../habbo/habbohotel/items/interactions/InteractionGate.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index a6452849..5202f041 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -43,17 +43,18 @@ public class InteractionGate extends HabboItem { if (client != null && !room.hasRights(client.getHabbo()) && !isWired) return; - // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't be triggered + // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close if (!isWired) { for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) if (room.hasHabbosAt(tile.x, tile.y)) return; } + // Gate closed = 0, open = 1 if (this.getExtradata().length() == 0) this.setExtradata("0"); - this.setExtradata((Integer.valueOf(this.getExtradata()) + 1) % 2 + ""); + this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + ""); room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); this.needsUpdate(true); room.updateItemState(this); From 986a3b323c042e95d1e126e132aeff0dd00e895d Mon Sep 17 00:00:00 2001 From: Ilany Date: Fri, 18 Sep 2020 15:04:57 +0200 Subject: [PATCH 3/3] Wired cannot trigger door when a Habbo is on it --- .../items/interactions/InteractionGate.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index 5202f041..f7ceb0e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -39,16 +39,15 @@ public class InteractionGate extends HabboItem { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE); - if (client != null && !room.hasRights(client.getHabbo()) && !isWired) + boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE); + + if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired) return; // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close - if (!isWired) { - for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) - if (room.hasHabbosAt(tile.x, tile.y)) - return; - } + for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) + if (room.hasHabbosAt(tile.x, tile.y)) + return; // Gate closed = 0, open = 1 if (this.getExtradata().length() == 0)