From 13669ba8ce57dad95402820c863e7fd407aade35 Mon Sep 17 00:00:00 2001 From: Lorenzune Date: Tue, 17 Mar 2026 01:34:18 +0100 Subject: [PATCH] feat(wired): add leave/click/action/short-period triggers - add wf_trg_leave_room, wf_trg_stuff_state, wf_trg_period_short, wf_trg_click_furni, wf_trg_click_tile, wf_trg_click_user and wf_trg_user_performs_action\n- add interaction type room_invisible_click_tile\n- persist selector-driven MatchFurni and ToggleRandom state changes\n- use configured duration in WiredEffectMuteHabbo --- .../habbo/habbohotel/items/ItemManager.java | 8 + .../wired/effects/WiredEffectMatchFurni.java | 1 + .../wired/effects/WiredEffectMuteHabbo.java | 2 +- .../effects/WiredEffectToggleRandom.java | 1 + .../WiredTriggerFurniStateToggled.java | 169 +++++++++++--- .../WiredTriggerHabboClicksFurni.java | 164 +++++++++++++ .../triggers/WiredTriggerHabboClicksTile.java | 47 ++++ .../triggers/WiredTriggerHabboClicksUser.java | 80 +++++++ .../triggers/WiredTriggerHabboLeavesRoom.java | 116 ++++++++++ .../WiredTriggerHabboPerformsAction.java | 217 ++++++++++++++++++ .../triggers/WiredTriggerRepeaterLong.java | 2 +- .../triggers/WiredTriggerRepeaterShort.java | 125 ++++++++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 10 + .../habbohotel/rooms/RoomUnitManager.java | 10 + .../habbo/habbohotel/wired/WiredHandler.java | 2 +- .../habbohotel/wired/WiredTriggerType.java | 6 + .../habbohotel/wired/WiredUserActionType.java | 18 ++ .../habbohotel/wired/core/WiredEvent.java | 42 ++++ .../habbohotel/wired/core/WiredManager.java | 84 +++++++ .../habbohotel/wired/migrate/WiredEvents.java | 89 +++++++ .../com/eu/habbo/messages/PacketManager.java | 4 +- .../eu/habbo/messages/incoming/Incoming.java | 2 + .../incoming/rooms/items/ClickFurniEvent.java | 43 ++++ .../incoming/rooms/users/ClickUserEvent.java | 33 +++ .../rooms/users/RoomUserActionEvent.java | 28 +++ .../rooms/users/RoomUserDanceEvent.java | 13 +- .../rooms/users/RoomUserSignEvent.java | 3 + .../rooms/users/RoomUserSitEvent.java | 9 +- 28 files changed, 1283 insertions(+), 45 deletions(-) create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksFurni.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksTile.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksUser.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboLeavesRoom.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboPerformsAction.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterShort.java create mode 100644 Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredUserActionType.java create mode 100644 Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ClickFurniEvent.java create mode 100644 Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ClickUserEvent.java diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 2a944f95..78bdda77 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -203,16 +203,24 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class)); this.interactionsList.add(new ItemInteraction("tile_walkmagic", InteractionTileWalkMagic.class)); this.interactionsList.add(new ItemInteraction("antenna", InteractionDefault.class)); + this.interactionsList.add(new ItemInteraction("room_invisible_click_tile", InteractionDefault.class)); this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class)); this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_click_furni", WiredTriggerHabboClicksFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_click_tile", WiredTriggerHabboClicksTile.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_click_user", WiredTriggerHabboClicksUser.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_user_performs_action", WiredTriggerHabboPerformsAction.class)); this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerHabboEntersRoom.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_leave_room", WiredTriggerHabboLeavesRoom.class)); this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerHabboSaysKeyword.class)); this.interactionsList.add(new ItemInteraction("wf_trg_periodically", WiredTriggerRepeater.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_period_short", WiredTriggerRepeaterShort.class)); this.interactionsList.add(new ItemInteraction("wf_trg_period_long", WiredTriggerRepeaterLong.class)); this.interactionsList.add(new ItemInteraction("wf_trg_state_changed", WiredTriggerFurniStateToggled.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_stuff_state", WiredTriggerFurniStateToggled.class)); this.interactionsList.add(new ItemInteraction("wf_trg_at_given_time", WiredTriggerAtSetTime.class)); this.interactionsList.add(new ItemInteraction("wf_trg_at_time_long", WiredTriggerAtTimeLong.class)); this.interactionsList.add(new ItemInteraction("wf_trg_collision", WiredTriggerCollision.class)); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 90348f35..e075f486 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -108,6 +108,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { if (!setting.state.equals(" ") && !item.getExtradata().equals(setting.state)) { item.setExtradata(setting.state); + item.needsUpdate(true); room.updateItemState(item); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index 41acb60e..443cb24c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -76,7 +76,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { if (room.hasRights(habbo)) continue; - room.muteHabbo(habbo, 60); + room.muteHabbo(habbo, Math.max(1, this.length)); habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index 370655af..8ba458c2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -197,6 +197,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { try { item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); + item.needsUpdate(true); room.updateItem(item); } catch (Exception e) { LOGGER.error("Caught exception", e); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java index 4f4a82f4..6c15531f 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java @@ -15,36 +15,48 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED; + private static final int MODE_ALL_STATES = 0; + private static final int MODE_SAVED_STATE = 1; - private THashSet items; + private THashSet snapshots; + private int triggerMode = MODE_ALL_STATES; public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); + this.snapshots = new THashSet<>(); } public WiredTriggerFurniStateToggled(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); + this.snapshots = new THashSet<>(); } @Override public boolean matches(HabboItem triggerItem, WiredEvent event) { - // Reject if this was triggered by a wired effect (to prevent loops) if (event.isTriggeredByEffect()) { return false; } HabboItem sourceItem = event.getSourceItem().orElse(null); - if (sourceItem != null) { - return this.items.contains(sourceItem); + if (sourceItem == null) { + return false; } - return false; + + StateSnapshot snapshot = this.getSnapshot(sourceItem.getId()); + if (snapshot == null) { + return false; + } + + if (this.triggerMode == MODE_SAVED_STATE) { + return snapshot.state.equals(this.normalizeState(sourceItem.getExtradata())); + } + + return true; } @Deprecated @@ -56,21 +68,36 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public String getWiredData() { return WiredManager.getGson().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + this.triggerMode, + new ArrayList<>(this.snapshots) )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); + this.snapshots = new THashSet<>(); + this.triggerMode = MODE_ALL_STATES; String wiredData = set.getString("wired_data"); - if (wiredData.startsWith("{")) { + if (wiredData != null && wiredData.startsWith("{")) { JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); + this.triggerMode = (data != null) ? data.triggerMode : MODE_ALL_STATES; + + if (data != null && data.snapshots != null && !data.snapshots.isEmpty()) { + for (StateSnapshot snapshot : data.snapshots) { + if (snapshot == null) continue; + + HabboItem item = room.getHabboItem(snapshot.itemId); + if (item != null) { + this.snapshots.add(new StateSnapshot(item.getId(), snapshot.state)); + } + } + } else if (data != null && data.itemIds != null) { + for (Integer id : data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.snapshots.add(this.captureSnapshot(item)); + } } } } else { @@ -79,10 +106,15 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { if (!wiredData.split(":")[2].equals("\t")) { for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) { + continue; + } + HabboItem item = room.getHabboItem(Integer.parseInt(s)); - if (item != null) - this.items.add(item); + if (item != null) { + this.snapshots.add(this.captureSnapshot(item)); + } } } } @@ -91,7 +123,8 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public void onPickUp() { - this.items.clear(); + this.snapshots.clear(); + this.triggerMode = MODE_ALL_STATES; } @Override @@ -101,33 +134,31 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); + THashSet snapshotsToRemove = new THashSet<>(); - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId()) { - items.add(item); + for (StateSnapshot snapshot : this.snapshots) { + HabboItem item = room.getHabboItem(snapshot.itemId); + if (item == null || item.getRoomId() != this.getRoomId()) { + snapshotsToRemove.add(snapshot); continue; } - - if (room.getHabboItem(item.getId()) == null) { - items.add(item); - } } - for (HabboItem item : items) { - this.items.remove(item); + for (StateSnapshot snapshot : snapshotsToRemove) { + this.snapshots.remove(snapshot); } message.appendBoolean(false); message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); + message.appendInt(this.snapshots.size()); + for (StateSnapshot snapshot : this.snapshots) { + message.appendInt(snapshot.itemId); } message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); - message.appendInt(0); + message.appendInt(1); + message.appendInt(this.triggerMode); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -135,14 +166,22 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public boolean saveData(WiredSettings settings) { - this.items.clear(); + this.snapshots.clear(); + this.triggerMode = (settings.getIntParams().length > 0 && settings.getIntParams()[0] == MODE_SAVED_STATE) + ? MODE_SAVED_STATE + : MODE_ALL_STATES; + + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (room == null) { + return true; + } int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) { - this.items.add(item); + this.snapshots.add(this.captureSnapshot(item)); } } @@ -154,11 +193,71 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { return true; } + private StateSnapshot captureSnapshot(HabboItem item) { + return new StateSnapshot(item.getId(), this.normalizeState(item.getExtradata())); + } + + private StateSnapshot getSnapshot(int itemId) { + for (StateSnapshot snapshot : this.snapshots) { + if (snapshot.itemId == itemId) { + return snapshot; + } + } + + return null; + } + + private String normalizeState(String state) { + return (state == null) ? "" : state; + } + static class JsonData { + int triggerMode; + List snapshots; List itemIds; + public JsonData() { + } + public JsonData(List itemIds) { this.itemIds = itemIds; } + + public JsonData(int triggerMode, List snapshots) { + this.triggerMode = triggerMode; + this.snapshots = snapshots; + } + } + + static class StateSnapshot { + int itemId; + String state; + + public StateSnapshot() { + } + + public StateSnapshot(int itemId, String state) { + this.itemId = itemId; + this.state = (state == null) ? "" : state; + } + + @Override + public int hashCode() { + return Integer.hashCode(this.itemId); + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + + if (!(object instanceof StateSnapshot)) { + return false; + } + + StateSnapshot that = (StateSnapshot) object; + return this.itemId == that.itemId; + } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksFurni.java new file mode 100644 index 00000000..9bf25e62 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksFurni.java @@ -0,0 +1,164 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.core.WiredEvent; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.ServerMessage; +import gnu.trove.set.hash.THashSet; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; + +public class WiredTriggerHabboClicksFurni extends InteractionWiredTrigger { + public static final WiredTriggerType type = WiredTriggerType.CLICKS_FURNI; + + private THashSet items; + + public WiredTriggerHabboClicksFurni(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + this.items = new THashSet<>(); + } + + public WiredTriggerHabboClicksFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + this.items = new THashSet<>(); + } + + @Override + public boolean matches(HabboItem triggerItem, WiredEvent event) { + HabboItem sourceItem = event.getSourceItem().orElse(null); + return sourceItem != null && this.items.contains(sourceItem); + } + + @Deprecated + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + return false; + } + + @Override + public WiredTriggerType getType() { + return type; + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + THashSet items = new THashSet<>(); + + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) { + items.addAll(this.items); + } else { + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) { + items.add(item); + } + } + } + + for (HabboItem item : items) { + this.items.remove(item); + } + + message.appendBoolean(false); + message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION); + message.appendInt(this.items.size()); + for (HabboItem item : this.items) { + message.appendInt(item.getId()); + } + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(0); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(0); + } + + @Override + public boolean saveData(WiredSettings settings) { + this.items.clear(); + + int count = settings.getFurniIds().length; + + for (int i = 0; i < count; i++) { + HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i]); + if (item != null) { + this.items.add(item); + } + } + + return true; + } + + @Override + public String getWiredData() { + return WiredManager.getGson().toJson(new JsonData( + this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + )); + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + this.items.clear(); + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); + for (Integer id : data.itemIds) { + HabboItem item = room.getHabboItem(id); + if (item != null) { + this.items.add(item); + } + } + } else { + if (wiredData.split(":").length >= 3) { + super.setDelay(Integer.parseInt(wiredData.split(":")[0])); + + if (!wiredData.split(":")[2].equals("\t")) { + for (String s : wiredData.split(":")[2].split(";")) { + if (s.isEmpty()) { + continue; + } + + try { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); + + if (item != null) { + this.items.add(item); + } + } catch (Exception e) { + } + } + } + } + } + } + + @Override + public void onPickUp() { + this.items.clear(); + } + + @Override + public boolean isTriggeredByRoomUnit() { + return true; + } + + static class JsonData { + List itemIds; + + public JsonData(List itemIds) { + this.itemIds = itemIds; + } + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksTile.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksTile.java new file mode 100644 index 00000000..6ddcc503 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksTile.java @@ -0,0 +1,47 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.core.WiredEvent; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class WiredTriggerHabboClicksTile extends WiredTriggerHabboClicksFurni { + public static final WiredTriggerType type = WiredTriggerType.CLICKS_TILE; + + private static final String CLICK_TILE_INTERACTION = "room_invisible_click_tile"; + + public WiredTriggerHabboClicksTile(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public WiredTriggerHabboClicksTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public boolean matches(HabboItem triggerItem, WiredEvent event) { + if (!super.matches(triggerItem, event)) { + return false; + } + + HabboItem sourceItem = event.getSourceItem().orElse(null); + return isClickTileItem(sourceItem); + } + + @Override + public WiredTriggerType getType() { + return type; + } + + private boolean isClickTileItem(HabboItem item) { + if (item == null || item.getBaseItem() == null || item.getBaseItem().getInteractionType() == null) { + return false; + } + + String interaction = item.getBaseItem().getInteractionType().getName(); + return interaction != null && interaction.equalsIgnoreCase(CLICK_TILE_INTERACTION); + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksUser.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksUser.java new file mode 100644 index 00000000..f64ca1c0 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboClicksUser.java @@ -0,0 +1,80 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.core.WiredEvent; +import com.eu.habbo.messages.ServerMessage; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class WiredTriggerHabboClicksUser extends InteractionWiredTrigger { + public static final WiredTriggerType type = WiredTriggerType.CLICKS_USER; + + public WiredTriggerHabboClicksUser(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public WiredTriggerHabboClicksUser(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public boolean matches(HabboItem triggerItem, WiredEvent event) { + return event.getActor().isPresent(); + } + + @Deprecated + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + return false; + } + + @Override + public String getWiredData() { + return ""; + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + } + + @Override + public void onPickUp() { + } + + @Override + public WiredTriggerType getType() { + return type; + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + message.appendBoolean(false); + message.appendInt(5); + message.appendInt(0); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(0); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(0); + } + + @Override + public boolean saveData(WiredSettings settings) { + return true; + } + + @Override + public boolean isTriggeredByRoomUnit() { + return true; + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboLeavesRoom.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboLeavesRoom.java new file mode 100644 index 00000000..36583ce3 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboLeavesRoom.java @@ -0,0 +1,116 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.core.WiredEvent; +import com.eu.habbo.messages.ServerMessage; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class WiredTriggerHabboLeavesRoom extends InteractionWiredTrigger { + public static final WiredTriggerType type = WiredTriggerType.LEAVE_ROOM; + + private String username = ""; + + public WiredTriggerHabboLeavesRoom(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public WiredTriggerHabboLeavesRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public boolean matches(HabboItem triggerItem, WiredEvent event) { + RoomUnit roomUnit = event.getActor().orElse(null); + Room room = event.getRoom(); + Habbo habbo = room.getHabbo(roomUnit); + + if (habbo != null) { + if (this.username.length() > 0) { + return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.username); + } + + return true; + } + return false; + } + + @Deprecated + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + return false; + } + + @Override + public String getWiredData() { + return WiredManager.getGson().toJson(new JsonData( + this.username + )); + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + String wiredData = set.getString("wired_data"); + + if (wiredData.startsWith("{")) { + JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); + this.username = data.username; + } else { + this.username = wiredData; + } + } + + @Override + public void onPickUp() { + this.username = ""; + } + + @Override + public WiredTriggerType getType() { + return type; + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + message.appendBoolean(false); + message.appendInt(5); + message.appendInt(0); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(this.username); + message.appendInt(0); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(0); + } + + @Override + public boolean saveData(WiredSettings settings) { + this.username = settings.getStringParam(); + + return true; + } + + @Override + public boolean isTriggeredByRoomUnit() { + return true; + } + + static class JsonData { + String username; + + public JsonData(String username) { + this.username = username; + } + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboPerformsAction.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboPerformsAction.java new file mode 100644 index 00000000..07b2195d --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboPerformsAction.java @@ -0,0 +1,217 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; +import com.eu.habbo.habbohotel.wired.core.WiredEvent; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.ServerMessage; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class WiredTriggerHabboPerformsAction extends InteractionWiredTrigger { + private static final WiredTriggerType type = WiredTriggerType.USER_PERFORMS_ACTION; + private static final int DEFAULT_ACTION = WiredUserActionType.WAVE; + + private int selectedAction = DEFAULT_ACTION; + private boolean signFilterEnabled = false; + private int signId = 0; + private boolean danceFilterEnabled = false; + private int danceId = 1; + + public WiredTriggerHabboPerformsAction(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public WiredTriggerHabboPerformsAction(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public boolean matches(HabboItem triggerItem, WiredEvent event) { + if (!event.getActor().isPresent()) { + return false; + } + + if (event.getActionId() != this.selectedAction) { + return false; + } + + if (this.selectedAction == WiredUserActionType.SIGN && this.signFilterEnabled) { + return event.getActionParameter() == this.signId; + } + + if (this.selectedAction == WiredUserActionType.DANCE && this.danceFilterEnabled) { + return event.getActionParameter() == this.danceId; + } + + return true; + } + + @Deprecated + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + return false; + } + + @Override + public String getWiredData() { + return WiredManager.getGson().toJson(new JsonData( + this.selectedAction, + this.signFilterEnabled, + this.signId, + this.danceFilterEnabled, + this.danceId + )); + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + this.resetSettings(); + + String wiredData = set.getString("wired_data"); + + if (wiredData != null && wiredData.startsWith("{")) { + JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); + + if (data == null) { + return; + } + + this.selectedAction = normalizeAction(data.selectedAction); + this.signFilterEnabled = data.signFilterEnabled; + this.signId = normalizeSignId(data.signId); + this.danceFilterEnabled = data.danceFilterEnabled; + this.danceId = normalizeDanceId(data.danceId); + } + } + + @Override + public void onPickUp() { + this.resetSettings(); + } + + @Override + public WiredTriggerType getType() { + return type; + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + message.appendBoolean(false); + message.appendInt(5); + message.appendInt(0); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(5); + message.appendInt(this.selectedAction); + message.appendInt(this.signFilterEnabled ? 1 : 0); + message.appendInt(this.signId); + message.appendInt(this.danceFilterEnabled ? 1 : 0); + message.appendInt(this.danceId); + message.appendInt(0); + message.appendInt(this.getType().code); + message.appendInt(0); + message.appendInt(0); + } + + @Override + public boolean saveData(WiredSettings settings) { + int[] intParams = settings.getIntParams(); + + this.resetSettings(); + + if (intParams.length > 0) { + this.selectedAction = normalizeAction(intParams[0]); + } + + if (intParams.length > 1) { + this.signFilterEnabled = (intParams[1] == 1); + } + + if (intParams.length > 2) { + this.signId = normalizeSignId(intParams[2]); + } + + if (intParams.length > 3) { + this.danceFilterEnabled = (intParams[3] == 1); + } + + if (intParams.length > 4) { + this.danceId = normalizeDanceId(intParams[4]); + } + + return true; + } + + @Override + public boolean isTriggeredByRoomUnit() { + return true; + } + + private void resetSettings() { + this.selectedAction = DEFAULT_ACTION; + this.signFilterEnabled = false; + this.signId = 0; + this.danceFilterEnabled = false; + this.danceId = 1; + } + + private int normalizeAction(int action) { + switch (action) { + case WiredUserActionType.WAVE: + case WiredUserActionType.BLOW_KISS: + case WiredUserActionType.LAUGH: + case WiredUserActionType.AWAKE: + case WiredUserActionType.RELAX: + case WiredUserActionType.SIT: + case WiredUserActionType.STAND: + case WiredUserActionType.LAY: + case WiredUserActionType.SIGN: + case WiredUserActionType.DANCE: + case WiredUserActionType.THUMB_UP: + return action; + default: + return DEFAULT_ACTION; + } + } + + private int normalizeSignId(int signId) { + if (signId < 0 || signId > 17) { + return 0; + } + + return signId; + } + + private int normalizeDanceId(int danceId) { + if (danceId < 1 || danceId > 4) { + return 1; + } + + return danceId; + } + + static class JsonData { + int selectedAction; + boolean signFilterEnabled; + int signId; + boolean danceFilterEnabled; + int danceId; + + public JsonData(int selectedAction, boolean signFilterEnabled, int signId, boolean danceFilterEnabled, int danceId) { + this.selectedAction = selectedAction; + this.signFilterEnabled = signFilterEnabled; + this.signId = signId; + this.danceFilterEnabled = danceFilterEnabled; + this.danceId = danceId; + } + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index f9094c09..dadac6be 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -139,7 +139,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements // Fire when elapsed time is a multiple of repeat time if (elapsedMs % this.repeatTime == 0) { if (this.getRoomId() != 0 && room.isLoaded()) { - WiredManager.triggerTimerRepeat(room, this); + WiredManager.triggerTimerRepeatLong(room, this); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterShort.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterShort.java new file mode 100644 index 00000000..00800e67 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterShort.java @@ -0,0 +1,125 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.triggers; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.ServerMessage; +import gnu.trove.procedure.TObjectProcedure; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class WiredTriggerRepeaterShort extends WiredTriggerRepeater { + public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_SHORT; + public static final int STEP_MS = 50; + public static final int DEFAULT_DELAY = 10 * STEP_MS; + public static final int MIN_DELAY = STEP_MS; + public static final int MAX_DELAY = 10 * STEP_MS; + + public WiredTriggerRepeaterShort(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + this.repeatTime = DEFAULT_DELAY; + } + + public WiredTriggerRepeaterShort(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + this.repeatTime = DEFAULT_DELAY; + } + + @Override + public void loadWiredData(ResultSet set, Room room) throws SQLException { + String wiredData = set.getString("wired_data"); + + if (wiredData != null && wiredData.startsWith("{")) { + JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class); + this.repeatTime = (data != null) ? data.repeatTime : DEFAULT_DELAY; + } else if (wiredData != null && wiredData.length() >= 1) { + this.repeatTime = Integer.parseInt(wiredData); + } else { + this.repeatTime = DEFAULT_DELAY; + } + + this.repeatTime = clampRepeatTime(this.repeatTime); + } + + @Override + public void onPickUp() { + this.repeatTime = DEFAULT_DELAY; + } + + @Override + public WiredTriggerType getType() { + return type; + } + + @Override + public void serializeWiredData(ServerMessage message, Room room) { + message.appendBoolean(false); + message.appendInt(5); + message.appendInt(0); + message.appendInt(this.getBaseItem().getSpriteId()); + message.appendInt(this.getId()); + message.appendString(""); + message.appendInt(1); + message.appendInt(this.repeatTime / STEP_MS); + message.appendInt(0); + message.appendInt(this.getType().code); + + if (!this.isTriggeredByRoomUnit()) { + List invalidTriggers = new ArrayList<>(); + room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() { + @Override + public boolean execute(InteractionWiredEffect object) { + if (object.requiresTriggeringUser()) { + invalidTriggers.add(object.getBaseItem().getSpriteId()); + } + return true; + } + }); + message.appendInt(invalidTriggers.size()); + for (Integer i : invalidTriggers) { + message.appendInt(i); + } + } else { + message.appendInt(0); + } + } + + @Override + public boolean saveData(WiredSettings settings) { + if (settings.getIntParams().length < 1) return false; + + int newRepeatTime = settings.getIntParams()[0] * STEP_MS; + this.repeatTime = clampRepeatTime(newRepeatTime); + + return true; + } + + @Override + public void onWiredTick(Room room, long tickCount, int tickIntervalMs) { + long elapsedMs = tickCount * tickIntervalMs; + + if (elapsedMs % this.repeatTime == 0) { + if (this.getRoomId() != 0 && room.isLoaded()) { + WiredManager.triggerTimerRepeatShort(room, this); + } + } + } + + private int clampRepeatTime(int repeatTime) { + if (repeatTime < MIN_DELAY) { + return DEFAULT_DELAY; + } + + if (repeatTime > MAX_DELAY) { + return MAX_DELAY; + } + + return repeatTime; + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 01e81ce6..6746c59d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -15,6 +15,8 @@ import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; +import com.eu.habbo.habbohotel.wired.core.WiredManager; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; @@ -2162,6 +2164,7 @@ public class Room implements Comparable, ISerialize, Runnable { - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + ""); this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + WiredManager.triggerUserPerformsAction(this, habbo.getRoomUnit(), WiredUserActionType.SIT, -1); } public void makeStand(Habbo habbo) { @@ -2171,12 +2174,19 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { + boolean wasSittingOrLaying = habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) + || habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY); habbo.getRoomUnit().cmdStand = true; habbo.getRoomUnit().setBodyRotation( RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); + habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + + if (wasSittingOrLaying) { + WiredManager.triggerUserPerformsAction(this, habbo.getRoomUnit(), WiredUserActionType.STAND, -1); + } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java index 9ac9c726..7a33df06 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -13,6 +13,7 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorMessagesComposer; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; @@ -217,6 +218,10 @@ public class RoomUnitManager { return; } + if (habbo.getRoomUnit() != null) { + WiredManager.triggerUserLeavesRoom(this.room, habbo.getRoomUnit()); + } + if (habbo.getRoomUnit() != null && habbo.getRoomUnit().getCurrentLocation() != null) { habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); } @@ -352,6 +357,7 @@ public class RoomUnitManager { } double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight(); + boolean hadLayStatus = habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY); if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) || (topItem != null && topItem.getBaseItem().allowSit())) { @@ -413,6 +419,10 @@ public class RoomUnitManager { } habbo.getRoomUnit().statusUpdate(true); + + if (!hadLayStatus && habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { + WiredManager.triggerUserPerformsAction(this.room, habbo.getRoomUnit(), WiredUserActionType.LAY, -1); + } } if (!habbos.isEmpty()) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 6aab1031..b837f0c0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -466,7 +466,7 @@ public class WiredHandler { room.getRoomSpecialTypes().getTriggers().forEach(t -> { if (t == null) return; - if (t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) { + if (t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG || t.getType() == WiredTriggerType.PERIODICALLY_SHORT) { ((WiredTriggerReset) t).resetTimer(); } }); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java index e1767c1b..2672758b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredTriggerType.java @@ -15,6 +15,12 @@ public enum WiredTriggerType { PERIODICALLY_LONG(12), BOT_REACHED_STF(13), BOT_REACHED_AVTR(14), + LEAVE_ROOM(16), + PERIODICALLY_SHORT(17), + CLICKS_FURNI(18), + CLICKS_TILE(19), + CLICKS_USER(20), + USER_PERFORMS_ACTION(21), SAY_COMMAND(0), IDLES(11), UNIDLES(11), diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredUserActionType.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredUserActionType.java new file mode 100644 index 00000000..eaf12377 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredUserActionType.java @@ -0,0 +1,18 @@ +package com.eu.habbo.habbohotel.wired; + +public final class WiredUserActionType { + public static final int WAVE = 1; + public static final int BLOW_KISS = 2; + public static final int LAUGH = 3; + public static final int AWAKE = 4; + public static final int RELAX = 5; + public static final int SIT = 6; + public static final int STAND = 7; + public static final int LAY = 8; + public static final int SIGN = 9; + public static final int DANCE = 10; + public static final int THUMB_UP = 11; + + private WiredUserActionType() { + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEvent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEvent.java index ca3c543b..369d7fba 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredEvent.java @@ -42,6 +42,18 @@ public final class WiredEvent { /** User walks off furniture */ USER_WALKS_OFF(WiredTriggerType.WALKS_OFF_FURNI), + + /** User clicks furniture */ + USER_CLICKS_FURNI(WiredTriggerType.CLICKS_FURNI), + + /** User clicks invisible click tile furniture */ + USER_CLICKS_TILE(WiredTriggerType.CLICKS_TILE), + + /** User clicks another user */ + USER_CLICKS_USER(WiredTriggerType.CLICKS_USER), + + /** User performs an avatar action */ + USER_PERFORMS_ACTION(WiredTriggerType.USER_PERFORMS_ACTION), /** Furniture state is toggled/changed */ FURNI_STATE_CHANGED(WiredTriggerType.STATE_CHANGED), @@ -54,9 +66,15 @@ public final class WiredEvent { /** Long timer repeat */ TIMER_REPEAT_LONG(WiredTriggerType.PERIODICALLY_LONG), + + /** Short timer repeat */ + TIMER_REPEAT_SHORT(WiredTriggerType.PERIODICALLY_SHORT), /** User enters the room */ USER_ENTERS_ROOM(WiredTriggerType.ENTER_ROOM), + + /** User leaves the room */ + USER_LEAVES_ROOM(WiredTriggerType.LEAVE_ROOM), /** Game starts */ GAME_STARTS(WiredTriggerType.GAME_STARTS), @@ -141,6 +159,8 @@ public final class WiredEvent { private final boolean triggeredByEffect; // true if triggered by a wired effect (to prevent loops) private final int callStackDepth; // recursion depth for trigger stacks effect private final int signalChannel; // channel for signal routing (0-based) + private final int actionId; // user action id for USER_PERFORMS_ACTION + private final int actionParameter; // sign/dance parameter when relevant private final long createdAtMs; private WiredEvent(Builder builder) { @@ -156,6 +176,8 @@ public final class WiredEvent { this.triggeredByEffect = builder.triggeredByEffect; this.callStackDepth = builder.callStackDepth; this.signalChannel = builder.signalChannel; + this.actionId = builder.actionId; + this.actionParameter = builder.actionParameter; this.createdAtMs = builder.createdAtMs; } @@ -258,6 +280,14 @@ public final class WiredEvent { return signalChannel; } + public int getActionId() { + return actionId; + } + + public int getActionParameter() { + return actionParameter; + } + /** * Get the timestamp when this event was created. * @return milliseconds since epoch @@ -313,6 +343,8 @@ public final class WiredEvent { private boolean triggeredByEffect; private int callStackDepth; private int signalChannel; + private int actionId; + private int actionParameter = -1; private long createdAtMs = System.currentTimeMillis(); private Builder(Type type, Room room) { @@ -417,6 +449,16 @@ public final class WiredEvent { return this; } + public Builder actionId(int actionId) { + this.actionId = actionId; + return this; + } + + public Builder actionParameter(int actionParameter) { + this.actionParameter = actionParameter; + return this; + } + /** * Set a custom creation timestamp. * @param createdAtMs milliseconds since epoch diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredManager.java index e31b948c..e758edf8 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/core/WiredManager.java @@ -235,6 +235,54 @@ public final class WiredManager { return handleEvent(event); } + /** + * Trigger when a user clicks furniture. + */ + public static boolean triggerUserClicksFurni(Room room, RoomUnit user, HabboItem item) { + if (!isEnabled() || room == null || user == null || item == null) { + return false; + } + + WiredEvent event = WiredEvents.userClicksFurni(room, user, item); + return handleEvent(event); + } + + /** + * Trigger when a user clicks invisible click tile furniture. + */ + public static boolean triggerUserClicksTile(Room room, RoomUnit user, HabboItem item) { + if (!isEnabled() || room == null || user == null || item == null) { + return false; + } + + WiredEvent event = WiredEvents.userClicksTile(room, user, item); + return handleEvent(event); + } + + /** + * Trigger when a user clicks another user. + */ + public static boolean triggerUserClicksUser(Room room, RoomUnit clickingUser, RoomUnit clickedUser) { + if (!isEnabled() || room == null || clickingUser == null || clickedUser == null) { + return false; + } + + WiredEvent event = WiredEvents.userClicksUser(room, clickingUser, clickedUser); + return handleEvent(event); + } + + /** + * Trigger when a user performs an avatar action. + */ + public static boolean triggerUserPerformsAction(Room room, RoomUnit user, int actionId, int actionParameter) { + if (!isEnabled() || room == null || user == null) { + return false; + } + + WiredEvent event = WiredEvents.userPerformsAction(room, user, actionId, actionParameter); + return handleEvent(event); + } + /** * Trigger when a user says something. */ @@ -259,6 +307,18 @@ public final class WiredManager { return handleEvent(event); } + /** + * Trigger when a user leaves the room. + */ + public static boolean triggerUserLeavesRoom(Room room, RoomUnit user) { + if (!isEnabled() || room == null || user == null) { + return false; + } + + WiredEvent event = WiredEvents.userLeavesRoom(room, user); + return handleEvent(event); + } + /** * Trigger when furniture state changes. */ @@ -295,6 +355,30 @@ public final class WiredManager { return handleEvent(event); } + /** + * Trigger a long periodic timer. + */ + public static boolean triggerTimerRepeatLong(Room room, HabboItem timerItem) { + if (!isEnabled() || room == null) { + return false; + } + + WiredEvent event = WiredEvents.timerRepeatLong(room, timerItem); + return handleEvent(event); + } + + /** + * Trigger a short periodic timer. + */ + public static boolean triggerTimerRepeatShort(Room room, HabboItem timerItem) { + if (!isEnabled() || room == null) { + return false; + } + + WiredEvent event = WiredEvents.timerRepeatShort(room, timerItem); + return handleEvent(event); + } + /** * Trigger game start. */ diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/migrate/WiredEvents.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/migrate/WiredEvents.java index 91bba744..e93072b2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/migrate/WiredEvents.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/migrate/WiredEvents.java @@ -67,6 +67,70 @@ public final class WiredEvents { .build(); } + /** + * Create an event for when a user clicks furniture. + * @param room the room + * @param user the clicking user + * @param item the clicked furniture + * @return the event + */ + public static WiredEvent userClicksFurni(Room room, RoomUnit user, HabboItem item) { + RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); + return WiredEvent.builder(WiredEvent.Type.USER_CLICKS_FURNI, room) + .actor(user) + .sourceItem(item) + .tile(tile) + .build(); + } + + /** + * Create an event for when a user clicks invisible click tile furniture. + * @param room the room + * @param user the clicking user + * @param item the clicked furniture + * @return the event + */ + public static WiredEvent userClicksTile(Room room, RoomUnit user, HabboItem item) { + RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); + return WiredEvent.builder(WiredEvent.Type.USER_CLICKS_TILE, room) + .actor(user) + .sourceItem(item) + .tile(tile) + .build(); + } + + /** + * Create an event for when a user clicks another user. + * @param room the room + * @param clickingUser the user performing the click + * @param clickedUser the user who was clicked + * @return the event + */ + public static WiredEvent userClicksUser(Room room, RoomUnit clickingUser, RoomUnit clickedUser) { + return WiredEvent.builder(WiredEvent.Type.USER_CLICKS_USER, room) + .actor(clickedUser) + .targetUnit(clickingUser) + .tile(clickedUser.getCurrentLocation()) + .build(); + } + + /** + * Create an event for when a user performs an avatar action. + * @param room the room + * @param user the acting user + * @param actionId the wired action id + * @param actionParameter sign/dance parameter, or -1 when unused + * @return the event + */ + public static WiredEvent userPerformsAction(Room room, RoomUnit user, int actionId, int actionParameter) { + return WiredEvent.builder(WiredEvent.Type.USER_PERFORMS_ACTION, room) + .actor(user) + .tile(user.getCurrentLocation()) + .actionId(actionId) + .actionParameter(actionParameter) + .build(); + } + /** * Create an event for when a user enters the room. * @param room the room @@ -80,6 +144,19 @@ public final class WiredEvents { .build(); } + /** + * Create an event for when a user leaves the room. + * @param room the room + * @param user the user who left + * @return the event + */ + public static WiredEvent userLeavesRoom(Room room, RoomUnit user) { + return WiredEvent.builder(WiredEvent.Type.USER_LEAVES_ROOM, room) + .actor(user) + .tile(user.getCurrentLocation()) + .build(); + } + // ========== User Interaction Events ========== /** @@ -153,6 +230,18 @@ public final class WiredEvents { .build(); } + /** + * Create an event for a short periodic timer. + * @param room the room + * @param timerItem the timer furniture + * @return the event + */ + public static WiredEvent timerRepeatShort(Room room, HabboItem timerItem) { + return WiredEvent.builder(WiredEvent.Type.TIMER_REPEAT_SHORT, room) + .sourceItem(timerItem) + .build(); + } + // ========== Game Events ========== /** diff --git a/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java b/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java index 6bd33db3..757e1636 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -387,6 +387,8 @@ public class PacketManager { this.registerHandler(Incoming.RoomPlacePaintEvent, RoomPlacePaintEvent.class); this.registerHandler(Incoming.RoomUserStartTypingEvent, RoomUserStartTypingEvent.class); this.registerHandler(Incoming.RoomUserStopTypingEvent, RoomUserStopTypingEvent.class); + this.registerHandler(Incoming.ClickFurniEvent, ClickFurniEvent.class); + this.registerHandler(Incoming.ClickUserEvent, ClickUserEvent.class); this.registerHandler(Incoming.ToggleFloorItemEvent, ToggleFloorItemEvent.class); this.registerHandler(Incoming.ToggleWallItemEvent, ToggleWallItemEvent.class); this.registerHandler(Incoming.RoomBackgroundEvent, RoomBackgroundEvent.class); @@ -647,4 +649,4 @@ public class PacketManager { this.registerHandler(Incoming.GameCenterEvent, GameCenterEvent.class); this.registerHandler(Incoming.GameCenterRequestGameStatusEvent, GameCenterRequestGameStatusEvent.class); } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 8c9625e7..5bdc6847 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -205,6 +205,7 @@ public class Incoming { public static final int RequestRoomDataEvent = 2230; public static final int RequestRoomHeightmapEvent = 2300; public static final int RequestGuildFurniWidgetEvent = 2651; + public static final int ClickFurniEvent = 6002; public static final int RequestOwnItemsEvent = 2105; public static final int RequestReportRoomEvent = 3267; public static final int ReportEvent = 1691; @@ -407,6 +408,7 @@ public class Incoming { // CUSTOM public static final int UpdateFurniturePositionEvent = 10019; + public static final int ClickUserEvent = 10020; public static final int RequestInventoryPetDelete = 10030; public static final int RequestInventoryBadgeDelete = 10031; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ClickFurniEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ClickFurniEvent.java new file mode 100644 index 00000000..6ae99006 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ClickFurniEvent.java @@ -0,0 +1,43 @@ +package com.eu.habbo.messages.incoming.rooms.items; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.incoming.MessageHandler; + +public class ClickFurniEvent extends MessageHandler { + private static final String CLICK_TILE_INTERACTION = "room_invisible_click_tile"; + + @Override + public void handle() throws Exception { + Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + + if (room == null) { + return; + } + + int itemId = Math.abs(this.packet.readInt()); + this.packet.readInt(); + + HabboItem item = room.getHabboItem(itemId); + + if (item == null) { + return; + } + + WiredManager.triggerUserClicksFurni(room, this.client.getHabbo().getRoomUnit(), item); + + if (isClickTileItem(item)) { + WiredManager.triggerUserClicksTile(room, this.client.getHabbo().getRoomUnit(), item); + } + } + + private boolean isClickTileItem(HabboItem item) { + if (item == null || item.getBaseItem() == null || item.getBaseItem().getInteractionType() == null) { + return false; + } + + String interaction = item.getBaseItem().getInteractionType().getName(); + return interaction != null && interaction.equalsIgnoreCase(CLICK_TILE_INTERACTION); + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ClickUserEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ClickUserEvent.java new file mode 100644 index 00000000..5426e842 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ClickUserEvent.java @@ -0,0 +1,33 @@ +package com.eu.habbo.messages.incoming.rooms.users; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.core.WiredManager; +import com.eu.habbo.messages.incoming.MessageHandler; + +public class ClickUserEvent extends MessageHandler { + @Override + public void handle() throws Exception { + Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + + if (room == null) { + return; + } + + RoomUnit clickingUser = this.client.getHabbo().getRoomUnit(); + + if (clickingUser == null) { + return; + } + + int roomUnitId = this.packet.readInt(); + Habbo clickedHabbo = room.getHabboByRoomUnitId(roomUnitId); + + if (clickedHabbo == null || clickedHabbo.getRoomUnit() == null) { + return; + } + + WiredManager.triggerUserClicksUser(room, clickingUser, clickedHabbo.getRoomUnit()); + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java index 41c29f25..bc32465b 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserActionEvent.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; +import com.eu.habbo.habbohotel.wired.core.WiredManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; @@ -26,6 +28,7 @@ public class RoomUserActionEvent extends MessageHandler { } int action = this.packet.readInt(); + int wiredAction = 0; if (action == 5) { UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.ACTION, true); @@ -34,8 +37,10 @@ public class RoomUserActionEvent extends MessageHandler { if (!event.isCancelled()) { if (event.idle) { room.idle(habbo); + wiredAction = WiredUserActionType.RELAX; } else { room.unIdle(habbo); + wiredAction = WiredUserActionType.AWAKE; } } } else { @@ -51,6 +56,29 @@ public class RoomUserActionEvent extends MessageHandler { } room.sendComposer(new RoomUserActionComposer(habbo.getRoomUnit(), RoomUserAction.fromValue(action)).compose()); + + if (wiredAction == 0) { + switch (action) { + case 1: + wiredAction = WiredUserActionType.WAVE; + break; + case 2: + wiredAction = WiredUserActionType.BLOW_KISS; + break; + case 3: + wiredAction = WiredUserActionType.LAUGH; + break; + case 7: + wiredAction = WiredUserActionType.THUMB_UP; + break; + default: + break; + } + } + + if (wiredAction != 0) { + WiredManager.triggerUserPerformsAction(room, habbo.getRoomUnit(), wiredAction, -1); + } } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java index bafd54dd..bda9bd4e 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java @@ -3,8 +3,9 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; +import com.eu.habbo.habbohotel.wired.core.WiredManager; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; public class RoomUserDanceEvent extends MessageHandler { @@ -14,7 +15,7 @@ public class RoomUserDanceEvent extends MessageHandler { return; int danceId = this.packet.readInt(); - if (danceId >= 0 && danceId <= 5) { + if (danceId >= 0 && danceId <= 4) { if (this.client.getHabbo().getRoomUnit().isInRoom()) { Habbo habbo = this.client.getHabbo(); @@ -29,8 +30,6 @@ public class RoomUserDanceEvent extends MessageHandler { } } - habbo.getRoomUnit().setDanceType(DanceType.values()[danceId]); - UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.DANCE, false); Emulator.getPluginManager().fireEvent(event); @@ -40,7 +39,11 @@ public class RoomUserDanceEvent extends MessageHandler { } } - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDanceComposer(habbo.getRoomUnit()).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().dance(habbo, DanceType.values()[danceId]); + + if (danceId > 0) { + WiredManager.triggerUserPerformsAction(this.client.getHabbo().getHabboInfo().getCurrentRoom(), habbo.getRoomUnit(), WiredUserActionType.DANCE, danceId); + } } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java index 3b2aaf93..fba5fccf 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java @@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredUserActionType; +import com.eu.habbo.habbohotel.wired.core.WiredManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSignEvent; @@ -22,6 +24,7 @@ public class RoomUserSignEvent extends MessageHandler { if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + ""); this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); + WiredManager.triggerUserPerformsAction(room, this.client.getHabbo().getRoomUnit(), WiredUserActionType.SIGN, event.sign); if(signId <= 10) { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java index f3c8df7f..debdb49c 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSitEvent.java @@ -7,11 +7,18 @@ import com.eu.habbo.plugin.events.users.UserIdleEvent; public class RoomUserSitEvent extends MessageHandler { @Override public void handle() throws Exception { + int posture = this.packet.readInt(); + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { if (this.client.getHabbo().getRoomUnit().isWalking()) { this.client.getHabbo().getRoomUnit().stopWalking(); } - this.client.getHabbo().getHabboInfo().getCurrentRoom().makeSit(this.client.getHabbo()); + + if (posture == 0) { + this.client.getHabbo().getHabboInfo().getCurrentRoom().makeStand(this.client.getHabbo()); + } else { + this.client.getHabbo().getHabboInfo().getCurrentRoom().makeSit(this.client.getHabbo()); + } UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event);