From 659a9d375f3d28468080bde656dd7c48fdcdd076 Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 20 Jul 2023 16:17:29 -0500 Subject: [PATCH] More Refactoring --- .../commands/list/MimicCommand.java | 2 +- .../habbohotel/commands/list/PullCommand.java | 2 +- .../habbohotel/commands/list/PushCommand.java | 2 +- .../commands/list/SoftKickCommand.java | 2 +- .../commands/list/SuperPullCommand.java | 2 +- .../games/football/FootballGame.java | 2 +- .../habbo/habbohotel/games/tag/TagGame.java | 2 +- .../com/eu/habbo/habbohotel/items/Item.java | 8 +- .../interactions/InteractionDefault.java | 5 +- .../interactions/InteractionEffectTile.java | 2 +- .../interactions/InteractionGuildGate.java | 2 +- .../interactions/InteractionGymEquipment.java | 6 +- .../InteractionInformationTerminal.java | 2 +- .../interactions/InteractionMultiHeight.java | 4 +- .../interactions/InteractionObstacle.java | 4 +- .../InteractionRentableSpace.java | 2 +- .../items/interactions/InteractionRoller.java | 4 +- .../interactions/InteractionRoomClubGate.java | 4 +- .../InteractionRoomClubTeleportTile.java | 2 +- .../interactions/InteractionTeleportTile.java | 2 +- .../items/interactions/InteractionTrap.java | 4 +- .../items/interactions/InteractionWater.java | 4 +- .../InteractionBattleBanzaiPuck.java | 8 +- .../InteractionBattleBanzaiTile.java | 8 +- .../gates/InteractionBattleBanzaiGate.java | 6 +- .../football/InteractionFootballGate.java | 2 +- .../games/freeze/InteractionFreezeBlock.java | 4 +- .../games/freeze/InteractionFreezeTile.java | 4 +- .../freeze/gates/InteractionFreezeGate.java | 6 +- .../games/tag/InteractionTagField.java | 6 +- .../tag/icetag/InteractionIceTagField.java | 4 +- .../InteractionRollerskateField.java | 4 +- .../conditions/WiredConditionGroupMember.java | 2 +- .../conditions/WiredConditionNotInGroup.java | 2 +- .../conditions/WiredConditionNotInTeam.java | 2 +- .../WiredConditionRoomWearsBadge.java | 2 +- .../conditions/WiredConditionTeamMember.java | 2 +- .../wired/effects/WiredEffectAlert.java | 2 +- .../effects/WiredEffectBotFollowRoom.java | 2 +- .../effects/WiredEffectBotGiveHandItem.java | 2 +- .../wired/effects/WiredEffectBotTalk.java | 2 +- .../effects/WiredEffectBotTalkToRoom.java | 2 +- .../wired/effects/WiredEffectBotTeleport.java | 2 +- .../effects/WiredEffectGiveHandItem.java | 2 +- ...redEffectGiveHotelviewBonusRarePoints.java | 2 +- .../WiredEffectGiveHotelviewHofPoints.java | 2 +- .../wired/effects/WiredEffectGiveRespect.java | 2 +- .../wired/effects/WiredEffectGiveReward.java | 2 +- .../wired/effects/WiredEffectGiveScore.java | 2 +- .../wired/effects/WiredEffectJoinTeam.java | 2 +- .../wired/effects/WiredEffectKickRoom.java | 2 +- .../wired/effects/WiredEffectLeaveTeam.java | 2 +- .../wired/effects/WiredEffectMuteRoom.java | 2 +- .../wired/effects/WiredEffectTeleport.java | 2 +- .../wired/effects/WiredEffectToggleFurni.java | 4 +- .../wired/effects/WiredEffectWhisper.java | 2 +- .../interactions/wired/extra/WiredBlob.java | 2 +- .../WiredTriggerFurniStateToggled.java | 4 +- .../triggers/WiredTriggerRoomEntersRoom.java | 2 +- .../triggers/WiredTriggerRoomSaysKeyword.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 245 ++----- .../habbohotel/rooms/RoomChatMessage.java | 2 +- .../habbohotel/rooms/RoomItemManager.java | 598 +++++++++++++++++- .../habbohotel/rooms/RoomSpecialTypes.java | 10 +- .../habbohotel/rooms/RoomUnitManager.java | 70 +- .../habbohotel/rooms/RoomWiredManager.java | 123 ++++ .../rooms/entities/items/RoomItem.java | 4 +- .../entities/items/types/RoomFloorItem.java | 30 - .../entities/items/types/RoomWallItem.java | 30 - .../entities/units/types/RoomAvatar.java | 5 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 3 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 79 +-- .../habbo/habbohotel/users/HabboManager.java | 2 - .../users/cache/HabboInfoCache.java | 22 + .../habbo/habbohotel/wired/WiredHandler.java | 3 +- .../rooms/items/PlaceObjectEvent.java | 46 +- .../rooms/users/GetUserTagsEvent.java | 2 +- .../incoming/rooms/users/IgnoreUserEvent.java | 2 +- .../rooms/users/UnignoreUserEvent.java | 2 +- .../incoming/trading/OpenTradingEvent.java | 2 +- 80 files changed, 961 insertions(+), 500 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java delete mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java delete mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomWallItem.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java index 110c1d9a..752146a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java @@ -19,7 +19,7 @@ public class MimicCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length == 2) { - Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.not_found"), ""), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java index bee583fa..8fee7982 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java @@ -17,7 +17,7 @@ public class PullCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length != 2) return true; - Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java index f9679b42..dea7b678 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java @@ -18,7 +18,7 @@ public class PushCommand extends Command { public boolean handle(GameClient gameClient, String[] params) { if (params.length != 2) return true; - Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_push.not_found"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java index e9cf4562..3cb717c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java @@ -15,7 +15,7 @@ public class SoftKickCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length != 2) return true; - final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); + final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.keys.cmd_softkick_error"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java index 400ef81c..d1e3b2cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java @@ -20,7 +20,7 @@ public class SuperPullCommand extends Command { return true; } - Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java index 279969e2..bed87dcd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java @@ -35,7 +35,7 @@ public class FootballGame extends Game { if (this.room == null || !this.room.isLoaded()) return; - Habbo habbo = this.room.getHabbo(kicker); + Habbo habbo = this.room.getRoomUnitManager().getHabboByRoomUnit(kicker); if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored")); if (habbo.getHabboInfo().getId() != this.room.getRoomInfo().getOwnerInfo().getId()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java index df080a9f..27241fbb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java @@ -36,7 +36,7 @@ public abstract class TagGame extends Game { if (event.room == null || event.roomUnit == null || event.location == null) return; if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentPosition(), event.location)) { - Habbo habbo = event.room.getHabbo(event.roomUnit); + Habbo habbo = event.room.getRoomUnitManager().getHabboByRoomUnit(event.roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getCurrentGame() != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java index 1d9ffce7..25e6ae8a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -12,7 +12,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class Item implements ISerialize { - @Getter private int id; @Getter @@ -33,7 +32,7 @@ public class Item implements ISerialize { private boolean allowWalk; private boolean allowSit; private boolean allowLay; - private boolean allowRecyle; + private boolean allowRecycle; private boolean allowTrade; private boolean allowMarketplace; private boolean allowGift; @@ -52,7 +51,6 @@ public class Item implements ISerialize { private String customParams; @Getter private String clothingOnWalk; - @Getter private ItemInteraction interactionType; @Getter @@ -103,7 +101,7 @@ public class Item implements ISerialize { this.allowWalk = set.getBoolean("allow_walk"); this.allowSit = set.getBoolean("allow_sit"); this.allowLay = set.getBoolean("allow_lay"); - this.allowRecyle = set.getBoolean("allow_recycle"); + this.allowRecycle = set.getBoolean("allow_recycle"); this.allowTrade = set.getBoolean("allow_trade"); this.allowMarketplace = set.getBoolean("allow_marketplace_sell"); this.allowGift = set.getBoolean("allow_gift"); @@ -164,7 +162,7 @@ public class Item implements ISerialize { } public boolean allowRecyle() { - return this.allowRecyle; + return this.allowRecycle; } public boolean allowTrade() { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java index b0a17a3d..bc6e535e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java @@ -21,7 +21,6 @@ import java.sql.SQLException; @Slf4j public class InteractionDefault extends RoomItem { - public InteractionDefault(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -110,7 +109,7 @@ public class InteractionDefault extends RoomItem { } if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) return; @@ -176,7 +175,7 @@ public class InteractionDefault extends RoomItem { } if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { 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 e03b75a5..a1c65f49 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 @@ -52,7 +52,7 @@ public class InteractionEffectTile extends InteractionPressurePlate { super.onWalkOn(roomUnit, room, objects); if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java index f7a5d4b0..04dbcf76 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java @@ -35,7 +35,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi if (roomUnit == null) return false; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasRight(Permission.ACC_GUILDGATE)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java index 307f2fd6..72d89ab5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java @@ -49,7 +49,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC this.roomUnitId = roomUnit.getVirtualId(); if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { this.startTime = Emulator.getIntUnixTimestamp(); @@ -66,7 +66,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC this.reset(room); if (roomUnit != null) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; @@ -107,7 +107,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC @Override public void cycle(Room room) { if (this.roomUnitId != -1) { - Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId); + Habbo habbo = room.getRoomUnitManager().getHabboByVirtualId(this.roomUnitId); if (habbo != null) { int timestamp = Emulator.getIntUnixTimestamp(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java index a8c215f7..b75412c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java @@ -40,7 +40,7 @@ public class InteractionInformationTerminal extends InteractionCustomValues { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null && this.values.containsKey("internalLink")) { habbo.getClient().sendResponse(new InClientLinkMessageComposer(this.values.get("internalLink"))); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java index 29582b62..4d851bee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java @@ -110,7 +110,7 @@ public class InteractionMultiHeight extends RoomItem { if (roomUnit != null && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { @@ -132,7 +132,7 @@ public class InteractionMultiHeight extends RoomItem { if (roomUnit != null && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java index b1627e31..f2a59ce1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java @@ -94,7 +94,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); @@ -123,7 +123,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java index f3caa812..703c528b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java @@ -77,7 +77,7 @@ public class InteractionRentableSpace extends RoomItem { if (this.getExtradata().isEmpty()) return false; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java index b72c0a3f..267cd835 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java @@ -4,8 +4,8 @@ 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.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -68,7 +68,7 @@ public class InteractionRoller extends RoomItem { @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(List>> itemsAtLocation) { if (NO_RULES) return true; if (itemsAtLocation.isEmpty()) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java index 0ed3e3ed..834a8e8e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java @@ -31,7 +31,7 @@ public class InteractionRoomClubGate extends InteractionDefault implements Condi @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return habbo != null && habbo.getHabboStats().hasActiveClub(); } @@ -69,7 +69,7 @@ public class InteractionRoomClubGate extends InteractionDefault implements Condi if (roomUnit == null || room == null) return; - room.getHabbo(roomUnit).getClient().sendResponse( + room.getRoomUnitManager().getHabboByRoomUnit(roomUnit).getClient().sendResponse( new CustomUserNotificationMessageComposer(CustomUserNotificationMessageComposer.GATE_NO_HC) ); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java index 853bf7f1..12a228a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java @@ -20,7 +20,7 @@ public class InteractionRoomClubTeleportTile extends InteractionTeleportTile { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { return habbo.getHabboStats().hasActiveClub(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java index c81a255f..9dff7a27 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java @@ -30,7 +30,7 @@ public class InteractionTeleportTile extends InteractionTeleport { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (!canUseTeleport(habbo.getClient(), room)) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java index 3ba91af7..b6407a93 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java @@ -22,9 +22,9 @@ public class InteractionTrap extends InteractionDefault { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - if (this.getExtradata().equals("0") || roomUnit == null || room.getHabbo(roomUnit) == null) return; + if (this.getExtradata().equals("0") || roomUnit == null || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) return; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); roomUnit.stopWalking(); super.onWalkOn(roomUnit, room, objects); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java index 438bf391..4e6003c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java @@ -118,7 +118,7 @@ public class InteractionWater extends InteractionDefault { } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(List>> itemsAtLocation) { for (Pair> set : itemsAtLocation) { for (RoomItem item : set.getValue()) { if(item != this) @@ -126,7 +126,7 @@ public class InteractionWater extends InteractionDefault { } } - return super.canStackAt(room, itemsAtLocation); + return super.canStackAt(itemsAtLocation); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java index 9a718558..a5dd1fb6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java @@ -5,11 +5,13 @@ import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionPushable; -import com.eu.habbo.habbohotel.rooms.*; +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.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import java.sql.ResultSet; import java.sql.SQLException; @@ -149,7 +151,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { - Habbo habbo = room.getHabbo(kicker); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(kicker); if (habbo != null) { BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java index 96d55a83..9667d347 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java @@ -5,9 +5,9 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; 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.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -62,7 +62,7 @@ public class InteractionBattleBanzaiTile extends RoomItem { if (state % 3 == 2) return; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) return; @@ -92,12 +92,12 @@ public class InteractionBattleBanzaiTile extends RoomItem { } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(List>> itemsAtLocation) { for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) return false; } - return super.canStackAt(room, itemsAtLocation); + return super.canStackAt(itemsAtLocation); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java index f6ec238e..58e6f2f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java @@ -54,12 +54,12 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { room.addGame(game); } - GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit)); + GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit)); if (team != null) { - game.removeHabbo(room.getHabbo(roomUnit)); + game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit)); } else { - game.addHabbo(room.getHabbo(roomUnit), this.teamColor); + game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor); } updateState(game, 5); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java index f18d6e7d..45cb0b6d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java @@ -113,7 +113,7 @@ public class InteractionFootballGate extends RoomItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboStats().getCache().containsKey(CACHE_KEY)) { String oldlook = (String) habbo.getHabboStats().getCache().get(CACHE_KEY); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java index 59942cf4..b464673f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java @@ -8,9 +8,9 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -91,7 +91,7 @@ public class InteractionFreezeBlock extends RoomItem { if (game == null || !game.state.equals(GameState.RUNNING)) return; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null || habbo.getHabboInfo().getCurrentGame() != FreezeGame.class) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java index 2c768abf..1f685c00 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java @@ -74,11 +74,11 @@ public class InteractionFreezeTile extends RoomItem { @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(List>> itemsAtLocation) { for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) return false; } - return super.canStackAt(room, itemsAtLocation); + return super.canStackAt(itemsAtLocation); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java index 38ab21f9..dc044e26 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java @@ -52,12 +52,12 @@ public class InteractionFreezeGate extends InteractionGameGate { room.addGame(game); } - GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit)); + GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit)); if (team != null) { - game.removeHabbo(room.getHabbo(roomUnit)); + game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit)); } else { - game.addHabbo(room.getHabbo(roomUnit), this.teamColor); + game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor); } updateState(game, 5); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java index 3fffa883..8020fdfe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java @@ -4,9 +4,9 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.tag.TagGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -29,7 +29,7 @@ public abstract class InteractionTagField extends RoomItem { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { return habbo.getHabboInfo().getCurrentGame() == null || habbo.getHabboInfo().getCurrentGame() == this.gameClazz; @@ -50,7 +50,7 @@ public abstract class InteractionTagField extends RoomItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getCurrentGame() == null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java index 7e5c6855..b811d7b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java @@ -28,7 +28,7 @@ public class InteractionIceTagField extends InteractionTagField { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); } @@ -37,7 +37,7 @@ public class InteractionIceTagField extends InteractionTagField { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null && this.stepTimes.containsKey(habbo)) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); this.stepTimes.remove(habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java index ed035ad4..e98f9044 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java @@ -28,7 +28,7 @@ public class InteractionRollerskateField extends InteractionTagField { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); } @@ -37,7 +37,7 @@ public class InteractionRollerskateField extends InteractionTagField { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null && this.stepTimes.containsKey(habbo)) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); this.stepTimes.remove(habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java index 42513d4b..27551a22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java @@ -25,7 +25,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return habbo != null && habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java index c5e3e487..28ea52a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java @@ -24,7 +24,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { if (room.getRoomInfo().getGuild().getId() == 0) return false; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return habbo == null || !habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index 50023f9f..98654167 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java @@ -33,7 +33,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { GameTeamColors teamColor = GameTeamColors.values()[teamValue]; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java index 0a627c63..24919fde 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java @@ -27,7 +27,7 @@ public class WiredConditionRoomWearsBadge extends InteractionWiredCondition { } String badgeCode = this.getWiredSettings().getStringParam(); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if(habbo == null) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java index d51889bd..c88d9631 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java @@ -33,7 +33,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { GameTeamColors teamColor = GameTeamColors.values()[teamValue]; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getGamePlayer() != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java index ac823641..058b5e42 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java @@ -20,7 +20,7 @@ public class WiredEffectAlert extends WiredEffectWhisper { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { habbo.alert(this.getWiredSettings().getStringParam() diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java index 498c1fa3..8954d19f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java @@ -25,7 +25,7 @@ public class WiredEffectBotFollowRoom extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()); if (habbo != null && bots.size() == 1) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index 1cf87079..cc037fbc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java @@ -36,7 +36,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomAvatar); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()); int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java index 606cf4cc..506b165c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java @@ -33,7 +33,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername()) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java index 1e4d63c9..98edc19c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java @@ -33,7 +33,7 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect { String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername()) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java index 74dab41b..457c08bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java @@ -75,7 +75,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { return; } - roomBot.getRoom().unIdle(roomBot.getRoom().getHabbo(roomBot)); + roomBot.getRoom().unIdle(roomBot.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomBot)); room.sendComposer(new AvatarEffectMessageComposer(roomBot, 4).compose()); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomBot), (long) WiredHandler.TELEPORT_DELAY + 1000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java index 7f09c624..bcdf33c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java @@ -27,7 +27,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { try { int itemId = Integer.parseInt(this.getWiredSettings().getStringParam()); - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { habbo.getRoomUnit().setHandItem(itemId); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java index 76e955de..500c6bfb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java @@ -33,7 +33,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends WiredEffectWhisper return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java index f723b244..041c99f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java @@ -34,7 +34,7 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java index b2bd2366..e26332f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java @@ -39,7 +39,7 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java index 9c7b4770..67d46f1d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java @@ -61,7 +61,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return habbo != null && WiredHandler.getReward(habbo, this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index a92d4ce0..8be92006 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -42,7 +42,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index b6605533..7d9fd773 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -35,7 +35,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { GameTeamColors teamColor = GameTeamColors.values()[teamValue]; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java index 9ba11734..c77e49ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java @@ -30,7 +30,7 @@ public class WiredEffectKickRoom extends InteractionWiredEffect { if (room == null) return false; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.hasRight(Permission.ACC_UNKICKABLE)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java index 8bcbbba3..c85bb9b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java @@ -23,7 +23,7 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getCurrentGame() != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java index bd204fd6..73f98575 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java @@ -33,7 +33,7 @@ public class WiredEffectMuteRoom extends InteractionWiredEffect { if (roomUnit == null) return true; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { if (room.hasRights(habbo)) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index 5dabd8cb..3becaf04 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -65,7 +65,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { // makes a temporary effect - roomHabbo.getRoom().unIdle(roomHabbo.getRoom().getHabbo(roomHabbo)); + roomHabbo.getRoom().unIdle(roomHabbo.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomHabbo)); room.sendComposer(new AvatarEffectMessageComposer(roomHabbo, 4).compose()); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomHabbo), (long) WiredHandler.TELEPORT_DELAY + 1000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java index 9ff7ba88..151120d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java @@ -14,9 +14,9 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import lombok.extern.slf4j.Slf4j; @@ -83,7 +83,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { return false; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); for (RoomItem item : this.getWiredSettings().getItems(room)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 4cad5227..2c8a259e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -32,7 +32,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } if (roomUnit != null) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { String msg = this.getWiredSettings().getStringParam().replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java index abfd4af5..80c8ad87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java @@ -59,7 +59,7 @@ public class WiredBlob extends InteractionDefault { if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return; - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { GamePlayer player = habbo.getHabboInfo().getGamePlayer(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java index 539efefe..aa086241 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java @@ -3,8 +3,8 @@ 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.rooms.Room; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -22,7 +22,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if(stuff.length == 0 || room.getHabbo(roomUnit) == null) { + if(stuff.length == 0 || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java index ce382315..5cefe33e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java @@ -25,7 +25,7 @@ public class WiredTriggerRoomEntersRoom extends InteractionWiredTrigger { return true; } - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.getWiredSettings().getStringParam()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java index af5897a6..f7d76934 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java @@ -31,7 +31,7 @@ public class WiredTriggerRoomSaysKeyword extends InteractionWiredTrigger { if (stuff[0] instanceof String) { if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); return !ownerOnly || (habbo != null && room.getRoomInfo().getOwnerInfo().getId() == habbo.getHabboInfo().getId()); } } 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 009ceaa5..b32181c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -70,6 +70,7 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; import io.netty.util.internal.ConcurrentSet; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.math3.util.Pair; @@ -95,6 +96,7 @@ public class Room implements Comparable, ISerialize, Runnable { private final RoomUnitManager roomUnitManager; @Getter private final RoomItemManager roomItemManager; + @Getter private TraxManager traxManager; private static final String CAUGHT_EXCEPTION = "Caught exception"; public static final Comparator SORT_SCORE = (o1, o2) -> o2.roomInfo.getScore() - o1.roomInfo.getScore(); @@ -114,14 +116,19 @@ public class Room implements Comparable, ISerialize, Runnable { public static final double MAXIMUM_FURNI_HEIGHT = 40d; public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); public final List userVotes; + @Getter private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); private final THashSet activeTrades; + @Getter private final TIntArrayList rights; private final TIntIntHashMap mutedHabbos; private final TIntObjectHashMap bannedHabbos; + @Getter private final ConcurrentSet games; + @Getter private final TIntObjectMap furniOwnerNames; private final TIntIntMap furniOwnerCount; + @Getter private final THashSet wordFilterWords; private final TIntObjectMap roomItems; private final Object loadLock = new Object(); @@ -130,33 +137,53 @@ public class Room implements Comparable, ISerialize, Runnable { public volatile boolean preventUncaching = false; public final ConcurrentHashMap.KeySetView scheduledComposers = ConcurrentHashMap.newKeySet(); public ConcurrentHashMap.KeySetView scheduledTasks = ConcurrentHashMap.newKeySet(); + @Getter private String wordQuiz = ""; + @Getter private int noVotes = 0; + @Getter private int yesVotes = 0; + @Getter private int wordQuizEnd = 0; public ScheduledFuture roomCycleTask; + @Getter + @Setter private RoomLayout layout; private final String layoutName; + @Getter + @Setter private volatile boolean allowBotsWalk; + @Setter private volatile boolean allowEffects; + @Getter private RoomPromotion promotion; + @Setter private volatile boolean needsUpdate; + @Getter private volatile boolean loaded; + @Getter private volatile boolean preLoaded; private int roomIdleCycles; private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); private long rollerCycle = System.currentTimeMillis(); + @Getter + @Setter private volatile int lastTimerReset = Emulator.getIntUnixTimestamp(); + @Getter + @Setter private volatile boolean muted; + @Getter private RoomSpecialTypes roomSpecialTypes; private boolean cycleOdd; + @Getter private long cycleTimestamp; + @Getter final HashMap triggersOnRoom; public Room(ResultSet set) throws SQLException { this.roomInfo = new RoomInfo(set); - this.roomUnitManager = new RoomUnitManager(this.roomInfo.getId()); - this.roomItemManager = new RoomItemManager(); + this.roomUnitManager = new RoomUnitManager(this); + this.roomItemManager = new RoomItemManager(this); this.layoutName = set.getString("model"); this.bannedHabbos = new TIntObjectHashMap<>(); @@ -212,7 +239,11 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadLayout(); this.loadRights(connection); + + //TODO Deprecated this.loadItems(connection); + + this.roomItemManager.load(connection); this.loadHeightmap(); this.roomUnitManager.load(connection); this.loadWordFilter(connection); @@ -408,7 +439,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - this.removeHabboItem(item.getId()); + this.removeHabboItem(item); item.onPickUp(this); item.setRoomId(0); item.needsUpdate(true); @@ -521,6 +552,10 @@ public class Room implements Comparable, ISerialize, Runnable { } } + public void updateBotsAt(RoomTile tile) { + this.updateBotsAt(tile.getX(), tile.getY()); + } + public void updateBotsAt(short x, short y) { RoomItem topItem = this.getTopItemAt(x, y); @@ -1090,7 +1125,7 @@ public class Room implements Comparable, ISerialize, Runnable { double newZ = unit.getCurrentZ() + zOffset; if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.HABBO) { - roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tileInFront); + roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(unit), roller, tileInFront); Emulator.getPluginManager().fireEvent(roomUserRolledEvent); if (roomUserRolledEvent.isCancelled()) @@ -1100,7 +1135,7 @@ public class Room implements Comparable, ISerialize, Runnable { // horse riding boolean isRiding = false; if (unit.getRoomUnitType() == RoomUnitType.HABBO) { - Habbo rollingHabbo = this.getHabbo(unit); + Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(unit); if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); if (riding != null) { @@ -1617,10 +1652,6 @@ public class Room implements Comparable, ISerialize, Runnable { return item; } - void removeHabboItem(int id) { - this.removeHabboItem(this.getHabboItem(id)); - } - public void removeHabboItem(RoomItem item) { if (item != null) { @@ -1788,18 +1819,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } - public void teleportHabboToLocation(Habbo habbo, short x, short y) { - this.teleportRoomUnitToLocation(habbo.getRoomUnit(), x, y, 0.0); - } - - public void teleportRoomUnitToItem(RoomUnit roomUnit, RoomItem item) { - this.teleportRoomUnitToLocation(roomUnit, item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); - } - - public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y) { - this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0); - } - public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) { if (this.loaded) { RoomTile tile = this.layout.getTile(x, y); @@ -2561,31 +2580,6 @@ public class Room implements Comparable, ISerialize, Runnable { return null; } - public Habbo getHabbo(String username) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { - if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)) - return habbo; - } - return null; - } - - public Habbo getHabbo(RoomUnit roomUnit) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { - if (habbo.getRoomUnit() == roomUnit) - return habbo; - } - return null; - } - - public Habbo getHabboByRoomUnitId(int roomUnitId) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { - if (habbo.getRoomUnit().getVirtualId() == roomUnitId) - return habbo; - } - - return null; - } - public void sendComposer(ServerMessage message) { for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo.getClient() == null) continue; @@ -3207,6 +3201,13 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.MAX_ITEMS; } + if (item instanceof InteractionMoodLight && !this.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) { + return FurnitureMovementError.MAX_DIMMERS; + } + if (item instanceof InteractionJukeBox && !this.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) { + return FurnitureMovementError.MAX_SOUNDFURNI; + } + if (tile == null || tile.getState() == RoomTileState.INVALID) { return FurnitureMovementError.INVALID_MOVE; } @@ -3280,7 +3281,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!item.canStackAt(this, tileFurniList)) { + if (!item.canStackAt(tileFurniList)) { return FurnitureMovementError.CANT_STACK; } @@ -3288,6 +3289,12 @@ public class Room implements Comparable, ISerialize, Runnable { } public FurnitureMovementError placeFloorFurniAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) { + FurnitureMovementError error = this.canPlaceFurnitureAt(item, owner, tile, rotation); + + if(!error.equals(FurnitureMovementError.NONE)) { + return error; + } + boolean pluginHelper = false; if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile)); @@ -3301,7 +3308,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - FurnitureMovementError fits = furnitureFitsAt(tile, item, rotation); + FurnitureMovementError fits = this.furnitureFitsAt(tile, item, rotation); if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) { return fits; @@ -3430,7 +3437,7 @@ public class Room implements Comparable, ISerialize, Runnable { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } - if (!magicTile && !item.canStackAt(this, tileFurniList)) { + if (!magicTile && !item.canStackAt(tileFurniList)) { return FurnitureMovementError.CANT_STACK; } } @@ -3542,144 +3549,4 @@ public class Room implements Comparable, ISerialize, Runnable { } return FurnitureMovementError.NONE; } - - public FurnitureMovementError slideFurniTo(RoomItem item, RoomTile tile, int rotation) { - boolean magicTile = item instanceof InteractionStackHelper; - - //Check if can be placed at new position - THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - - List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - } - - if (!magicTile && !item.canStackAt(this, tileFurniList)) { - return FurnitureMovementError.CANT_STACK; - } - - item.setRotation(rotation); - - //Place at new position - if (magicTile) { - item.setZ(tile.getZ()); - item.setExtradata("" + item.getZ() * 100); - } - if (item.getZ() > MAXIMUM_FURNI_HEIGHT) { - item.setZ(MAXIMUM_FURNI_HEIGHT); - } - double offset = this.getStackHeight(tile.getX(), tile.getY(), false, item) - item.getZ(); - this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose()); - - //Update Habbos at old position - for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t); - this.updateBotsAt(t.getX(), t.getY()); - } - return FurnitureMovementError.NONE; - } - - public TIntObjectMap getHabboQueue() { - return this.habboQueue; - } - - public TIntArrayList getRights() { - return this.rights; - } - - public ConcurrentSet getGames() { - return this.games; - } - - public TIntObjectMap getFurniOwnerNames() { - return this.furniOwnerNames; - } - - public THashSet getWordFilterWords() { - return this.wordFilterWords; - } - - public String getWordQuiz() { - return this.wordQuiz; - } - - public int getNoVotes() { - return this.noVotes; - } - - public int getYesVotes() { - return this.yesVotes; - } - - public int getWordQuizEnd() { - return this.wordQuizEnd; - } - - public RoomLayout getLayout() { - return this.layout; - } - - public boolean isAllowBotsWalk() { - return this.allowBotsWalk; - } - - public RoomPromotion getPromotion() { - return this.promotion; - } - - public boolean isLoaded() { - return this.loaded; - } - - public boolean isPreLoaded() { - return this.preLoaded; - } - - public int getLastTimerReset() { - return this.lastTimerReset; - } - - public boolean isMuted() { - return this.muted; - } - - public RoomSpecialTypes getRoomSpecialTypes() { - return this.roomSpecialTypes; - } - - public TraxManager getTraxManager() { - return this.traxManager; - } - - public long getCycleTimestamp() { - return this.cycleTimestamp; - } - - public HashMap getTriggersOnRoom() { - return this.triggersOnRoom; - } - - public void setLayout(RoomLayout layout) { - this.layout = layout; - } - - public void setAllowBotsWalk(boolean allowBotsWalk) { - this.allowBotsWalk = allowBotsWalk; - } - - public void setAllowEffects(boolean allowEffects) { - this.allowEffects = allowEffects; - } - - public void setNeedsUpdate(boolean needsUpdate) { - this.needsUpdate = needsUpdate; - } - - public void setLastTimerReset(int lastTimerReset) { - this.lastTimerReset = lastTimerReset; - } - - public void setMuted(boolean muted) { - this.muted = muted; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index 9dde4a35..e8d0aeca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -49,7 +49,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { public RoomChatMessage(MessageHandler message) { if (message.packet.getMessageId() == Incoming.whisperEvent) { String data = message.packet.readString(); - this.targetHabbo = message.client.getHabbo().getRoomUnit().getRoom().getHabbo(data.split(" ")[0]); + this.targetHabbo = message.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(data.split(" ")[0]); this.message = data.substring(data.split(" ")[0].length() + 1); } else { this.message = message.packet.readString(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java index 8873a7bd..c3c5a236 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -1,37 +1,58 @@ package com.eu.habbo.habbohotel.rooms; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy; +import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; +import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; +import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomFloorItem; -import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomWallItem; -import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; +import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; +import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.ItemRemoveMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent; +import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent; +import com.eu.habbo.plugin.events.furniture.FurniturePlacedEvent; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.math3.util.Pair; -import java.util.HashMap; -import java.util.HashSet; +import java.awt.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +@Getter public class RoomItemManager { + private final Room room; + private final RoomWiredManager wiredManager; private final ConcurrentHashMap currentItems; - private final HashMap floorItems; - private final HashMap wallItems; + private final ConcurrentHashMap floorItems; + private final ConcurrentHashMap wallItems; private final HashSet cycleTasks; - private final HashMap> wiredTriggers; - private final HashMap> wiredEffects; - private final HashMap> wiredConditions; - private final HashMap wiredExtras; private final HashMap nests; private final HashMap petDrinks; private final HashMap petFoods; @@ -42,19 +63,18 @@ public class RoomItemManager { private final HashMap gameTimers; private final HashMap banzaiTeleporters; private final HashMap freezeExitTile; - public RoomItemManager() { - this.currentItems = new ConcurrentHashMap<>(); + private final HashMap undefinedSpecials; - this.floorItems = new HashMap<>(); - this.wallItems = new HashMap<>(); + public RoomItemManager(Room room) { + this.room = room; + this.currentItems = new ConcurrentHashMap<>(); + this.wiredManager = new RoomWiredManager(); + + this.floorItems = new ConcurrentHashMap<>(); + this.wallItems = new ConcurrentHashMap<>(); this.cycleTasks = new HashSet<>(0); - this.wiredTriggers = new HashMap<>(0); - this.wiredEffects = new HashMap<>(0); - this.wiredConditions = new HashMap<>(0); - this.wiredExtras = new HashMap<>(0); - this.nests = new HashMap<>(0); this.petDrinks = new HashMap<>(0); this.petFoods = new HashMap<>(0); @@ -68,5 +88,531 @@ public class RoomItemManager { this.banzaiTeleporters = new HashMap<>(0); this.freezeExitTile = new HashMap<>(0); + + this.undefinedSpecials = new HashMap<>(0); + } + + public synchronized void load(Connection connection) { + this.loadItems(connection); + } + + private synchronized void loadItems(Connection connection) { + this.currentItems.clear(); + this.wiredManager.clear(); + + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); + + if (item != null) { + this.addRoomItem(item); + } + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + public void addRoomItem(RoomItem item) { + if (this.currentItems.size() > Room.MAXIMUM_FURNI) { + log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.room.getRoomInfo().getId(), this.currentItems.size(), Room.MAXIMUM_FURNI); + } + + synchronized (this.currentItems) { + try { + this.currentItems.put(item.getId(), item); + this.sortItem(item); + item.setRoomId(this.room.getRoomInfo().getId()); + } catch (Exception ignored) { + + } + } + } + + public void removeHabboItem(RoomItem item) { + if (item != null) { + + RoomItem i; + synchronized (this.currentItems) { + i = this.currentItems.remove(item.getId()); + } + + if (i != null) { + if (item instanceof ICycleable) { + this.removeCycleTask((ICycleable) item); + } + + if (item instanceof InteractionWired wired) { + this.wiredManager.removeWired(wired); + } else if (item instanceof InteractionBattleBanzaiTeleporter) { + this.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item); + } else if (item instanceof InteractionRoller) { + this.removeRoller((InteractionRoller) item); + } else if (item instanceof InteractionGameScoreboard) { + this.removeScoreboard((InteractionGameScoreboard) item); + } else if (item instanceof InteractionGameGate) { + this.removeGameGate((InteractionGameGate) item); + } else if (item instanceof InteractionGameTimer) { + this.removeGameTimer((InteractionGameTimer) item); + } else if (item instanceof InteractionFreezeExitTile) { + this.removeFreezeExitTile((InteractionFreezeExitTile) item); + } else if (item instanceof InteractionNest) { + this.removeNest((InteractionNest) item); + } else if (item instanceof InteractionPetDrink) { + this.removePetDrink((InteractionPetDrink) item); + } else if (item instanceof InteractionPetFood) { + this.removePetFood((InteractionPetFood) item); + } else if (item instanceof InteractionPetToy) { + this.removePetToy((InteractionPetToy) item); + } else if (item instanceof InteractionPetTree) { + this.removeUndefined(item); + } else if (item instanceof InteractionPetTrampoline) { + this.removeUndefined(item); + } else if (item instanceof InteractionMoodLight) { + this.removeUndefined(item); + } else if (item instanceof InteractionPyramid) { + this.removeUndefined(item); + } else if (item instanceof InteractionMusicDisc) { + this.removeUndefined(item); + } else if (item instanceof InteractionBattleBanzaiSphere) { + this.removeUndefined(item); + } else if (item instanceof InteractionTalkingFurniture) { + this.removeUndefined(item); + } else if (item instanceof InteractionWaterItem) { + this.removeUndefined(item); + } else if (item instanceof InteractionWater) { + this.removeUndefined(item); + } else if (item instanceof InteractionMuteArea) { + this.removeUndefined(item); + } else if (item instanceof InteractionTagPole) { + this.removeUndefined(item); + } else if (item instanceof InteractionTagField) { + this.removeUndefined(item); + } else if (item instanceof InteractionJukeBox) { + this.removeUndefined(item); + } else if (item instanceof InteractionPetBreedingNest) { + this.removeUndefined(item); + } else if (item instanceof InteractionBlackHole) { + this.removeUndefined(item); + } else if (item instanceof InteractionWiredHighscore) { + this.removeUndefined(item); + } else if (item instanceof InteractionStickyPole) { + this.removeUndefined(item); + } else if (item instanceof WiredBlob) { + this.removeUndefined(item); + } else if (item instanceof InteractionTent) { + this.removeUndefined(item); + } else if (item instanceof InteractionSnowboardSlope) { + this.removeUndefined(item); + } else if (item instanceof InteractionBuildArea) { + this.removeUndefined(item); + } + } + } + } + + public HashSet getItemsOfType(Class type) { + return this.currentItems.values().stream() + .filter(item -> type.equals(item.getClass())) + .collect(Collectors.toCollection(HashSet::new)); + } + + public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) { + if (this.currentItems.size() >= Room.MAXIMUM_FURNI) { + return FurnitureMovementError.MAX_ITEMS; + } + + if (item instanceof InteractionMoodLight && !this.getItemsOfType(InteractionMoodLight.class).isEmpty()) { + return FurnitureMovementError.MAX_DIMMERS; + } + if (item instanceof InteractionJukeBox && !this.getItemsOfType(InteractionJukeBox.class).isEmpty()) { + return FurnitureMovementError.MAX_SOUNDFURNI; + } + + if (tile == null || tile.getState() == RoomTileState.INVALID) { + return FurnitureMovementError.INVALID_MOVE; + } + + rotation %= 8; + if (this.room.hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { + return FurnitureMovementError.NONE; + } + + if (habbo.getHabboStats().isRentingSpace()) { + RoomItem rentSpace = this.currentItems.get(habbo.getHabboStats().getRentedItemId()); + + if (rentSpace != null) { + if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(tile.getX(), tile.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { + return FurnitureMovementError.NO_RIGHTS; + } else { + return FurnitureMovementError.NONE; + } + } + } + + for (RoomItem area : this.getItemsOfType(InteractionBuildArea.class)) { + if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) { + return FurnitureMovementError.NONE; + } + } + + return FurnitureMovementError.NO_RIGHTS; + } + + public FurnitureMovementError placeFloorItemAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) { + boolean pluginHelper = false; + if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { + FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile)); + + if (event.isCancelled()) { + return FurnitureMovementError.CANCEL_PLUGIN_PLACE; + } + + pluginHelper = event.hasPluginHelper(); + } + + THashSet occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + + FurnitureMovementError fits = this.furnitureFitsAt(item, tile, rotation); + + if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) { + return fits; + } + + double height = tile.getStackHeight(); + + for (RoomTile tile2 : occupiedTiles) { + double sHeight = tile2.getStackHeight(); + if (sHeight > height) { + height = sHeight; + } + } + + if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { + FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height)); + if (event.hasChangedHeight()) { + height = event.getUpdatedHeight(); + } + } + + item.setZ(height); + item.setX(tile.getX()); + item.setY(tile.getY()); + item.setRotation(rotation); + item.needsUpdate(true); + + this.addRoomItem(item); + + item.onPlace(this.room); + this.room.updateTiles(occupiedTiles); + + this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose()); + + for (RoomTile t : occupiedTiles) { + this.room.updateHabbosAt(t); + this.room.updateBotsAt(t); + } + + Emulator.getThreading().run(item); + return FurnitureMovementError.NONE; + } + + public void pickUpItem(RoomItem item, Habbo picker) { + if (item == null) + return; + + if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) { + Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker); + Emulator.getPluginManager().fireEvent(furniturePickedUpEvent); + + if (furniturePickedUpEvent.isCancelled()) + return; + } + + this.removeHabboItem(item); + item.onPickUp(this.room); + item.setRoomId(0); + item.needsUpdate(true); + + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { + this.room.sendComposer(new RemoveFloorItemComposer(item).compose()); + + THashSet updatedTiles = new THashSet<>(); + Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { + double stackHeight = this.room.getStackHeight(x, y, false); + RoomTile tile = this.room.getLayout().getTile(x, y); + + if (tile != null) { + tile.setStackHeight(stackHeight); + updatedTiles.add(tile); + } + } + } + this.room.sendComposer(new HeightMapUpdateMessageComposer(this.room, updatedTiles).compose()); + this.room.updateTiles(updatedTiles); + updatedTiles.forEach(tile -> { + this.room.updateHabbosAt(tile); + this.room.updateBotsAt(tile.getX(), tile.getY()); + }); + } else if (item.getBaseItem().getType() == FurnitureType.WALL) { + this.room.sendComposer(new ItemRemoveMessageComposer(item).compose()); + } + + Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getUserId())); + if (habbo != null) { + habbo.getInventory().getItemsComponent().addItem(item); + habbo.getClient().sendResponse(new UnseenItemsComposer(item)); + habbo.getClient().sendResponse(new FurniListInvalidateComposer()); + } + Emulator.getThreading().run(item); + } + + public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation) { + return furnitureFitsAt(item, tile, rotation, true); + } + + public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation, boolean checkForUnits) { + if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) + return FurnitureMovementError.INVALID_MOVE; + + if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE; + + + THashSet occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + for (RoomTile t : occupiedTiles) { + if (t.getState() == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE; + if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) { + if (checkForUnits) { + if (this.room.getRoomUnitManager().hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS; + } + if (checkForUnits) { + if (!this.room.getRoomUnitManager().getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS; + } + if (checkForUnits) { + if (this.room.getRoomUnitManager().hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS; + } + } + } + + Optional stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + + List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { + tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); + + RoomItem topItem = this.room.getTopItemAt(t.getX(), t.getY(), item); + if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { + return FurnitureMovementError.CANT_STACK; + } + + if ((stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) || topItem != null && (topItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() == InteractionWater.class || item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class))) { + return FurnitureMovementError.CANT_STACK; + } + } + + if (!item.canStackAt(tileFurniList)) { + return FurnitureMovementError.CANT_STACK; + } + + return FurnitureMovementError.NONE; + } + + public void addCycleTask(ICycleable task) { + this.cycleTasks.add(task); + } + + public void removeCycleTask(ICycleable task) { + this.cycleTasks.remove(task); + } + + public void addBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) { + this.banzaiTeleporters.put(item.getId(), item); + } + + public void removeBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) { + this.banzaiTeleporters.remove(item.getId()); + } + + public void addRoller(InteractionRoller item) { + synchronized (this.rollers) { + this.rollers.put(item.getId(), item); + } + } + + public void removeRoller(InteractionRoller roller) { + synchronized (this.rollers) { + this.rollers.remove(roller.getId()); + } + } + + public void addGameScoreboard(InteractionGameScoreboard scoreboard) { + this.gameScoreboards.put(scoreboard.getId(), scoreboard); + } + + public void removeScoreboard(InteractionGameScoreboard scoreboard) { + this.gameScoreboards.remove(scoreboard.getId()); + } + + public void addGameGate(InteractionGameGate gameGate) { + this.gameGates.put(gameGate.getId(), gameGate); + } + + public void removeGameGate(InteractionGameGate gameGate) { + this.gameGates.remove(gameGate.getId()); + } + + public void addGameTimer(InteractionGameTimer gameTimer) { + this.gameTimers.put(gameTimer.getId(), gameTimer); + } + + public void removeGameTimer(InteractionGameTimer gameTimer) { + this.gameTimers.remove(gameTimer.getId()); + } + + public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { + this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile); + } + + public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { + this.freezeExitTile.remove(freezeExitTile.getId()); + } + + public void addNest(InteractionNest item) { + this.nests.put(item.getId(), item); + } + + public void removeNest(InteractionNest item) { + this.nests.remove(item.getId()); + } + + public void addPetDrink(InteractionPetDrink item) { + this.petDrinks.put(item.getId(), item); + } + + public void removePetDrink(InteractionPetDrink item) { + this.petDrinks.remove(item.getId()); + } + + public void addPetFood(InteractionPetFood item) { + this.petFoods.put(item.getId(), item); + } + + public void removePetFood(InteractionPetFood petFood) { + this.petFoods.remove(petFood.getId()); + } + + public InteractionPetToy getPetToy(int itemId) { + return this.petToys.get(itemId); + } + + public void addPetToy(InteractionPetToy item) { + this.petToys.put(item.getId(), item); + } + + public void removePetToy(InteractionPetToy petToy) { + this.petToys.remove(petToy.getId()); + } + + public void addUndefined(RoomItem item) { + synchronized (this.undefinedSpecials) { + this.undefinedSpecials.put(item.getId(), item); + } + } + + public void removeUndefined(RoomItem item) { + synchronized (this.undefinedSpecials) { + this.undefinedSpecials.remove(item.getId()); + } + } + + private void sortItem(RoomItem item) { + if(item.getBaseItem().getType().equals(FurnitureType.FLOOR)) { + this.floorItems.put(item.getId(), item); + this.sortFloorItem(item); + } else if(item.getBaseItem().getType().equals(FurnitureType.WALL)) { + this.wallItems.put(item.getId(), item); + } + } + + private void sortFloorItem(RoomItem item) { + if (item instanceof ICycleable) { + this.addCycleTask((ICycleable) item); + } + + if(item instanceof InteractionWired wired) { + this.wiredManager.addWired(wired); + } else if (item instanceof InteractionBattleBanzaiTeleporter interactionBattleBanzaiTeleporter) { + this.addBanzaiTeleporter(interactionBattleBanzaiTeleporter); + } else if (item instanceof InteractionRoller interactionRoller) { + this.addRoller(interactionRoller); + } else if (item instanceof InteractionGameScoreboard interactionGameScoreboard) { + this.addGameScoreboard(interactionGameScoreboard); + } else if (item instanceof InteractionGameGate interactionGameGate) { + this.addGameGate(interactionGameGate); + } else if (item instanceof InteractionGameTimer interactionGameTimer) { + this.addGameTimer(interactionGameTimer); + } else if (item instanceof InteractionFreezeExitTile interactionFreezeExitTile) { + this.addFreezeExitTile(interactionFreezeExitTile); + } else if (item instanceof InteractionNest interactionNest) { + this.addNest(interactionNest); + } else if (item instanceof InteractionPetDrink interactionPetDrink) { + this.addPetDrink(interactionPetDrink); + } else if (item instanceof InteractionPetFood interactionPetFood) { + this.addPetFood(interactionPetFood); + } else if (item instanceof InteractionPetToy interactionPetToy) { + this.addPetToy(interactionPetToy); + } else if (item instanceof InteractionPetTree) { + this.addUndefined(item); + } else if (item instanceof InteractionPetTrampoline) { + this.addUndefined(item); + } else if (item instanceof InteractionMoodLight) { + this.addUndefined(item); + } else if (item instanceof InteractionPyramid) { + this.addUndefined(item); + } else if (item instanceof InteractionMusicDisc) { + this.addUndefined(item); + } else if (item instanceof InteractionBattleBanzaiSphere) { + this.addUndefined(item); + } else if (item instanceof InteractionTalkingFurniture) { + this.addUndefined(item); + } else if (item instanceof InteractionWater) { + this.addUndefined(item); + } else if (item instanceof InteractionWaterItem) { + this.addUndefined(item); + } else if (item instanceof InteractionMuteArea) { + this.addUndefined(item); + } else if (item instanceof InteractionBuildArea) { + this.addUndefined(item); + } else if (item instanceof InteractionTagPole) { + this.addUndefined(item); + } else if (item instanceof InteractionTagField) { + this.addUndefined(item); + } else if (item instanceof InteractionJukeBox) { + this.addUndefined(item); + } else if (item instanceof InteractionPetBreedingNest) { + this.addUndefined(item); + } else if (item instanceof InteractionBlackHole) { + this.addUndefined(item); + } else if (item instanceof InteractionWiredHighscore) { + this.addUndefined(item); + } else if (item instanceof InteractionStickyPole) { + this.addUndefined(item); + } else if (item instanceof WiredBlob) { + this.addUndefined(item); + } else if (item instanceof InteractionTent) { + this.addUndefined(item); + } else if (item instanceof InteractionSnowboardSlope) { + this.addUndefined(item); + } else if (item instanceof InteractionFireworks) { + this.addUndefined(item); + } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java index 2697254d..c0c8c64b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -27,8 +27,8 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.awt.*; -import java.util.*; import java.util.List; +import java.util.*; public class RoomSpecialTypes { private final THashMap banzaiTeleporters; @@ -636,14 +636,14 @@ public class RoomSpecialTypes { } } - public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { - this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile); - } - public THashMap getFreezeExitTiles() { return this.freezeExitTile; } + public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { + this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile); + } + public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) { this.freezeExitTile.remove(freezeExitTile.getId()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java index a08b97c7..e25e5225 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -36,7 +36,7 @@ import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; @Slf4j @Getter public class RoomUnitManager { - private final int roomId; + private final Room room; private final ConcurrentHashMap currentRoomUnits; private final ConcurrentHashMap currentRoomHabbos; private final ConcurrentHashMap currentRoomBots; @@ -44,15 +44,13 @@ public class RoomUnitManager { private volatile int roomUnitCounter; public final Object roomUnitLock; - public RoomUnitManager(int roomId) { - this.roomId = roomId; + public RoomUnitManager(Room room) { + this.room = room; this.currentRoomUnits = new ConcurrentHashMap<>(); - this.currentRoomHabbos = new ConcurrentHashMap<>(); this.currentRoomBots = new ConcurrentHashMap<>(); this.currentRoomPets = new ConcurrentHashMap<>(); this.roomUnitCounter = 0; - this.roomUnitLock = new Object(); } @@ -62,23 +60,23 @@ public class RoomUnitManager { } private synchronized void loadBots(Connection connection) { + this.currentRoomBots.clear(); + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) { - statement.setInt(1, this.roomId); + statement.setInt(1, this.room.getRoomInfo().getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set); - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.roomId); - - if (bot != null && room != null) { - bot.setRoom(room); + if (bot != null) { + bot.setRoom(this.room); bot.setRoomUnit(new RoomBot()); - bot.getRoomUnit().setRoom(room); - bot.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"))); + bot.getRoomUnit().setRoom(this.room); + bot.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"))); if (bot.getRoomUnit().getCurrentPosition() == null || bot.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) { - bot.getRoomUnit().setCurrentZ(room.getLayout().getDoorTile().getStackHeight()); - bot.getRoomUnit().setLocation(room.getLayout().getDoorTile()); - bot.getRoomUnit().setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); + bot.getRoomUnit().setCurrentZ(this.room.getLayout().getDoorTile().getStackHeight()); + bot.getRoomUnit().setLocation(this.room.getLayout().getDoorTile()); + bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection())); } else { bot.getRoomUnit().setCurrentZ(set.getDouble("z")); bot.getRoomUnit().setPreviousLocationZ(set.getDouble("z")); @@ -87,7 +85,7 @@ public class RoomUnitManager { bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); bot.getRoomUnit().setInRoom(true); - room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE); + this.room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE); this.addRoomUnit(bot); } } @@ -100,21 +98,22 @@ public class RoomUnitManager { } private synchronized void loadPets(Connection connection) { + this.currentRoomPets.clear(); + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) { - statement.setInt(1, this.roomId); + statement.setInt(1, this.room.getRoomInfo().getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { Pet pet = PetManager.loadPet(set); - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.roomId); - pet.setRoom(room); + pet.setRoom(this.room); pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setRoom(room); - pet.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"))); + pet.getRoomUnit().setRoom(this.room); + pet.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"))); if (pet.getRoomUnit().getCurrentPosition() == null || pet.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) { - pet.getRoomUnit().setCurrentZ(room.getLayout().getDoorTile().getStackHeight()); - pet.getRoomUnit().setLocation(room.getLayout().getDoorTile()); - pet.getRoomUnit().setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); + pet.getRoomUnit().setCurrentZ(this.room.getLayout().getDoorTile().getStackHeight()); + pet.getRoomUnit().setLocation(this.room.getLayout().getDoorTile()); + pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection())); } else { pet.getRoomUnit().setCurrentZ(set.getDouble("z")); pet.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); @@ -122,7 +121,7 @@ public class RoomUnitManager { pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); pet.getRoomUnit().setCanWalk(true); this.addRoomUnit(pet); - room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); + this.room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); } } } catch (SQLException e) { @@ -138,23 +137,19 @@ public class RoomUnitManager { this.currentRoomUnits.put(unit.getRoomUnit().getVirtualId(), unit.getRoomUnit()); this.roomUnitCounter++; - switch(unit.getRoomUnit().getRoomUnitType()) { - case HABBO: + switch (unit.getRoomUnit().getRoomUnitType()) { + case HABBO -> { this.currentRoomHabbos.put(((Habbo) unit).getHabboInfo().getId(), (Habbo) unit); unit.getRoomUnit().getRoom().updateDatabaseUserCount(); - break; - case BOT: - this.currentRoomBots.put(((Bot) unit).getId(), (Bot) unit); - break; - case PET: + } + case BOT -> this.currentRoomBots.put(((Bot) unit).getId(), (Bot) unit); + case PET -> { this.currentRoomPets.put(((Pet) unit).getId(), (Pet) unit); - Habbo habbo = this.getRoomHabboById(((Pet) unit).getUserId()); - if (habbo != null) { unit.getRoomUnit().getRoom().getFurniOwnerNames().put(((Pet) unit).getUserId(), this.getRoomHabboById(((Pet) unit).getUserId()).getHabboInfo().getUsername()); } - break; + } } } } @@ -185,10 +180,15 @@ public class RoomUnitManager { public Habbo getRoomHabboById(int habboId) { return this.currentRoomHabbos.get(habboId); } + public Habbo getRoomHabboByUsername(String username) { return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)).findFirst().orElse(null); } + public Habbo getHabboByVirtualId(int virtualId) { + return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit().getVirtualId() == virtualId).findFirst().orElse(null); + } + public Habbo getHabboByRoomUnit(RoomUnit roomUnit) { return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit() == roomUnit).findFirst().orElse(null); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java new file mode 100644 index 00000000..cbc80553 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java @@ -0,0 +1,123 @@ +package com.eu.habbo.habbohotel.rooms; + +import com.eu.habbo.habbohotel.items.interactions.*; +import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collections; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +@Slf4j +@Getter +public class RoomWiredManager { + private final ConcurrentHashMap currentWireds; + private final ConcurrentHashMap> currentWiredTriggers; + private final ConcurrentHashMap> currentWiredEffects; + private final ConcurrentHashMap> currentWiredConditions; + private final ConcurrentHashMap currentWiredExtras; + + public RoomWiredManager() { + this.currentWireds = new ConcurrentHashMap<>(0); + this.currentWiredTriggers = new ConcurrentHashMap<>(0); + this.currentWiredEffects = new ConcurrentHashMap<>(0); + this.currentWiredConditions = new ConcurrentHashMap<>(0); + this.currentWiredExtras = new ConcurrentHashMap<>(0); + } + + public void addWired(InteractionWired wired) { + this.currentWireds.put(wired.getId(), wired); + sortWired(wired); + } + + public void removeWired(InteractionWired wired) { + InteractionWired w = this.currentWireds.remove(wired.getId()); + + if (w instanceof InteractionWiredTrigger trigger) { + removeWiredTrigger(trigger); + } else if (w instanceof InteractionWiredEffect effect) { + removeWiredEffect(effect); + } else if (w instanceof InteractionWiredCondition condition) { + removeWiredCondition(condition); + } else if (w instanceof InteractionWiredExtra extra) { + removeWiredExtra(extra); + } else { + log.error("Error occurred while removing undefined Wired Type"); + } + } + + private void sortWired(InteractionWired wired) { + if (wired instanceof InteractionWiredTrigger trigger) { + addWiredTrigger(trigger); + } else if (wired instanceof InteractionWiredEffect effect) { + addWiredEffect(effect); + } else if (wired instanceof InteractionWiredCondition condition) { + addWiredCondition(condition); + } else if (wired instanceof InteractionWiredExtra extra) { + addWiredExtra(extra); + } else { + log.error("Undefined Wired Type"); + } + } + + public void addWiredTrigger(InteractionWiredTrigger trigger) { + currentWiredTriggers.computeIfAbsent(trigger.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(trigger); + } + + public void removeWiredTrigger(InteractionWiredTrigger trigger) { + Set triggers = currentWiredTriggers.get(trigger.getType()); + if (triggers != null) { + triggers.remove(trigger); + if (triggers.isEmpty()) { + currentWiredTriggers.remove(trigger.getType()); + } + } + } + + public void addWiredEffect(InteractionWiredEffect effect) { + currentWiredEffects.computeIfAbsent(effect.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(effect); + } + + public void removeWiredEffect(InteractionWiredEffect effect) { + Set effects = currentWiredEffects.get(effect.getType()); + if (effects != null) { + effects.remove(effect); + if (effects.isEmpty()) { + currentWiredEffects.remove(effect.getType()); + } + } + } + + public void addWiredCondition(InteractionWiredCondition condition) { + currentWiredConditions.computeIfAbsent(condition.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(condition); + } + + public void removeWiredCondition(InteractionWiredCondition condition) { + Set conditions = currentWiredConditions.get(condition.getType()); + if (conditions != null) { + conditions.remove(condition); + if (conditions.isEmpty()) { + currentWiredConditions.remove(condition.getType()); + } + } + } + + public void addWiredExtra(InteractionWiredExtra extra) { + currentWiredExtras.put(extra.getId(), extra); + } + + public void removeWiredExtra(InteractionWiredExtra extra) { + currentWiredExtras.remove(extra.getId()); + } + + public void clear() { + this.currentWireds.clear(); + this.currentWiredTriggers.clear(); + this.currentWiredConditions.clear(); + this.currentWiredEffects.clear(); + this.currentWiredExtras.clear(); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java index e2ad56ce..7f359c50 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java @@ -272,7 +272,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoalLocation() && roomUnit.getGoalLocation() == room.getLayout().getTile(this.x, this.y)) { - Habbo habbo = room.getHabbo(roomUnit); + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null && habbo.getClient() != null) { String[] clothingKeys = Arrays.stream(this.getBaseItem().getClothingOnWalk().split("\\.")).map(k -> k.split("-")[0]).toArray(String[]::new); @@ -459,7 +459,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { return this.baseItem.getStateCount() > 1; } - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(List>> itemsAtLocation) { return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java deleted file mode 100644 index cef8ef9d..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.eu.habbo.habbohotel.rooms.entities.items.types; - -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class RoomFloorItem extends RoomItem { - public RoomFloorItem(ResultSet set, Item baseItem) throws SQLException { - super(set, baseItem); - } - - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return false; - } - - @Override - public boolean isWalkable() { - return false; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomWallItem.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomWallItem.java deleted file mode 100644 index ea71dbb8..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomWallItem.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.eu.habbo.habbohotel.rooms.entities.items.types; - -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class RoomWallItem extends RoomItem { - public RoomWallItem(ResultSet set, Item baseItem) throws SQLException { - super(set, baseItem); - } - - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return false; - } - - @Override - public boolean isWalkable() { - return false; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java index a0a8989c..ec1fb767 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomFloorItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; @@ -299,7 +298,7 @@ public class RoomAvatar extends RoomUnit { return this; } - private void handleSitStatus(RoomFloorItem topItem) { + private void handleSitStatus(RoomItem topItem) { if(!this.isCmdSitEnabled()) { if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) { this.removeStatus(RoomUnitStatus.SIT); @@ -311,7 +310,7 @@ public class RoomAvatar extends RoomUnit { } } - private void handleLayStatus(RoomFloorItem topItem) { + private void handleLayStatus(RoomItem topItem) { if(!this.isCmdLayEnabled()) { if((topItem == null || !topItem.getBaseItem().allowLay()) && this.hasStatus(RoomUnitStatus.LAY)) { this.removeStatus(RoomUnitStatus.LAY); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 35889c5a..18c2bc3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; @@ -59,7 +60,7 @@ public class Habbo extends Unit implements Runnable { private volatile boolean disconnected = false; private volatile boolean disconnecting = false; - public Habbo(ResultSet set) { + public Habbo(ResultSet set) throws SQLException { this.client = null; this.habboInfo = new HabboInfo(set); this.habboStats = HabboStats.load(this.habboInfo); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index a27e1e0f..2f6bf88d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -26,91 +26,64 @@ import java.util.List; @Slf4j @Getter +@Setter +@Accessors(chain = true) public class HabboInfo implements Runnable { - - public boolean firstVisit = false; - @Setter + private final int id; private String username; - @Setter private String motto; - @Setter - @Accessors(chain = true) private String look; - @Setter private HabboGender gender; - @Setter private String mail; - @Setter private String sso; - @Setter private String ipRegister; - @Setter private String ipLogin; - private int id; - @Setter private int accountCreated; - @Setter private PermissionGroup permissionGroup; private int credits; - @Setter private int lastOnline; - @Setter private int homeRoom; - @Setter private boolean online; - @Setter private int roomQueueId; - @Setter private RideablePet riding; - @Setter private Class currentGame; private TIntIntHashMap currencies; - @Setter private GamePlayer gamePlayer; - @Setter private int photoRoomId; - @Setter private int photoTimestamp; - @Setter private String photoURL; - @Setter private String photoJSON; - @Setter private int webPublishTimestamp; - @Setter private String machineID; private List savedSearches = new ArrayList<>(); private List messengerCategories = new ArrayList<>(); + public boolean firstVisit = false; - public HabboInfo(ResultSet set) { - try { - this.id = set.getInt("id"); - this.username = set.getString("username"); - this.motto = set.getString("motto"); - this.look = set.getString("look"); - this.gender = HabboGender.valueOf(set.getString("gender")); - this.mail = set.getString("mail"); - this.sso = set.getString("auth_ticket"); - this.ipRegister = set.getString("ip_register"); - this.ipLogin = set.getString("ip_current"); - this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(set.getInt("rank")); + public HabboInfo(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.username = set.getString("username"); + this.motto = set.getString("motto"); + this.look = set.getString("look"); + this.gender = HabboGender.valueOf(set.getString("gender")); + this.mail = set.getString("mail"); + this.sso = set.getString("auth_ticket"); + this.ipRegister = set.getString("ip_register"); + this.ipLogin = set.getString("ip_current"); + this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(set.getInt("rank")); - if (this.permissionGroup == null) { - log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); - log.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); - this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(1); - } - - this.accountCreated = set.getInt("account_created"); - this.credits = set.getInt("credits"); - this.homeRoom = set.getInt("home_room"); - this.lastOnline = set.getInt("last_online"); - this.machineID = set.getString("machine_id"); - this.online = false; - } catch (SQLException e) { - log.error("Caught SQL exception", e); + if (this.permissionGroup == null) { + log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + log.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(1); } + this.accountCreated = set.getInt("account_created"); + this.credits = set.getInt("credits"); + this.homeRoom = set.getInt("home_room"); + this.lastOnline = set.getInt("last_online"); + this.machineID = set.getString("machine_id"); + this.online = false; + this.loadCurrencies(); this.loadSavedSearches(); this.loadMessengerCategories(); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java index f8a69995..5795b45a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -28,10 +28,8 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j public class HabboManager { - //Configuration. Loaded from database & updated accordingly. public static String WELCOME_MESSAGE = ""; - public static boolean NAMECHANGE_ENABLED = false; @Getter private final ConcurrentHashMap onlineHabbos; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java new file mode 100644 index 00000000..8eb8f3ca --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java @@ -0,0 +1,22 @@ +package com.eu.habbo.habbohotel.users.cache; + +import com.eu.habbo.habbohotel.users.HabboInfo; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.util.LinkedHashMap; +import java.util.Map; + +@Slf4j +@Getter +public class HabboInfoCache { + private final LinkedHashMap habboInfoCache; + + public HabboInfoCache() { + this.habboInfoCache = new LinkedHashMap(16, 0.75f, true) { + protected boolean removeEldestEntry(Map.Entry eldest) { + return false; + } + }; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 87aa305e..9687c708 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -14,10 +14,10 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -43,7 +43,6 @@ import java.util.List; public class WiredHandler { public static int MAXIMUM_FURNI_SELECTION = 5; public static int TELEPORT_DELAY = 500; - private static ObjectMapper objectMapper = null; public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java index 2c888ead..e6c83653 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlaceObjectEvent.java @@ -16,42 +16,33 @@ import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; public class PlaceObjectEvent extends MessageHandler { @Override public void handle() { - String[] values = this.packet.readString().split(" "); - - int itemId = -1; - - if (values.length != 0) itemId = Integer.parseInt(values[0]); - if (!this.client.getHabbo().getRoomUnit().isInRoom()) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } Room room = this.client.getHabbo().getRoomUnit().getRoom(); + if (room == null) { return; } - RoomItem rentSpace = null; - if (this.client.getHabbo().getHabboStats().isRentingSpace()) { - rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); + String[] values = this.packet.readString().split(" "); + + int itemId = -1; + + if (values.length != 0) { + itemId = Integer.parseInt(values[0]); } RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); - if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) - return; - - if (room.getRoomInfo().getId() != item.getRoomId() && item.getRoomId() != 0) - return; - - //TODO move this to canStackAt() though find a way to handle the different bubble alert keys - if (item instanceof InteractionMoodLight && !room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_DIMMERS.getErrorCode())); + //PostIts have their own event + if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) { return; } - if (item instanceof InteractionJukeBox && !room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_SOUNDFURNI.getErrorCode())); + + if (room.getRoomInfo().getId() != item.getRoomId() && item.getRoomId() != 0) { return; } @@ -71,12 +62,19 @@ public class PlaceObjectEvent extends MessageHandler { } RoomItem buildArea = null; + for (RoomItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { if (((InteractionBuildArea) area).inSquare(tile)) { buildArea = area; } } + RoomItem rentSpace = null; + + if (this.client.getHabbo().getHabboStats().isRentingSpace()) { + rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); + } + if ((rentSpace != null || buildArea != null) && !room.hasRights(this.client.getHabbo())) { if (item instanceof InteractionRoller || item instanceof InteractionStackHelper || @@ -94,18 +92,14 @@ public class PlaceObjectEvent extends MessageHandler { return; } } - FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); + + FurnitureMovementError error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; } - error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo()); - if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); - return; - } } else { FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/GetUserTagsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/GetUserTagsEvent.java index 37696e30..7283013c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/GetUserTagsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/GetUserTagsEvent.java @@ -10,7 +10,7 @@ public class GetUserTagsEvent extends MessageHandler { int roomUnitId = this.packet.readInt(); if (this.client.getHabbo().getRoomUnit().getRoom() != null) { - Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getHabboByRoomUnitId(roomUnitId); + Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getHabboByVirtualId(roomUnitId); if (habbo != null) { this.client.sendResponse(new UserTagsMessageComposer(habbo)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreUserEvent.java index dcbfa00f..1897dfa8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/IgnoreUserEvent.java @@ -15,7 +15,7 @@ public class IgnoreUserEvent extends MessageHandler { if (room != null) { String username = this.packet.readString(); - Habbo habbo = room.getHabbo(username); + Habbo habbo = room.getRoomUnitManager().getRoomHabboByUsername(username); if (habbo != null) { if (habbo == this.client.getHabbo()) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnignoreUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnignoreUserEvent.java index 91ca8a76..bdc1b240 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnignoreUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnignoreUserEvent.java @@ -13,7 +13,7 @@ public class UnignoreUserEvent extends MessageHandler { if (room != null) { String username = this.packet.readString(); - Habbo habbo = room.getHabbo(username); + Habbo habbo = room.getRoomUnitManager().getRoomHabboByUsername(username); if (habbo != null) { if (habbo.getHabboStats().allowTalk()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java index 2a88aefc..431d2619 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java @@ -19,7 +19,7 @@ public class OpenTradingEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getVirtualId()) { - Habbo targetUser = room.getHabboByRoomUnitId(userId); + Habbo targetUser = room.getRoomUnitManager().getHabboByVirtualId(userId); boolean tradeAnywhere = this.client.getHabbo().hasRight(Permission.ACC_TRADE_ANYWHERE);