From 86cf51ab05fc9fd6108c1a66e231f6f3546a9932 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 20 Nov 2021 02:55:26 +0100 Subject: [PATCH] New event to be able to edit floor items while loading room (to hide furniture for example) --- .../habbo/habbohotel/rooms/RoomManager.java | 13 +++++++- .../events/rooms/RoomFloorItemsLoadEvent.java | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 05ddc66a..eb9af764 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -42,11 +42,13 @@ import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageCompo import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; +import com.eu.habbo.plugin.events.rooms.RoomFloorItemsLoadEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; +import com.eu.habbo.plugin.events.users.UsernameTalkEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TIntProcedure; @@ -788,7 +790,16 @@ public class RoomManager { { final THashSet floorItems = new THashSet<>(); - room.getFloorItems().forEach(new TObjectProcedure() { + THashSet allFloorItems = new THashSet<>(room.getFloorItems()); + + if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) { + RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems)); + if (roomFloorItemsLoadEvent.hasChangedFloorItems()) { + allFloorItems = roomFloorItemsLoadEvent.getFloorItems(); + } + } + + allFloorItems.forEach(new TObjectProcedure() { @Override public boolean execute(HabboItem object) { if (room.isHideWired() && object instanceof InteractionWired) diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java new file mode 100644 index 00000000..01bea305 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java @@ -0,0 +1,30 @@ +package com.eu.habbo.plugin.events.rooms; + +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.plugin.events.users.UserEvent; +import gnu.trove.set.hash.THashSet; + +public class RoomFloorItemsLoadEvent extends UserEvent { + private THashSet floorItems; + private boolean changedFloorItems; + + public RoomFloorItemsLoadEvent(Habbo habbo, THashSet floorItems) { + super(habbo); + this.floorItems = floorItems; + this.changedFloorItems = false; + } + + public void setFloorItems(THashSet floorItems) { + this.changedFloorItems = true; + this.floorItems = floorItems; + } + + public boolean hasChangedFloorItems() { + return this.changedFloorItems; + } + + public THashSet getFloorItems() { + return this.floorItems; + } +}