From 7cf3e3e86383add55de41ad9c5f900492a0330f0 Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 15 Jun 2023 16:28:23 -0500 Subject: [PATCH 01/42] Remove serialization per wired. --- .../items/interactions/InteractionWired.java | 85 +++++++++++---- .../InteractionWiredCondition.java | 15 --- .../interactions/InteractionWiredEffect.java | 44 ++++---- .../interactions/InteractionWiredTrigger.java | 39 +++---- .../interactions/wired/WiredSettings.java | 78 +++++--------- .../WiredConditionDateRangeActive.java | 42 +------- .../WiredConditionFurniHaveFurni.java | 42 ++------ .../WiredConditionFurniHaveHabbo.java | 35 +----- .../WiredConditionFurniTypeMatch.java | 34 +----- .../conditions/WiredConditionGroupMember.java | 26 +---- .../conditions/WiredConditionHabboCount.java | 36 ++----- .../WiredConditionHabboHasEffect.java | 28 +---- .../WiredConditionHabboHasHandItem.java | 29 +---- .../WiredConditionHabboWearsBadge.java | 26 +---- .../WiredConditionLessTimeElapsed.java | 29 +---- .../WiredConditionMatchStatePosition.java | 79 ++++---------- .../WiredConditionMoreTimeElapsed.java | 32 +----- .../WiredConditionNotFurniHaveFurni.java | 40 ++----- .../WiredConditionNotFurniHaveHabbo.java | 35 +----- .../WiredConditionNotFurniTypeMatch.java | 35 +----- .../WiredConditionNotHabboCount.java | 33 +----- .../WiredConditionNotHabboHasEffect.java | 28 +---- .../WiredConditionNotHabboWearsBadge.java | 26 +---- .../conditions/WiredConditionNotInGroup.java | 26 +---- .../conditions/WiredConditionNotInTeam.java | 29 +---- .../conditions/WiredConditionTeamMember.java | 30 +----- .../WiredConditionTriggerOnFurni.java | 34 +----- .../wired/effects/WiredEffectBotClothes.java | 54 ++-------- .../effects/WiredEffectBotFollowHabbo.java | 58 ++-------- .../effects/WiredEffectBotGiveHandItem.java | 58 ++-------- .../wired/effects/WiredEffectBotTalk.java | 68 ++---------- .../effects/WiredEffectBotTalkToHabbo.java | 59 ++-------- .../wired/effects/WiredEffectBotTeleport.java | 59 ++-------- .../effects/WiredEffectBotWalkToFurni.java | 56 ++-------- .../WiredEffectChangeFurniDirection.java | 54 +++------- ...redEffectGiveHotelviewBonusRarePoints.java | 50 ++------- .../WiredEffectGiveHotelviewHofPoints.java | 50 ++------- .../wired/effects/WiredEffectGiveRespect.java | 50 ++------- .../wired/effects/WiredEffectGiveReward.java | 87 +++------------ .../wired/effects/WiredEffectGiveScore.java | 59 ++-------- .../effects/WiredEffectGiveScoreToTeam.java | 49 ++------- .../wired/effects/WiredEffectJoinTeam.java | 57 ++-------- .../wired/effects/WiredEffectKickHabbo.java | 54 ++-------- .../wired/effects/WiredEffectLeaveTeam.java | 51 ++------- .../wired/effects/WiredEffectMatchFurni.java | 85 +++++---------- .../effects/WiredEffectMoveFurniAway.java | 54 ++-------- .../wired/effects/WiredEffectMoveFurniTo.java | 61 ++--------- .../effects/WiredEffectMoveFurniTowards.java | 57 ++-------- .../effects/WiredEffectMoveRotateFurni.java | 60 ++--------- .../wired/effects/WiredEffectMuteHabbo.java | 41 ++----- .../wired/effects/WiredEffectResetTimers.java | 45 +------- .../wired/effects/WiredEffectTeleport.java | 68 ++---------- .../wired/effects/WiredEffectToggleFurni.java | 102 +++++------------- .../effects/WiredEffectToggleRandom.java | 68 ++---------- .../effects/WiredEffectTriggerStacks.java | 79 +++----------- .../wired/effects/WiredEffectWhisper.java | 80 ++------------ .../wired/extra/WiredExtraRandom.java | 14 +-- .../wired/extra/WiredExtraUnseen.java | 12 +-- .../interfaces/IWiredEffectInteraction.java | 10 ++ .../wired/interfaces/IWiredInteraction.java | 21 ++++ .../interfaces/IWiredTriggerInteraction.java | 10 ++ .../wired/triggers/WiredTriggerAtSetTime.java | 44 +------- .../triggers/WiredTriggerAtTimeLong.java | 44 +------- .../triggers/WiredTriggerBotReachedFurni.java | 63 +---------- .../triggers/WiredTriggerBotReachedHabbo.java | 27 +---- .../wired/triggers/WiredTriggerCollision.java | 26 +---- .../WiredTriggerFurniStateToggled.java | 49 +-------- .../wired/triggers/WiredTriggerGameEnds.java | 39 +------ .../triggers/WiredTriggerGameStarts.java | 38 +------ .../triggers/WiredTriggerHabboEntersRoom.java | 26 +---- .../WiredTriggerHabboSaysKeyword.java | 31 +----- .../WiredTriggerHabboWalkOffFurni.java | 50 ++------- .../WiredTriggerHabboWalkOnFurni.java | 48 +-------- .../wired/triggers/WiredTriggerRepeater.java | 44 +------- .../triggers/WiredTriggerRepeaterLong.java | 43 +------- .../triggers/WiredTriggerScoreAchieved.java | 29 +---- .../com/eu/habbo/habbohotel/rooms/Room.java | 2 +- .../habbo/habbohotel/wired/WiredHandler.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 12 ++- .../incoming/wired/UpdateConditionEvent.java | 24 +++-- .../incoming/wired/UpdateTriggerEvent.java | 25 +++-- .../wired/WiredConditionDataComposer.java | 25 ++++- .../wired/WiredEffectDataComposer.java | 34 +++++- .../wired/WiredTriggerDataComposer.java | 30 +++++- 84 files changed, 784 insertions(+), 2826 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 84838123..256b85f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -3,12 +3,19 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectWhisper; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; -import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import gnu.trove.map.hash.TLongLongHashMap; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; @@ -17,27 +24,41 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public abstract class InteractionWired extends InteractionDefault { +public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction { + @Getter + @Setter + private THashSet items; + + @Getter + @Setter + private String wiredData; + + @Getter + @Setter + private WiredSettings wiredSettings; + private long cooldown; private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.items = new THashSet<>(); + this.wiredData = ""; + this.wiredSettings = new WiredSettings(); this.setExtradata("0"); } InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.items = new THashSet<>(); + this.wiredData = ""; + this.wiredSettings = new WiredSettings(); this.setExtradata("0"); } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); - public abstract String getWiredData(); - - public abstract void serializeWiredData(ServerMessage message, Room room); - - public abstract void loadWiredData(ResultSet set, Room room) throws SQLException; + public abstract boolean saveData() throws WiredSaveException; @Override public void run() { @@ -65,11 +86,9 @@ public abstract class InteractionWired extends InteractionDefault { @Override public void onPickUp(Room room) { - this.onPickUp(); + this.items.clear(); } - public abstract void onPickUp(); - public void activateBox(Room room) { this.activateBox(room, null, 0L); } @@ -124,17 +143,21 @@ public abstract class InteractionWired extends InteractionDefault { this.userExecutionCache.put(roomUnitId, timestamp); } - public static WiredSettings readSettings(ClientMessage packet, boolean isEffect) - { + public WiredSettings loadWiredSettings(ClientMessage packet, boolean isWiredEffect) { + WiredSettings settings = new WiredSettings(); + int intParamCount = packet.readInt(); - int[] intParams = new int[intParamCount]; + int[] integerParams = new int[intParamCount]; for(int i = 0; i < intParamCount; i++) { - intParams[i] = packet.readInt(); + integerParams[i] = packet.readInt(); } - String stringParam = packet.readString(); + settings.setIntegerParams(integerParams); + settings.setStringParam(packet.readString()); + + System.out.println(settings.getStringParam()); int itemCount = packet.readInt(); int[] itemIds = new int[itemCount]; @@ -144,15 +167,39 @@ public abstract class InteractionWired extends InteractionDefault { itemIds[i] = packet.readInt(); } - WiredSettings settings = new WiredSettings(intParams, stringParam, itemIds, -1); + settings.setItems(itemIds); - if(isEffect) + if(isWiredEffect) { settings.setDelay(packet.readInt()); } - settings.setStuffTypeSelectionCode(packet.readInt()); - return settings; + settings.setSelectionType(packet.readInt()); + + this.wiredSettings = settings; + + return this.wiredSettings; } + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { + WiredSettings settings = new WiredSettings(); + + String wiredData = set.getString("wired_data"); + +// if(wiredData.startsWith("{")) { +// WiredEffectWhisper.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredEffectWhisper.JsonData.class); +// this.getWiredSettings().setDelay(data.delay); +// this.message = data.message; +// } +// else { +// this.message = ""; +// +// if (wiredData.split("\t").length >= 2) { +// super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); +// this.message = wiredData.split("\t")[1]; +// } +// +// this.needsUpdate(true); +// } + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index df4fbd0d..d21ec978 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -2,9 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; @@ -21,16 +19,6 @@ public abstract class InteractionWiredCondition extends InteractionWired { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return true; - } - - @Override - public boolean isWalkable() { - return true; - } - @Override public void onClick(GameClient client, Room room, Object[] objects) { if (client != null) { @@ -43,10 +31,7 @@ public abstract class InteractionWiredCondition extends InteractionWired { public abstract WiredConditionType getType(); - public abstract boolean saveData(WiredSettings settings); - public WiredConditionOperator operator() { return WiredConditionOperator.AND; } - } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index e58e3659..d650e391 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -3,34 +3,45 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredEffectInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; -public abstract class InteractionWiredEffect extends InteractionWired { - private int delay; +public abstract class InteractionWiredEffect extends InteractionWired implements IWiredEffectInteraction { + @Getter + @Setter + private List blockedTriggers; public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionWiredEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionWiredEffect(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, userId, item, extraData, limitedStack, limitedSells); } - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return true; - } + public List getBlockedTriggers(Room room) { + List blockedTriggers = new ArrayList<>(); + THashSet triggers = room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()); - @Override - public boolean isWalkable() { - return true; + for(InteractionWiredTrigger trigger : triggers) { + if(!trigger.isTriggeredByRoomUnit()) { + blockedTriggers.add(trigger.getBaseItem().getSpriteId()); + } + } + + return blockedTriggers; } @Override @@ -43,19 +54,8 @@ public abstract class InteractionWiredEffect extends InteractionWired { } } - public abstract boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException; - - public int getDelay() { - return this.delay; - } - - protected void setDelay(int value) { - this.delay = value; - } - public abstract WiredEffectType getType(); - public boolean requiresTriggeringUser() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index db67dd84..72d5c7b3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -3,16 +3,24 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredTriggerInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; -public abstract class InteractionWiredTrigger extends InteractionWired { - private int delay; +public abstract class InteractionWiredTrigger extends InteractionWired implements IWiredTriggerInteraction { + @Getter + @Setter + private List blockedEffects; protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -22,14 +30,17 @@ public abstract class InteractionWiredTrigger extends InteractionWired { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return true; - } + public List getBlockedEffects(Room room) { + List blockedEffects = new ArrayList<>(); + THashSet effects = room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()); - @Override - public boolean isWalkable() { - return true; + for(InteractionWiredEffect effect : effects) { + if (!effect.requiresTriggeringUser()) { + blockedEffects.add(effect.getBaseItem().getSpriteId()); + } + } + + return blockedEffects; } @Override @@ -44,16 +55,6 @@ public abstract class InteractionWiredTrigger extends InteractionWired { public abstract WiredTriggerType getType(); - public abstract boolean saveData(WiredSettings settings); - - protected int getDelay() { - return this.delay; - } - - protected void setDelay(int value) { - this.delay = value; - } - public boolean isTriggeredByRoomUnit() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index b6027a06..cd1c582a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -1,63 +1,33 @@ package com.eu.habbo.habbohotel.items.interactions.wired; +import lombok.Getter; +import lombok.Setter; + public class WiredSettings { - private int[] intParams; + @Getter + @Setter + private int[] integerParams; + + @Getter + @Setter private String stringParam; - private int[] furniIds; - private int stuffTypeSelectionCode; + + @Getter + @Setter + private int[] items; + @Getter + @Setter private int delay; - public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode, int delay) - { - this.furniIds = furniIds; - this.intParams = intParams; - this.stringParam = stringParam; - this.stuffTypeSelectionCode = stuffTypeSelectionCode; - this.delay = delay; - } + @Getter + @Setter + private int selectionType; - public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode) - { - this(intParams, stringParam, furniIds, stuffTypeSelectionCode, 0); - } - - public int getStuffTypeSelectionCode() { - return stuffTypeSelectionCode; - } - - public void setStuffTypeSelectionCode(int stuffTypeSelectionCode) { - this.stuffTypeSelectionCode = stuffTypeSelectionCode; - } - - public int[] getFurniIds() { - return furniIds; - } - - public void setFurniIds(int[] furniIds) { - this.furniIds = furniIds; - } - - public String getStringParam() { - return stringParam; - } - - public void setStringParam(String stringParam) { - this.stringParam = stringParam; - } - - public int[] getIntParams() { - return intParams; - } - - public void setIntParams(int[] intParams) { - this.intParams = intParams; - } - - public int getDelay() { - return delay; - } - - public void setDelay(int delay) { - this.delay = delay; + public WiredSettings() { + this.items = new int[0]; + this.integerParams = new int[0]; + this.stringParam = ""; + this.delay = 0; + this.selectionType = 0; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index 1774a6de..73e1662b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -55,38 +55,15 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { return type; } - /** - * Sends information about this wired condition to the client. - * @param message the message to send data with - * @param room the room this wired condition is in - */ - @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.startDate); - message.appendInt(this.endDate); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.startDate); - message.appendInt(this.endDate); - } - /** * Saves the given {@link WiredSettings} object to this wired condition. - * @param settings the settings to save * @return {@code true} if the settings were saved successfully, {@code false} otherwise * */ @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 2) return false; - this.startDate = settings.getIntParams()[0]; - this.endDate = settings.getIntParams()[1]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 2) return false; + this.startDate = this.getWiredSettings().getIntegerParams()[0]; + this.endDate = this.getWiredSettings().getIntegerParams()[1]; return true; } @@ -123,7 +100,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { * @throws SQLException if an error occurs while getting data from the ResultSet object */ @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -143,15 +120,6 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { } } - /** - * Called when this item is picked up. Resets the startDate and endDate member variables to 0. - */ - @Override - public void onPickUp() { - this.startDate = 0; - this.endDate = 0; - } - /** * A nested class for storing the wired data for this wired condition in JSON format. */ diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 752454a8..f5cc38af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -67,7 +67,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -90,46 +90,18 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.items.clear(); - this.all = false; - } - @Override public WiredConditionType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); + public boolean saveData() { + if (this.getWiredSettings().getIntegerParams().length < 1) return false; - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); + this.all = this.getWiredSettings().getIntegerParams()[0] == 1; - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if (settings.getIntParams().length < 1) return false; - - this.all = settings.getIntParams()[0] == 1; - - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -138,7 +110,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java index abae0d25..9510f4eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java @@ -36,11 +36,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { this.items = new THashSet<>(); } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); @@ -69,7 +64,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -106,30 +101,8 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - int count = settings.getFurniIds().length; + public boolean saveData() { + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; @@ -139,7 +112,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index 38b06c51..875ba6c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java @@ -30,11 +30,6 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); @@ -62,7 +57,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -95,29 +90,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - int count = settings.getFurniIds().length; + public boolean saveData() { + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -126,7 +100,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(settings.getFurniIds()[i])); + this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); } } 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 d9c1d1ad..57eb15ca 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 @@ -39,14 +39,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) { - - } - - @Override - public void onPickUp() { - - } + public void loadWiredSettings(ResultSet set, Room room) {} @Override public WiredConditionType getType() { @@ -54,22 +47,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index 839b7db4..35e7df50 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -14,7 +14,6 @@ import java.sql.SQLException; public class WiredConditionHabboCount extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.USER_COUNT; - private int lowerLimit = 0; private int upperLimit = 50; @@ -42,7 +41,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -56,40 +55,17 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { this.upperLimit = Integer.parseInt(data[1]); } } - - @Override - public void onPickUp() { - this.lowerLimit = 0; - this.upperLimit = 50; - } - + @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.lowerLimit); - message.appendInt(this.upperLimit); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 2) return false; - this.lowerLimit = settings.getIntParams()[0]; - this.upperLimit = settings.getIntParams()[1]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 2) return false; + this.lowerLimit = this.getWiredSettings().getIntegerParams()[0]; + this.upperLimit = this.getWiredSettings().getIntegerParams()[1]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 52f951f7..39a7ce72 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -39,7 +39,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -50,35 +50,15 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.effectId = 0; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(true); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.effectId + ""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.effectId = settings.getIntParams()[0]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.effectId = this.getWiredSettings().getIntegerParams()[0]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 5f7f8b0f..f3e6698a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -34,25 +34,9 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.handItem); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.handItem = settings.getIntParams()[0]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.handItem = this.getWiredSettings().getIntegerParams()[0]; return true; } @@ -71,7 +55,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) { + public void loadWiredSettings(ResultSet set, Room room) { try { String wiredData = set.getString("wired_data"); @@ -86,11 +70,6 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.handItem = 0; - } - static class JsonData { int handItemId; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java index 81831829..e584e653 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java @@ -51,7 +51,7 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -62,34 +62,14 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.badge = ""; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.badge); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - this.badge = settings.getStringParam(); + public boolean saveData() { + this.badge = this.getWiredSettings().getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index 9c75f4f3..3f526230 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -39,7 +39,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); try { @@ -54,36 +54,15 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.cycles = 0; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.cycles); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.cycles = settings.getIntParams()[0]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.cycles = this.getWiredSettings().getIntegerParams()[0]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index e3a68648..684fd033 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -21,21 +21,19 @@ import java.util.List; public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; - - private final THashSet settings; - + private final THashSet wiredMatchSettings; private boolean state; private boolean position; private boolean direction; public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.settings = new THashSet<>(); + this.wiredMatchSettings = new THashSet<>(); } public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.settings = new THashSet<>(); + this.wiredMatchSettings = new THashSet<>(); } @Override @@ -44,53 +42,28 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.settings.size()); - - for (WiredMatchFurniSetting item : this.settings) - message.appendInt(item.getItem_id()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(4); - message.appendInt(this.state ? 1 : 0); - message.appendInt(this.direction ? 1 : 0); - message.appendInt(this.position ? 1 : 0); - message.appendInt(10); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 3) return false; - this.state = settings.getIntParams()[0] == 1; - this.direction = settings.getIntParams()[1] == 1; - this.position = settings.getIntParams()[2] == 1; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 3) return false; + this.state = this.getWiredSettings().getIntegerParams()[0] == 1; + this.direction = this.getWiredSettings().getIntegerParams()[1] == 1; + this.position = this.getWiredSettings().getIntegerParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return true; - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - this.settings.clear(); + this.wiredMatchSettings.clear(); for (int i = 0; i < count; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem item = room.getHabboItem(itemId); if (item != null) - this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY())); + this.wiredMatchSettings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY())); } return true; @@ -98,12 +71,12 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.settings.isEmpty()) + if (this.wiredMatchSettings.isEmpty()) return true; THashSet s = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) { + for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { HabboItem item = room.getHabboItem(setting.getItem_id()); if (item != null) { @@ -128,7 +101,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition if (!s.isEmpty()) { for (WiredMatchFurniSetting setting : s) { - this.settings.remove(setting); + this.wiredMatchSettings.remove(setting); } } @@ -141,12 +114,12 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition this.state, this.position, this.direction, - new ArrayList<>(this.settings) + new ArrayList<>(this.wiredMatchSettings) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -154,7 +127,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition this.state = data.state; this.position = data.position; this.direction = data.direction; - this.settings.addAll(data.settings); + this.wiredMatchSettings.addAll(data.settings); } else { String[] data = wiredData.split(":"); @@ -166,7 +139,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition String[] stuff = items[i].split("-"); if (stuff.length >= 5) - this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); + this.wiredMatchSettings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); } this.state = data[2].equals("1"); @@ -175,21 +148,13 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } - @Override - public void onPickUp() { - this.settings.clear(); - this.direction = false; - this.position = false; - this.state = false; - } - private void refresh() { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room != null) { THashSet remove = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) { + for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { HabboItem item = room.getHabboItem(setting.getItem_id()); if (item == null) { remove.add(setting); @@ -197,14 +162,14 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } for (WiredMatchFurniSetting setting : remove) { - this.settings.remove(setting); + this.wiredMatchSettings.remove(setting); } } } @Override public THashSet getMatchFurniSettings() { - return this.settings; + return this.wiredMatchSettings; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index ea0b85f8..8397f74a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -3,18 +3,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { private static final WiredConditionType type = WiredConditionType.TIME_MORE_THAN; + private static final int PARAM_CYCLE = 0; private int cycles; @@ -39,7 +39,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); try { @@ -54,36 +54,14 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.cycles = 0; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.cycles); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.cycles = settings.getIntParams()[0]; + public boolean saveData() throws WiredSaveException { + this.cycles = this.getWiredSettings().getIntegerParams()[PARAM_CYCLE]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 05feda6b..3fb23eec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -68,7 +68,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -103,45 +103,17 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.all = false; - this.items.clear(); - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.all = this.getWiredSettings().getIntegerParams()[0] == 1; - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.all = settings.getIntParams()[0] == 1; - - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -150,7 +122,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java index 4410a39c..682dfaff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java @@ -37,11 +37,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { this.items = new THashSet<>(); } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.refresh(); @@ -70,7 +65,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -106,30 +101,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - int count = settings.getFurniIds().length; + public boolean saveData() { + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -138,7 +111,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index 36966574..660ac80c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java @@ -19,7 +19,6 @@ import java.util.stream.Collectors; public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS; - private final THashSet items = new THashSet<>(); public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { @@ -57,7 +56,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -84,40 +83,14 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - int count = settings.getFurniIds().length; + public boolean saveData() { + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -126,7 +99,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(settings.getFurniIds()[i])); + this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java index d9fe194c..2a99324d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java @@ -42,7 +42,7 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -56,39 +56,16 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.upperLimit = 0; - this.lowerLimit = 20; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.lowerLimit); - message.appendInt(this.upperLimit); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 2) return false; - this.lowerLimit = settings.getIntParams()[0]; - this.upperLimit = settings.getIntParams()[1]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 2) return false; + this.lowerLimit = this.getWiredSettings().getIntegerParams()[0]; + this.upperLimit = this.getWiredSettings().getIntegerParams()[1]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java index 749245f8..7e82d619 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java @@ -39,7 +39,7 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -50,35 +50,15 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.effectId = 0; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.effectId + ""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.effectId = settings.getIntParams()[0]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.effectId = this.getWiredSettings().getIntegerParams()[0]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java index 96d293ce..fc644d05 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java @@ -52,7 +52,7 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -63,34 +63,14 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } } - @Override - public void onPickUp() { - this.badge = ""; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.badge); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - this.badge = settings.getStringParam(); + public boolean saveData() { + this.badge = this.getWiredSettings().getStringParam(); return true; } 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 2a6a0458..9c1b7fdb 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 @@ -39,14 +39,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) { - - } - - @Override - public void onPickUp() { - - } + public void loadWiredSettings(ResultSet set, Room room) {} @Override public WiredConditionType getType() { @@ -54,22 +47,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { return true; } } 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 fdd025cf..e139ebd6 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 @@ -46,7 +46,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) { + public void loadWiredSettings(ResultSet set, Room room) { try { String wiredData = set.getString("wired_data"); @@ -62,36 +62,15 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.teamColor = GameTeamColors.RED; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.teamColor.type); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[this.getWiredSettings().getIntegerParams()[0]]; return true; } 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 d78a616b..7e1b29f3 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 @@ -48,7 +48,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) { + public void loadWiredSettings(ResultSet set, Room room) { try { String wiredData = set.getString("wired_data"); @@ -64,37 +64,15 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.teamColor = GameTeamColors.RED; - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.teamColor.type); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; - + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[this.getWiredSettings().getIntegerParams()[0]]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index a8d9aae7..50dbbc3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -58,7 +58,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -85,40 +85,14 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { } } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public WiredConditionType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - int count = settings.getFurniIds().length; + public boolean saveData() { + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -127,7 +101,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); + HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); if (item != null) { this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index b0e1ff48..28840faf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -33,24 +33,9 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName + ((char) 9) + "" + this.botLook); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - String dataString = settings.getStringParam(); - int delay = settings.getDelay(); + public boolean saveData() throws WiredSaveException { + String dataString = this.getWiredSettings().getStringParam(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -66,7 +51,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); this.botLook = data[1]; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -90,16 +75,16 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.botName = data.bot_name; this.botLook = data.look; } @@ -107,7 +92,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length >= 3) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.botName = data[1]; this.botLook = data[2]; } @@ -116,29 +101,6 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.botLook = ""; - this.botName = ""; - this.setDelay(0); - } - - public String getBotName() { - return this.botName; - } - - public void setBotName(String botName) { - this.botName = botName; - } - - public String getBotLook() { - return this.botLook; - } - - public void setBotLook(String botLook) { - this.botLook = botLook; - } - static class JsonData { String bot_name; String look; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index 5d8d17c9..e2b7a583 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -34,56 +34,25 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(1); - message.appendInt(this.mode); - message.appendInt(1); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Mode is invalid"); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); - - int mode = settings.getIntParams()[0]; + int mode = this.getWiredSettings().getIntegerParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String botName = settings.getStringParam().replace("\t", ""); + String botName = this.getWiredSettings().getStringParam().replace("\t", ""); botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.botName = botName; this.mode = mode; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -116,16 +85,16 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.mode = data.mode; this.botName = data.bot_name; } @@ -133,7 +102,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 3) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0); this.botName = data[2]; } @@ -142,13 +111,6 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.botName = ""; - this.mode = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 c82b0eda..72df62a5 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 @@ -38,55 +38,24 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(1); - message.appendInt(this.itemId); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Missing item id"); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing item id"); - - int itemId = settings.getIntParams()[0]; + int itemId = this.getWiredSettings().getIntegerParams()[0]; if(itemId < 0) itemId = 0; - String botName = settings.getStringParam(); + String botName = this.getWiredSettings().getStringParam(); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.itemId = itemId; this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -130,16 +99,16 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.itemId = data.item_id; this.botName = data.bot_name; } @@ -147,7 +116,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 3) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.itemId = Integer.parseInt(data[1]); this.botName = data[2]; } @@ -156,13 +125,6 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.botName = ""; - this.itemId = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 11681d45..394291e3 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 @@ -36,30 +36,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName + "" + ((char) 9) + "" + this.message); - message.appendInt(1); - message.appendInt(this.mode); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); - int mode = settings.getIntParams()[0]; + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Mode is invalid"); + int mode = this.getWiredSettings().getIntegerParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = settings.getStringParam(); + String dataString = this.getWiredSettings().getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) @@ -70,12 +54,12 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); this.mode = mode; @@ -125,16 +109,16 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.mode = data.mode; this.botName = data.bot_name; this.message = data.message; @@ -143,7 +127,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 4) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; this.message = data[3]; @@ -153,38 +137,6 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.mode = 0; - this.botName = ""; - this.message = ""; - this.setDelay(0); - } - - public int getMode() { - return this.mode; - } - - public void setMode(int mode) { - this.mode = mode; - } - - public String getBotName() { - return this.botName; - } - - public void setBotName(String botName) { - this.botName = botName; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - @Override protected long requiredCooldown() { return 500; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index 2c3b0698..ccbbe0da 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -37,45 +37,14 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName + "" + ((char) 9) + "" + this.message); - message.appendInt(1); - message.appendInt(this.mode); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing mode"); - int mode = settings.getIntParams()[0]; + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Missing mode"); + int mode = this.getWiredSettings().getIntegerParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = settings.getStringParam(); + String dataString = this.getWiredSettings().getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) throw new WiredSaveException("Malformed data string"); @@ -85,7 +54,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -93,7 +62,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); this.mode = mode; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -143,16 +112,16 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.mode = data.mode; this.botName = data.bot_name; this.message = data.message; @@ -161,7 +130,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { String[] data = wiredData.split(((char) 9) + ""); if (data.length == 4) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; this.botName = data[2]; this.message = data[3]; @@ -171,14 +140,6 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.botName = ""; - this.message = ""; - this.mode = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 69be9e5e..c6102396 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 @@ -2,10 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -13,7 +11,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; @@ -84,38 +81,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - String botName = settings.getStringParam(); - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + String botName = this.getWiredSettings().getStringParam(); + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -124,7 +92,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -133,7 +101,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -141,7 +109,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { this.items.clear(); this.items.addAll(newItems); this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -193,18 +161,18 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } } - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.botName = data.bot_name; for(int itemId : data.items) { @@ -218,7 +186,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { String[] wiredDataSplit = set.getString("wired_data").split("\t"); if (wiredDataSplit.length >= 2) { - this.setDelay(Integer.parseInt(wiredDataSplit[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataSplit[0])); String[] data = wiredDataSplit[1].split(";"); if (data.length > 1) { @@ -237,13 +205,6 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.botName = ""; - this.items.clear(); - this.setDelay(0); - } - static class JsonData { String bot_name; List items; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index c1b4da34..e13566cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -38,38 +38,9 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - String botName = settings.getStringParam(); - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + String botName = this.getWiredSettings().getStringParam(); + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -78,7 +49,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -87,7 +58,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -95,7 +66,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { this.items.clear(); this.items.addAll(newItems); this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -145,18 +116,18 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } } - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new ArrayList<>(); String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.botName = data.bot_name; for(int itemId : data.items) { @@ -170,7 +141,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { String[] wiredDataSplit = set.getString("wired_data").split("\t"); if (wiredDataSplit.length >= 2) { - this.setDelay(Integer.parseInt(wiredDataSplit[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataSplit[0])); String[] data = wiredDataSplit[1].split(";"); if (data.length > 1) { @@ -189,13 +160,6 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.botName = ""; - this.setDelay(0); - } - static class JsonData { String bot_name; List items; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index c0383efb..f28743fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -120,11 +120,11 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { @Override public String getWiredData() { ArrayList settings = new ArrayList<>(this.items.values()); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); @@ -132,7 +132,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.startRotation = data.start_direction; this.blockedAction = data.blocked_action; @@ -148,7 +148,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { String[] data = wiredData.split("\t"); if (data.length >= 4) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.startRotation = RoomUserRotation.fromValue(Integer.parseInt(data[1])); this.blockedAction = Integer.parseInt(data[2]); @@ -179,44 +179,16 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.setDelay(0); - this.items.clear(); - this.blockedAction = 0; - this.startRotation = RoomUserRotation.NORTH; - } - @Override public WiredEffectType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (Map.Entry item : this.items.entrySet()) { - message.appendInt(item.getKey().getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.startRotation != null ? this.startRotation.getValue() : 0); - message.appendInt(this.blockedAction); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("Invalid data"); - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); - - int startDirectionInt = settings.getIntParams()[0]; + int startDirectionInt = this.getWiredSettings().getIntegerParams()[0]; if(startDirectionInt < 0 || startDirectionInt > 7 || (startDirectionInt % 2) != 0) { throw new WiredSaveException("Start direction is invalid"); @@ -224,13 +196,13 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionInt); - int blockedActionInt = settings.getIntParams()[1]; + int blockedActionInt = this.getWiredSettings().getIntegerParams()[1]; if(blockedActionInt < 0 || blockedActionInt > 6) { throw new WiredSaveException("Blocked action is invalid"); } - int itemsCount = settings.getFurniIds().length; + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -239,7 +211,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { THashMap newItems = new THashMap<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -248,7 +220,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { newItems.put(it, new WiredChangeDirectionSetting(it.getId(), it.getRotation(), startDirection)); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -257,7 +229,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { this.items.putAll(newItems); this.startRotation = startDirection; this.blockedAction = blockedActionInt; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } 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 5ba1cda4..01d55a9f 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 @@ -32,44 +32,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.amount + ""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) { + public boolean saveData() { try { - this.amount = Integer.parseInt(settings.getStringParam()); + this.amount = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -96,21 +66,21 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay(), this.amount)); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getWiredSettings().getDelay(), this.amount)); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); this.amount = 0; if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.amount = data.amount; } else { if (wiredData.split("\t").length >= 2) { - super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split("\t")[0])); try { this.amount = Integer.parseInt(wiredData.split("\t")[1]); @@ -120,12 +90,6 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } } - @Override - public void onPickUp() { - this.amount = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 f518cd0c..69cba25f 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 @@ -31,44 +31,14 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.amount + ""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) { + public boolean saveData() { try { - this.amount = Integer.parseInt(settings.getStringParam()); + this.amount = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -95,23 +65,23 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.amount, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.amount, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); this.amount = data.amount; - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); } else { this.amount = 0; if (wiredData.split("\t").length >= 2) { - super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split("\t")[0])); try { this.amount = Integer.parseInt(this.getWiredData().split("\t")[1]); @@ -123,12 +93,6 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.amount = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 9d80cc4d..c4796d6a 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 @@ -32,44 +32,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.respects + ""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) { + public boolean saveData() { try { - this.respects = Integer.parseInt(settings.getStringParam()); + this.respects = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -94,24 +64,24 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.respects, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.respects, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); this.respects = data.amount; - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); } else { String[] data = wiredData.split("\t"); this.respects = 0; if (data.length >= 2) { - super.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); try { this.respects = Integer.parseInt(data[1]); @@ -123,12 +93,6 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.respects = 0; - this.setDelay(0); - } - @Override public boolean requiresTriggeringUser() { return true; 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 da0c9b36..7229d273 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 @@ -30,14 +30,12 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { public final static int LIMIT_N_DAY = 1; public final static int LIMIT_N_HOURS = 2; public final static int LIMIT_N_MINUTES = 3; - private final static WiredEffectType type = WiredEffectType.GIVE_REWARD; private int limit; private int limitationInterval; private int given; private int rewardTime; private boolean uniqueRewards; - private final THashSet rewardItems = new THashSet<>(); public WiredEffectGiveReward(ResultSet set, Item baseItem) throws SQLException { @@ -57,18 +55,17 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { @Override public String getWiredData() { - ArrayList rewards = new ArrayList<>(this.rewardItems); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.limit = data.limit; this.given = data.given; this.rewardTime = data.reward_time; @@ -84,7 +81,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { this.rewardTime = Integer.parseInt(data[2]); this.uniqueRewards = data[3].equals("1"); this.limitationInterval = Integer.parseInt(data[4]); - this.setDelay(Integer.parseInt(data[5])); + this.getWiredSettings().setDelay(Integer.parseInt(data[5])); if (data.length > 6) { if (!data[6].equalsIgnoreCase("\t")) { @@ -106,17 +103,6 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.limit = 0; - this.limitationInterval = 0; - this.given = 0; - this.rewardTime = 0; - this.uniqueRewards = false; - this.rewardItems.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; @@ -132,55 +118,15 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(this.rewardItems.size()); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - StringBuilder s = new StringBuilder(); - - for (WiredGiveRewardItem item : this.rewardItems) { - s.append(item.wiredString()).append(";"); - } - message.appendString(s.toString()); - message.appendInt(4); - message.appendInt(this.rewardTime); - message.appendInt(this.uniqueRewards); - message.appendInt(this.limit); - message.appendInt(this.limitationInterval); - message.appendInt(this.limit > 0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if (gameClient.getHabbo().hasRight(Permission.ACC_SUPERWIRED)) { - if (settings.getIntParams().length < 4) throw new WiredSaveException("Invalid data"); - this.rewardTime = settings.getIntParams()[0]; - this.uniqueRewards = settings.getIntParams()[1] == 1; - this.limit = settings.getIntParams()[2]; - this.limitationInterval = settings.getIntParams()[3]; + public boolean saveData() throws WiredSaveException { + if (this.getWiredSettings().getIntegerParams().length < 4) throw new WiredSaveException("Invalid data"); + this.rewardTime = this.getWiredSettings().getIntegerParams()[0]; + this.uniqueRewards = this.getWiredSettings().getIntegerParams()[1] == 1; + this.limit = this.getWiredSettings().getIntegerParams()[2]; + this.limitationInterval = this.getWiredSettings().getIntegerParams()[3]; this.given = 0; - String data = settings.getStringParam(); + String data = this.getWiredSettings().getStringParam(); String[] items = data.split(";"); @@ -197,18 +143,15 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } } - gameClient.sendResponse(new WiredValidationErrorComposer(Emulator.getTexts().getValue("alert.superwired.invalid"))); + //TODO THROW ERROR +// gameClient.sendResponse(new WiredValidationErrorComposer(Emulator.getTexts().getValue("alert.superwired.invalid"))); return false; } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); WiredHandler.dropRewards(this.getId()); return true; - } - - gameClient.getHabbo().whisper("U cannot do this.", RoomChatMessageBubbles.ALERT); - return false; } @Override @@ -244,6 +187,4 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { this.delay = delay; } } - - } 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 ef253238..08cc276d 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 @@ -96,18 +96,18 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.score, this.count, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.score, this.count, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); this.score = data.score; this.count = data.count; - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); } else { String[] data = wiredData.split(";"); @@ -115,79 +115,40 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { if (data.length == 3) { this.score = Integer.parseInt(data[0]); this.count = Integer.parseInt(data[1]); - this.setDelay(Integer.parseInt(data[2])); + this.getWiredSettings().setDelay(Integer.parseInt(data[2])); } this.needsUpdate(true); } } - @Override - public void onPickUp() { - this.score = 0; - this.count = 0; - this.setDelay(0); - } - @Override public WiredEffectType getType() { return WiredEffectGiveScore.type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.score); - message.appendInt(this.count); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("Invalid data"); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); - - int score = settings.getIntParams()[0]; + int score = this.getWiredSettings().getIntegerParams()[0]; if(score < 1 || score > 100) throw new WiredSaveException("Score is invalid"); - int timesPerGame = settings.getIntParams()[1]; + int timesPerGame = this.getWiredSettings().getIntegerParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.score = score; this.count = timesPerGame; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 00b483f0..684a8e6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -60,11 +60,11 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.points, this.count, this.teamColor, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.points, this.count, this.teamColor, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { @@ -72,7 +72,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { this.points = data.score; this.count = data.count; this.teamColor = data.team; - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); } else { String[] data = set.getString("wired_data").split(";"); @@ -81,65 +81,38 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { this.points = Integer.parseInt(data[0]); this.count = Integer.parseInt(data[1]); this.teamColor = GameTeamColors.values()[Integer.parseInt(data[2])]; - this.setDelay(Integer.parseInt(data[3])); + this.getWiredSettings().setDelay(Integer.parseInt(data[3])); } this.needsUpdate(true); } } - @Override - public void onPickUp() { - this.startTimes.clear(); - this.points = 0; - this.count = 0; - this.teamColor = GameTeamColors.RED; - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(3); - message.appendInt(this.points); - message.appendInt(this.count); - message.appendInt(this.teamColor.type); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 3) throw new WiredSaveException("Invalid data"); - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); - - int points = settings.getIntParams()[0]; + int points = this.getWiredSettings().getIntegerParams()[0]; if(points < 1 || points > 100) throw new WiredSaveException("Points is invalid"); - int timesPerGame = settings.getIntParams()[1]; + int timesPerGame = this.getWiredSettings().getIntegerParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - int team = settings.getIntParams()[2]; + int team = this.getWiredSettings().getIntegerParams()[2]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -147,7 +120,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { this.points = points; this.count = timesPerGame; this.teamColor = GameTeamColors.values()[team]; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } 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 e83fa361..2d219cf6 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 @@ -59,23 +59,23 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.teamColor, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.teamColor, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.teamColor = data.team; } else { String[] data = set.getString("wired_data").split("\t"); if (data.length >= 1) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); if (data.length >= 2) { this.teamColor = GameTeamColors.values()[Integer.parseInt(data[1])]; @@ -86,64 +86,27 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.teamColor = GameTeamColors.RED; - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.teamColor.type); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("invalid data"); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); - - int team = settings.getIntParams()[0]; + int team = this.getWiredSettings().getIntegerParams()[0]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.teamColor = GameTeamColors.values()[team]; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index 180b15e1..7bb1e644 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -69,16 +69,16 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.message = data.message; } else { @@ -86,7 +86,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { String[] data = set.getString("wired_data").split("\t"); if (data.length >= 1) { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); if (data.length >= 2) { this.message = data[1]; @@ -94,64 +94,28 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { } } catch (Exception e) { this.message = ""; - this.setDelay(0); + this.getWiredSettings().setDelay(0); } this.needsUpdate(true); } } - @Override - public void onPickUp() { - this.message = ""; - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.message); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - String message = settings.getStringParam(); - int delay = settings.getDelay(); + public boolean saveData() throws WiredSaveException { + String message = this.getWiredSettings().getStringParam(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } 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 9265a125..6f6afd44 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 @@ -54,70 +54,35 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); } else { - this.setDelay(Integer.parseInt(wiredData)); + this.getWiredSettings().setDelay(Integer.parseInt(wiredData)); } } - @Override - public void onPickUp() { - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int delay = settings.getDelay(); + public boolean saveData() throws WiredSaveException { + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index ab995a51..68c22de6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -28,28 +28,28 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; private final boolean checkForWiredResetPermission = true; - private final THashSet settings; + private final THashSet wiredMatchSettings; private boolean state = false; private boolean direction = false; private boolean position = false; public WiredEffectMatchFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.settings = new THashSet<>(0); + this.wiredMatchSettings = new THashSet<>(0); } public WiredEffectMatchFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.settings = new THashSet<>(0); + this.wiredMatchSettings = new THashSet<>(0); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if(this.settings.isEmpty()) + if(this.wiredMatchSettings.isEmpty()) return true; - for (WiredMatchFurniSetting setting : this.settings) { + for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { HabboItem item = room.getHabboItem(setting.getItem_id()); if (item != null) { if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { @@ -90,21 +90,21 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int @Override public String getWiredData() { this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<>(this.settings), this.getDelay())); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<>(this.wiredMatchSettings), this.getWiredSettings().getDelay())); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if(wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.state = data.state; this.direction = data.direction; this.position = data.position; - this.settings.clear(); - this.settings.addAll(data.items); + this.wiredMatchSettings.clear(); + this.wiredMatchSettings.addAll(data.items); } else { String[] data = set.getString("wired_data").split(":"); @@ -119,7 +119,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int String[] stuff = item.split(Pattern.quote("-")); if (stuff.length >= 5) { - this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); + this.wiredMatchSettings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); } } catch (Exception e) { @@ -130,62 +130,29 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int this.state = data[2].equals("1"); this.direction = data[3].equals("1"); this.position = data[4].equals("1"); - this.setDelay(Integer.parseInt(data[5])); + this.getWiredSettings().setDelay(Integer.parseInt(data[5])); this.needsUpdate(true); } } - @Override - public void onPickUp() { - this.settings.clear(); - this.state = false; - this.direction = false; - this.position = false; - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - this.refresh(); - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.settings.size()); - - for (WiredMatchFurniSetting item : this.settings) - message.appendInt(item.getItem_id()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(3); - message.appendInt(this.state ? 1 : 0); - message.appendInt(this.direction ? 1 : 0); - message.appendInt(this.position ? 1 : 0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); - boolean setState = settings.getIntParams()[0] == 1; - boolean setDirection = settings.getIntParams()[1] == 1; - boolean setPosition = settings.getIntParams()[2] == 1; + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 3) throw new WiredSaveException("Invalid data"); + boolean setState = this.getWiredSettings().getIntegerParams()[0] == 1; + boolean setDirection = this.getWiredSettings().getIntegerParams()[1] == 1; + boolean setPosition = this.getWiredSettings().getIntegerParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) throw new WiredSaveException("Trying to save wired in unloaded room"); - int itemsCount = settings.getFurniIds().length; + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -194,7 +161,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int List newSettings = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -203,7 +170,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY())); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); @@ -211,9 +178,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int this.state = setState; this.direction = setDirection; this.position = setPosition; - this.settings.clear(); - this.settings.addAll(newSettings); - this.setDelay(delay); + this.wiredMatchSettings.clear(); + this.wiredMatchSettings.addAll(newSettings); + this.getWiredSettings().setDelay(delay); return true; } @@ -224,7 +191,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int if (room != null && room.isLoaded()) { THashSet remove = new THashSet<>(); - for (WiredMatchFurniSetting setting : this.settings) { + for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { HabboItem item = room.getHabboItem(setting.getItem_id()); if (item == null) { remove.add(setting); @@ -232,7 +199,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } for (WiredMatchFurniSetting setting : remove) { - this.settings.remove(setting); + this.wiredMatchSettings.remove(setting); } } @@ -240,7 +207,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int @Override public THashSet getMatchFurniSettings() { - return this.settings; + return this.wiredMatchSettings; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index cec31bf6..f48771e1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -99,19 +99,19 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); if (item != null) { @@ -122,7 +122,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -137,48 +137,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -187,7 +153,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -196,14 +162,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.items.clear(); this.items.addAll(newItems); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index cd052fe7..770f32eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -40,7 +40,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { } @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + public boolean saveData() throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) @@ -49,16 +49,16 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { this.items.clear(); this.indexOffset.clear(); - if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); - this.direction = settings.getIntParams()[0]; - this.spacing = settings.getIntParams()[1]; + if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("invalid data"); + this.direction = this.getWiredSettings().getIntegerParams()[0]; + this.spacing = this.getWiredSettings().getIntegerParams()[1]; - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(settings.getFurniIds()[i])); + this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -137,43 +137,13 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( this.direction, this.spacing, - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.direction); - message.appendInt(this.spacing); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -181,7 +151,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); this.direction = data.direction; this.spacing = data.spacing; - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -196,7 +166,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { try { this.direction = Integer.parseInt(data[0]); this.spacing = Integer.parseInt(data[1]); - this.setDelay(Integer.parseInt(data[2])); + this.getWiredSettings().setDelay(Integer.parseInt(data[2])); } catch (Exception ignored) { } @@ -210,15 +180,6 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.setDelay(0); - this.items.clear(); - this.direction = 0; - this.spacing = 0; - this.indexOffset.clear(); - } - @Override protected long requiredCooldown() { return 495; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 86400d3b..65263d68 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -35,8 +35,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { private THashSet items; private THashMap lastDirections; - - + public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); @@ -234,19 +233,19 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -258,7 +257,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -273,48 +272,14 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -323,7 +288,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -332,14 +297,14 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.items.clear(); this.items.addAll(newItems); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 6272bc69..41ebeb2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -97,19 +97,19 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement return WiredHandler.getGsonBuilder().create().toJson(new JsonData( this.direction, this.rotation, - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.direction = data.direction; this.rotation = data.rotation; for (Integer id: data.itemIds) { @@ -125,7 +125,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement try { this.direction = Integer.parseInt(data[0]); this.rotation = Integer.parseInt(data[1]); - this.setDelay(Integer.parseInt(data[2])); + this.getWiredSettings().setDelay(Integer.parseInt(data[2])); } catch (Exception e) { System.out.println(e); } @@ -140,70 +140,32 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement } } - @Override - public void onPickUp() { - this.direction = 0; - this.rotation = 0; - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(2); - message.appendInt(this.direction); - message.appendInt(this.rotation); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + public boolean saveData() throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return false; - if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); + if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("invalid data"); - this.direction = settings.getIntParams()[0]; - this.rotation = settings.getIntParams()[1]; + this.direction = this.getWiredSettings().getIntegerParams()[0]; + this.rotation = this.getWiredSettings().getIntegerParams()[1]; - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false; this.items.clear(); for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(settings.getFurniIds()[i])); + this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); } - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index 34afbb2f..97c3ca6f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -34,29 +34,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.message); - message.appendInt(1); - message.appendInt(this.length); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - message.appendInt(0); - } + public boolean saveData() throws WiredSaveException { + if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("invalid data"); - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); + this.length = this.getWiredSettings().getIntegerParams()[0]; + this.message = this.getWiredSettings().getStringParam(); - this.length = settings.getIntParams()[0]; - this.message = settings.getStringParam(); - - this.setDelay(settings.getDelay()); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -83,19 +67,19 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.length, this.message )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); this.length = data.length; this.message = data.message; } else { @@ -103,7 +87,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { if (data.length >= 3) { try { - this.setDelay(Integer.parseInt(data[0])); + this.getWiredSettings().setDelay(Integer.parseInt(data[0])); this.length = Integer.parseInt(data[1]); this.message = data[2]; } catch (Exception ignored) { @@ -112,13 +96,6 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.setDelay(0); - this.message = ""; - this.length = 0; - } - @Override public WiredEffectType getType() { return type; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 032471ac..1dce90f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -33,39 +33,8 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.getDelay()); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) { - this.setDelay(settings.getDelay()); + public boolean saveData() { + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -84,7 +53,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -99,13 +68,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { } } - this.setDelay(this.delay); - } - - @Override - public void onPickUp() { - this.delay = 0; - this.setDelay(0); + this.getWiredSettings().setDelay(this.delay); } @Override 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 202da6dd..c081474d 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 @@ -81,52 +81,10 @@ public class WiredEffectTeleport extends InteractionWiredEffect { Emulator.getThreading().run(() -> { roomUnit.setWiredTeleporting(true); }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); } - + @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) - message.appendInt(item.getId()); - - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -135,7 +93,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -144,14 +102,14 @@ public class WiredEffectTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.items.clear(); this.items.addAll(newItems); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -175,19 +133,19 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new ArrayList<>(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); if (item != null) { @@ -198,7 +156,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -213,12 +171,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; 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 2b623c3b..c3fc25fb 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 @@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -38,8 +39,6 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE; - private final THashSet items; - private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); @@ -84,86 +83,41 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); + this.setItems(new THashSet<>()); } - public WiredEffectToggleFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); + public WiredEffectToggleFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, userId, item, extraData, limitedStack, limitedSells); + this.setItems(new THashSet<>()); } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); } - List newItems = new ArrayList<>(); + THashSet newItems = new THashSet<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - if(it == null) + if(it == null) { throw new WiredSaveException(String.format("Item %s not found", itemId)); + } newItems.add(it); } - int delay = settings.getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) + if(this.getWiredSettings().getDelay() > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) { throw new WiredSaveException("Delay too long"); + } - this.items.clear(); - this.items.addAll(newItems); - this.setDelay(delay); + this.setItems(newItems); + this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); return true; } @@ -173,7 +127,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { Habbo habbo = room.getHabbo(roomUnit); THashSet itemsToRemove = new THashSet<>(); - for (HabboItem item : this.items) { + for (HabboItem item : this.getItems()) { if (item == null || item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { itemsToRemove.add(item); continue; @@ -196,7 +150,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { } } - this.items.removeAll(itemsToRemove); + this.getItems().removeAll(itemsToRemove); return true; } @@ -204,19 +158,19 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) + this.getWiredSettings().getDelay(), + this.getItems().stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { - this.items.clear(); + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { + this.getItems().clear(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -225,14 +179,14 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { } if (item != null) { - this.items.add(item); + this.getItems().add(item); } } } else { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -243,19 +197,13 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { continue; if (item != null) - this.items.add(item); + this.getItems().add(item); } } } } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index 48c52c48..cdbddb46 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -88,52 +88,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -142,7 +98,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -151,14 +107,14 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.items.clear(); this.items.addAll(newItems); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -186,19 +142,19 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -212,7 +168,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -230,12 +186,6 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java index 64939ddc..efe43fa8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java @@ -37,51 +37,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(this.getDelay()); - - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - int itemsCount = settings.getFurniIds().length; + public boolean saveData() throws WiredSaveException { + int itemsCount = this.getWiredSettings().getItems().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -90,7 +47,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = settings.getFurniIds()[i]; + int itemId = this.getWiredSettings().getItems()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -99,14 +56,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { newItems.add(it); } - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.items.clear(); this.items.addAll(newItems); - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -138,31 +95,31 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { } } } - Object[] newStuff = new Object[stuff.length + 1]; - System.arraycopy(stuff, 0, newStuff, 0, stuff.length); - newStuff[newStuff.length - 1] = this; - WiredHandler.executeEffectsAtTiles(usedTiles, roomUnit, room, newStuff); - return true; - } + Object[] newStuff = new Object[stuff.length + 1]; + System.arraycopy(stuff, 0, newStuff, 0, stuff.length); + newStuff[newStuff.length - 1] = this; + WiredHandler.executeEffectsAtTiles(usedTiles, roomUnit, room, newStuff); + return true; + } @Override public String getWiredData() { return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getDelay(), + this.getWiredSettings().getDelay(), this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); + this.getWiredSettings().setDelay(data.delay); for (Integer id: data.itemIds) { HabboItem item = room.getHabboItem(id); if (item != null) { @@ -173,7 +130,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { String[] wiredDataOld = wiredData.split("\t"); if (wiredDataOld.length >= 1) { - this.setDelay(Integer.parseInt(wiredDataOld[0])); + this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); } if (wiredDataOld.length == 2) { if (wiredDataOld[1].contains(";")) { @@ -188,12 +145,6 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { } } - @Override - public void onPickUp() { - this.items.clear(); - this.setDelay(0); - } - @Override public WiredEffectType getType() { return type; 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 3aa3543d..13bf67d6 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 @@ -1,11 +1,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; @@ -14,14 +11,11 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectWhisper extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; @@ -37,51 +31,20 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.message); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - message.appendInt(this.getDelay()); + public boolean saveData() throws WiredSaveException { + String message = this.getWiredSettings().getStringParam(); - if (this.requiresTriggeringUser()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } + //TODO Removed ability to `If user has rights of SUPER WIRED can override these two lines` + message = Emulator.getGameEnvironment().getWordFilter().filter(message, null); + message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - @Override - public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { - String message = settings.getStringParam(); - - if(gameClient.getHabbo() == null || !gameClient.getHabbo().hasRight(Permission.ACC_SUPERWIRED)) { - message = Emulator.getGameEnvironment().getWordFilter().filter(message, null); - message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - } - - int delay = settings.getDelay(); + int delay = this.getWiredSettings().getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); this.message = message; - this.setDelay(delay); + this.getWiredSettings().setDelay(delay); return true; } @@ -114,34 +77,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getDelay())); - } - - @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.setDelay(data.delay); - this.message = data.message; - } - else { - this.message = ""; - - if (wiredData.split("\t").length >= 2) { - super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); - this.message = wiredData.split("\t")[1]; - } - - this.needsUpdate(true); - } - } - - @Override - public void onPickUp() { - this.message = ""; - this.setDelay(0); + return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getWiredSettings().getDelay())); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java index 55b01606..cd091d36 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; @@ -29,18 +30,11 @@ public class WiredExtraRandom extends InteractionWiredExtra { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - - } + public void loadWiredSettings(ResultSet set, Room room) {} @Override - public void loadWiredData(ResultSet set, Room room) { - - } - - @Override - public void onPickUp() { - + public boolean saveData() throws WiredSaveException { + return true; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java index b3931aa3..3f6d2d1f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import lombok.Getter; import java.sql.ResultSet; @@ -37,18 +38,13 @@ public class WiredExtraUnseen extends InteractionWiredExtra { } @Override - public void serializeWiredData(ServerMessage message, Room room) { + public void loadWiredSettings(ResultSet set, Room room) { } @Override - public void loadWiredData(ResultSet set, Room room) { - - } - - @Override - public void onPickUp() { - this.seenList.clear(); + public boolean saveData() throws WiredSaveException { + return false; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java new file mode 100644 index 00000000..2d1174a4 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java @@ -0,0 +1,10 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.rooms.Room; + +import java.util.List; + +public interface IWiredEffectInteraction { + List getBlockedTriggers(Room room); + void setBlockedTriggers(List value); +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java new file mode 100644 index 00000000..374a341b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java @@ -0,0 +1,21 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; +import gnu.trove.set.hash.THashSet; + +import java.util.Map; + +public interface IWiredInteraction { + THashSet getItems(); + void setItems(THashSet value); + String getWiredData(); + void setWiredData(String value); + WiredSettings getWiredSettings(); + void setWiredSettings(WiredSettings value); + boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); + boolean saveData() throws WiredSaveException; +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java new file mode 100644 index 00000000..aa7c6700 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java @@ -0,0 +1,10 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.rooms.Room; + +import java.util.List; + +public interface IWiredTriggerInteraction { + List getBlockedEffects(Room room); + void setBlockedEffects(List value); +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index d9ce1284..c8d34d46 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -44,7 +44,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -63,51 +63,15 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); } - @Override - public void onPickUp() { - this.executeTime = 0; - this.taskId = 0; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.executeTime / 500); - message.appendInt(1); - message.appendInt(this.getType().getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.executeTime = settings.getIntParams()[0] * 500; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.executeTime = this.getWiredSettings().getIntegerParams()[0] * 500; this.resetTimer(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index bde10d78..2872552a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -43,7 +43,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -62,51 +62,15 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); } - @Override - public void onPickUp() { - this.executeTime = 0; - this.taskId = 0; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.executeTime / 500); - message.appendInt(1); - message.appendInt(this.getType().getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.executeTime = settings.getIntParams()[0] * 500; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.executeTime = this.getWiredSettings().getIntegerParams()[0] * 500; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index c069c39d..c9de3550 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -44,62 +44,15 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(0); - message.appendInt(0); - message.appendInt(WiredTriggerType.BOT_REACHED_STF.getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { - this.botName = settings.getStringParam(); + public boolean saveData() { + this.botName = this.getWiredSettings().getStringParam(); this.items.clear(); - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); } return true; @@ -124,7 +77,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -161,12 +114,6 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.items.clear(); - this.botName = ""; - } - static class JsonData { String botName; List itemIds; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java index c303cb59..4f162e4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java @@ -31,24 +31,8 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.botName); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - this.botName = settings.getStringParam(); - + public boolean saveData() { + this.botName = this.getWiredSettings().getStringParam(); return true; } @@ -65,7 +49,7 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -76,11 +60,6 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.botName = ""; - } - @Override public boolean isTriggeredByRoomUnit() { return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index 317ac801..332c6c64 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -35,14 +35,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) { - - } - - @Override - public void onPickUp() { - - } + public void loadWiredSettings(ResultSet set, Room room) {} @Override public WiredTriggerType getType() { @@ -50,22 +43,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { return true; } 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 48bd083d..40f25250 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 @@ -62,7 +62,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items = new THashSet<>(); String wiredData = set.getString("wired_data"); @@ -76,7 +76,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } } else { if (wiredData.split(":").length >= 3) { - super.setDelay(Integer.parseInt(wiredData.split(":")[0])); +// this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO Trigger has delay??? if (!wiredData.split(":")[2].equals("\t")) { for (String s : wiredData.split(":")[2].split(";")) { @@ -90,58 +90,19 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId()) { - items.add(item); - continue; - } - - if (room.getHabboItem(item.getId()) == null) { - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { this.items.clear(); - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index 3de40ee4..a9ec094a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -35,13 +35,7 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) { - } - - @Override - public void onPickUp() { - - } + public void loadWiredSettings(ResultSet set, Room room) {} @Override public WiredTriggerType getType() { @@ -49,36 +43,7 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 922e5f3f..e54716ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -35,12 +35,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) { - } - - @Override - public void onPickUp() { - + public void loadWiredSettings(ResultSet set, Room room) { } @Override @@ -49,36 +44,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(type.getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index a6e0ae7c..2ce7633c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -48,7 +48,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -59,34 +59,14 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.username = ""; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.username); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - this.username = settings.getStringParam(); + public boolean saveData() { + this.username = this.getWiredSettings().getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index 0e3a04c4..d4c713b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -49,7 +49,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -66,37 +66,16 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.ownerOnly = false; - this.key = ""; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(this.key); - message.appendInt(0); - message.appendInt(1); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.ownerOnly = settings.getIntParams()[0] == 1; - this.key = settings.getStringParam(); + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.ownerOnly = this.getWiredSettings().getIntegerParams()[0] == 1; + this.key = this.getWiredSettings().getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java index 02623288..5fc66a30 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java @@ -50,7 +50,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -64,7 +64,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } } else { if (wiredData.split(":").length >= 3) { - super.setDelay(Integer.parseInt(wiredData.split(":")[0])); +// super.setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO THIS TRIGGER HAS DELAY? if (!wiredData.split(":")[2].equals("\t")) { for (String s : wiredData.split(":")[2].split(";")) { @@ -83,58 +83,20 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } } } - - @Override - public void onPickUp() { - this.items.clear(); - } - + @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { this.items.clear(); - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index 4c779ca6..c4e9758f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java @@ -48,46 +48,13 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } @Override - public void serializeWiredData(ServerMessage message, Room room) { - THashSet items = new THashSet<>(); - - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()) == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - message.appendBoolean(false); - message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - message.appendInt(this.items.size()); - for (HabboItem item : this.items) { - message.appendInt(item.getId()); - } - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(0); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { + public boolean saveData() { this.items.clear(); - int count = settings.getFurniIds().length; + int count = this.getWiredSettings().getItems().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); } return true; @@ -101,7 +68,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { this.items.clear(); String wiredData = set.getString("wired_data"); @@ -115,7 +82,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } } else { if (wiredData.split(":").length >= 3) { - super.setDelay(Integer.parseInt(wiredData.split(":")[0])); +// super.setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO this trigger has delay??? if (!wiredData.split(":")[2].equals("\t")) { for (String s : wiredData.split(":")[2].split(";")) { @@ -135,11 +102,6 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.items.clear(); - } - @Override public boolean isTriggeredByRoomUnit() { return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index c97eaad8..18fdc2da 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -45,7 +45,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -62,51 +62,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } } - @Override - public void onPickUp() { - this.repeatTime = DEFAULT_DELAY; - this.counter = 0; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.repeatTime / 500); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.repeatTime = settings.getIntParams()[0] * 500; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.repeatTime = this.getWiredSettings().getIntegerParams()[0] * 500; this.counter = 0; if (this.repeatTime < 500) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 8984c313..cba7eb26 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -44,7 +44,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -61,50 +61,15 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } } - @Override - public void onPickUp() { - this.repeatTime = DEFAULT_DELAY; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.repeatTime / 5000); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - - if (!this.isTriggeredByRoomUnit()) { - List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> { - if (object.requiresTriggeringUser()) { - invalidTriggers.add(object.getBaseItem().getSpriteId()); - } - return true; - }); - message.appendInt(invalidTriggers.size()); - for (Integer i : invalidTriggers) { - message.appendInt(i); - } - } else { - message.appendInt(0); - } - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.repeatTime = settings.getIntParams()[0] * 5000; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.repeatTime = this.getWiredSettings().getIntegerParams()[0] * 5000; this.counter = 0; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index 449e165e..bc1c2fa0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -44,7 +44,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { } @Override - public void loadWiredData(ResultSet set, Room room) throws SQLException { + public void loadWiredSettings(ResultSet set, Room room) throws SQLException { String wiredData = set.getString("wired_data"); if (wiredData.startsWith("{")) { @@ -58,36 +58,15 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { } } - @Override - public void onPickUp() { - this.score = 0; - } - @Override public WiredTriggerType getType() { return type; } @Override - public void serializeWiredData(ServerMessage message, Room room) { - message.appendBoolean(false); - message.appendInt(5); - message.appendInt(0); - message.appendInt(this.getBaseItem().getSpriteId()); - message.appendInt(this.getId()); - message.appendString(""); - message.appendInt(1); - message.appendInt(this.score); - message.appendInt(0); - message.appendInt(this.getType().getCode()); - message.appendInt(0); - message.appendInt(0); - } - - @Override - public boolean saveData(WiredSettings settings) { - if(settings.getIntParams().length < 1) return false; - this.score = settings.getIntParams()[0]; + public boolean saveData() { + if(this.getWiredSettings().getIntegerParams().length < 1) return false; + this.score = this.getWiredSettings().getIntegerParams()[0]; return true; } 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 afb0a400..87efb614 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -498,7 +498,7 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem item = this.getHabboItem(set.getInt("id")); if (item instanceof InteractionWired interactionWired) { - interactionWired.loadWiredData(set, this); + interactionWired.loadWiredSettings(set, this); } } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); 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 a05f7975..1ecd3b79 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -243,7 +243,7 @@ public class WiredHandler { effect.activateBox(room, roomUnit, millis); } - }, effect.getDelay() * 500L); + }, effect.getWiredSettings().getDelay() * 500L); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index ba66ade6..efdf48af 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -19,20 +19,22 @@ public class UpdateActionEvent extends MessageHandler { if (room != null) { if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + //TODO Check SUPER WIRED PERMISSIONS TOO + InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId); try { - if (effect == null) + if (effect == null) { throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId)); + } - WiredSettings settings = InteractionWired.readSettings(this.packet, true); - if (effect.saveData(settings, this.client)) { + effect.loadWiredSettings(this.packet, true); + + if (effect.saveData()) { this.client.sendResponse(new WiredSavedComposer()); effect.needsUpdate(true); Emulator.getThreading().run(effect); } - - } catch (WiredSaveException e) { this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index 47aa0d8a..7cd9bbd9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -21,19 +21,21 @@ public class UpdateConditionEvent extends MessageHandler { if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); - if (condition != null) { - WiredSettings settings = InteractionWired.readSettings(this.packet, false); - - if (condition.saveData(settings)) { - this.client.sendResponse(new WiredSavedComposer()); - - condition.needsUpdate(true); - - Emulator.getThreading().run(condition); - } else { - this.client.sendResponse(new WiredValidationErrorComposer("There was an error while saving that condition")); + try { + if (condition == null) { + throw new WiredSaveException(String.format("Wired condition with item id %s not found in room", itemId)); } + condition.loadWiredSettings(this.packet, true); + + if (condition.saveData()) { + this.client.sendResponse(new WiredSavedComposer()); + condition.needsUpdate(true); + Emulator.getThreading().run(condition); + } + } + catch (WiredSaveException e) { + this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index 57859f62..df74806f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -21,18 +21,21 @@ public class UpdateTriggerEvent extends MessageHandler { if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); - if (trigger != null) { - WiredSettings settings = InteractionWired.readSettings(this.packet, false); - - if (trigger.saveData(settings)) { - this.client.sendResponse(new WiredSavedComposer()); - - trigger.needsUpdate(true); - - Emulator.getThreading().run(trigger); - } else { - this.client.sendResponse(new WiredValidationErrorComposer("There was an error while saving that trigger")); + try { + if (trigger == null) { + throw new WiredSaveException(String.format("Wired trigger with item id %s not found in room", itemId)); } + + trigger.loadWiredSettings(this.packet, false); + + if (trigger.saveData()) { + this.client.sendResponse(new WiredSavedComposer()); + trigger.needsUpdate(true); + Emulator.getThreading().run(trigger); + } + } + catch (WiredSaveException e) { + this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java index a3265514..ac804c27 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java @@ -2,6 +2,8 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -15,7 +17,28 @@ public class WiredConditionDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredConditionDataComposer); - this.condition.serializeWiredData(this.response, this.room); +// this.condition.serializeWiredData(this.response, this.room); @DEPRECATED + + this.response.appendBoolean(false); + this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + this.response.appendInt(this.condition.getItems().size()); + + for (HabboItem item : this.condition.getItems()) { + this.response.appendInt(item.getId()); + } + + this.response.appendInt(this.condition.getBaseItem().getSpriteId()); + this.response.appendInt(this.condition.getId()); + this.response.appendString(this.condition.getWiredSettings().getStringParam()); + this.response.appendInt(this.condition.getWiredSettings().getIntegerParams().length); + + for (int param : this.condition.getWiredSettings().getIntegerParams()) { + this.response.appendInt(param); + } + + this.response.appendInt(this.condition.getWiredSettings().getSelectionType()); + this.response.appendInt(this.condition.getType().getCode()); + this.condition.needsUpdate(true); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java index 0b0757cc..9c05e26c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java @@ -2,6 +2,8 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -15,8 +17,38 @@ public class WiredEffectDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredEffectDataComposer); - this.effect.serializeWiredData(this.response, this.room); + +// this.effect.serializeWiredData(this.response, this.room); @DEPRECATED + + this.response.appendBoolean(false); + this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + this.response.appendInt(this.effect.getItems().size()); + + for (HabboItem item : this.effect.getItems()) { + this.response.appendInt(item.getId()); + } + + this.response.appendInt(this.effect.getBaseItem().getSpriteId()); + this.response.appendInt(this.effect.getId()); + this.response.appendString(this.effect.getWiredSettings().getStringParam()); + this.response.appendInt(this.effect.getWiredSettings().getIntegerParams().length); + + for (int param : this.effect.getWiredSettings().getIntegerParams()) { + this.response.appendInt(param); + } + + this.response.appendInt(this.effect.getWiredSettings().getSelectionType()); + this.response.appendInt(this.effect.getType().getCode()); + this.response.appendInt(this.effect.getWiredSettings().getDelay()); + + this.response.appendInt(this.effect.getBlockedTriggers(this.room).size()); + + for(int blockedTrigger : this.effect.getBlockedTriggers(this.room)) { + this.response.appendInt(blockedTrigger); + } + this.effect.needsUpdate(true); + return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java index bea9262c..d3f5216a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java @@ -2,6 +2,8 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -15,7 +17,33 @@ public class WiredTriggerDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredTriggerDataComposer); - this.trigger.serializeWiredData(this.response, this.room); +// this.trigger.serializeWiredData(this.response, this.room); @DEPRECATED + + this.response.appendBoolean(false); + this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); + this.response.appendInt(this.trigger.getItems().size()); + + for (HabboItem item : this.trigger.getItems()) { + this.response.appendInt(item.getId()); + } + + this.response.appendInt(this.trigger.getBaseItem().getSpriteId()); + this.response.appendInt(this.trigger.getId()); + this.response.appendString(this.trigger.getWiredSettings().getStringParam()); + this.response.appendInt(this.trigger.getWiredSettings().getIntegerParams().length); + + for (int param : this.trigger.getWiredSettings().getIntegerParams()) { + this.response.appendInt(param); + } + + this.response.appendInt(this.trigger.getWiredSettings().getSelectionType()); + this.response.appendInt(this.trigger.getType().getCode()); + this.response.appendInt(this.trigger.getBlockedEffects(this.room).size()); + + for(int blockedTrigger : this.trigger.getBlockedEffects(this.room)) { + this.response.appendInt(blockedTrigger); + } + this.trigger.needsUpdate(true); return this.response; } From 00a81ed5c3d3868efeb6661909bf28e88a1a3a4e Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 15 Jun 2023 19:06:18 -0500 Subject: [PATCH 02/42] WiredSettings Serialization on Database --- .../items/interactions/InteractionWired.java | 42 ++++--------- .../interactions/wired/WiredSettings.java | 3 +- .../conditions/WiredConditionGroupMember.java | 3 - .../wired/effects/WiredEffectAlert.java | 2 +- .../wired/effects/WiredEffectGiveEffect.java | 2 +- .../effects/WiredEffectGiveHandItem.java | 2 +- .../wired/effects/WiredEffectWhisper.java | 38 ++---------- .../wired/interfaces/IWiredSettings.java | 17 ++++++ .../WiredTriggerHabboSaysKeyword.java | 61 +++++-------------- .../wired/WiredExclusionStrategy.java | 35 +++++++++++ .../incoming/wired/UpdateActionEvent.java | 9 +-- .../incoming/wired/UpdateConditionEvent.java | 9 +-- .../incoming/wired/UpdateTriggerEvent.java | 9 +-- 13 files changed, 97 insertions(+), 135 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 256b85f5..7d8f478b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -3,11 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectWhisper; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; @@ -40,7 +40,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi private long cooldown; private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); - InteractionWired(ResultSet set, Item baseItem) throws SQLException { + public InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.items = new THashSet<>(); this.wiredData = ""; @@ -57,17 +57,14 @@ public abstract class InteractionWired extends InteractionDefault implements IWi } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); - public abstract boolean saveData() throws WiredSaveException; @Override public void run() { if (this.needsUpdate()) { - String wiredData = this.getWiredData(); + WiredExclusionStrategy exclusionStrategy = new WiredExclusionStrategy(this.wiredSettings); - if (wiredData == null) { - wiredData = ""; - } + String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) { if (this.getRoomId() != 0) { @@ -105,7 +102,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi return 50L; } - public boolean canExecute(long newMillis) { return newMillis - this.cooldown >= this.requiredCooldown(); } @@ -143,7 +139,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi this.userExecutionCache.put(roomUnitId, timestamp); } - public WiredSettings loadWiredSettings(ClientMessage packet, boolean isWiredEffect) { + public void loadWiredSettings(ClientMessage packet, boolean isWiredEffect) { WiredSettings settings = new WiredSettings(); int intParamCount = packet.readInt(); @@ -157,8 +153,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi settings.setIntegerParams(integerParams); settings.setStringParam(packet.readString()); - System.out.println(settings.getStringParam()); - int itemCount = packet.readInt(); int[] itemIds = new int[itemCount]; @@ -177,29 +171,17 @@ public abstract class InteractionWired extends InteractionDefault implements IWi settings.setSelectionType(packet.readInt()); this.wiredSettings = settings; - - return this.wiredSettings; } public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - WiredSettings settings = new WiredSettings(); - String wiredData = set.getString("wired_data"); -// if(wiredData.startsWith("{")) { -// WiredEffectWhisper.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredEffectWhisper.JsonData.class); -// this.getWiredSettings().setDelay(data.delay); -// this.message = data.message; -// } -// else { -// this.message = ""; -// -// if (wiredData.split("\t").length >= 2) { -// super.setDelay(Integer.parseInt(wiredData.split("\t")[0])); -// this.message = wiredData.split("\t")[1]; -// } -// -// this.needsUpdate(true); -// } + WiredSettings settings = new WiredSettings(); + + if(wiredData.startsWith("{")) { + settings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); + } + + this.wiredSettings = settings; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index cd1c582a..716afb67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -1,9 +1,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import lombok.Getter; import lombok.Setter; -public class WiredSettings { +public class WiredSettings implements IWiredSettings { @Getter @Setter private int[] integerParams; 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 57eb15ca..915ef653 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 @@ -38,9 +38,6 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { return ""; } - @Override - public void loadWiredSettings(ResultSet set, Room room) {} - @Override public WiredConditionType getType() { return type; 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 14e83480..2bedaa9f 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 @@ -23,7 +23,7 @@ public class WiredEffectAlert extends WiredEffectWhisper { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - habbo.alert(this.message + habbo.alert(this.getWiredSettings().getStringParam() .replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "") .replace("%username%", habbo.getHabboInfo().getUsername()) .replace("%roomsloaded%", Emulator.getGameEnvironment().getRoomManager().loadedRoomsCount() + "")); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index 71345755..f13df167 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -21,7 +21,7 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { int effectId; try { - effectId = Integer.parseInt(this.message); + effectId = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } 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 df98240e..7df4e147 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 @@ -20,7 +20,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { try { - int itemId = Integer.parseInt(this.message); + int itemId = Integer.parseInt(this.getWiredSettings().getStringParam()); Habbo habbo = room.getHabbo(roomUnit); 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 13bf67d6..c9798119 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 @@ -20,8 +20,6 @@ import java.sql.SQLException; public class WiredEffectWhisper extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; - protected String message = ""; - public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -31,31 +29,18 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } @Override - public boolean saveData() throws WiredSaveException { - String message = this.getWiredSettings().getStringParam(); - - //TODO Removed ability to `If user has rights of SUPER WIRED can override these two lines` - message = Emulator.getGameEnvironment().getWordFilter().filter(message, null); - message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.message = message; - this.getWiredSettings().setDelay(delay); + public boolean saveData() { return true; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.message.length() > 0) { + if (this.getWiredSettings().getStringParam().length() > 0) { if (roomUnit != null) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - String msg = this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""); + 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() + ""); habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED))); Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg })); @@ -66,7 +51,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } } else { for (Habbo h : room.getHabbos()) { - h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.message.replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); + h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); } return true; @@ -75,11 +60,6 @@ public class WiredEffectWhisper extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getWiredSettings().getDelay())); - } - @Override public WiredEffectType getType() { return type; @@ -89,14 +69,4 @@ public class WiredEffectWhisper extends InteractionWiredEffect { public boolean requiresTriggeringUser() { return true; } - - static class JsonData { - String message; - int delay; - - public JsonData(String message, int delay) { - this.message = message; - this.delay = delay; - } - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java new file mode 100644 index 00000000..657c092a --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java @@ -0,0 +1,17 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import lombok.Getter; +import lombok.Setter; + +public interface IWiredSettings { + int[] getIntegerParams(); + void setIntegerParams(int[] value); + String getStringParam(); + void setStringParam(String value); + int[] getItems(); + void setItems(int[] value); + int getDelay(); + void setDelay(int value); + int getSelectionType(); + void setSelectionType(int value); +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index d4c713b2..e062aae3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -16,54 +16,37 @@ import java.sql.SQLException; public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { private static final WiredTriggerType type = WiredTriggerType.SAY_SOMETHING; - private boolean ownerOnly = false; - private String key = ""; + private static int PARAM_OWNER_ONLY = 0; public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, userId, item, extraData, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.key.length() > 0) { - if (stuff[0] instanceof String) { - if (((String) stuff[0]).toLowerCase().contains(this.key.toLowerCase())) { - Habbo habbo = room.getHabbo(roomUnit); - return !this.ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId()); - } + if (this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + + boolean ownerOnly = this.getWiredSettings().getIntegerParams()[PARAM_OWNER_ONLY] == 1; + + if (stuff[0] instanceof String) { + if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) { + Habbo habbo = room.getHabbo(roomUnit); + return !ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId()); } } + return false; } @Override public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.ownerOnly, - this.key - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.ownerOnly = data.ownerOnly; - this.key = data.key; - } else { - String[] data = wiredData.split("\t"); - - if (data.length == 2) { - this.ownerOnly = data[0].equalsIgnoreCase("1"); - this.key = data[1]; - } - } + return ""; } @Override @@ -73,10 +56,6 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { @Override public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.ownerOnly = this.getWiredSettings().getIntegerParams()[0] == 1; - this.key = this.getWiredSettings().getStringParam(); - return true; } @@ -84,14 +63,4 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { public boolean isTriggeredByRoomUnit() { return true; } - - static class JsonData { - boolean ownerOnly; - String key; - - public JsonData(boolean ownerOnly, String key) { - this.ownerOnly = ownerOnly; - this.key = key; - } - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java new file mode 100644 index 00000000..4ea1898b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java @@ -0,0 +1,35 @@ +package com.eu.habbo.habbohotel.wired; + +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; +import com.google.gson.ExclusionStrategy; +import com.google.gson.FieldAttributes; + +public class WiredExclusionStrategy implements ExclusionStrategy { + private WiredSettings wiredSettings; + public WiredExclusionStrategy(WiredSettings settings) { + this.wiredSettings = settings; + } + @Override + public boolean shouldSkipField(FieldAttributes fieldAttributes) { + String fieldName = fieldAttributes.getName(); + + switch (fieldName) { + case "stringParam": + return this.wiredSettings.getStringParam().isEmpty(); + case "integerParams": + return this.wiredSettings.getIntegerParams().length == 0; + case "delay": + return this.wiredSettings.getDelay() == 0; + case "items": + return this.wiredSettings.getItems().length == 0; + case "selectionType": + default: + return true; + } + } + + @Override + public boolean shouldSkipClass(Class aClass) { + return false; + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index efdf48af..78f8629c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -29,12 +29,9 @@ public class UpdateActionEvent extends MessageHandler { } effect.loadWiredSettings(this.packet, true); - - if (effect.saveData()) { - this.client.sendResponse(new WiredSavedComposer()); - effect.needsUpdate(true); - Emulator.getThreading().run(effect); - } + this.client.sendResponse(new WiredSavedComposer()); + effect.needsUpdate(true); + Emulator.getThreading().run(effect); } catch (WiredSaveException e) { this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index 7cd9bbd9..c22ad8e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -27,12 +27,9 @@ public class UpdateConditionEvent extends MessageHandler { } condition.loadWiredSettings(this.packet, true); - - if (condition.saveData()) { - this.client.sendResponse(new WiredSavedComposer()); - condition.needsUpdate(true); - Emulator.getThreading().run(condition); - } + this.client.sendResponse(new WiredSavedComposer()); + condition.needsUpdate(true); + Emulator.getThreading().run(condition); } catch (WiredSaveException e) { this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index df74806f..d58e73cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -27,12 +27,9 @@ public class UpdateTriggerEvent extends MessageHandler { } trigger.loadWiredSettings(this.packet, false); - - if (trigger.saveData()) { - this.client.sendResponse(new WiredSavedComposer()); - trigger.needsUpdate(true); - Emulator.getThreading().run(trigger); - } + this.client.sendResponse(new WiredSavedComposer()); + trigger.needsUpdate(true); + Emulator.getThreading().run(trigger); } catch (WiredSaveException e) { this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage())); From 94dd34a11eaa6fff2a545a0c43979d989c64f5be Mon Sep 17 00:00:00 2001 From: Stankman Date: Fri, 16 Jun 2023 19:30:07 -0500 Subject: [PATCH 03/42] Refactored All Wireds --- .../items/interactions/InteractionWired.java | 27 +-- .../interactions/InteractionWiredEffect.java | 6 +- .../interactions/InteractionWiredTrigger.java | 8 +- .../interactions/wired/WiredSettings.java | 32 ++- .../interactions/wired/WiredTriggerReset.java | 5 - .../WiredConditionDateRangeActive.java | 92 +------- .../WiredConditionFurniHaveFurni.java | 110 ++------- .../WiredConditionFurniHaveHabbo.java | 106 +-------- .../WiredConditionFurniTypeMatch.java | 105 +-------- .../conditions/WiredConditionGroupMember.java | 17 +- .../conditions/WiredConditionHabboCount.java | 56 +---- .../WiredConditionHabboHasEffect.java | 48 +--- .../WiredConditionHabboHasHandItem.java | 60 +---- .../WiredConditionHabboWearsBadge.java | 60 ++--- .../WiredConditionLessTimeElapsed.java | 47 +--- .../WiredConditionMatchStatePosition.java | 186 +++------------ .../WiredConditionMoreTimeElapsed.java | 46 +--- .../WiredConditionNotFurniHaveFurni.java | 122 +--------- .../WiredConditionNotFurniHaveHabbo.java | 105 +-------- .../WiredConditionNotFurniTypeMatch.java | 103 +------- .../WiredConditionNotHabboCount.java | 55 +---- .../WiredConditionNotHabboHasEffect.java | 46 +--- .../WiredConditionNotHabboWearsBadge.java | 58 +---- .../conditions/WiredConditionNotInGroup.java | 17 +- .../conditions/WiredConditionNotInTeam.java | 56 +---- .../WiredConditionNotMatchStatePosition.java | 4 +- .../WiredConditionNotTriggerOnFurni.java | 10 +- .../conditions/WiredConditionTeamMember.java | 55 +---- .../WiredConditionTriggerOnFurni.java | 112 +-------- .../wired/effects/WiredEffectBotClothes.java | 84 +------ .../effects/WiredEffectBotFollowHabbo.java | 83 +------ .../effects/WiredEffectBotGiveHandItem.java | 85 +------ .../wired/effects/WiredEffectBotTalk.java | 97 +------- .../effects/WiredEffectBotTalkToHabbo.java | 110 ++------- .../wired/effects/WiredEffectBotTeleport.java | 174 +++----------- .../effects/WiredEffectBotWalkToFurni.java | 132 +---------- .../WiredEffectChangeFurniDirection.java | 208 +++-------------- .../wired/effects/WiredEffectGiveEffect.java | 4 + .../effects/WiredEffectGiveHandItem.java | 4 + ...redEffectGiveHotelviewBonusRarePoints.java | 76 ++---- .../WiredEffectGiveHotelviewHofPoints.java | 77 ++---- .../wired/effects/WiredEffectGiveRespect.java | 83 ++----- .../wired/effects/WiredEffectGiveReward.java | 166 ++++--------- .../wired/effects/WiredEffectGiveScore.java | 102 ++------ .../effects/WiredEffectGiveScoreToTeam.java | 115 ++------- .../wired/effects/WiredEffectJoinTeam.java | 83 +------ .../wired/effects/WiredEffectKickHabbo.java | 74 +----- .../wired/effects/WiredEffectLeaveTeam.java | 41 +--- .../wired/effects/WiredEffectMatchFurni.java | 219 ++++-------------- .../effects/WiredEffectMoveFurniAway.java | 112 +-------- .../wired/effects/WiredEffectMoveFurniTo.java | 182 +++------------ .../effects/WiredEffectMoveFurniTowards.java | 117 +--------- .../effects/WiredEffectMoveRotateFurni.java | 170 +++----------- .../wired/effects/WiredEffectMuteHabbo.java | 77 +----- .../wired/effects/WiredEffectResetTimers.java | 56 +---- .../wired/effects/WiredEffectTeleport.java | 131 ++--------- .../wired/effects/WiredEffectToggleFurni.java | 143 ++---------- .../effects/WiredEffectToggleRandom.java | 104 +-------- .../effects/WiredEffectTriggerStacks.java | 103 +------- .../wired/effects/WiredEffectWhisper.java | 50 ++-- .../wired/extra/WiredExtraRandom.java | 18 -- .../wired/extra/WiredExtraUnseen.java | 20 -- .../interfaces/IWiredEffectInteraction.java | 3 + .../wired/interfaces/IWiredInteraction.java | 9 - .../wired/interfaces/IWiredSettings.java | 10 +- .../interfaces/IWiredTriggerInteraction.java | 3 + .../wired/interfaces/WiredTriggerReset.java | 5 + .../wired/triggers/WiredTriggerAtSetTime.java | 63 +---- .../triggers/WiredTriggerAtTimeLong.java | 61 +---- .../triggers/WiredTriggerBotReachedFurni.java | 98 +------- .../triggers/WiredTriggerBotReachedHabbo.java | 48 +--- .../wired/triggers/WiredTriggerCollision.java | 20 +- .../WiredTriggerFurniStateToggled.java | 93 +------- .../wired/triggers/WiredTriggerGameEnds.java | 17 +- .../triggers/WiredTriggerGameStarts.java | 18 +- .../triggers/WiredTriggerHabboEntersRoom.java | 56 +---- .../WiredTriggerHabboSaysKeyword.java | 21 +- .../WiredTriggerHabboWalkOffFurni.java | 89 +------ .../WiredTriggerHabboWalkOnFurni.java | 94 +------- .../wired/triggers/WiredTriggerRepeater.java | 78 ++----- .../triggers/WiredTriggerRepeaterLong.java | 58 +---- .../triggers/WiredTriggerScoreAchieved.java | 49 +--- .../com/eu/habbo/habbohotel/rooms/Room.java | 3 +- .../wired/WiredExclusionStrategy.java | 6 +- .../habbo/habbohotel/wired/WiredHandler.java | 2 +- .../wired/WiredConditionDataComposer.java | 9 +- .../wired/WiredEffectDataComposer.java | 9 +- .../wired/WiredTriggerDataComposer.java | 9 +- 88 files changed, 846 insertions(+), 5139 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/WiredTriggerReset.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 7d8f478b..87ec676b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -6,14 +6,12 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import gnu.trove.map.hash.TLongLongHashMap; -import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -22,13 +20,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; @Slf4j public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction { - @Getter - @Setter - private THashSet items; - @Getter @Setter private String wiredData; @@ -42,7 +38,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); this.wiredData = ""; this.wiredSettings = new WiredSettings(); this.setExtradata("0"); @@ -50,18 +45,19 @@ public abstract class InteractionWired extends InteractionDefault implements IWi InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); this.wiredData = ""; this.wiredSettings = new WiredSettings(); this.setExtradata("0"); } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); - public abstract boolean saveData() throws WiredSaveException; @Override public void run() { if (this.needsUpdate()) { + //TODO HERE IS WERE WIRED_SAVE_EXCEPTION WILL BE THROWN + //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers + WiredExclusionStrategy exclusionStrategy = new WiredExclusionStrategy(this.wiredSettings); String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings); @@ -83,7 +79,8 @@ public abstract class InteractionWired extends InteractionDefault implements IWi @Override public void onPickUp(Room room) { - this.items.clear(); + this.wiredSettings = null; + //TODO not sure about this } public void activateBox(Room room) { @@ -143,25 +140,25 @@ public abstract class InteractionWired extends InteractionDefault implements IWi WiredSettings settings = new WiredSettings(); int intParamCount = packet.readInt(); - int[] integerParams = new int[intParamCount]; + List integerParams = new ArrayList<>(); for(int i = 0; i < intParamCount; i++) { - integerParams[i] = packet.readInt(); + integerParams.add(packet.readInt()); } settings.setIntegerParams(integerParams); settings.setStringParam(packet.readString()); int itemCount = packet.readInt(); - int[] itemIds = new int[itemCount]; + List itemIds = new ArrayList<>(); for(int i = 0; i < itemCount; i++) { - itemIds[i] = packet.readInt(); + itemIds.add(packet.readInt()); } - settings.setItems(itemIds); + settings.setItemIds(itemIds); if(isWiredEffect) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index d650e391..e53b9da9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -23,6 +23,10 @@ public abstract class InteractionWiredEffect extends InteractionWired implements @Setter private List blockedTriggers; + @Getter + @Setter + private WiredEffectType type; + public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -54,8 +58,6 @@ public abstract class InteractionWiredEffect extends InteractionWired implements } } - public abstract WiredEffectType getType(); - public boolean requiresTriggeringUser() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index 72d5c7b3..7a9af300 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -2,10 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredTriggerInteraction; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; import gnu.trove.set.hash.THashSet; @@ -22,6 +20,10 @@ public abstract class InteractionWiredTrigger extends InteractionWired implement @Setter private List blockedEffects; + @Getter + @Setter + private WiredTriggerType type; + protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -53,8 +55,6 @@ public abstract class InteractionWiredTrigger extends InteractionWired implement } } - public abstract WiredTriggerType getType(); - public boolean isTriggeredByRoomUnit() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index 716afb67..a3c35255 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -1,13 +1,20 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import gnu.trove.map.hash.THashMap; +import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; +import java.util.ArrayList; +import java.util.List; + public class WiredSettings implements IWiredSettings { @Getter @Setter - private int[] integerParams; + private List integerParams; @Getter @Setter @@ -15,7 +22,7 @@ public class WiredSettings implements IWiredSettings { @Getter @Setter - private int[] items; + private List itemIds; @Getter @Setter private int delay; @@ -25,10 +32,27 @@ public class WiredSettings implements IWiredSettings { private int selectionType; public WiredSettings() { - this.items = new int[0]; - this.integerParams = new int[0]; + this.itemIds = new ArrayList<>(); + this.integerParams = new ArrayList<>(); this.stringParam = ""; this.delay = 0; this.selectionType = 0; } + + public THashSet getItems(Room room) { + THashSet items = new THashSet<>(); + + for(int itemId : this.itemIds) { + HabboItem item = room.getHabboItem(itemId); + + if(item == null || item.getRoomId() == 0) { + this.itemIds.remove(itemId); + continue; + } + + items.add(item); + } + + return items; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java deleted file mode 100644 index 81dd0284..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.wired; - -public interface WiredTriggerReset { - void resetTimer(); -} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index 73e1662b..5a6ef2ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -3,12 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; @@ -18,10 +15,8 @@ import java.sql.SQLException; * a given range. */ public class WiredConditionDateRangeActive extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.DATE_RANGE; - - private int startDate; // the start of the date range - private int endDate; // the end of the date range + public final int PARAM_START_DATE = 0; + public final int PARAM_END_DATE = 1; /** * Creates a new instance of this class. @@ -46,27 +41,6 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { super(id, userId, item, extradata, limitedStack, limitedSells); } - /** - * Returns the {@link WiredConditionType} of this object. - * @return the type of this wired condition - */ - @Override - public WiredConditionType getType() { - return type; - } - - /** - * Saves the given {@link WiredSettings} object to this wired condition. - * @return {@code true} if the settings were saved successfully, {@code false} otherwise - * */ - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 2) return false; - this.startDate = this.getWiredSettings().getIntegerParams()[0]; - this.endDate = this.getWiredSettings().getIntegerParams()[1]; - return true; - } - /** * Determines if the wired condition is met. * @param roomUnit the room unit that triggered the condition @@ -78,63 +52,19 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int time = Emulator.getIntUnixTimestamp(); - return this.startDate < time && this.endDate >= time; + + int startDate = this.getWiredSettings().getIntegerParams().get(PARAM_START_DATE); + int endDate = this.getWiredSettings().getIntegerParams().get(PARAM_END_DATE); + + return startDate < time && endDate >= time; } /** - * Gets the wired data for this wired condition in JSON format. - * @return the wired data in JSON format + * Returns the {@link WiredConditionType} of this object. + * @return the type of this wired condition */ @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.startDate, - this.endDate - )); - } - - /** - * Loads the wired data for this wired condition from a database. - * @param set the ResultSet object to get data from - * @param room the room that this wired condition is in - * @throws SQLException if an error occurs while getting data from the ResultSet object - */ - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.startDate = data.startDate; - this.endDate = data.endDate; - } else { - String[] data = wiredData.split("\t"); - - if (data.length == 2) { - try { - this.startDate = Integer.parseInt(data[0]); - this.endDate = Integer.parseInt(data[1]); - } catch (Exception ignored) { - } - } - } - } - - /** - * A nested class for storing the wired data for this wired condition in JSON format. - */ - static class JsonData { - int startDate; - int endDate; - - /** - * Creates a new instance of this class. - * @param startDate the start of the date range - * @param endDate the end of the date range - */ - public JsonData(int startDate, int endDate) { - this.startDate = startDate; - this.endDate = endDate; - } + public WiredConditionType getType() { + return WiredConditionType.DATE_RANGE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index f5cc38af..61297586 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -3,14 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -20,119 +18,41 @@ import java.util.List; import java.util.Objects; public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI; - - private boolean all; - private final THashSet items; + public final int PARAM_ALL_FURNI = 0; public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredConditionFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); - - if (this.items.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; - - if (this.all) { - return this.items.stream().allMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); - }); - } else { - return this.items.stream().anyMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); - }); } - } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, - this.items.stream().map(HabboItem::getId).toList() - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.all = data.all; - - data.itemIds.stream().mapToInt(id -> id).mapToObj(room::getHabboItem).filter(Objects::nonNull).forEach(this.items::add); + boolean allFurni = this.getWiredSettings().getIntegerParams().get(PARAM_ALL_FURNI) == 1; + if (allFurni) { + return this.getWiredSettings().getItems(room).stream().allMatch(item -> { + double minZ = item.getZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + }); } else { - String[] data = wiredData.split(":"); - - if (data.length >= 1) { - this.all = (data[0].equals("1")); - - if (data.length == 2) { - String[] itemsSplit = data[1].split(";"); - Arrays.stream(itemsSplit).map(s -> room.getHabboItem(Integer.parseInt(s))).filter(Objects::nonNull).forEach(this.items::add); - } - } + return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { + double minZ = item.getZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + }); } } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if (this.getWiredSettings().getIntegerParams().length < 1) return false; - - this.all = this.getWiredSettings().getIntegerParams()[0] == 1; - - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); - - if (item != null) - this.items.add(item); - } - - return true; - } - return false; - } - - private void refresh() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - this.items.removeIf(i -> room.getHabboItem(i.getId()) == null); - } - - static class JsonData { - boolean all; - List itemIds; - - public JsonData(boolean all, List itemIds) { - this.all = all; - this.itemIds = itemIds; - } + return WiredConditionType.FURNI_HAS_FURNI; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java index 9510f4eb..be5d9169 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -13,7 +12,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -23,31 +21,25 @@ import java.util.List; import java.util.stream.Collectors; public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; - protected THashSet items; - public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredConditionFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); - - if (this.items.isEmpty()) + if (this.getWiredSettings().getItemIds().isEmpty()) { return true; + } Collection habbos = room.getHabbos(); Collection bots = room.getCurrentBots().valueCollection(); Collection pets = room.getCurrentPets().valueCollection(); - return this.items.stream().allMatch(item -> { + return this.getWiredSettings().getItems(room).stream().allMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || @@ -55,98 +47,8 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { }); } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - - for(int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(":"); - - if (data.length >= 1) { - - String[] items = data[1].split(";"); - - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - int count = this.getWiredSettings().getItems().length; - - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); - - if (item != null) - this.items.add(item); - } - - return true; - } - - return false; - } - - private void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredConditionType.FURNI_HAVE_HABBO; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index 875ba6c3..ee9721db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java @@ -3,13 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -18,10 +16,6 @@ import java.util.List; import java.util.stream.Collectors; public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.STUFF_IS; - - private final THashSet items = new THashSet<>(); - public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -32,104 +26,23 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); + if(this.getWiredSettings().getItemIds().isEmpty()) { + return true; + } - if(items.isEmpty()) - return false; + if(stuff.length == 0) { + return true; + } - if (stuff != null) { - if (stuff.length >= 1) { - if (stuff[0] instanceof HabboItem triggeringItem) { - return this.items.stream().anyMatch(item -> item == triggeringItem); - } - } + if (stuff[0] instanceof HabboItem triggeringItem) { + return this.getWiredSettings().getItems(room).stream().anyMatch(item -> item == triggeringItem); } return false; } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - - for(int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(";"); - - for (String s : data) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) { - this.items.add(item); - } - } - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); - } - } - - return true; - } - - private void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredConditionType.STUFF_IS; } } 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 915ef653..af4e452f 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 @@ -13,8 +13,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionGroupMember extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP; - public WiredConditionGroupMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -25,26 +23,17 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (room.getGuildId() == 0) + if (room.getGuildId() == 0) { return false; + } Habbo habbo = room.getHabbo(roomUnit); return habbo != null && habbo.getHabboStats().hasGuild(room.getGuildId()); } - @Override - public String getWiredData() { - return ""; - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; + return WiredConditionType.ACTOR_IN_GROUP; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index 35e7df50..3ab4ca4a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -13,9 +13,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionHabboCount extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.USER_COUNT; - private int lowerLimit = 0; - private int upperLimit = 50; + public final int PARAM_LOWER_LIMIT = 0; + public final int PARAM_UPPER_LIMIT = 1; public WiredConditionHabboCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -27,56 +26,15 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - int count = room.getUserCount(); + int lowerLimit = this.getWiredSettings().getIntegerParams().get(PARAM_LOWER_LIMIT); + int upperLimit = this.getWiredSettings().getIntegerParams().get(PARAM_UPPER_LIMIT); + int userCount = room.getUserCount(); - return count >= this.lowerLimit && count <= this.upperLimit; + return userCount >= lowerLimit && userCount <= upperLimit; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.lowerLimit, - this.upperLimit - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.lowerLimit = data.lowerLimit; - this.upperLimit = data.upperLimit; - } else { - String[] data = wiredData.split(":"); - - this.lowerLimit = Integer.parseInt(data[0]); - this.upperLimit = Integer.parseInt(data[1]); - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 2) return false; - this.lowerLimit = this.getWiredSettings().getIntegerParams()[0]; - this.upperLimit = this.getWiredSettings().getIntegerParams()[1]; - - return true; - } - - static class JsonData { - int lowerLimit; - int upperLimit; - - public JsonData(int lowerLimit, int upperLimit) { - this.lowerLimit = lowerLimit; - this.upperLimit = upperLimit; - } + return WiredConditionType.USER_COUNT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 39a7ce72..84047e17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -13,9 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionHabboHasEffect extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_EFFECT; - - protected int effectId = 0; + public final int PARAM_EFFECT_ID = 0; public WiredConditionHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -27,47 +25,17 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) return false; - return roomUnit.getEffectId() == this.effectId; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.effectId - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.effectId = data.effectId; - } else { - this.effectId = Integer.parseInt(wiredData); + if (roomUnit == null) { + return false; } + + int effectId = this.getWiredSettings().getIntegerParams().get(PARAM_EFFECT_ID); + + return roomUnit.getEffectId() == effectId; } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.effectId = this.getWiredSettings().getIntegerParams()[0]; - - return true; - } - - static class JsonData { - int effectId; - - public JsonData(int effectId) { - this.effectId = effectId; - } + return WiredConditionType.ACTOR_WEARS_EFFECT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index f3e6698a..3270ce20 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -2,12 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; @@ -15,10 +12,7 @@ import java.sql.SQLException; @Slf4j public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { - - public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM; - - private int handItem; + public final int PARAM_HAND_ITEM_ID = 0; public WiredConditionHabboHasHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -28,53 +22,19 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.handItem = this.getWiredSettings().getIntegerParams()[0]; - - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) return false; - return roomUnit.getHandItem() == this.handItem; + if (roomUnit == null) { + return false; + } + + int handItemId = this.getWiredSettings().getIntegerParams().get(PARAM_HAND_ITEM_ID); + + return roomUnit.getHandItem() == handItemId; } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.handItem - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) { - try { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.handItem = data.handItemId; - } else { - this.handItem = Integer.parseInt(wiredData); - } - } catch (Exception e) { - log.error("Caught exception", e); - } - } - - static class JsonData { - int handItemId; - - public JsonData(int handItemId) { - this.handItemId = handItemId; - } + public WiredConditionType getType() { + return WiredConditionType.ACTOR_HAS_HANDITEM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java index e584e653..14035fa3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java @@ -15,10 +15,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_BADGE; - - protected String badge = ""; - public WiredConditionHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -29,56 +25,30 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return true; + } + + String badgeCode = this.getWiredSettings().getStringParam(); Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) { - synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) { - for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) { - if (badge.getCode().equalsIgnoreCase(this.badge)) { - return true; - } + if(habbo == null) { + return false; + } + + synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) { + for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) { + if (badge.getCode().equalsIgnoreCase(badgeCode)) { + return true; } } } + return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.badge - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.badge = data.badge; - } else { - this.badge = wiredData; - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - this.badge = this.getWiredSettings().getStringParam(); - - return true; - } - - static class JsonData { - String badge; - - public JsonData(String badge) { - this.badge = badge; - } + return WiredConditionType.ACTOR_WEARS_BADGE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index 3f526230..e5c71a6c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -14,9 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.TIME_LESS_THAN; - - private int cycles; + public final int PARAM_CYCLE = 0; public WiredConditionLessTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -28,49 +26,12 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < this.cycles; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.cycles - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - try { - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.cycles = data.cycles; - } else { - if (!wiredData.equals("")) - this.cycles = Integer.parseInt(wiredData); - } - } catch (Exception ignored) { - } + int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE); + return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < cycles; } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.cycles = this.getWiredSettings().getIntegerParams()[0]; - return true; - } - - static class JsonData { - int cycles; - - public JsonData(int cycles) { - this.cycles = cycles; - } + return WiredConditionType.TIME_LESS_THAN; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 684fd033..3592eceb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -3,201 +3,89 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; +import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { - public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT; - private final THashSet wiredMatchSettings; - private boolean state; - private boolean position; - private boolean direction; + public final int PARAM_STATE = 0; + public final int PARAM_ROTATION = 1; + public final int PARAM_POSITION = 2; + + @Getter + private THashSet matchFurniSettings; public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.wiredMatchSettings = new THashSet<>(); } public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.wiredMatchSettings = new THashSet<>(); } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 3) return false; - this.state = this.getWiredSettings().getIntegerParams()[0] == 1; - this.direction = this.getWiredSettings().getIntegerParams()[1] == 1; - this.position = this.getWiredSettings().getIntegerParams()[2] == 1; - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room == null) - return true; - - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.wiredMatchSettings.clear(); - - for (int i = 0; i < count; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem item = room.getHabboItem(itemId); - - if (item != null) - this.wiredMatchSettings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY())); - } - - return true; + return WiredConditionType.MATCH_SSHOT; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.wiredMatchSettings.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; - - THashSet s = new THashSet<>(); - - for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { - HabboItem item = room.getHabboItem(setting.getItem_id()); - - if (item != null) { - if (this.state) { - if (!item.getExtradata().equals(setting.getState())) - return false; - } - - if (this.position) { - if (!(setting.getX() == item.getX() && setting.getY() == item.getY())) - return false; - } - - if (this.direction) { - if (setting.getRotation() != item.getRotation()) - return false; - } - } else { - s.add(setting); - } } - if (!s.isEmpty()) { - for (WiredMatchFurniSetting setting : s) { - this.wiredMatchSettings.remove(setting); + boolean state = this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; + boolean position = this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; + boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; + + for(HabboItem item : this.getWiredSettings().getItems(room)) { + WiredMatchFurniSetting setting = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + + this.matchFurniSettings.add(setting); + + if(state) { + if(!item.getExtradata().equals(setting.getState())) { + return false; + } + } + + if(position) { + if (!(setting.getX() == item.getX() && setting.getY() == item.getY())) { + return false; + } + } + + if(rotation) { + if (setting.getRotation() != item.getRotation()) { + return false; + } } } return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.state, - this.position, - this.direction, - new ArrayList<>(this.wiredMatchSettings) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.state = data.state; - this.position = data.position; - this.direction = data.direction; - this.wiredMatchSettings.addAll(data.settings); - } else { - String[] data = wiredData.split(":"); - - int itemCount = Integer.parseInt(data[0]); - - String[] items = data[1].split(";"); - - for (int i = 0; i < itemCount; i++) { - String[] stuff = items[i].split("-"); - - if (stuff.length >= 5) - this.wiredMatchSettings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); - } - - this.state = data[2].equals("1"); - this.direction = data[3].equals("1"); - this.position = data[4].equals("1"); - } - } - - private void refresh() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - THashSet remove = new THashSet<>(); - - for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { - HabboItem item = room.getHabboItem(setting.getItem_id()); - if (item == null) { - remove.add(setting); - } - } - - for (WiredMatchFurniSetting setting : remove) { - this.wiredMatchSettings.remove(setting); - } - } - } - - @Override - public THashSet getMatchFurniSettings() { - return this.wiredMatchSettings; - } - @Override public boolean shouldMatchState() { - return this.state; + return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; } @Override public boolean shouldMatchRotation() { - return this.direction; + return this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; } @Override public boolean shouldMatchPosition() { - return this.position; - } - - static class JsonData { - boolean state; - boolean position; - boolean direction; - List settings; - - public JsonData(boolean state, boolean position, boolean direction, List settings) { - this.state = state; - this.position = position; - this.direction = direction; - this.settings = settings; - } + return this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index 8397f74a..289c8faf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -13,11 +13,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { - private static final WiredConditionType type = WiredConditionType.TIME_MORE_THAN; private static final int PARAM_CYCLE = 0; - private int cycles; - public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -28,48 +25,11 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > this.cycles; + int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE); + return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > cycles; } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.cycles - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - try { - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.cycles = data.cycles; - } else { - if (!wiredData.equals("")) - this.cycles = Integer.parseInt(wiredData); - } - } catch (Exception ignored) { - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - this.cycles = this.getWiredSettings().getIntegerParams()[PARAM_CYCLE]; - return true; - } - - static class JsonData { - int cycles; - - public JsonData(int cycles) { - this.cycles = cycles; - } + return WiredConditionType.TIME_MORE_THAN; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 3fb23eec..6f5481e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -11,7 +10,6 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -20,37 +18,33 @@ import java.util.List; import java.util.stream.Collectors; public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI; - - private boolean all; - private final THashSet items; + public final int PARAM_ALL_FURNI = 0; public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredConditionNotFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); - - if (this.items.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; + } - if(this.all) { - return this.items.stream().allMatch(item -> { + boolean allFurni = this.getWiredSettings().getIntegerParams().get(PARAM_ALL_FURNI) == 1; + + if(allFurni) { + return this.getWiredSettings().getItems(room).stream().allMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); }); } else { - return this.items.stream().anyMatch(item -> { + return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); @@ -58,97 +52,9 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.all = data.all; - - for (int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(":"); - - if (data.length >= 1) { - this.all = (data[0].equals("1")); - - if (data.length == 2) { - String[] items = data[1].split(";"); - - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.all = this.getWiredSettings().getIntegerParams()[0] == 1; - - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); - - if (item != null) - this.items.add(item); - } - - return true; - } - return false; - } - - private void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } + return WiredConditionType.NOT_FURNI_HAVE_FURNI; } @Override @@ -157,14 +63,4 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { //return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR; return WiredConditionOperator.AND; } - - static class JsonData { - boolean all; - List itemIds; - - public JsonData(boolean all, List itemIds) { - this.all = all; - this.itemIds = itemIds; - } - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java index 682dfaff..912c1d71 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -13,7 +12,6 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -23,32 +21,25 @@ import java.util.List; import java.util.stream.Collectors; public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; - - protected THashSet items; - public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); - - if (this.items.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; + } Collection habbos = room.getHabbos(); Collection bots = room.getCurrentBots().valueCollection(); Collection pets = room.getCurrentPets().valueCollection(); - return this.items.stream().noneMatch(item -> { + return this.getWiredSettings().getItems(room).stream().noneMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || @@ -56,96 +47,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { }); } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class); - - for(int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(":"); - - if (data.length >= 1) { - String[] items = data[1].split(";"); - - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); - - if (item != null) - this.items.add(item); - } - - return true; - } - - return false; - } - - private void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredConditionType.NOT_FURNI_HAVE_HABBO; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index 660ac80c..c5252b66 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java @@ -3,13 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -31,104 +29,23 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.refresh(); - - if(items.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; - - if (stuff != null) { - if (stuff.length >= 1) { - if (stuff[0] instanceof HabboItem triggeringItem) { - return this.items.stream().noneMatch(item -> item == triggeringItem); - } - } } - return true; - } - - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class); - - for(int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = set.getString("wired_data").split(";"); - - for (String s : data) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) { - this.items.add(item); - } - } + if(stuff.length == 0) { + return true; } + + if (stuff[0] instanceof HabboItem triggeringItem) { + return this.getWiredSettings().getItems(room).stream().noneMatch(item -> item == triggeringItem); + } + + return false; } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); - } - } - - return true; - } - - private void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (room.getHabboItem(item.getId()) == null) - items.add(item); - } - } - - for (HabboItem item : items) { - this.items.remove(item); - } - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredConditionType.NOT_STUFF_IS; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java index 2a99324d..134623ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java @@ -12,12 +12,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboCount extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.NOT_USER_COUNT; - - private int lowerLimit = 10; - private int upperLimit = 20; - +public class WiredConditionNotHabboCount extends WiredConditionHabboCount { public WiredConditionNotHabboCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -28,55 +23,11 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - int count = room.getUserCount(); - - return count < this.lowerLimit || count > this.upperLimit; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.lowerLimit, - this.upperLimit - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class); - this.lowerLimit = data.lowerLimit; - this.upperLimit = data.upperLimit; - } else { - String[] data = wiredData.split(":"); - this.lowerLimit = Integer.parseInt(data[0]); - this.upperLimit = Integer.parseInt(data[1]); - } + return !super.execute(roomUnit, room, stuff); } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 2) return false; - this.lowerLimit = this.getWiredSettings().getIntegerParams()[0]; - this.upperLimit = this.getWiredSettings().getIntegerParams()[1]; - - return true; - } - - static class JsonData { - int lowerLimit; - int upperLimit; - - public JsonData(int lowerLimit, int upperLimit) { - this.lowerLimit = lowerLimit; - this.upperLimit = upperLimit; - } + return WiredConditionType.NOT_USER_COUNT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java index 7e82d619..5f77d51d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java @@ -12,11 +12,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { - private static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_EFFECT; - - protected int effectId; - +public class WiredConditionNotHabboHasEffect extends WiredConditionHabboHasEffect { public WiredConditionNotHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -27,47 +23,11 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) return false; - return roomUnit.getEffectId() != this.effectId; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.effectId - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.effectId = data.effectId; - } else { - this.effectId = Integer.parseInt(wiredData); - } + return !super.execute(roomUnit, room, stuff); } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.effectId = this.getWiredSettings().getIntegerParams()[0]; - - return true; - } - - static class JsonData { - int effectId; - - public JsonData(int effectId) { - this.effectId = effectId; - } + return WiredConditionType.NOT_ACTOR_WEARS_EFFECT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java index fc644d05..7d02d83c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java @@ -1,20 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition { +public class WiredConditionNotHabboWearsBadge extends WiredConditionHabboWearsBadge { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_BADGE; protected String badge = ""; @@ -29,57 +23,11 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Habbo habbo = room.getHabbo(roomUnit); - - if (habbo != null) { - synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) { - for (HabboBadge b : habbo.getInventory().getBadgesComponent().getWearingBadges()) { - if (b.getCode().equalsIgnoreCase(this.badge)) - return false; - } - } - return true; - } - - return true; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.badge - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.badge = data.badge; - } else { - this.badge = wiredData; - } + return !super.execute(roomUnit, room, stuff); } @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - this.badge = this.getWiredSettings().getStringParam(); - - return true; - } - - static class JsonData { - String badge; - - public JsonData(String badge) { - this.badge = badge; - } + return WiredConditionType.NOT_ACTOR_WEARS_BADGE; } } 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 9c1b7fdb..c9f6e0c3 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 @@ -13,8 +13,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionNotInGroup extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP; - public WiredConditionNotInGroup(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -33,21 +31,8 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { return habbo == null || !habbo.getHabboStats().hasGuild(room.getGuildId()); } - @Override - public String getWiredData() { - return ""; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) {} - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; + return WiredConditionType.NOT_ACTOR_IN_GROUP; } } 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 e139ebd6..e5b7130c 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 @@ -15,9 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionNotInTeam extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_TEAM; - - private GameTeamColors teamColor = GameTeamColors.RED; + public final int PARAM_TEAM = 0; public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -29,57 +27,25 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM); + + if(teamValue < 1 || teamValue > 4) { + return false; + } + + GameTeamColors teamColor = GameTeamColors.values()[teamValue]; + Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); // user is not part of any team + return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor); } return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.teamColor - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) { - try { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.teamColor = data.teamColor; - } else { - if (!wiredData.equals("")) - this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)]; - } - } catch (Exception e) { - this.teamColor = GameTeamColors.RED; - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.teamColor = GameTeamColors.values()[this.getWiredSettings().getIntegerParams()[0]]; - - return true; - } - - static class JsonData { - GameTeamColors teamColor; - - public JsonData(GameTeamColors teamColor) { - this.teamColor = teamColor; - } + return WiredConditionType.NOT_ACTOR_IN_TEAM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java index d6b11988..1586a471 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java @@ -9,8 +9,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStatePosition { - public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT; - public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -26,6 +24,6 @@ public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStat @Override public WiredConditionType getType() { - return type; + return WiredConditionType.NOT_MATCH_SSHOT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java index 21ea027e..c00d00c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java @@ -21,15 +21,7 @@ public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurn @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) - return false; - - this.refresh(); - - if (this.items.isEmpty()) - return true; - - return !triggerOnFurni(roomUnit, room); + return !super.execute(roomUnit, room, stuff); } @Override 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 7e1b29f3..db2c0aab 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 @@ -15,9 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionTeamMember extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.ACTOR_IN_TEAM; - - private GameTeamColors teamColor = GameTeamColors.RED; + public final int PARAM_TEAM = 0; public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -29,58 +27,27 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM); + + if(teamValue < 1 || teamValue > 4) { + return false; + } + + GameTeamColors teamColor = GameTeamColors.values()[teamValue]; + Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { if (habbo.getHabboInfo().getGamePlayer() != null) { - return habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); + return habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor); } } return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.teamColor - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) { - try { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.teamColor = data.teamColor; - } else { - if (!wiredData.equals("")) - this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)]; - } - } catch (Exception e) { - this.teamColor = GameTeamColors.RED; - } - } - @Override public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.teamColor = GameTeamColors.values()[this.getWiredSettings().getIntegerParams()[0]]; - return true; - } - - static class JsonData { - GameTeamColors teamColor; - - public JsonData(GameTeamColors teamColor) { - this.teamColor = teamColor; - } + return WiredConditionType.ACTOR_IN_TEAM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index 50dbbc3d..802325e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -3,14 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -19,10 +17,6 @@ import java.util.List; import java.util.stream.Collectors; public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { - public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI; - - protected THashSet items = new THashSet<>(); - public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -33,99 +27,16 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) + if(this.getWiredSettings().getItemIds().isEmpty()) { + return true; + } + + if(roomUnit == null) { return false; + } - this.refresh(); - - if (this.items.isEmpty()) - return false; - - return triggerOnFurni(roomUnit, room); - } - - protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) { THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); - return this.items.stream().anyMatch(itemsAtUser::contains); - } - - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - - for(int id : data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(";"); - - for (String s : data) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) { - this.items.add(item); - } - } - } - } - - @Override - public WiredConditionType getType() { - return type; - } - - @Override - public boolean saveData() { - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; - - this.items.clear(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(this.getWiredSettings().getItems()[i]); - - if (item != null) { - this.items.add(item); - } - } - } - - return true; - } - - protected void refresh() { - THashSet items = new THashSet<>(); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) { - items.addAll(this.items); - } else { - for (HabboItem item : this.items) { - if (item.getRoomId() != room.getId()) - items.add(item); - } - } - - this.items.removeAll(items); + return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains); } @Override @@ -133,11 +44,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { return WiredConditionOperator.AND; } - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + @Override + public WiredConditionType getType() { + return WiredConditionType.TRIGGER_ON_FURNI; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index 28840faf..2eceb51b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -19,11 +19,6 @@ import java.util.List; import java.util.regex.Pattern; public class WiredEffectBotClothes extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_CLOTHES; - - private String botName = ""; - private String botLook = ""; - public WiredEffectBotClothes(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -33,83 +28,26 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { } @Override - public boolean saveData() throws WiredSaveException { - String dataString = this.getWiredSettings().getStringParam(); - int delay = this.getWiredSettings().getDelay(); + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + String[] stringParams = this.getWiredSettings().getStringParam().split("\t"); - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); + String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); + String botLook = stringParams[1]; - String splitBy = "\t"; - if(!dataString.contains(splitBy)) - throw new WiredSaveException("Malformed data string"); + List bots = room.getBots(botName); - String[] data = dataString.split(Pattern.quote(splitBy)); + if(bots.size() == 0) { + return false; + } - if (data.length != 2) - throw new WiredSaveException("Malformed data string. Invalid data length"); - - this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.botLook = data[1]; - this.getWiredSettings().setDelay(delay); + Bot bot = bots.get(0); + bot.setFigure(botLook); return true; } @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - List bots = room.getBots(this.botName); - - if (bots.size() == 1) { - Bot bot = bots.get(0); - bot.setFigure(this.botLook); - } - - return true; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.botName = data.bot_name; - this.botLook = data.look; - } - else { - String[] data = wiredData.split(((char) 9) + ""); - - if (data.length >= 3) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.botName = data[1]; - this.botLook = data[2]; - } - - this.needsUpdate(true); - } - } - - static class JsonData { - String bot_name; - String look; - int delay; - - public JsonData(String bot_name, String look, int delay) { - this.bot_name = bot_name; - this.look = look; - this.delay = delay; - } + return WiredEffectType.BOT_CLOTHES; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index e2b7a583..906ace42 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -20,10 +20,7 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_FOLLOW_AVATAR; - - private String botName = ""; - private int mode = 0; + public final int PARAM_MODE = 0; public WiredEffectBotFollowHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -33,45 +30,15 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Mode is invalid"); - - int mode = this.getWiredSettings().getIntegerParams()[0]; - - if(mode != 0 && mode != 1) - throw new WiredSaveException("Mode is invalid"); - - String botName = this.getWiredSettings().getStringParam().replace("\t", ""); - botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.botName = botName; - this.mode = mode; - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - - List bots = room.getBots(this.botName); + List bots = room.getBots(this.getWiredSettings().getStringParam()); if (habbo != null && bots.size() == 1) { Bot bot = bots.get(0); - if (this.mode == 1) { + if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) { bot.startFollowingHabbo(habbo); } else { bot.stopFollowingHabbo(); @@ -84,47 +51,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.mode = data.mode; - this.botName = data.bot_name; - } - else { - String[] data = wiredData.split(((char) 9) + ""); - - if (data.length == 3) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0); - this.botName = data[2]; - } - - this.needsUpdate(true); - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - String bot_name; - int mode; - int delay; - - public JsonData(String bot_name, int mode, int delay) { - this.bot_name = bot_name; - this.mode = mode; - this.delay = delay; - } + public WiredEffectType getType() { + return WiredEffectType.BOT_FOLLOW_AVATAR; } } 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 72df62a5..aaff903f 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 @@ -24,11 +24,7 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_GIVE_HANDITEM; - - private String botName = ""; - private int itemId; - + public final int PARAM_ITEM_ID = 0; public WiredEffectBotGiveHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -37,44 +33,17 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Missing item id"); - - int itemId = this.getWiredSettings().getIntegerParams()[0]; - - if(itemId < 0) - itemId = 0; - - String botName = this.getWiredSettings().getStringParam(); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.itemId = itemId; - this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - List bots = room.getBots(this.botName); + List bots = room.getBots(this.getWiredSettings().getStringParam()); + int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID); if (habbo != null && bots.size() == 1) { Bot bot = bots.get(0); List tasks = new ArrayList<>(); - tasks.add(new RoomUnitGiveHanditem(roomUnit, room, this.itemId)); + tasks.add(new RoomUnitGiveHanditem(roomUnit, room, itemId)); tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0)); tasks.add(() -> { if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) { @@ -88,7 +57,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { bot.getRoomUnit().setGoalLocation(tile); } - Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId)); + Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, itemId)); Emulator.getThreading().run(new RoomUnitWalkToLocation(bot.getRoomUnit(), tile, room, tasks, tasks)); return true; @@ -98,47 +67,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.itemId = data.item_id; - this.botName = data.bot_name; - } - else { - String[] data = wiredData.split(((char) 9) + ""); - - if (data.length == 3) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.itemId = Integer.parseInt(data[1]); - this.botName = data[2]; - } - - this.needsUpdate(true); - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - String bot_name; - int item_id; - int delay; - - public JsonData(String bot_name, int item_id, int delay) { - this.bot_name = bot_name; - this.item_id = item_id; - this.delay = delay; - } + public WiredEffectType getType() { + return WiredEffectType.BOT_GIVE_HANDITEM; } } 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 394291e3..9dff1030 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 @@ -21,11 +21,7 @@ import java.util.List; import java.util.regex.Pattern; public class WiredEffectBotTalk extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_TALK; - - private int mode; - private String botName = ""; - private String message = ""; + public final int PARAM_MODE = 0; public WiredEffectBotTalk(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -35,46 +31,12 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Mode is invalid"); - int mode = this.getWiredSettings().getIntegerParams()[0]; - - if(mode != 0 && mode != 1) - throw new WiredSaveException("Mode is invalid"); - - String dataString = this.getWiredSettings().getStringParam(); - - String splitBy = "\t"; - if(!dataString.contains(splitBy)) - throw new WiredSaveException("Malformed data string"); - - String[] data = dataString.split(Pattern.quote(splitBy)); - - if (data.length != 2) - throw new WiredSaveException("Malformed data string. Invalid data length"); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.getWiredSettings().setDelay(delay); - this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.mode = mode; - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - String message = this.message; + String[] stringParams = this.getWiredSettings().getStringParam().split("\t"); + + 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); @@ -85,18 +47,18 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName()) .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") - .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName) + .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + ""); } - List bots = room.getBots(this.botName); + List bots = room.getBots(botName); if (bots.size() == 1) { Bot bot = bots.get(0); if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) { - if (this.mode == 1) { + if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) { bot.shout(message); } else { bot.talk(message); @@ -108,51 +70,12 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.mode = data.mode; - this.botName = data.bot_name; - this.message = data.message; - } - else { - String[] data = wiredData.split(((char) 9) + ""); - - if (data.length == 4) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; - this.botName = data[2]; - this.message = data[3]; - } - - this.needsUpdate(true); - } + public WiredEffectType getType() { + return WiredEffectType.BOT_TALK; } @Override protected long requiredCooldown() { return 500; } - - static class JsonData { - String bot_name; - int mode; - String message; - int delay; - - public JsonData(String bot_name, int mode, String message, int delay) { - this.bot_name = bot_name; - this.mode = mode; - this.message = message; - this.delay = delay; - } - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index ccbbe0da..a772444a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -22,11 +22,7 @@ import java.util.List; import java.util.regex.Pattern; public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_TALK_TO_AVATAR; - - private int mode; - private String botName = ""; - private String message = ""; + public final int PARAM_MODE = 0; public WiredEffectBotTalkToHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -36,59 +32,27 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("Missing mode"); - int mode = this.getWiredSettings().getIntegerParams()[0]; - - if(mode != 0 && mode != 1) - throw new WiredSaveException("Mode is invalid"); - - String dataString = this.getWiredSettings().getStringParam(); - String splitBy = "\t"; - if(!dataString.contains(splitBy)) - throw new WiredSaveException("Malformed data string"); - - String[] data = dataString.split(Pattern.quote(splitBy)); - - if (data.length != 2) - throw new WiredSaveException("Malformed data string. Invalid data length"); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.mode = mode; - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + String[] stringParams = this.getWiredSettings().getStringParam().split("\t"); + + 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); if (habbo != null) { - String m = this.message; - m = m.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername()) + message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "") .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "") .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName()) .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") - .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName) + .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + ""); - List bots = room.getBots(this.botName); + List bots = room.getBots(botName); if (bots.size() != 1) { return false; @@ -96,11 +60,11 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { Bot bot = bots.get(0); - if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ m })) { - if (this.mode == 1) { - bot.whisper(m, habbo); + if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) { + if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) { + bot.whisper(message, habbo); } else { - bot.talk(habbo.getHabboInfo().getUsername() + ": " + m); + bot.talk(habbo.getHabboInfo().getUsername() + ": " + message); } } @@ -111,51 +75,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.mode = data.mode; - this.botName = data.bot_name; - this.message = data.message; - } - else { - String[] data = wiredData.split(((char) 9) + ""); - - if (data.length == 4) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0; - this.botName = data[2]; - this.message = data[3]; - } - - this.needsUpdate(true); - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - String bot_name; - int mode; - String message; - int delay; - - public JsonData(String bot_name, int mode, String message, int delay) { - this.bot_name = bot_name; - this.mode = mode; - this.message = message; - this.delay = delay; - } + public WiredEffectType getType() { + return WiredEffectType.BOT_TALK_TO_AVATAR; } } 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 c6102396..2b0f48f9 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 @@ -19,24 +19,48 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; public class WiredEffectBotTeleport extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_TELEPORT; - - private THashSet items; - private String botName = ""; - public WiredEffectBotTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredEffectBotTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); + } + + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } + + String botName = this.getWiredSettings().getStringParam(); + List bots = room.getBots(botName); + + if (bots.size() == 0) { + return false; + } + + Bot bot = bots.get(0); + + int i = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()) + 1; + int j = 1; + + for (HabboItem item : this.getWiredSettings().getItems(room)) { + if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) { + if (i == j) { + teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY())); + return true; + } else { + j++; + } + } + } + + return true; } public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { @@ -80,140 +104,8 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); } - @Override - public boolean saveData() throws WiredSaveException { - String botName = this.getWiredSettings().getStringParam(); - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.getWiredSettings().setDelay(delay); - - return true; - } - @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.items.isEmpty()) - return false; - - List bots = room.getBots(this.botName); - - if (bots.size() != 1) { - return false; - } - - Bot bot = bots.get(0); - - int i = Emulator.getRandom().nextInt(this.items.size()) + 1; - int j = 1; - - for (HabboItem item : this.items) { - if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) { - if (i == j) { - teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY())); - return true; - } else { - j++; - } - } - } - - return true; - } - - @Override - public String getWiredData() { - ArrayList itemIds = new ArrayList<>(); - - if (this.items != null) { - for (HabboItem item : this.items) { - if (item.getRoomId() != 0) { - itemIds.add(item.getId()); - } - } - } - - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); - - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.botName = data.bot_name; - - for(int itemId : data.items) { - HabboItem item = room.getHabboItem(itemId); - - if (item != null) - this.items.add(item); - } - } - else { - String[] wiredDataSplit = set.getString("wired_data").split("\t"); - - if (wiredDataSplit.length >= 2) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataSplit[0])); - String[] data = wiredDataSplit[1].split(";"); - - if (data.length > 1) { - this.botName = data[0]; - - for (int i = 1; i < data.length; i++) { - HabboItem item = room.getHabboItem(Integer.parseInt(data[i])); - - if (item != null) - this.items.add(item); - } - } - } - - this.needsUpdate(true); - } - } - - static class JsonData { - String bot_name; - List items; - int delay; - - public JsonData(String bot_name, List items, int delay) { - this.bot_name = bot_name; - this.items = items; - this.delay = delay; - } + return WiredEffectType.BOT_TELEPORT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index e13566cc..f0905b3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -2,18 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; @@ -22,73 +18,32 @@ import java.util.List; import java.util.stream.Collectors; public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.BOT_MOVE; - - private List items; - private String botName = ""; - public WiredEffectBotWalkToFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new ArrayList<>(); } public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new ArrayList<>(); - } - - @Override - public boolean saveData() throws WiredSaveException { - String botName = this.getWiredSettings().getStringParam(); - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - List bots = room.getBots(this.botName); + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } - if (this.items.isEmpty() || bots.size() != 1) { - return true; + String botName = this.getWiredSettings().getStringParam(); + List bots = room.getBots(botName); + + if (bots.size() == 0) { + return false; } Bot bot = bots.get(0); - this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); + this.getWiredSettings().getItems(room).removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); // Bots shouldn't walk to the tile they are already standing on - List possibleItems = this.items.stream() + List possibleItems = this.getWiredSettings().getItems(room).stream() .filter(item -> !room.getBotsOnItem(item).contains(bot)) .collect(Collectors.toList()); @@ -105,70 +60,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } @Override - public String getWiredData() { - ArrayList itemIds = new ArrayList<>(); - - if (this.items != null) { - for (HabboItem item : this.items) { - if (item.getRoomId() != 0) { - itemIds.add(item.getId()); - } - } - } - - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new ArrayList<>(); - - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.botName = data.bot_name; - - for(int itemId : data.items) { - HabboItem item = room.getHabboItem(itemId); - - if (item != null) - this.items.add(item); - } - } - else { - String[] wiredDataSplit = set.getString("wired_data").split("\t"); - - if (wiredDataSplit.length >= 2) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataSplit[0])); - String[] data = wiredDataSplit[1].split(";"); - - if (data.length > 1) { - this.botName = data[0]; - - for (int i = 1; i < data.length; i++) { - HabboItem item = room.getHabboItem(Integer.parseInt(data[i])); - - if (item != null) - this.items.add(item); - } - } - } - - this.needsUpdate(true); - } - } - - static class JsonData { - String bot_name; - List items; - int delay; - - public JsonData(String bot_name, List items, int delay) { - this.bot_name = bot_name; - this.items = items; - this.delay = delay; - } + public WiredEffectType getType() { + return WiredEffectType.BOT_MOVE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index f28743fb..baa91bfa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -1,17 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.map.hash.THashMap; @@ -19,11 +16,11 @@ import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; import java.util.Map; public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { + public final int PARAM_START_ROTATION = 0; + public final int PARAM_BLOCKED_ACTION = 1; public static final int ACTION_WAIT = 0; public static final int ACTION_TURN_RIGHT_45 = 1; public static final int ACTION_TURN_RIGHT_90 = 2; @@ -32,12 +29,6 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { public static final int ACTION_TURN_BACK = 5; public static final int ACTION_TURN_RANDOM = 6; - public static final WiredEffectType type = WiredEffectType.MOVE_DIRECTION; - - private final THashMap items = new THashMap<>(0); - private RoomUserRotation startRotation = RoomUserRotation.NORTH; - private int blockedAction = 0; - public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -48,67 +39,67 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items.keySet()) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; } - for (HabboItem item : items) { - this.items.remove(item); + int startRotationValue = this.getWiredSettings().getIntegerParams().get(PARAM_START_ROTATION); + int blockActionValue = this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION); + + if(startRotationValue < 0 || startRotationValue > 7 || (startRotationValue % 2) != 0) { + return false; } - if (this.items.isEmpty()) return false; + if(blockActionValue < 0 || blockActionValue > 6) { + return false; + } - for (Map.Entry entry : this.items.entrySet()) { - HabboItem item = entry.getKey(); - RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue()); + RoomUserRotation startRotation = RoomUserRotation.fromValue(startRotationValue); + for(HabboItem item : this.getWiredSettings().getItems(room)) { + WiredChangeDirectionSetting setting = new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startRotation); + RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); int count = 1; while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { - entry.getValue().setDirection(this.nextRotation(entry.getValue().getDirection())); + setting.setDirection(this.nextRotation(setting.getDirection())); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue()); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); if (tile != null && tile.getState() != RoomTileState.INVALID) { targetTile = tile; } count++; } - } - for (Map.Entry entry : this.items.entrySet()) { - HabboItem item = entry.getKey(); - int newDirection = entry.getValue().getDirection().getValue(); + int newDirectionValue = setting.getDirection().getValue(); - RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirection); + RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirectionValue); - if(item.getRotation() != entry.getValue().getRotation()) { - if(room.furnitureFitsAt(targetTile, item, entry.getValue().getRotation(), false) != FurnitureMovementError.NONE) + if(item.getRotation() != setting.getRotation()) { + if(room.furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE) continue; - room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().getRotation(), null, true); + room.moveFurniTo(item, newTargetTile, setting.getRotation(), null, true); } boolean hasRoomUnits = false; - THashSet newOccupiedTiles = room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + THashSet newOccupiedTiles = room.getLayout().getTilesAt(newTargetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); for(RoomTile tile : newOccupiedTiles) { for (RoomUnit _roomUnit : room.getRoomUnits(tile)) { hasRoomUnits = true; - if(_roomUnit.getCurrentLocation() == targetTile) { - Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{entry.getKey()})); + if(_roomUnit.getCurrentLocation() == newTargetTile) { + Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{item})); break; } } } - if (targetTile != null && targetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { + if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { if (!hasRoomUnits) { - RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()); - double oldZ = entry.getKey().getZ(); - if(room.moveFurniTo(entry.getKey(), targetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) { - room.sendComposer(new FloorItemOnRollerComposer(entry.getKey(), null, oldLocation, oldZ, targetTile, entry.getKey().getZ(), 0, room).compose()); + RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); + double oldZ = item.getZ(); + if(room.moveFurniTo(item, newTargetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) { + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getZ(), 0, room).compose()); } } } @@ -117,129 +108,11 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - ArrayList settings = new ArrayList<>(this.items.values()); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - - this.items.clear(); - - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.startRotation = data.start_direction; - this.blockedAction = data.blocked_action; - - for(WiredChangeDirectionSetting setting : data.items) { - HabboItem item = room.getHabboItem(setting.getItem_id()); - - if (item != null) { - this.items.put(item, setting); - } - } - } - else { - String[] data = wiredData.split("\t"); - - if (data.length >= 4) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.startRotation = RoomUserRotation.fromValue(Integer.parseInt(data[1])); - this.blockedAction = Integer.parseInt(data[2]); - - int itemCount = Integer.parseInt(data[3]); - - if (itemCount > 0) { - for (int i = 4; i < data.length; i++) { - String[] subData = data[i].split(":"); - - if (subData.length >= 2) { - HabboItem item = room.getHabboItem(Integer.parseInt(subData[0])); - - if (item != null) { - int rotation = item.getRotation(); - - if (subData.length > 2) { - rotation = Integer.parseInt(subData[2]); - } - - this.items.put(item, new WiredChangeDirectionSetting(item.getId(), rotation, RoomUserRotation.fromValue(Integer.parseInt(subData[1])))); - } - } - } - } - } - - this.needsUpdate(true); - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("Invalid data"); - - int startDirectionInt = this.getWiredSettings().getIntegerParams()[0]; - - if(startDirectionInt < 0 || startDirectionInt > 7 || (startDirectionInt % 2) != 0) { - throw new WiredSaveException("Start direction is invalid"); - } - - RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionInt); - - int blockedActionInt = this.getWiredSettings().getIntegerParams()[1]; - - if(blockedActionInt < 0 || blockedActionInt > 6) { - throw new WiredSaveException("Blocked action is invalid"); - } - - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - THashMap newItems = new THashMap<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.put(it, new WiredChangeDirectionSetting(it.getId(), it.getRotation(), startDirection)); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.putAll(newItems); - this.startRotation = startDirection; - this.blockedAction = blockedActionInt; - this.getWiredSettings().setDelay(delay); - - return true; - } - private RoomUserRotation nextRotation(RoomUserRotation currentRotation) { - return switch (this.blockedAction) { + return switch (this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION)) { case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite(); case ACTION_TURN_LEFT_45 -> RoomUserRotation.counterClockwise(currentRotation); - case ACTION_TURN_LEFT_90 -> - RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentRotation)); + case ACTION_TURN_LEFT_90 -> RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentRotation)); case ACTION_TURN_RIGHT_45 -> RoomUserRotation.clockwise(currentRotation); case ACTION_TURN_RIGHT_90 -> RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentRotation)); case ACTION_TURN_RANDOM -> RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)); @@ -253,17 +126,8 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return 495; } - static class JsonData { - RoomUserRotation start_direction; - int blocked_action; - List items; - int delay; - - public JsonData(RoomUserRotation start_direction, int blocked_action, List items, int delay) { - this.start_direction = start_direction; - this.blocked_action = blocked_action; - this.items = items; - this.delay = delay; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.MOVE_DIRECTION; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index f13df167..d07674f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -18,6 +18,10 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + int effectId; try { 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 7df4e147..1bc19834 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 @@ -19,6 +19,10 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + try { int itemId = Integer.parseInt(this.getWiredSettings().getStringParam()); 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 01d55a9f..8498349e 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 @@ -18,11 +18,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; - - private int amount = 0; - +public class WiredEffectGiveHotelviewBonusRarePoints extends WiredEffectWhisper { public WiredEffectGiveHotelviewBonusRarePoints(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -32,76 +28,30 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public boolean saveData() { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + + int amount; + try { - this.amount = Integer.parseInt(this.getWiredSettings().getStringParam()); + amount = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo == null) + if (habbo == null) { return false; + } - if (this.amount > 0) { - habbo.givePoints(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount); + if (amount > 0) { + habbo.givePoints(Emulator.getConfig().getInt("hotelview.promotional.points.type"), amount); habbo.getClient().sendResponse(new BonusRareInfoMessageComposer(habbo)); } return true; } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getWiredSettings().getDelay(), this.amount)); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - this.amount = 0; - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.amount = data.amount; - } else { - if (wiredData.split("\t").length >= 2) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split("\t")[0])); - - try { - this.amount = Integer.parseInt(wiredData.split("\t")[1]); - } catch (Exception ignored) { - } - } - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - int delay; - int amount; - - public JsonData(int delay, int amount) { - this.delay = delay; - this.amount = amount; - } - } } 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 69cba25f..514a45ef 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 @@ -18,10 +18,6 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; - - private int amount = 0; - public WiredEffectGiveHotelviewHofPoints(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -31,32 +27,27 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } @Override - public boolean saveData() { + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + + int amount; + try { - this.amount = Integer.parseInt(this.getWiredSettings().getStringParam()); + amount = Integer.parseInt(this.getWiredSettings().getStringParam()); } catch (Exception e) { return false; } - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - if (habbo == null) + if (habbo == null) { return false; + } - if (this.amount > 0) { - habbo.getHabboStats().hofPoints += this.amount; + if (amount > 0) { + habbo.getHabboStats().hofPoints += amount; Emulator.getThreading().run(habbo.getHabboStats()); } @@ -64,47 +55,7 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.amount, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.amount = data.amount; - this.getWiredSettings().setDelay(data.delay); - } - else { - this.amount = 0; - - if (wiredData.split("\t").length >= 2) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split("\t")[0])); - - try { - this.amount = Integer.parseInt(this.getWiredData().split("\t")[1]); - } catch (Exception ignored) { - } - } - - this.needsUpdate(true); - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - int amount; - int delay; - - public JsonData(int amount, int delay) { - this.amount = amount; - this.delay = delay; - } + public WiredEffectType getType() { + return WiredEffectType.SHOW_MESSAGE; } } 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 c4796d6a..5623dfa1 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 @@ -19,10 +19,6 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectGiveRespect extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; - - private int respects = 0; - public WiredEffectGiveRespect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -30,81 +26,34 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { public WiredEffectGiveRespect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - - @Override - public boolean saveData() { - try { - this.respects = Integer.parseInt(this.getWiredSettings().getStringParam()); - } catch (Exception e) { - return false; - } - - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - @Override public WiredEffectType getType() { - return type; + return WiredEffectType.SHOW_MESSAGE; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } + + int respects; + + try { + respects = Integer.parseInt(this.getWiredSettings().getStringParam()); + } catch (Exception e) { + return false; + } + Habbo habbo = room.getHabbo(roomUnit); - if (habbo == null) + if (habbo == null) { return false; + } habbo.getHabboStats().increaseRespectPointsReceived(respects); - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), this.respects); + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), respects); return true; } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.respects, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.respects = data.amount; - this.getWiredSettings().setDelay(data.delay); - } - else { - String[] data = wiredData.split("\t"); - this.respects = 0; - - if (data.length >= 2) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - - try { - this.respects = Integer.parseInt(data[1]); - } catch (Exception ignored) { - } - } - - this.needsUpdate(true); - } - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - int amount; - int delay; - - public JsonData(int amount, int delay) { - this.amount = amount; - this.delay = delay; - } - } } \ No newline at end of file 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 7229d273..e9a39f32 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 @@ -30,13 +30,12 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { public final static int LIMIT_N_DAY = 1; public final static int LIMIT_N_HOURS = 2; public final static int LIMIT_N_MINUTES = 3; - private final static WiredEffectType type = WiredEffectType.GIVE_REWARD; - private int limit; - private int limitationInterval; + public final int PARAM_REWARD_LIMIT = 0; + public final int PARAM_UNIQUE_REWARD = 1; + public final int PARAM_LIMIT = 2; + public final int PARAM_LIMITATION_INTERVAL = 3; + public THashSet rewardItems = new THashSet<>(); private int given; - private int rewardTime; - private boolean uniqueRewards; - private final THashSet rewardItems = new THashSet<>(); public WiredEffectGiveReward(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -48,115 +47,49 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int rewardTime = this.getWiredSettings().getIntegerParams().get(PARAM_REWARD_LIMIT); + boolean uniqueRewards = this.getWiredSettings().getIntegerParams().get(PARAM_UNIQUE_REWARD) == 1; + int limit = this.getWiredSettings().getIntegerParams().get(PARAM_LIMIT); + int limitationInterval = this.getWiredSettings().getIntegerParams().get(PARAM_LIMITATION_INTERVAL); + + String data = this.getWiredSettings().getStringParam(); + + String[] items = data.split(";"); + + int i = 1; + + for(String item : items) { + String[] d = item.split(","); + + if(d.length == 3) { + if(!(d[1].contains(":") || d[1].contains(";"))) { + this.rewardItems.add(new WiredGiveRewardItem(i, d[0].equalsIgnoreCase("0"), d[1], Integer.valueOf(d[2]))); + continue; + } + } + + return false; + } + Habbo habbo = room.getHabbo(roomUnit); return habbo != null && WiredHandler.getReward(habbo, this); } - @Override - public String getWiredData() { - ArrayList rewards = new ArrayList<>(this.rewardItems); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getWiredSettings().getDelay())); + public int getLimit() { + return this.getWiredSettings().getIntegerParams().get(PARAM_LIMIT); } - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.limit = data.limit; - this.given = data.given; - this.rewardTime = data.reward_time; - this.uniqueRewards = data.unique_rewards; - this.limitationInterval = data.limit_interval; - this.rewardItems.clear(); - this.rewardItems.addAll(data.rewards); - } else { - String[] data = wiredData.split(":"); - if (data.length > 0) { - this.limit = Integer.parseInt(data[0]); - this.given = Integer.parseInt(data[1]); - this.rewardTime = Integer.parseInt(data[2]); - this.uniqueRewards = data[3].equals("1"); - this.limitationInterval = Integer.parseInt(data[4]); - this.getWiredSettings().setDelay(Integer.parseInt(data[5])); - - if (data.length > 6) { - if (!data[6].equalsIgnoreCase("\t")) { - String[] items = data[6].split(";"); - - this.rewardItems.clear(); - - for (String s : items) { - try { - this.rewardItems.add(new WiredGiveRewardItem(s)); - } catch (Exception ignored) { - } - } - } - } - - this.needsUpdate(true); - } - } + public int getRewardTime() { + return this.getWiredSettings().getIntegerParams().get(PARAM_REWARD_LIMIT); } - @Override - public WiredEffectType getType() { - return type; + public boolean isUniqueRewards() { + return this.getWiredSettings().getIntegerParams().get(PARAM_UNIQUE_REWARD) == 1; } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - - if (client.getHabbo().hasRight(Permission.ACC_SUPERWIRED)) { - client.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.superwired.info"), RoomChatMessageBubbles.BOT); - } - } - - @Override - public boolean saveData() throws WiredSaveException { - if (this.getWiredSettings().getIntegerParams().length < 4) throw new WiredSaveException("Invalid data"); - this.rewardTime = this.getWiredSettings().getIntegerParams()[0]; - this.uniqueRewards = this.getWiredSettings().getIntegerParams()[1] == 1; - this.limit = this.getWiredSettings().getIntegerParams()[2]; - this.limitationInterval = this.getWiredSettings().getIntegerParams()[3]; - this.given = 0; - - String data = this.getWiredSettings().getStringParam(); - - String[] items = data.split(";"); - - this.rewardItems.clear(); - - int i = 1; - for (String s : items) { - String[] d = s.split(","); - - if (d.length == 3) { - if (!(d[1].contains(":") || d[1].contains(";"))) { - this.rewardItems.add(new WiredGiveRewardItem(i, d[0].equalsIgnoreCase("0"), d[1], Integer.parseInt(d[2]))); - continue; - } - } - - //TODO THROW ERROR -// gameClient.sendResponse(new WiredValidationErrorComposer(Emulator.getTexts().getValue("alert.superwired.invalid"))); - return false; - } - - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - WiredHandler.dropRewards(this.getId()); - return true; - } - - @Override - public boolean requiresTriggeringUser() { - return true; + public int getLimitationInterval() { + return this.getWiredSettings().getIntegerParams().get(PARAM_LIMITATION_INTERVAL); } @Override @@ -165,26 +98,11 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } public void incrementGiven() { - given++; + this.given++; } - static class JsonData { - int limit; - int given; - int reward_time; - boolean unique_rewards; - int limit_interval; - List rewards; - int delay; - - public JsonData(int limit, int given, int reward_time, boolean unique_rewards, int limit_interval, List rewards, int delay) { - this.limit = limit; - this.given = given; - this.reward_time = reward_time; - this.unique_rewards = unique_rewards; - this.limit_interval = limit_interval; - this.rewards = rewards; - this.delay = delay; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.GIVE_REWARD; } -} +} \ No newline at end of file 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 08cc276d..647e4440 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 @@ -1,17 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.iterator.TObjectIntIterator; import gnu.trove.map.TObjectIntMap; @@ -20,16 +17,11 @@ import gnu.trove.map.hash.TObjectIntHashMap; import java.sql.ResultSet; import java.sql.SQLException; import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; import java.util.Map; public class WiredEffectGiveScore extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.GIVE_SCORE; - - private int score; - private int count; - + public final int PARAM_SCORE = 0; + public final int PARAM_TIMES_PER_GAME = 1; private final TObjectIntMap> data = new TObjectIntHashMap<>(); public WiredEffectGiveScore(ResultSet set, Item baseItem) throws SQLException { @@ -42,6 +34,17 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int score = this.getWiredSettings().getIntegerParams().get(PARAM_SCORE); + int timesPerGame = this.getWiredSettings().getIntegerParams().get(PARAM_TIMES_PER_GAME); + + if(score < 1 || score > 100) { + return false; + } + + if(timesPerGame < 1 || timesPerGame > 10) { + return false; + } + Habbo habbo = room.getHabbo(roomUnit); if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { @@ -63,10 +66,10 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { if (map.getValue() == habbo.getHabboInfo().getId()) { if (map.getKey() == gameStartTime) { - if (iterator.value() < this.count) { + if (iterator.value() < timesPerGame) { iterator.setValue(iterator.value() + 1); - habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); + habbo.getHabboInfo().getGamePlayer().addScore(score, true); return true; } @@ -85,7 +88,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { if (habbo.getHabboInfo().getGamePlayer() != null) { - habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); + habbo.getHabboInfo().getGamePlayer().addScore(score, true); } return true; @@ -94,79 +97,8 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.score, this.count, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.score = data.score; - this.count = data.count; - this.getWiredSettings().setDelay(data.delay); - } - else { - String[] data = wiredData.split(";"); - - if (data.length == 3) { - this.score = Integer.parseInt(data[0]); - this.count = Integer.parseInt(data[1]); - this.getWiredSettings().setDelay(Integer.parseInt(data[2])); - } - - this.needsUpdate(true); - } - } - @Override public WiredEffectType getType() { - return WiredEffectGiveScore.type; - } - - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("Invalid data"); - - int score = this.getWiredSettings().getIntegerParams()[0]; - - if(score < 1 || score > 100) - throw new WiredSaveException("Score is invalid"); - - int timesPerGame = this.getWiredSettings().getIntegerParams()[1]; - - if(timesPerGame < 1 || timesPerGame > 10) - throw new WiredSaveException("Times per game is invalid"); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.score = score; - this.count = timesPerGame; - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - int score; - int count; - int delay; - - public JsonData(int score, int count, int delay) { - this.score = score; - this.count = count; - this.delay = delay; - } + return WiredEffectType.GIVE_SCORE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 684a8e6e..c0153cb8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -1,19 +1,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.map.hash.TIntIntHashMap; @@ -21,12 +18,9 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.GIVE_SCORE_TEAM; - - private int points; - private int count; - private GameTeamColors teamColor = GameTeamColors.RED; - + public final int PARAM_SCORE = 0; + public final int PARAM_TIMES_PER_GAME = 1; + public final int PARAM_TEAM = 2; private final TIntIntHashMap startTimes = new TIntIntHashMap(); public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { @@ -39,16 +33,33 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int score = this.getWiredSettings().getIntegerParams().get(PARAM_SCORE); + int timesPerGame = this.getWiredSettings().getIntegerParams().get(PARAM_TIMES_PER_GAME); + int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM); + + if(score < 1 || score > 100) { + return false; + } + + if(timesPerGame < 1 || timesPerGame > 10) { + return false; + } + + if(teamValue < 1 || teamValue > 4) { + return false; + } + + GameTeamColors teamColor = GameTeamColors.values()[teamValue]; + for (Game game : room.getGames()) { if (game != null && game.state.equals(GameState.RUNNING)) { int c = this.startTimes.get(game.getStartTime()); - if (c < this.count) { - GameTeam team = game.getTeam(this.teamColor); + if (c < timesPerGame) { + GameTeam team = game.getTeam(teamColor); if (team != null) { - team.addTeamScore(this.points); - + team.addTeamScore(score); this.startTimes.put(game.getStartTime(), c + 1); } } @@ -58,84 +69,8 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.points, this.count, this.teamColor, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.points = data.score; - this.count = data.count; - this.teamColor = data.team; - this.getWiredSettings().setDelay(data.delay); - } - else { - String[] data = set.getString("wired_data").split(";"); - - if (data.length == 4) { - this.points = Integer.parseInt(data[0]); - this.count = Integer.parseInt(data[1]); - this.teamColor = GameTeamColors.values()[Integer.parseInt(data[2])]; - this.getWiredSettings().setDelay(Integer.parseInt(data[3])); - } - - this.needsUpdate(true); - } - } - @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 3) throw new WiredSaveException("Invalid data"); - - int points = this.getWiredSettings().getIntegerParams()[0]; - - if(points < 1 || points > 100) - throw new WiredSaveException("Points is invalid"); - - int timesPerGame = this.getWiredSettings().getIntegerParams()[1]; - - if(timesPerGame < 1 || timesPerGame > 10) - throw new WiredSaveException("Times per game is invalid"); - - int team = this.getWiredSettings().getIntegerParams()[2]; - - if(team < 1 || team > 4) - throw new WiredSaveException("Team is invalid"); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.points = points; - this.count = timesPerGame; - this.teamColor = GameTeamColors.values()[team]; - this.getWiredSettings().setDelay(delay); - - return true; - } - - static class JsonData { - int score; - int count; - GameTeamColors team; - int delay; - - public JsonData(int score, int count, GameTeamColors team, int delay) { - this.score = score; - this.count = count; - this.team = team; - this.delay = delay; - } + return WiredEffectType.GIVE_SCORE_TEAM; } } 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 2d219cf6..01a05aea 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 @@ -22,9 +22,7 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectJoinTeam extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.JOIN_TEAM; - - private GameTeamColors teamColor = GameTeamColors.RED; + public final int PARAM_TEAM = 0; public WiredEffectJoinTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -36,19 +34,26 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM); + + if(teamValue < 1 || teamValue > 4) { + return false; + } + + GameTeamColors teamColor = GameTeamColors.values()[teamValue]; + Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class); - if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getCurrentGame() != null && (habbo.getHabboInfo().getCurrentGame() != WiredGame.class || (habbo.getHabboInfo().getCurrentGame() == WiredGame.class && habbo.getHabboInfo().getGamePlayer().getTeamColor() != this.teamColor))) { - // remove from current game + if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getCurrentGame() != null && (habbo.getHabboInfo().getCurrentGame() != WiredGame.class || (habbo.getHabboInfo().getCurrentGame() == WiredGame.class && habbo.getHabboInfo().getGamePlayer().getTeamColor() != teamColor))) { Game currentGame = room.getGame(habbo.getHabboInfo().getCurrentGame()); currentGame.removeHabbo(habbo); } if(habbo.getHabboInfo().getGamePlayer() == null) { - game.addHabbo(habbo, this.teamColor); + game.addHabbo(habbo, teamColor); } return true; @@ -57,72 +62,8 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.teamColor, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.teamColor = data.team; - } - else { - String[] data = set.getString("wired_data").split("\t"); - - if (data.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - - if (data.length >= 2) { - this.teamColor = GameTeamColors.values()[Integer.parseInt(data[1])]; - } - } - - this.needsUpdate(true); - } - } - @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("invalid data"); - - int team = this.getWiredSettings().getIntegerParams()[0]; - - if(team < 1 || team > 4) - throw new WiredSaveException("Team is invalid"); - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.teamColor = GameTeamColors.values()[team]; - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - GameTeamColors team; - int delay; - - public JsonData(GameTeamColors team, int delay) { - this.team = team; - this.delay = delay; - } + return WiredEffectType.JOIN_TEAM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index 7bb1e644..2f569106 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -24,10 +24,6 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectKickHabbo extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.KICK_USER; - - private String message = ""; - public WiredEffectKickHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -56,8 +52,9 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { room.giveEffect(habbo, 4, 2); - if (!this.message.isEmpty()) - habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.message, habbo, habbo, RoomChatMessageBubbles.ALERT))); + if (!this.getWiredSettings().getStringParam().isEmpty()) { + habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam(), habbo, habbo, RoomChatMessageBubbles.ALERT))); + } Emulator.getThreading().run(new RoomUnitKick(habbo, room, true), 2000); @@ -67,71 +64,8 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.message = data.message; - } - else { - try { - String[] data = set.getString("wired_data").split("\t"); - - if (data.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - - if (data.length >= 2) { - this.message = data[1]; - } - } - } catch (Exception e) { - this.message = ""; - this.getWiredSettings().setDelay(0); - } - - this.needsUpdate(true); - } - } - @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - String message = this.getWiredSettings().getStringParam(); - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - String message; - int delay; - - public JsonData(String message, int delay) { - this.message = message; - this.delay = delay; - } + return WiredEffectType.KICK_USER; } } 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 6f6afd44..fd2a6d83 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 @@ -21,8 +21,6 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectLeaveTeam extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.LEAVE_TEAM; - public WiredEffectLeaveTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -52,45 +50,8 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - } - else { - this.getWiredSettings().setDelay(Integer.parseInt(wiredData)); - } - } - @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.getWiredSettings().setDelay(delay); - return true; - } - - static class JsonData { - int delay; - - public JsonData(int delay) { - this.delay = delay; - } + return WiredEffectType.LEAVE_TEAM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 68c22de6..95b7506b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -1,20 +1,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; @@ -25,219 +23,86 @@ import java.util.regex.Pattern; @Slf4j public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { - - private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; private final boolean checkForWiredResetPermission = true; - private final THashSet wiredMatchSettings; - private boolean state = false; - private boolean direction = false; - private boolean position = false; + public final int PARAM_STATE = 0; + public final int PARAM_ROTATION = 1; + public final int PARAM_POSITION = 2; + @Getter + private THashSet matchFurniSettings; public WiredEffectMatchFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.wiredMatchSettings = new THashSet<>(0); } public WiredEffectMatchFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.wiredMatchSettings = new THashSet<>(0); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - - if(this.wiredMatchSettings.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return true; + } - for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { - HabboItem item = room.getHabboItem(setting.getItem_id()); - if (item != null) { - if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { - if (!setting.getState().equals(" ") && !item.getExtradata().equals(setting.getState())) { - item.setExtradata(setting.getState()); - room.updateItemState(item); - } + boolean state = this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; + boolean position = this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; + boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; + + for(HabboItem item : this.getWiredSettings().getItems(room)) { + WiredMatchFurniSetting setting = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + + this.matchFurniSettings.add(setting); + + if (state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { + if (!setting.getState().equals(" ") && !item.getExtradata().equals(setting.getState())) { + item.setExtradata(setting.getState()); + room.updateItemState(item); } + } - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); + double oldZ = item.getZ(); - if(this.direction && !this.position) { - if(item.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, item, setting.getRotation(), false) == FurnitureMovementError.NONE) { - room.moveFurniTo(item, oldLocation, setting.getRotation(), null, true); - } + if(rotation && !position) { + if(item.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, item, setting.getRotation(), false) == FurnitureMovementError.NONE) { + room.moveFurniTo(item, oldLocation, setting.getRotation(), null, true); } - else if(this.position) { - boolean slideAnimation = !this.direction || item.getRotation() == setting.getRotation(); - RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); - int newRotation = this.direction ? setting.getRotation() : item.getRotation(); + } + else if(position) { + boolean slideAnimation = !rotation || item.getRotation() == setting.getRotation(); + RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); + int newRotation = rotation ? setting.getRotation() : item.getRotation(); - if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { - if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - if(slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); - } + if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { + if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { + if(slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } } } - } } return true; } - @Override - public String getWiredData() { - this.refresh(); - return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<>(this.wiredMatchSettings), this.getWiredSettings().getDelay())); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if(wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.state = data.state; - this.direction = data.direction; - this.position = data.position; - this.wiredMatchSettings.clear(); - this.wiredMatchSettings.addAll(data.items); - } - else { - String[] data = set.getString("wired_data").split(":"); - - int itemCount = Integer.parseInt(data[0]); - - String[] items = data[1].split(Pattern.quote(";")); - - for (String item : items) { - try { - - String[] stuff = item.split(Pattern.quote("-")); - - if (stuff.length >= 5) { - this.wiredMatchSettings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4]))); - } - - } catch (Exception e) { - log.error("Caught exception", e); - } - } - - this.state = data[2].equals("1"); - this.direction = data[3].equals("1"); - this.position = data[4].equals("1"); - this.getWiredSettings().setDelay(Integer.parseInt(data[5])); - this.needsUpdate(true); - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 3) throw new WiredSaveException("Invalid data"); - boolean setState = this.getWiredSettings().getIntegerParams()[0] == 1; - boolean setDirection = this.getWiredSettings().getIntegerParams()[1] == 1; - boolean setPosition = this.getWiredSettings().getIntegerParams()[2] == 1; - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room == null) - throw new WiredSaveException("Trying to save wired in unloaded room"); - - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newSettings = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY())); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.state = setState; - this.direction = setDirection; - this.position = setPosition; - this.wiredMatchSettings.clear(); - this.wiredMatchSettings.addAll(newSettings); - this.getWiredSettings().setDelay(delay); - - return true; - } - - private void refresh() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null && room.isLoaded()) { - THashSet remove = new THashSet<>(); - - for (WiredMatchFurniSetting setting : this.wiredMatchSettings) { - HabboItem item = room.getHabboItem(setting.getItem_id()); - if (item == null) { - remove.add(setting); - } - } - - for (WiredMatchFurniSetting setting : remove) { - this.wiredMatchSettings.remove(setting); - } - - } - } - - @Override - public THashSet getMatchFurniSettings() { - return this.wiredMatchSettings; - } - @Override public boolean shouldMatchState() { - return this.state; + return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; } @Override public boolean shouldMatchRotation() { - return this.direction; + return this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; } @Override public boolean shouldMatchPosition() { - return this.position; + return this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; } - static class JsonData { - boolean state; - boolean direction; - boolean position; - List items; - int delay; - - public JsonData(boolean state, boolean direction, boolean position, List items, int delay) { - this.state = state; - this.direction = direction; - this.position = position; - this.items = items; - this.delay = delay; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.MATCH_SSHOT; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index f48771e1..d5912f57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -1,32 +1,20 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; public class WiredEffectMoveFurniAway extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.FLEE; - - private THashSet items = new THashSet<>(); - public WiredEffectMoveFurniAway(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -37,16 +25,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() == 0) - items.add(item); - } - - this.items.removeAll(items); - - for (HabboItem item : this.items) { + for (HabboItem item : this.getWiredSettings().getItems(room)) { RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); RoomUnit target = room.getRoomUnits().stream().min(Comparator.comparingDouble(a -> a.getCurrentLocation().distance(t))).orElse(null); @@ -96,96 +75,13 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.getWiredSettings().setDelay(delay); - - return true; - } - @Override protected long requiredCooldown() { return 495; } - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.FLEE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 770f32eb..1d018a22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -1,17 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -25,11 +22,8 @@ import java.util.Map; import java.util.stream.Collectors; public class WiredEffectMoveFurniTo extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO; - private final List items = new ArrayList<>(); - private int direction; - private int spacing = 1; - private final Map indexOffset = new LinkedHashMap<>(); + public final int PARAM_DIRECTION = 0; + public final int PARAM_SPACING = 1; public WiredEffectMoveFurniTo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -39,80 +33,44 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room == null) - return false; - - this.items.clear(); - this.indexOffset.clear(); - - if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("invalid data"); - this.direction = this.getWiredSettings().getIntegerParams()[0]; - this.spacing = this.getWiredSettings().getIntegerParams()[1]; - - int count = this.getWiredSettings().getItems().length; - for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); - } - - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - List items = new ArrayList<>(); - - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - - if (this.items.isEmpty()) + if(this.getWiredSettings().getItemIds().isEmpty()) { return false; + } - if (stuff != null && stuff.length > 0) { - for (Object object : stuff) { - if (object instanceof HabboItem) { - HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size())); + if(stuff == null || stuff.length == 0) { + return false; + } - if (targetItem != null) { - int indexOffset = 0; - if (!this.indexOffset.containsKey(targetItem.getId())) { - this.indexOffset.put(targetItem.getId(), indexOffset); - } else { - indexOffset = this.indexOffset.get(targetItem.getId()) + this.spacing; + int direction = this.getWiredSettings().getIntegerParams().get(PARAM_DIRECTION); + int spacing = this.getWiredSettings().getIntegerParams().get(PARAM_SPACING); + + for (Object object : stuff) { + if (object instanceof HabboItem) { + int randomItemIndex = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()); + + HabboItem[] items = this.getWiredSettings().getItems(room).toArray(new HabboItem[this.getWiredSettings().getItemIds().size()]); + + HabboItem randomItem = items[randomItemIndex]; + + if (randomItem != null) { + int indexOffset = 0; + + RoomTile objectTile = room.getLayout().getTile(randomItem.getX(), randomItem.getY()); + + if (objectTile != null) { + THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()); + + RoomTile tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); + if (tile == null || !tile.getAllowStack()) { + indexOffset = 0; + tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); } - RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY()); - - if (objectTile != null) { - THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()); - - RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); - if (tile == null || !tile.getAllowStack()) { - indexOffset = 0; - tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset); - } - - room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose()); - refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation())); - room.updateTiles(refreshTiles); - this.indexOffset.put(targetItem.getId(), indexOffset); - } + room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose()); + refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation())); + room.updateTiles(refreshTiles); } } } @@ -121,81 +79,13 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - THashSet itemsToRemove = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - itemsToRemove.add(item); - } - - for (HabboItem item : itemsToRemove) { - this.items.remove(item); - } - - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.direction, - this.spacing, - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.direction = data.direction; - this.spacing = data.spacing; - this.getWiredSettings().setDelay(data.delay); - - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split("\t"); - - if (data.length == 4) { - try { - this.direction = Integer.parseInt(data[0]); - this.spacing = Integer.parseInt(data[1]); - this.getWiredSettings().setDelay(Integer.parseInt(data[2])); - } catch (Exception ignored) { - } - - for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - @Override protected long requiredCooldown() { return 495; } - static class JsonData { - int direction; - int spacing; - int delay; - List itemIds; - - public JsonData(int direction, int spacing, int delay, List itemIds) { - this.direction = direction; - this.spacing = spacing; - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.MOVE_FURNI_TO; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 65263d68..a0b304a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -1,15 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.threading.runnables.WiredCollissionRunnable; @@ -30,21 +27,15 @@ import java.util.stream.Collectors; * @author Beny. */ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.CHASE; - - private THashSet items; - private THashMap lastDirections; public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); this.lastDirections = new THashMap<>(); } public WiredEffectMoveFurniTowards(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); this.lastDirections = new THashMap<>(); } @@ -82,23 +73,11 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; } - for (HabboItem item : items) { - this.items.remove(item); - } - - for (HabboItem item : this.items) { - - if (item == null) - continue; - + for (HabboItem item : this.getWiredSettings().getItems(room)) { // direction the furni will move in RoomUserRotation moveDirection = null; RoomUserRotation lastDirection = lastDirections.get(item.getId()); @@ -230,97 +209,13 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.getWiredSettings().setDelay(delay); - - return true; - } - @Override protected long requiredCooldown() { return 495; } - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.CHASE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 41ebeb2c..6b71d159 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -1,16 +1,13 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -24,39 +21,34 @@ import java.util.stream.Collectors; @Slf4j public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable { - - public static final WiredEffectType type = WiredEffectType.MOVE_ROTATE; - private final THashSet items = new THashSet<>(WiredHandler.MAXIMUM_FURNI_SELECTION / 2); - private int direction; - private int rotation; - private final THashSet itemCooldowns; + public final int PARAM_DIRECTION = 0; + public final int PARAM_ROTATION = 1; public WiredEffectMoveRotateFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.itemCooldowns = new THashSet<>(); } public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.itemCooldowns = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - // remove items that are no longer in the room - this.items.removeIf(item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } - for (HabboItem item : this.items) { - if(this.itemCooldowns.contains(item)) - continue; + int direction = this.getWiredSettings().getIntegerParams().get(PARAM_DIRECTION); + int rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION); - int newRotation = this.rotation > 0 ? this.getNewRotation(item) : item.getRotation(); + for (HabboItem item : this.getWiredSettings().getItems(room)) { + int newRotation = rotation > 0 ? this.getNewRotation(item, rotation) : item.getRotation(); RoomTile newLocation = room.getLayout().getTile(item.getX(), item.getY()); RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); - if(this.direction > 0) { - RoomUserRotation moveDirection = this.getMovementDirection(); + if(direction > 0) { + RoomUserRotation moveDirection = this.getMovementDirection(direction); newLocation = room.getLayout().getTile( (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) @@ -68,7 +60,6 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true); if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) { if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - this.itemCooldowns.add(item); if(slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } @@ -79,105 +70,13 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement return true; } - @Override - public String getWiredData() { - THashSet itemsToRemove = new THashSet<>(this.items.size() / 2); - - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null)) - itemsToRemove.add(item); - } - - for (HabboItem item : itemsToRemove) { - this.items.remove(item); - } - - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.direction, - this.rotation, - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.direction = data.direction; - this.rotation = data.rotation; - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split("\t"); - - if (data.length == 4) { - try { - this.direction = Integer.parseInt(data[0]); - this.rotation = Integer.parseInt(data[1]); - this.getWiredSettings().setDelay(Integer.parseInt(data[2])); - } catch (Exception e) { - System.out.println(e); - } - - for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean saveData() throws WiredSaveException { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room == null) - return false; - - if(this.getWiredSettings().getIntegerParams().length < 2) throw new WiredSaveException("invalid data"); - - this.direction = this.getWiredSettings().getIntegerParams()[0]; - this.rotation = this.getWiredSettings().getIntegerParams()[1]; - - int count = this.getWiredSettings().getItems().length; - if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false; - - this.items.clear(); - for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(this.getWiredSettings().getItems()[i])); - } - - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - - /** * Returns a new rotation for an item based on the wired options * * @param item HabboItem * @return new rotation */ - private int getNewRotation(HabboItem item) { + private int getNewRotation(HabboItem item, int rotation) { if(item.getMaximumRotations() == 2) { return item.getRotation() == 0 ? 4 : 0; @@ -186,11 +85,11 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement return item.getRotation(); } else if(item.getMaximumRotations() > 4) { - if (this.rotation == 1) { + if (rotation == 1) { return item.getRotation() == item.getMaximumRotations() - 1 ? 0 : item.getRotation() + 1; - } else if (this.rotation == 2) { + } else if (rotation == 2) { return item.getRotation() > 0 ? item.getRotation() - 1 : item.getMaximumRotations() - 1; - } else if (this.rotation == 3) { //Random rotation + } else if (rotation == 3) { //Random rotation THashSet possibleRotations = new THashSet<>(); for (int i = 0; i < item.getMaximumRotations(); i++) { @@ -210,15 +109,15 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement } } else { - if (this.rotation == 1) { + if (rotation == 1) { return (item.getRotation() + 2) % 8; - } else if (this.rotation == 2) { + } else if (rotation == 2) { int rot = (item.getRotation() - 2) % 8; if(rot < 0) { rot += 8; } return rot; - } else if (this.rotation == 3) { //Random rotation + } else if (rotation == 3) { //Random rotation THashSet possibleRotations = new THashSet<>(); for (int i = 0; i < item.getMaximumRotations(); i++) { @@ -246,46 +145,35 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement * * @return direction */ - private RoomUserRotation getMovementDirection() { + private RoomUserRotation getMovementDirection(int direction) { RoomUserRotation movemementDirection = RoomUserRotation.NORTH; - if (this.direction == 1) { + if (direction == 1) { movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; - } else if (this.direction == 2) { + } else if (direction == 2) { if (Emulator.getRandom().nextInt(2) == 1) { movemementDirection = RoomUserRotation.EAST; } else { movemementDirection = RoomUserRotation.WEST; } - } else if (this.direction == 3) { + } else if (direction == 3) { if (Emulator.getRandom().nextInt(2) != 1) { movemementDirection = RoomUserRotation.SOUTH; } - } else if (this.direction == 4) { + } else if (direction == 4) { movemementDirection = RoomUserRotation.SOUTH; - } else if (this.direction == 5) { + } else if (direction == 5) { movemementDirection = RoomUserRotation.EAST; - } else if (this.direction == 7) { + } else if (direction == 7) { movemementDirection = RoomUserRotation.WEST; } return movemementDirection; } @Override - public void cycle(Room room) { - this.itemCooldowns.clear(); - } + public void cycle(Room room) {} - static class JsonData { - int direction; - int rotation; - int delay; - List itemIds; - - public JsonData(int direction, int rotation, int delay, List itemIds) { - this.direction = direction; - this.rotation = rotation; - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.MOVE_ROTATE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index 97c3ca6f..1072db61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -1,29 +1,21 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; public class WiredEffectMuteHabbo extends InteractionWiredEffect { - private static final WiredEffectType type = WiredEffectType.MUTE_TRIGGER; - - private int length = 5; - private String message = ""; + private final int PARAM_LENGTH = 0; public WiredEffectMuteHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -33,20 +25,11 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - if(this.getWiredSettings().getIntegerParams().length < 1) throw new WiredSaveException("invalid data"); - - this.length = this.getWiredSettings().getIntegerParams()[0]; - this.message = this.getWiredSettings().getStringParam(); - - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + int length = this.getWiredSettings().getIntegerParams().get(PARAM_LENGTH); + String message = this.getWiredSettings().getStringParam(); + if (roomUnit == null) return true; @@ -58,63 +41,15 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { room.muteHabbo(habbo, 60); - habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); + habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); } return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.length, - this.message - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - this.length = data.length; - this.message = data.message; - } else { - String[] data = wiredData.split("\t"); - - if (data.length >= 3) { - try { - this.getWiredSettings().setDelay(Integer.parseInt(data[0])); - this.length = Integer.parseInt(data[1]); - this.message = data[2]; - } catch (Exception ignored) { - } - } - } - } @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } - - static class JsonData { - int delay; - int length; - String message; - - public JsonData(int delay, int length, String message) { - this.delay = delay; - this.length = length; - this.message = message; - } + return WiredEffectType.MUTE_TRIGGER; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 1dce90f7..f5f626ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -1,29 +1,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredResetTimers; -import gnu.trove.procedure.TObjectProcedure; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectResetTimers extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.RESET_TIMERS; - - private int delay = 0; - public WiredEffectResetTimers(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -32,55 +21,14 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() { - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Emulator.getThreading().run(new WiredResetTimers(room), this.delay); - + Emulator.getThreading().run(new WiredResetTimers(room), this.getWiredSettings().getDelay()); return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.delay - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.delay = data.delay; - } else { - try { - if (!wiredData.equals("")) { - this.delay = Integer.parseInt(wiredData); - } - } catch (Exception ignored) { - } - } - - this.getWiredSettings().setDelay(this.delay); - } - @Override public WiredEffectType getType() { - return type; - } - - static class JsonData { - int delay; - - public JsonData(int delay) { - this.delay = delay; - } + return WiredEffectType.RESET_TIMERS; } } 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 c081474d..17ed1868 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 @@ -1,10 +1,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -12,12 +10,10 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; @@ -41,6 +37,23 @@ public class WiredEffectTeleport extends InteractionWiredEffect { this.items = new ArrayList<>(); } + @Override + public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } + + int randomItemIndex = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()); + + HabboItem[] items = this.getWiredSettings().getItems(room).toArray(new HabboItem[this.getWiredSettings().getItemIds().size()]); + + HabboItem randomItem = items[randomItemIndex]; + + teleportUnitToTile(roomUnit, room.getLayout().getTile(randomItem.getX(), randomItem.getY())); + + return true; + } + public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting()) return; @@ -81,118 +94,14 @@ public class WiredEffectTeleport extends InteractionWiredEffect { Emulator.getThreading().run(() -> { roomUnit.setWiredTeleporting(true); }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); } - - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.getWiredSettings().setDelay(delay); - - return true; - } - - @Override - public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() - || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); - - if (!this.items.isEmpty()) { - int i = Emulator.getRandom().nextInt(this.items.size()); - HabboItem item = this.items.get(i); - - teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); - return true; - } - - return false; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new ArrayList<>(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - - @Override - public WiredEffectType getType() { - return type; - } - - @Override - public boolean requiresTriggeringUser() { - return true; - } @Override protected long requiredCooldown() { return 50L; } - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.TELEPORT; } } 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 c3fc25fb..b35a7630 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 @@ -1,7 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; @@ -15,14 +13,11 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze 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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -30,15 +25,10 @@ import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; @Slf4j public class WiredEffectToggleFurni extends InteractionWiredEffect { - - public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE; - private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); @@ -83,139 +73,54 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setItems(new THashSet<>()); } public WiredEffectToggleFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { super(id, userId, item, extraData, limitedStack, limitedSells); - this.setItems(new THashSet<>()); - } - - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - THashSet newItems = new THashSet<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) { - throw new WiredSaveException(String.format("Item %s not found", itemId)); - } - - newItems.add(it); - } - - if(this.getWiredSettings().getDelay() > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) { - throw new WiredSaveException("Delay too long"); - } - - this.setItems(newItems); - this.getWiredSettings().setDelay(this.getWiredSettings().getDelay()); - - return true; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } + Habbo habbo = room.getHabbo(roomUnit); - THashSet itemsToRemove = new THashSet<>(); - for (HabboItem item : this.getItems()) { + for (HabboItem item : this.getWiredSettings().getItems(room)) { + if (item == null || item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { - itemsToRemove.add(item); continue; } - try { - if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer) { - int state = 0; - if (!item.getExtradata().isEmpty()) { - try { - state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. - } catch (NumberFormatException ignored) { + if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) { + continue; + } + + if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer) { + int state = 0; + + if (!item.getExtradata().isEmpty()) { + try { + state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. + } catch (NumberFormatException ignored) { - } } - item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); } - } catch (Exception e) { - log.error("Caught exception", e); + + try { + item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); + } catch (Exception e) { + log.error("Caught exception", e); + } } } - this.getItems().removeAll(itemsToRemove); - return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.getItems().stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.getItems().clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) { - continue; - } - - if (item != null) { - this.getItems().add(item); - } - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) - continue; - - if (item != null) - this.getItems().add(item); - } - } - } - } - } - @Override public WiredEffectType getType() { - return type; - } - - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + return WiredEffectType.TOGGLE_STATE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index cdbddb46..5337bab9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -1,7 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; @@ -15,13 +14,11 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze 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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -34,11 +31,6 @@ import java.util.stream.Collectors; @Slf4j public class WiredEffectToggleRandom extends InteractionWiredEffect { - - public static final WiredEffectType type = WiredEffectType.TOGGLE_RANDOM; - - private final THashSet items = new THashSet<>(); - private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); @@ -87,45 +79,10 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.getWiredSettings().setDelay(delay); - - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = this.items; - - for (HabboItem item : items) { + for (HabboItem item : this.getWiredSettings().getItems(room)) { if (item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { - this.items.remove(item); continue; } @@ -139,65 +96,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - - if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) - continue; - - if (item != null) - this.items.add(item); - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable) - continue; - - if (item != null) - this.items.add(item); - } - } - } - } - } - @Override public WiredEffectType getType() { - return type; - } - - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + return WiredEffectType.TOGGLE_RANDOM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java index efe43fa8..69afc0fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java @@ -1,17 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.set.hash.THashSet; @@ -22,54 +19,19 @@ import java.util.List; import java.util.stream.Collectors; public class WiredEffectTriggerStacks extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.CALL_STACKS; - - private THashSet items; - public WiredEffectTriggerStacks(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredEffectTriggerStacks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); - } - - @Override - public boolean saveData() throws WiredSaveException { - int itemsCount = this.getWiredSettings().getItems().length; - - if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { - throw new WiredSaveException("Too many furni selected"); - } - - List newItems = new ArrayList<>(); - - for (int i = 0; i < itemsCount; i++) { - int itemId = this.getWiredSettings().getItems()[i]; - HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); - - if(it == null) - throw new WiredSaveException(String.format("Item %s not found", itemId)); - - newItems.add(it); - } - - int delay = this.getWiredSettings().getDelay(); - - if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) - throw new WiredSaveException("Delay too long"); - - this.items.clear(); - this.items.addAll(newItems); - this.getWiredSettings().setDelay(delay); - - return true; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getItemIds().isEmpty()) { + return false; + } if (stuff == null || (stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks)) { return false; @@ -79,7 +41,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { boolean found; - for (HabboItem item : this.items) { + for (HabboItem item : this.getWiredSettings().getItems(room)) { //if(item instanceof InteractionWiredTrigger) { found = false; @@ -104,64 +66,13 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.getWiredSettings().getDelay(), - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.getWiredSettings().setDelay(data.delay); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] wiredDataOld = wiredData.split("\t"); - - if (wiredDataOld.length >= 1) { - this.getWiredSettings().setDelay(Integer.parseInt(wiredDataOld[0])); - } - if (wiredDataOld.length == 2) { - if (wiredDataOld[1].contains(";")) { - for (String s : wiredDataOld[1].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - - @Override - public WiredEffectType getType() { - return type; - } - @Override protected long requiredCooldown() { return 250; } - static class JsonData { - int delay; - List itemIds; - - public JsonData(int delay, List itemIds) { - this.delay = delay; - this.itemIds = itemIds; - } + @Override + public WiredEffectType getType() { + return WiredEffectType.CALL_STACKS; } } 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 c9798119..a131fb72 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 @@ -11,15 +11,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; public class WiredEffectWhisper extends InteractionWiredEffect { - public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE; - public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -28,45 +25,38 @@ public class WiredEffectWhisper extends InteractionWiredEffect { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public boolean saveData() { - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (this.getWiredSettings().getStringParam().length() > 0) { - if (roomUnit != null) { - Habbo habbo = room.getHabbo(roomUnit); + if(this.getWiredSettings().getStringParam().isEmpty()) { + return false; + } - 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() + ""); - habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED))); - Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg })); + if (roomUnit != null) { + Habbo habbo = room.getHabbo(roomUnit); - if (habbo.getRoomUnit().isIdle()) { - habbo.getRoomUnit().getRoom().unIdle(habbo); - } - return true; + 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() + ""); + habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED))); + Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg })); + + if (habbo.getRoomUnit().isIdle()) { + habbo.getRoomUnit().getRoom().unIdle(habbo); } - } else { - for (Habbo h : room.getHabbos()) { - h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); - } - return true; } + } else { + for (Habbo h : room.getHabbos()) { + h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); + } + + return true; } + return false; } @Override public WiredEffectType getType() { - return type; - } - - @Override - public boolean requiresTriggeringUser() { - return true; + return WiredEffectType.SHOW_MESSAGE; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java index cd091d36..a3788f1f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java @@ -23,22 +23,4 @@ public class WiredExtraRandom extends InteractionWiredExtra { public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { return false; } - - @Override - public String getWiredData() { - return null; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) {} - - @Override - public boolean saveData() throws WiredSaveException { - return true; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) { - - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java index 3f6d2d1f..6a9b4a01 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java @@ -32,26 +32,6 @@ public class WiredExtraUnseen extends InteractionWiredExtra { return false; } - @Override - public String getWiredData() { - return null; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) { - - } - - @Override - public boolean saveData() throws WiredSaveException { - return false; - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) { - - } - @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java index 2d1174a4..689532a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredEffectInteraction.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.util.List; public interface IWiredEffectInteraction { + WiredEffectType getType(); + void setType(WiredEffectType value); List getBlockedTriggers(Room room); void setBlockedTriggers(List value); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java index 374a341b..a3533e27 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java @@ -3,19 +3,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.set.hash.THashSet; - -import java.util.Map; - public interface IWiredInteraction { - THashSet getItems(); - void setItems(THashSet value); String getWiredData(); void setWiredData(String value); WiredSettings getWiredSettings(); void setWiredSettings(WiredSettings value); boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); - boolean saveData() throws WiredSaveException; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java index 657c092a..5bccb38a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredSettings.java @@ -3,13 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import lombok.Getter; import lombok.Setter; +import java.util.List; + public interface IWiredSettings { - int[] getIntegerParams(); - void setIntegerParams(int[] value); + List getIntegerParams(); + void setIntegerParams(List value); String getStringParam(); void setStringParam(String value); - int[] getItems(); - void setItems(int[] value); + List getItemIds(); + void setItemIds(List value); int getDelay(); void setDelay(int value); int getSelectionType(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java index aa7c6700..b27a81ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredTriggerInteraction.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.util.List; public interface IWiredTriggerInteraction { + WiredTriggerType getType(); + void setType(WiredTriggerType value); List getBlockedEffects(Room room); void setBlockedEffects(List value); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/WiredTriggerReset.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/WiredTriggerReset.java new file mode 100644 index 00000000..f8c9fa03 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/WiredTriggerReset.java @@ -0,0 +1,5 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +public interface WiredTriggerReset { + void resetTimer(); +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index c8d34d46..6d429b35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -3,24 +3,19 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredExecuteTask; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements WiredTriggerReset { - public final static WiredTriggerType type = WiredTriggerType.AT_GIVEN_TIME; + public final int PARAM_EXECUTE_TIME = 0; - public int executeTime; public int taskId; public WiredTriggerAtSetTime(ResultSet set, Item baseItem) throws SQLException { @@ -33,48 +28,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return true; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.executeTime - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.executeTime = data.executeTime; - } else { - if (wiredData.length() >= 1) { - this.executeTime = (Integer.parseInt(wiredData)); - } - } - - if (this.executeTime < 500) { - this.executeTime = 20 * 500; - } - this.taskId = 1; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); - } - - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.executeTime = this.getWiredSettings().getIntegerParams()[0] * 500; - - this.resetTimer(); - + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); //TODO *500? return true; } @@ -82,14 +36,11 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi public void resetTimer() { this.taskId++; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); } - static class JsonData { - int executeTime; - - public JsonData(int executeTime) { - this.executeTime = executeTime; - } + @Override + public WiredTriggerType getType() { + return WiredTriggerType.AT_GIVEN_TIME; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 2872552a..9e3761bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -3,24 +3,19 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.WiredExecuteTask; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements WiredTriggerReset { - private static final WiredTriggerType type = WiredTriggerType.AT_GIVEN_TIME; + public final int PARAM_EXECUTE_TIME = 0; public int taskId; - private int executeTime; public WiredTriggerAtTimeLong(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -32,61 +27,19 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return true; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.executeTime - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.executeTime = data.executeTime; - } else { - if (wiredData.length() >= 1) { - this.executeTime = (Integer.parseInt(wiredData)); - } - } - - if (this.executeTime < 500) { - this.executeTime = 20 * 500; - } this.taskId = 1; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); - } - - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.executeTime = this.getWiredSettings().getIntegerParams()[0] * 500; - + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); return true; } @Override public void resetTimer() { this.taskId++; - - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); } - static class JsonData { - int executeTime; - - public JsonData(int executeTime) { - this.executeTime = executeTime; - } + @Override + public WiredTriggerType getType() { + return WiredTriggerType.AT_GIVEN_TIME; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index c9de3550..8fab5b26 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -3,124 +3,44 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Slf4j public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { - - - public final static WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI; - - private final THashSet items; - private String botName = ""; - public WiredTriggerBotReachedFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredTriggerBotReachedFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); - } - - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.botName = this.getWiredSettings().getStringParam(); - - this.items.clear(); - - int count = this.getWiredSettings().getItems().length; - - for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); - } - - return true; } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (stuff.length >= 1) { - if (stuff[0] instanceof HabboItem) { - return this.items.contains(stuff[0]) && room.getBots(this.botName).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); - } + if(stuff.length == 0) { + return false; } + + if (stuff[0] instanceof HabboItem) { + return this.getWiredSettings().getItems(room).contains(stuff[0]) && room.getBots(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); + } + return false; } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.botName, - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.botName = data.botName; - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - String[] data = wiredData.split(":"); - - if (data.length == 1) { - this.botName = data[0]; - } else if (data.length == 2) { - this.botName = data[0]; - - String[] items = data[1].split(";"); - - for (String id : items) { - try { - HabboItem item = room.getHabboItem(Integer.parseInt(id)); - - if (item != null) - this.items.add(item); - } catch (Exception e) { - log.error("Caught exception", e); - } - } - } - } - } - - static class JsonData { - String botName; - List itemIds; - - public JsonData(String botName, List itemIds) { - this.botName = botName; - this.itemIds = itemIds; - } + public WiredTriggerType getType() { + return WiredTriggerType.WALKS_ON_FURNI; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java index 4f162e4c..8269cef8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java @@ -13,10 +13,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { - public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_AVTR; - - private String botName = ""; - public WiredTriggerBotReachedHabbo(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -25,51 +21,13 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.botName = this.getWiredSettings().getStringParam(); - return true; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return room.getBots(this.botName).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); + return room.getBots(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.botName - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.botName = data.botName; - } else { - this.botName = wiredData; - } - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - String botName; - - public JsonData(String botName) { - this.botName = botName; - } + public WiredTriggerType getType() { + return WiredTriggerType.BOT_REACHED_AVTR; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index 332c6c64..d221039a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -29,26 +29,8 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { return stuff.length > 0 && stuff[0] instanceof HabboItem; } - @Override - public String getWiredData() { - return ""; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) {} - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; + return WiredTriggerType.COLLISION; } } 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 40f25250..5bd49045 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,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -11,7 +10,6 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -20,104 +18,29 @@ import java.util.List; import java.util.stream.Collectors; public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED; - - private THashSet items; - public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredTriggerFurniStateToggled(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (stuff.length >= 1) { - Habbo habbo = room.getHabbo(roomUnit); - - if (habbo != null) { - for (Object object : stuff) { - if (object instanceof WiredEffectType) { - return false; - } - } - - if (stuff[0] instanceof HabboItem) { - return this.items.contains(stuff[0]); - } - } + if(stuff.length == 0 || room.getHabbo(roomUnit) == null) { + return false; } + + if (stuff[0] instanceof HabboItem && !(stuff[0] instanceof WiredEffectType)) { + return this.getWiredSettings().getItems(room).contains(stuff[0]); + } + return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items = new THashSet<>(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - if (wiredData.split(":").length >= 3) { -// this.getWiredSettings().setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO Trigger has delay??? - - if (!wiredData.split(":")[2].equals("\t")) { - for (String s : wiredData.split(":")[2].split(";")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } - } - } - } - } - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.items.clear(); - - int count = this.getWiredSettings().getItems().length; - - for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); - } - - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredTriggerType.STATE_CHANGED; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index a9ec094a..107eb428 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -14,8 +14,6 @@ import java.util.ArrayList; import java.util.List; public class WiredTriggerGameEnds extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.GAME_ENDS; - public WiredTriggerGameEnds(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -29,21 +27,8 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { return true; } - @Override - public String getWiredData() { - return ""; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) {} - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; + return WiredTriggerType.GAME_ENDS; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index e54716ec..1a377dd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -14,8 +14,6 @@ import java.util.ArrayList; import java.util.List; public class WiredTriggerGameStarts extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.GAME_STARTS; - public WiredTriggerGameStarts(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -29,22 +27,8 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { return true; } - @Override - public String getWiredData() { - return ""; - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) { - } - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; + return WiredTriggerType.GAME_STARTS; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index 2ce7633c..96658240 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -14,10 +14,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { - public static final WiredTriggerType type = WiredTriggerType.ENTER_ROOM; - - private String username = ""; - public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -28,59 +24,21 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { + if(this.getWiredSettings().getStringParam().isEmpty()) { + return true; + } + Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - if (this.username.length() > 0) { - return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.username); - } - - return true; + return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.getWiredSettings().getStringParam()); } + return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.username - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.username = data.username; - } else { - this.username = wiredData; - } - } - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.username = this.getWiredSettings().getStringParam(); - - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - String username; - - public JsonData(String username) { - this.username = username; - } + return WiredTriggerType.ENTER_ROOM; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index e062aae3..fcf60b01 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -14,8 +14,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.SAY_SOMETHING; - private static int PARAM_OWNER_ONLY = 0; public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { @@ -32,7 +30,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { return false; } - boolean ownerOnly = this.getWiredSettings().getIntegerParams()[PARAM_OWNER_ONLY] == 1; + boolean ownerOnly = this.getWiredSettings().getIntegerParams().get(PARAM_OWNER_ONLY) == 1; if (stuff[0] instanceof String) { if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) { @@ -44,23 +42,8 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { return false; } - @Override - public String getWiredData() { - return ""; - } - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; + return WiredTriggerType.SAY_SOMETHING; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java index 5fc66a30..fb9a92c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java @@ -3,13 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -18,100 +16,29 @@ import java.util.List; import java.util.stream.Collectors; public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { - public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI; - - private final THashSet items; - public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredTriggerHabboWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (stuff.length >= 1) { - if (stuff[0] instanceof HabboItem) { - return this.items.contains(stuff[0]); - } + if(stuff.length == 0) { + return false; } + + if (stuff[0] instanceof HabboItem) { + return this.getWiredSettings().getItems(room).contains(stuff[0]); + } + return false; } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new WiredTriggerFurniStateToggled.JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - if (wiredData.split(":").length >= 3) { -// super.setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO THIS TRIGGER HAS DELAY? - - if (!wiredData.split(":")[2].equals("\t")) { - for (String s : wiredData.split(":")[2].split(";")) { - if (s.isEmpty()) - continue; - - try { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } catch (Exception ignored) { - } - } - } - } - } - } @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.items.clear(); - - int count = this.getWiredSettings().getItems().length; - - for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); - } - - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredTriggerType.WALKS_OFF_FURNI; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index c4e9758f..e89ac30e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java @@ -1,117 +1,39 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { - public static final WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI; - - private THashSet items; - public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new THashSet<>(); } public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new THashSet<>(); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (stuff.length >= 1) { - if (stuff[0] instanceof HabboItem) { - return this.items.contains(stuff[0]); - } + if(stuff.length == 0) { + return false; } + + if (stuff[0] instanceof HabboItem) { + return this.getWiredSettings().getItems(room).contains(stuff[0]); + } + return false; } @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - this.items.clear(); - - int count = this.getWiredSettings().getItems().length; - - for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(this.getWiredSettings().getItems()[i])); - } - - return true; - } - - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - this.items.clear(); - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - for (Integer id: data.itemIds) { - HabboItem item = room.getHabboItem(id); - if (item != null) { - this.items.add(item); - } - } - } else { - if (wiredData.split(":").length >= 3) { -// super.setDelay(Integer.parseInt(wiredData.split(":")[0])); TODO this trigger has delay??? - - if (!wiredData.split(":")[2].equals("\t")) { - for (String s : wiredData.split(":")[2].split(";")) { - if (s.isEmpty()) - continue; - - try { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } catch (Exception ignored) { - } - } - } - } - } - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - List itemIds; - - public JsonData(List itemIds) { - this.itemIds = itemIds; - } + return WiredTriggerType.WALKS_ON_FURNI; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 18fdc2da..42911bf3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -4,26 +4,20 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; +import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { - public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY; - public static final int DEFAULT_DELAY = 10 * 500; - - protected int repeatTime = DEFAULT_DELAY; + public final int PARAM_REPEAT_TIME = 0; protected int counter = 0; - public WiredTriggerRepeater(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -38,52 +32,25 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.repeatTime - )); - } + public void cycle(Room room) { + if(this.getWiredSettings() == null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) { + statement.setInt(1, room.getId()); - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.repeatTime = data.repeatTime; - } else { - if (wiredData.length() >= 1) { - this.repeatTime = (Integer.parseInt(wiredData)); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.loadWiredSettings(set, room); + } + } + } + } catch (SQLException e) { + throw new RuntimeException(e); } } - if (this.repeatTime < 500) { - this.repeatTime = 20 * 500; - } - } - - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.repeatTime = this.getWiredSettings().getIntegerParams()[0] * 500; - this.counter = 0; - - if (this.repeatTime < 500) { - this.repeatTime = 500; - } - - return true; - } - - @Override - public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) { + if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) { this.counter = 0; if (this.getRoomId() != 0) { if (room.isLoaded()) { @@ -104,11 +71,8 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } } - static class JsonData { - int repeatTime; - - public JsonData(int repeatTime) { - this.repeatTime = repeatTime; - } + @Override + public WiredTriggerType getType() { + return WiredTriggerType.PERIODICALLY; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index cba7eb26..41c21c74 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -4,22 +4,18 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { public static final int DEFAULT_DELAY = 10 * 5000; - private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG; + private static final int PARAM_REPEAT_TIME = 0; private int repeatTime = DEFAULT_DELAY; private int counter = 0; @@ -36,49 +32,10 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements return true; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.repeatTime - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.repeatTime = data.repeatTime; - } else { - if (wiredData.length() >= 1) { - this.repeatTime = (Integer.parseInt(wiredData)); - } - } - - if (this.repeatTime < 5000) { - this.repeatTime = 20 * 5000; - } - } - - @Override - public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.repeatTime = this.getWiredSettings().getIntegerParams()[0] * 5000; - this.counter = 0; - return true; - } - - @Override public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) { + if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { this.counter = 0; if (this.getRoomId() != 0) { if (room.isLoaded()) { @@ -99,11 +56,8 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } } - static class JsonData { - int repeatTime; - - public JsonData(int repeatTime) { - this.repeatTime = repeatTime; - } + @Override + public WiredTriggerType getType() { + return WiredTriggerType.PERIODICALLY_LONG; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index bc1c2fa0..f7d712fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -13,8 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.SCORE_ACHIEVED; - private int score = 0; + public final int PARAM_SCORE = 0; public WiredTriggerScoreAchieved(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -30,56 +29,14 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { int points = (Integer) stuff[0]; int amountAdded = (Integer) stuff[1]; - return points - amountAdded < this.score && points >= this.score; + return points - amountAdded < this.getWiredSettings().getIntegerParams().get(PARAM_SCORE) && points >= this.getWiredSettings().getIntegerParams().get(PARAM_SCORE); } return false; } - @Override - public String getWiredData() { - return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.score - )); - } - - @Override - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - if (wiredData.startsWith("{")) { - JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.score = data.score; - } else { - try { - this.score = Integer.parseInt(wiredData); - } catch (Exception ignored) { - } - } - } - @Override public WiredTriggerType getType() { - return type; - } - - @Override - public boolean saveData() { - if(this.getWiredSettings().getIntegerParams().length < 1) return false; - this.score = this.getWiredSettings().getIntegerParams()[0]; - return true; - } - - @Override - public boolean isTriggeredByRoomUnit() { - return true; - } - - static class JsonData { - int score; - - public JsonData(int score) { - this.score = score; - } + return WiredTriggerType.SCORE_ACHIEVED; } } 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 87efb614..e2f2d113 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1086,8 +1086,7 @@ public class Room implements Comparable, ISerialize, Runnable { synchronized (this.loadLock) { if (this.loaded) { try { - Emulator.getThreading().run( - Room.this::cycle); + Emulator.getThreading().run(Room.this::cycle); } catch (Exception e) { log.error(CAUGHT_EXCEPTION, e); } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java index 4ea1898b..c281029c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java @@ -17,11 +17,11 @@ public class WiredExclusionStrategy implements ExclusionStrategy { case "stringParam": return this.wiredSettings.getStringParam().isEmpty(); case "integerParams": - return this.wiredSettings.getIntegerParams().length == 0; + return this.wiredSettings.getIntegerParams().size() == 0; case "delay": return this.wiredSettings.getDelay() == 0; - case "items": - return this.wiredSettings.getItems().length == 0; + case "itemIds": + return this.wiredSettings.getItemIds().size() == 0; case "selectionType": default: return true; 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 1ecd3b79..79c0bad8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectGiveReward; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTriggerStacks; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java index ac804c27..2f05e67a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java @@ -2,7 +2,6 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -21,16 +20,16 @@ public class WiredConditionDataComposer extends MessageComposer { this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - this.response.appendInt(this.condition.getItems().size()); + this.response.appendInt(this.condition.getWiredSettings().getItemIds().size()); - for (HabboItem item : this.condition.getItems()) { - this.response.appendInt(item.getId()); + for (int itemId : this.condition.getWiredSettings().getItemIds()) { + this.response.appendInt(itemId); } this.response.appendInt(this.condition.getBaseItem().getSpriteId()); this.response.appendInt(this.condition.getId()); this.response.appendString(this.condition.getWiredSettings().getStringParam()); - this.response.appendInt(this.condition.getWiredSettings().getIntegerParams().length); + this.response.appendInt(this.condition.getWiredSettings().getIntegerParams().size()); for (int param : this.condition.getWiredSettings().getIntegerParams()) { this.response.appendInt(param); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java index 9c05e26c..b3b87a45 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java @@ -2,7 +2,6 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -22,16 +21,16 @@ public class WiredEffectDataComposer extends MessageComposer { this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - this.response.appendInt(this.effect.getItems().size()); + this.response.appendInt(this.effect.getWiredSettings().getItemIds().size()); - for (HabboItem item : this.effect.getItems()) { - this.response.appendInt(item.getId()); + for (int itemId : this.effect.getWiredSettings().getItemIds()) { + this.response.appendInt(itemId); } this.response.appendInt(this.effect.getBaseItem().getSpriteId()); this.response.appendInt(this.effect.getId()); this.response.appendString(this.effect.getWiredSettings().getStringParam()); - this.response.appendInt(this.effect.getWiredSettings().getIntegerParams().length); + this.response.appendInt(this.effect.getWiredSettings().getIntegerParams().size()); for (int param : this.effect.getWiredSettings().getIntegerParams()) { this.response.appendInt(param); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java index d3f5216a..3031e4df 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java @@ -2,7 +2,6 @@ package com.eu.habbo.messages.outgoing.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -21,16 +20,16 @@ public class WiredTriggerDataComposer extends MessageComposer { this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); - this.response.appendInt(this.trigger.getItems().size()); + this.response.appendInt(this.trigger.getWiredSettings().getItemIds().size()); - for (HabboItem item : this.trigger.getItems()) { - this.response.appendInt(item.getId()); + for (int itemId : this.trigger.getWiredSettings().getItemIds()) { + this.response.appendInt(itemId); } this.response.appendInt(this.trigger.getBaseItem().getSpriteId()); this.response.appendInt(this.trigger.getId()); this.response.appendString(this.trigger.getWiredSettings().getStringParam()); - this.response.appendInt(this.trigger.getWiredSettings().getIntegerParams().length); + this.response.appendInt(this.trigger.getWiredSettings().getIntegerParams().size()); for (int param : this.trigger.getWiredSettings().getIntegerParams()) { this.response.appendInt(param); From a1521054536125502485c0ee49dd295ebb39c78a Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 11:25:00 -0500 Subject: [PATCH 04/42] More refactoring --- .../items/interactions/InteractionWired.java | 166 ++++++++++++------ .../InteractionWiredCondition.java | 10 -- .../interactions/InteractionWiredEffect.java | 10 -- .../interactions/InteractionWiredTrigger.java | 11 -- .../interactions/wired/WiredSettings.java | 21 ++- .../effects/WiredEffectMoveRotateFurni.java | 8 + .../wired/interfaces/IWiredInteraction.java | 2 - .../triggers/WiredTriggerHabboEntersRoom.java | 15 +- .../WiredTriggerHabboSaysKeyword.java | 7 + .../wired/triggers/WiredTriggerRepeater.java | 21 +-- .../triggers/WiredTriggerRepeaterLong.java | 9 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 4 +- .../incoming/wired/UpdateConditionEvent.java | 4 +- .../incoming/wired/UpdateTriggerEvent.java | 4 +- .../wired/WiredConditionDataComposer.java | 1 - .../wired/WiredEffectDataComposer.java | 2 - .../wired/WiredTriggerDataComposer.java | 1 - 18 files changed, 170 insertions(+), 128 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 87ec676b..f216e3c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; @@ -9,8 +10,11 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; +import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; +import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; +import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; +import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; import gnu.trove.map.hash.TLongLongHashMap; import lombok.Getter; import lombok.Setter; @@ -25,10 +29,6 @@ import java.util.List; @Slf4j public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction { - @Getter - @Setter - private String wiredData; - @Getter @Setter private WiredSettings wiredSettings; @@ -38,20 +38,111 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.wiredData = ""; this.wiredSettings = new WiredSettings(); this.setExtradata("0"); } InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.wiredData = ""; this.wiredSettings = new WiredSettings(); this.setExtradata("0"); } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); + /** + * On Room Loading run this, get Wired Data from Database and save it into the item + * + * @param set + * @throws SQLException + */ + public void loadWiredSettings(ResultSet set) throws SQLException { + String wiredData = set.getString("wired_data"); + + this.wiredSettings = new WiredSettings(); + + if(wiredData.startsWith("{")) { + this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); + } + + this.loadDefaultParams(); + } + + /** + * + * When double clicking into the wired, verify items first and load its default parameters + * then create a composer based on it's Wired Settings + * + * @param client + * @param room + * @param objects + * @throws Exception + */ + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + this.wiredSettings.getItems(room); + + //TODO Im not sure about this, the function is optional on its children maybe later just make it abstract + this.loadDefaultParams(); + + if (client != null) { + if (room.hasRights(client.getHabbo())) { + MessageComposer composer = null; + if(this instanceof InteractionWiredEffect) { + composer = new WiredEffectDataComposer((InteractionWiredEffect) this, room); + } else if(this instanceof InteractionWiredCondition) { + composer = new WiredConditionDataComposer((InteractionWiredCondition) this, room); + } else if(this instanceof InteractionWiredTrigger) { + composer = new WiredTriggerDataComposer((InteractionWiredTrigger) this, room); + } + + client.sendResponse(composer); + this.activateBox(room); + } + } + } + + /** + * When click save changes on the wired this executes, reads all the packet + * And updates wired current Wired Settings + * + * @param packet + */ + public void saveWiredSettings(ClientMessage packet) { + int intParamCount = packet.readInt(); + List integerParams = new ArrayList<>(); + + for(int i = 0; i < intParamCount; i++) + { + integerParams.add(packet.readInt()); + } + + this.wiredSettings.setIntegerParams(integerParams); + this.wiredSettings.setStringParam(packet.readString()); + + int itemCount = packet.readInt(); + List itemIds = new ArrayList<>(); + + for(int i = 0; i < itemCount; i++) + { + itemIds.add(packet.readInt()); + } + + this.wiredSettings.setItemIds(itemIds); + + if(this instanceof InteractionWiredEffect) { + this.wiredSettings.setDelay(packet.readInt()); + } + + this.wiredSettings.setSelectionType(packet.readInt()); + } + + /** + * This is executed on 3 different situations + * When finishing executing: `saveWiredSettings`, when placing this item on floor, and when picking it up. + * This what it does is converts Wired Settings into a JSON string + * and updates wired_data in the database + */ @Override public void run() { if (this.needsUpdate()) { @@ -62,6 +153,10 @@ public abstract class InteractionWired extends InteractionDefault implements IWi String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings); + if(wiredData.equalsIgnoreCase("{}")) { + wiredData = ""; + } + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) { if (this.getRoomId() != 0) { statement.setString(1, wiredData); @@ -77,12 +172,18 @@ public abstract class InteractionWired extends InteractionDefault implements IWi super.run(); } + /** + * When picking up the wired, all its settings are erased and updated in database + * + * @param room + */ @Override public void onPickUp(Room room) { - this.wiredSettings = null; - //TODO not sure about this + this.wiredSettings.dispose(); } + public void loadDefaultParams() {} + public void activateBox(Room room) { this.activateBox(room, null, 0L); } @@ -123,7 +224,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi long lastTimestamp = this.userExecutionCache.get(roomUnitId); return timestamp - lastTimestamp >= 100L; } - } return true; } @@ -135,50 +235,4 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public void addUserExecutionCache(int roomUnitId, long timestamp) { this.userExecutionCache.put(roomUnitId, timestamp); } - - public void loadWiredSettings(ClientMessage packet, boolean isWiredEffect) { - WiredSettings settings = new WiredSettings(); - - int intParamCount = packet.readInt(); - List integerParams = new ArrayList<>(); - - for(int i = 0; i < intParamCount; i++) - { - integerParams.add(packet.readInt()); - } - - settings.setIntegerParams(integerParams); - settings.setStringParam(packet.readString()); - - int itemCount = packet.readInt(); - List itemIds = new ArrayList<>(); - - for(int i = 0; i < itemCount; i++) - { - itemIds.add(packet.readInt()); - } - - settings.setItemIds(itemIds); - - if(isWiredEffect) - { - settings.setDelay(packet.readInt()); - } - - settings.setSelectionType(packet.readInt()); - - this.wiredSettings = settings; - } - - public void loadWiredSettings(ResultSet set, Room room) throws SQLException { - String wiredData = set.getString("wired_data"); - - WiredSettings settings = new WiredSettings(); - - if(wiredData.startsWith("{")) { - settings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); - } - - this.wiredSettings = settings; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index d21ec978..a9b85cce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -19,16 +19,6 @@ public abstract class InteractionWiredCondition extends InteractionWired { super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public void onClick(GameClient client, Room room, Object[] objects) { - if (client != null) { - if (room.hasRights(client.getHabbo())) { - client.sendResponse(new WiredConditionDataComposer(this, room)); - this.activateBox(room); - } - } - } - public abstract WiredConditionType getType(); public WiredConditionOperator operator() { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index e53b9da9..b9bef234 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -48,16 +48,6 @@ public abstract class InteractionWiredEffect extends InteractionWired implements return blockedTriggers; } - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if (client != null) { - if (room.hasRights(client.getHabbo())) { - client.sendResponse(new WiredEffectDataComposer(this, room)); - this.activateBox(room); - } - } - } - public boolean requiresTriggeringUser() { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index 7a9af300..be6fc806 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -45,18 +45,7 @@ public abstract class InteractionWiredTrigger extends InteractionWired implement return blockedEffects; } - @Override - public void onClick(GameClient client, Room room, Object[] objects) { - if (client != null) { - if (room.hasRights(client.getHabbo())) { - client.sendResponse(new WiredTriggerDataComposer(this, room)); - this.activateBox(room); - } - } - } - public boolean isTriggeredByRoomUnit() { return false; } - } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index a3c35255..8fdba9dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; @@ -29,7 +30,7 @@ public class WiredSettings implements IWiredSettings { @Getter @Setter - private int selectionType; + private transient int selectionType; public WiredSettings() { this.itemIds = new ArrayList<>(); @@ -42,11 +43,15 @@ public class WiredSettings implements IWiredSettings { public THashSet getItems(Room room) { THashSet items = new THashSet<>(); - for(int itemId : this.itemIds) { - HabboItem item = room.getHabboItem(itemId); + if(this.itemIds.size() == 0) { + return items; + } + + for(int i = 0; i < this.itemIds.size(); i++) { + HabboItem item = room.getHabboItem(this.itemIds.get(i)); if(item == null || item.getRoomId() == 0) { - this.itemIds.remove(itemId); + this.itemIds.remove(i); continue; } @@ -55,4 +60,12 @@ public class WiredSettings implements IWiredSettings { return items; } + + public void dispose() { + this.integerParams.clear(); + this.itemIds.clear(); + this.stringParam = ""; + this.delay = 0; + this.selectionType = 0; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 6b71d159..b6257b58 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -32,6 +32,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement super(id, userId, item, extradata, limitedStack, limitedSells); } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if(this.getWiredSettings().getItemIds().isEmpty()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java index a3533e27..fc6f20f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java @@ -4,8 +4,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; public interface IWiredInteraction { - String getWiredData(); - void setWiredData(String value); WiredSettings getWiredSettings(); void setWiredSettings(WiredSettings value); boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index 96658240..c6b86584 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -2,18 +2,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { + public final int PARAM_ANY_USER = 0; public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -24,7 +22,9 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if(this.getWiredSettings().getStringParam().isEmpty()) { + boolean anyUser = this.getWiredSettings().getIntegerParams().get(PARAM_ANY_USER) == 0; + + if(this.getWiredSettings().getStringParam().isEmpty() && !anyUser || anyUser) { return true; } @@ -37,6 +37,13 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredTriggerType getType() { return WiredTriggerType.ENTER_ROOM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index fcf60b01..18b05113 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -24,6 +24,13 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { super(id, userId, item, extraData, limitedStack, limitedSells); } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (this.getWiredSettings().getStringParam().isEmpty()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 42911bf3..a6b2d407 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -32,23 +32,14 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public void cycle(Room room) { - if(this.getWiredSettings() == null) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) { - statement.setInt(1, room.getId()); - - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - this.loadWiredSettings(set, room); - } - } - } - } catch (SQLException e) { - throw new RuntimeException(e); - } + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); } + } + @Override + public void cycle(Room room) { this.counter += 500; if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) { this.counter = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 41c21c74..58314aa2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -14,9 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { - public static final int DEFAULT_DELAY = 10 * 5000; private static final int PARAM_REPEAT_TIME = 0; - private int repeatTime = DEFAULT_DELAY; private int counter = 0; public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { @@ -32,6 +30,13 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public void cycle(Room room) { this.counter += 500; 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 e2f2d113..d1141146 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -498,7 +498,7 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem item = this.getHabboItem(set.getInt("id")); if (item instanceof InteractionWired interactionWired) { - interactionWired.loadWiredSettings(set, this); + interactionWired.loadWiredSettings(set); } } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index 78f8629c..2c86e59f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; @@ -28,7 +26,7 @@ public class UpdateActionEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId)); } - effect.loadWiredSettings(this.packet, true); + effect.saveWiredSettings(this.packet); this.client.sendResponse(new WiredSavedComposer()); effect.needsUpdate(true); Emulator.getThreading().run(effect); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index c22ad8e3..55f95f27 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; @@ -26,7 +24,7 @@ public class UpdateConditionEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired condition with item id %s not found in room", itemId)); } - condition.loadWiredSettings(this.packet, true); + condition.saveWiredSettings(this.packet); this.client.sendResponse(new WiredSavedComposer()); condition.needsUpdate(true); Emulator.getThreading().run(condition); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index d58e73cd..b251c097 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -1,9 +1,7 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; @@ -26,7 +24,7 @@ public class UpdateTriggerEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired trigger with item id %s not found in room", itemId)); } - trigger.loadWiredSettings(this.packet, false); + trigger.saveWiredSettings(this.packet); this.client.sendResponse(new WiredSavedComposer()); trigger.needsUpdate(true); Emulator.getThreading().run(trigger); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java index 2f05e67a..ed3c8305 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java @@ -16,7 +16,6 @@ public class WiredConditionDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredConditionDataComposer); -// this.condition.serializeWiredData(this.response, this.room); @DEPRECATED this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java index b3b87a45..be8e0ae6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java @@ -17,8 +17,6 @@ public class WiredEffectDataComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredEffectDataComposer); -// this.effect.serializeWiredData(this.response, this.room); @DEPRECATED - this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); this.response.appendInt(this.effect.getWiredSettings().getItemIds().size()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java index 3031e4df..706a60fa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java @@ -16,7 +16,6 @@ public class WiredTriggerDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.wiredTriggerDataComposer); -// this.trigger.serializeWiredData(this.response, this.room); @DEPRECATED this.response.appendBoolean(false); this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION); From 6d49cfc37cf6298d05a61bc1e13a50fd33c80357 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 17:33:42 -0500 Subject: [PATCH 05/42] Default Params and JSON serialization done --- pom.xml | 19 ++++++++++ .../items/interactions/InteractionWired.java | 19 +++++----- .../interactions/wired/WiredSettings.java | 11 ++++-- .../WiredConditionDateRangeActive.java | 8 +++++ .../WiredConditionFurniHaveFurni.java | 7 ++++ .../conditions/WiredConditionHabboCount.java | 8 +++++ .../WiredConditionHabboHasEffect.java | 7 ++++ .../WiredConditionHabboHasHandItem.java | 7 ++++ .../WiredConditionLessTimeElapsed.java | 7 ++++ .../WiredConditionMatchStatePosition.java | 19 +++++++--- .../WiredConditionMoreTimeElapsed.java | 10 +++++- .../WiredConditionNotFurniHaveFurni.java | 7 ++++ .../conditions/WiredConditionNotInTeam.java | 10 ++++++ .../conditions/WiredConditionTeamMember.java | 10 ++++++ .../effects/WiredEffectBotFollowHabbo.java | 7 ++++ .../effects/WiredEffectBotGiveHandItem.java | 7 ++++ .../wired/effects/WiredEffectBotTalk.java | 7 ++++ .../effects/WiredEffectBotTalkToHabbo.java | 7 ++++ .../WiredEffectChangeFurniDirection.java | 8 +++++ .../wired/effects/WiredEffectGiveScore.java | 8 +++++ .../effects/WiredEffectGiveScoreToTeam.java | 11 ++++++ .../wired/effects/WiredEffectJoinTeam.java | 8 +++++ .../wired/effects/WiredEffectMatchFurni.java | 15 ++++---- .../wired/effects/WiredEffectMoveFurniTo.java | 15 ++++---- .../wired/triggers/WiredTriggerAtSetTime.java | 7 ++++ .../triggers/WiredTriggerAtTimeLong.java | 7 ++++ .../triggers/WiredTriggerHabboEntersRoom.java | 12 +------ .../WiredTriggerHabboSaysKeyword.java | 16 ++++----- .../triggers/WiredTriggerRepeaterLong.java | 2 +- .../triggers/WiredTriggerScoreAchieved.java | 7 ++++ .../wired/WiredExclusionStrategy.java | 35 ------------------- .../habbo/habbohotel/wired/WiredHandler.java | 11 ++++++ 32 files changed, 252 insertions(+), 87 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java diff --git a/pom.xml b/pom.xml index 4f2ad716..ef4c1a5a 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,25 @@ 2.8.9 + + + com.fasterxml.jackson.core + jackson-core + 2.15.2 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + mysql diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index f216e3c8..1a926b1e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -15,6 +14,7 @@ import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageCompose import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; +import com.fasterxml.jackson.core.JsonProcessingException; import gnu.trove.map.hash.TLongLongHashMap; import lombok.Getter; import lombok.Setter; @@ -32,7 +32,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi @Getter @Setter private WiredSettings wiredSettings; - private long cooldown; private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); @@ -64,13 +63,11 @@ public abstract class InteractionWired extends InteractionDefault implements IWi if(wiredData.startsWith("{")) { this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); } - - this.loadDefaultParams(); } /** * - * When double clicking into the wired, verify items first and load its default parameters + * When double-clicking into the wired, verify items first and load its default parameters * then create a composer based on it's Wired Settings * * @param client @@ -82,9 +79,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public void onClick(GameClient client, Room room, Object[] objects) throws Exception { this.wiredSettings.getItems(room); - //TODO Im not sure about this, the function is optional on its children maybe later just make it abstract - this.loadDefaultParams(); - if (client != null) { if (room.hasRights(client.getHabbo())) { MessageComposer composer = null; @@ -148,10 +142,15 @@ public abstract class InteractionWired extends InteractionDefault implements IWi if (this.needsUpdate()) { //TODO HERE IS WERE WIRED_SAVE_EXCEPTION WILL BE THROWN //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers + this.loadDefaultParams(); - WiredExclusionStrategy exclusionStrategy = new WiredExclusionStrategy(this.wiredSettings); + String wiredData = ""; - String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings); + try { + wiredData = WiredHandler.getObjectMapper().writeValueAsString(this.wiredSettings); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } if(wiredData.equalsIgnoreCase("{}")) { wiredData = ""; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index 8fdba9dc..7264bca5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import gnu.trove.map.hash.THashMap; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; @@ -15,22 +15,27 @@ import java.util.List; public class WiredSettings implements IWiredSettings { @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List integerParams; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private String stringParam; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List itemIds; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int delay; @Getter @Setter - private transient int selectionType; + @JsonIgnore + private int selectionType; public WiredSettings() { this.itemIds = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index 5a6ef2ee..a7f6ed4a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -59,6 +59,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { return startDate < time && endDate >= time; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + /** * Returns the {@link WiredConditionType} of this object. * @return the type of this wired condition diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 61297586..70a575ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -51,6 +51,13 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.FURNI_HAS_FURNI; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index 3ab4ca4a..2c048889 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -33,6 +33,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { return userCount >= lowerLimit && userCount <= upperLimit; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.USER_COUNT; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 84047e17..57174423 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -34,6 +34,13 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { return roomUnit.getEffectId() == effectId; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_WEARS_EFFECT; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 3270ce20..416e9f06 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -33,6 +33,13 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { return roomUnit.getHandItem() == handItemId; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_HAS_HANDITEM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index e5c71a6c..7d562667 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -30,6 +30,13 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < cycles; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.TIME_LESS_THAN; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 3592eceb..cea8ed52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -32,11 +32,6 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public WiredConditionType getType() { - return WiredConditionType.MATCH_SSHOT; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if(this.getWiredSettings().getItemIds().isEmpty()) { @@ -74,6 +69,15 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; @@ -88,4 +92,9 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition public boolean shouldMatchPosition() { return this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; } + + @Override + public WiredConditionType getType() { + return WiredConditionType.MATCH_SSHOT; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index 289c8faf..feb39c35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -13,7 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { - private static final int PARAM_CYCLE = 0; + public final int PARAM_CYCLE = 0; public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -28,6 +28,14 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE); return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > cycles; } + + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.TIME_MORE_THAN; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 6f5481e7..88dae5fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -52,6 +52,13 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.NOT_FURNI_HAVE_FURNI; 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 e5b7130c..375329a1 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 @@ -16,6 +16,7 @@ import java.sql.SQLException; public class WiredConditionNotInTeam extends InteractionWiredCondition { public final int PARAM_TEAM = 0; + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -44,6 +45,15 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.NOT_ACTOR_IN_TEAM; 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 db2c0aab..cb178496 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 @@ -16,6 +16,7 @@ import java.sql.SQLException; public class WiredConditionTeamMember extends InteractionWiredCondition { public final int PARAM_TEAM = 0; + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -46,6 +47,15 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_IN_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index 906ace42..c4f81483 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -50,6 +50,13 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_FOLLOW_AVATAR; 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 aaff903f..73b3afa5 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 @@ -66,6 +66,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_GIVE_HANDITEM; 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 9dff1030..45f1786f 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 @@ -69,6 +69,13 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_TALK; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index a772444a..32f90687 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -74,6 +74,13 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_TALK_TO_AVATAR; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index baa91bfa..42e591b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -108,6 +108,14 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + private RoomUserRotation nextRotation(RoomUserRotation currentRotation) { return switch (this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION)) { case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite(); 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 647e4440..68b8c78e 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 @@ -97,6 +97,14 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.GIVE_SCORE; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index c0153cb8..03d60277 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -23,6 +23,8 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { public final int PARAM_TEAM = 2; private final TIntIntHashMap startTimes = new TIntIntHashMap(); + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; + public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -69,6 +71,15 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.GIVE_SCORE_TEAM; 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 01a05aea..04a16702 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 @@ -23,6 +23,7 @@ import java.util.List; public class WiredEffectJoinTeam extends InteractionWiredEffect { public final int PARAM_TEAM = 0; + private GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredEffectJoinTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -62,6 +63,13 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.JOIN_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 95b7506b..c39962bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -1,15 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -17,9 +14,6 @@ import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; @Slf4j public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { @@ -86,6 +80,15 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 1d018a22..56167acc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -8,18 +8,11 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class WiredEffectMoveFurniTo extends InteractionWiredEffect { public final int PARAM_DIRECTION = 0; @@ -79,6 +72,14 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override protected long requiredCooldown() { return 495; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index 6d429b35..8b90322e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -32,6 +32,13 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public void resetTimer() { this.taskId++; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 9e3761bd..1dc95757 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -32,6 +32,13 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public void resetTimer() { this.taskId++; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index c6b86584..4250a2b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -11,7 +11,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { - public final int PARAM_ANY_USER = 0; public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -22,9 +21,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - boolean anyUser = this.getWiredSettings().getIntegerParams().get(PARAM_ANY_USER) == 0; - - if(this.getWiredSettings().getStringParam().isEmpty() && !anyUser || anyUser) { + if(this.getWiredSettings().getStringParam().isEmpty()) { return true; } @@ -37,13 +34,6 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { return false; } - @Override - public void loadDefaultParams() { - if(this.getWiredSettings().getIntegerParams().size() == 0) { - this.getWiredSettings().getIntegerParams().add(0); - } - } - @Override public WiredTriggerType getType() { return WiredTriggerType.ENTER_ROOM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index 18b05113..bae1ebfb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { - private static int PARAM_OWNER_ONLY = 0; + public int PARAM_OWNER_ONLY = 0; public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -24,13 +24,6 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { super(id, userId, item, extraData, limitedStack, limitedSells); } - @Override - public void loadDefaultParams() { - if(this.getWiredSettings().getIntegerParams().size() == 0) { - this.getWiredSettings().getIntegerParams().add(0); - } - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (this.getWiredSettings().getStringParam().isEmpty()) { @@ -49,6 +42,13 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredTriggerType getType() { return WiredTriggerType.SAY_SOMETHING; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 58314aa2..bad6837c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { - private static final int PARAM_REPEAT_TIME = 0; + public final int PARAM_REPEAT_TIME = 0; private int counter = 0; public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index f7d712fa..ac31e535 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -35,6 +35,13 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public WiredTriggerType getType() { return WiredTriggerType.SCORE_ACHIEVED; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java deleted file mode 100644 index c281029c..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.eu.habbo.habbohotel.wired; - -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.google.gson.ExclusionStrategy; -import com.google.gson.FieldAttributes; - -public class WiredExclusionStrategy implements ExclusionStrategy { - private WiredSettings wiredSettings; - public WiredExclusionStrategy(WiredSettings settings) { - this.wiredSettings = settings; - } - @Override - public boolean shouldSkipField(FieldAttributes fieldAttributes) { - String fieldName = fieldAttributes.getName(); - - switch (fieldName) { - case "stringParam": - return this.wiredSettings.getStringParam().isEmpty(); - case "integerParams": - return this.wiredSettings.getIntegerParams().size() == 0; - case "delay": - return this.wiredSettings.getDelay() == 0; - case "itemIds": - return this.wiredSettings.getItemIds().size() == 0; - case "selectionType": - default: - return true; - } - } - - @Override - public boolean shouldSkipClass(Class aClass) { - 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 79c0bad8..fe21586a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -27,6 +27,7 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredConditionFailedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceivedEvent; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.GsonBuilder; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -48,6 +49,8 @@ public class WiredHandler { private static GsonBuilder gsonBuilder = null; + private static ObjectMapper objectMapper = null; + public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { if (triggerType == WiredTriggerType.CUSTOM) return false; @@ -257,6 +260,14 @@ public class WiredHandler { return gsonBuilder; } + public static ObjectMapper getObjectMapper() { + if(objectMapper == null) { + objectMapper = new ObjectMapper(); + } + + return objectMapper; + } + public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { for (RoomTile tile : tiles) { if (room != null) { From eefcc5b89c26c4c5db1729ef18d862fada0fb415 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 17:49:18 -0500 Subject: [PATCH 06/42] Refactored LoadDefaultParams to LoadDefaultIntegerParams and removed GSON --- .../items/interactions/InteractionWired.java | 10 +++++----- .../conditions/WiredConditionDateRangeActive.java | 2 +- .../conditions/WiredConditionFurniHaveFurni.java | 2 +- .../wired/conditions/WiredConditionHabboCount.java | 2 +- .../conditions/WiredConditionHabboHasEffect.java | 2 +- .../conditions/WiredConditionHabboHasHandItem.java | 2 +- .../conditions/WiredConditionLessTimeElapsed.java | 2 +- .../WiredConditionMatchStatePosition.java | 2 +- .../conditions/WiredConditionMoreTimeElapsed.java | 2 +- .../WiredConditionNotFurniHaveFurni.java | 2 +- .../wired/conditions/WiredConditionNotInTeam.java | 2 +- .../wired/conditions/WiredConditionTeamMember.java | 2 +- .../wired/effects/WiredEffectBotFollowHabbo.java | 2 +- .../wired/effects/WiredEffectBotGiveHandItem.java | 2 +- .../wired/effects/WiredEffectBotTalk.java | 2 +- .../wired/effects/WiredEffectBotTalkToHabbo.java | 2 +- .../effects/WiredEffectChangeFurniDirection.java | 2 +- .../wired/effects/WiredEffectGiveScore.java | 2 +- .../wired/effects/WiredEffectGiveScoreToTeam.java | 2 +- .../wired/effects/WiredEffectJoinTeam.java | 2 +- .../wired/effects/WiredEffectMatchFurni.java | 2 +- .../wired/effects/WiredEffectMoveFurniTo.java | 2 +- .../wired/effects/WiredEffectMoveRotateFurni.java | 2 +- .../wired/triggers/WiredTriggerAtSetTime.java | 2 +- .../wired/triggers/WiredTriggerAtTimeLong.java | 2 +- .../triggers/WiredTriggerHabboEntersRoom.java | 2 +- .../triggers/WiredTriggerHabboSaysKeyword.java | 2 +- .../wired/triggers/WiredTriggerRepeater.java | 2 +- .../wired/triggers/WiredTriggerRepeaterLong.java | 2 +- .../wired/triggers/WiredTriggerScoreAchieved.java | 2 +- .../java/com/eu/habbo/habbohotel/rooms/Room.java | 4 ++-- .../eu/habbo/habbohotel/wired/WiredHandler.java | 14 +------------- 32 files changed, 37 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 1a926b1e..5f8ddf4a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -55,13 +55,13 @@ public abstract class InteractionWired extends InteractionDefault implements IWi * @param set * @throws SQLException */ - public void loadWiredSettings(ResultSet set) throws SQLException { + public void loadWiredSettings(ResultSet set) throws SQLException, JsonProcessingException { String wiredData = set.getString("wired_data"); this.wiredSettings = new WiredSettings(); if(wiredData.startsWith("{")) { - this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); + this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); } } @@ -140,9 +140,9 @@ public abstract class InteractionWired extends InteractionDefault implements IWi @Override public void run() { if (this.needsUpdate()) { - //TODO HERE IS WERE WIRED_SAVE_EXCEPTION WILL BE THROWN + //TODO HERE IS WHERE WIRED_SAVE_EXCEPTION WILL BE THROWN //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers - this.loadDefaultParams(); + this.loadDefaultIntegerParams(); String wiredData = ""; @@ -181,7 +181,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi this.wiredSettings.dispose(); } - public void loadDefaultParams() {} + public void loadDefaultIntegerParams() {} public void activateBox(Room room) { this.activateBox(room, null, 0L); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index a7f6ed4a..ccf676b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -60,7 +60,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 70a575ed..04df4150 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -52,7 +52,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index 2c048889..6ac364e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -34,7 +34,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 57174423..77026560 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -35,7 +35,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 416e9f06..6e725e58 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -34,7 +34,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index 7d562667..71868641 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -31,7 +31,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index cea8ed52..3fab95cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -70,7 +70,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index feb39c35..e8bf6b64 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -30,7 +30,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 88dae5fd..bc9a9e1b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -53,7 +53,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } 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 375329a1..54e33e17 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 @@ -46,7 +46,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(1); this.getWiredSettings().getIntegerParams().add(1); 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 cb178496..7ad53922 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 @@ -48,7 +48,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(1); this.getWiredSettings().getIntegerParams().add(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index c4f81483..d6d63d88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -51,7 +51,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } 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 73b3afa5..044bc6c0 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 @@ -67,7 +67,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); } 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 45f1786f..cf8a33e5 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 @@ -70,7 +70,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index 32f90687..a70db984 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -75,7 +75,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 42e591b7..0739e0e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -109,7 +109,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); 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 68b8c78e..97c9c63f 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 @@ -98,7 +98,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(1); this.getWiredSettings().getIntegerParams().add(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 03d60277..2ddf195f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -72,7 +72,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(1); this.getWiredSettings().getIntegerParams().add(1); 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 04a16702..5a1517db 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 @@ -64,7 +64,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index c39962bd..22031c46 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -81,7 +81,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 56167acc..cabae23c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -73,7 +73,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().isEmpty()) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index b6257b58..0045c293 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -33,7 +33,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(0); this.getWiredSettings().getIntegerParams().add(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index 8b90322e..ece26ad1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -33,7 +33,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(1); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 1dc95757..3e95a175 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -33,7 +33,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(1); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index 4250a2b8..a28b781c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -38,4 +38,4 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { public WiredTriggerType getType() { return WiredTriggerType.ENTER_ROOM; } -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index bae1ebfb..02c9e9c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -43,7 +43,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index a6b2d407..6a298bfd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -32,7 +32,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(1); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index bad6837c..e61a170c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -31,7 +31,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(1); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index ac31e535..24ff6810 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -36,7 +36,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { } @Override - public void loadDefaultParams() { + public void loadDefaultIntegerParams() { if(this.getWiredSettings().getIntegerParams().size() == 0) { this.getWiredSettings().getIntegerParams().add(1); } 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 d1141146..8f9824f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -500,8 +500,8 @@ public class Room implements Comparable, ISerialize, Runnable { if (item instanceof InteractionWired interactionWired) { interactionWired.loadWiredSettings(set); } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error(CAUGHT_EXCEPTION, e); } } } 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 fe21586a..8eeac470 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -7,11 +7,11 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectGiveReward; import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTriggerStacks; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; 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.RoomUnit; @@ -28,7 +28,6 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceivedEvent; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.GsonBuilder; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -42,13 +41,9 @@ import java.util.List; @Slf4j public class WiredHandler { - - //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_FURNI_SELECTION = 5; public static int TELEPORT_DELAY = 500; - private static GsonBuilder gsonBuilder = null; - private static ObjectMapper objectMapper = null; public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { @@ -253,13 +248,6 @@ public class WiredHandler { return executed; } - public static GsonBuilder getGsonBuilder() { - if(gsonBuilder == null) { - gsonBuilder = new GsonBuilder(); - } - return gsonBuilder; - } - public static ObjectMapper getObjectMapper() { if(objectMapper == null) { objectMapper = new ObjectMapper(); From 0a14f3509359dd606dfe13b36d8840770d8c537b Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 18:05:43 -0500 Subject: [PATCH 07/42] Wired At Set Time param times 500 --- .../habbohotel/items/interactions/InteractionWired.java | 2 ++ .../wired/effects/WiredEffectMoveRotateFurni.java | 2 +- .../interactions/wired/triggers/WiredTriggerAtSetTime.java | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 5f8ddf4a..2badaea9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -62,6 +62,8 @@ public abstract class InteractionWired extends InteractionDefault implements IWi if(wiredData.startsWith("{")) { this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); + } else { + //TODO READ OLD DATA SAVING } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 0045c293..b9704055 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -184,4 +184,4 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement public WiredEffectType getType() { return WiredEffectType.MOVE_ROTATE; } -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index ece26ad1..c03adbdf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -28,7 +28,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); //TODO *500? + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); return true; } @@ -42,8 +42,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public void resetTimer() { this.taskId++; - - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); } @Override From d5036979c4a619bfa8ebd611ee21819f0fc5d50f Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 18:34:04 -0500 Subject: [PATCH 08/42] Added TODOs --- .../habbohotel/items/interactions/InteractionWired.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 2badaea9..fe8f321f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -61,9 +61,12 @@ public abstract class InteractionWired extends InteractionDefault implements IWi this.wiredSettings = new WiredSettings(); if(wiredData.startsWith("{")) { + //TODO CHECK IF WIRED_DATA IS MS4_DATA this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); + + //TODO CHECK IF WIRED_DATA IS MS3_DATA AND READ IT } else { - //TODO READ OLD DATA SAVING + //TODO READ MS1-MS2_DATA } } From a6c6e8222f84e3e2a26e8294eb5bf8b2d6d893f7 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 19 Jun 2023 08:57:31 -0500 Subject: [PATCH 09/42] Fixed Wired Change Direction, and Permissions Rights --- .../WiredEffectChangeFurniDirection.java | 66 ++++++++++++++----- .../WiredTriggerHabboWalkOnFurni.java | 4 +- .../permissions/PermissionGroup.java | 9 +-- .../permissions/PermissionsManager.java | 2 +- .../wired/WiredChangeDirectionSetting.java | 2 +- .../habbo/habbohotel/wired/WiredHandler.java | 28 +++----- 6 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 0739e0e7..1fa147ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -9,17 +9,15 @@ import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map; +import java.util.HashMap; public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { - public final int PARAM_START_ROTATION = 0; + public final int PARAM_START_DIRECTION = 0; public final int PARAM_BLOCKED_ACTION = 1; public static final int ACTION_WAIT = 0; public static final int ACTION_TURN_RIGHT_45 = 1; @@ -29,12 +27,21 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { public static final int ACTION_TURN_BACK = 5; public static final int ACTION_TURN_RANDOM = 6; + private int defaultDirectionValue; + + private int defaultBlockActionValue; + + private boolean requiresUpdate = false; + private final HashMap itemsSettings; + public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + this.itemsSettings = new HashMap<>(); } public WiredEffectChangeFurniDirection(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + this.itemsSettings = new HashMap<>(); } @Override @@ -43,10 +50,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return false; } - int startRotationValue = this.getWiredSettings().getIntegerParams().get(PARAM_START_ROTATION); + int startDirectionValue = this.getWiredSettings().getIntegerParams().get(PARAM_START_DIRECTION); int blockActionValue = this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION); - if(startRotationValue < 0 || startRotationValue > 7 || (startRotationValue % 2) != 0) { + if(startDirectionValue < 0 || startDirectionValue > 7 || (startDirectionValue % 2) != 0) { return false; } @@ -54,14 +61,36 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return false; } - RoomUserRotation startRotation = RoomUserRotation.fromValue(startRotationValue); + if(this.defaultDirectionValue != startDirectionValue) { + this.defaultDirectionValue = startDirectionValue; + this.requiresUpdate = true; + } + + RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionValue); + + if(this.requiresUpdate) { + for (WiredChangeDirectionSetting setting : this.itemsSettings.values()) { + setting.setDirection(startDirection); + } + this.requiresUpdate = false; + } for(HabboItem item : this.getWiredSettings().getItems(room)) { - WiredChangeDirectionSetting setting = new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startRotation); + WiredChangeDirectionSetting setting = null; + if(!this.itemsSettings.containsKey(item)) { + this.itemsSettings.put(item, new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection)); + } else { + setting = this.itemsSettings.get(item); + } + + if(setting == null) { + continue; + } + RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); int count = 1; - while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { - setting.setDirection(this.nextRotation(setting.getDirection())); + while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { + setting.setDirection(this.nextDirection(setting.getDirection())); RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); if (tile != null && tile.getState() != RoomTileState.INVALID) { @@ -83,6 +112,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } boolean hasRoomUnits = false; + THashSet newOccupiedTiles = room.getLayout().getTilesAt(newTargetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); for(RoomTile tile : newOccupiedTiles) { for (RoomUnit _roomUnit : room.getRoomUnits(tile)) { @@ -116,16 +146,16 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } } - private RoomUserRotation nextRotation(RoomUserRotation currentRotation) { + private RoomUserRotation nextDirection(RoomUserRotation currentDirection) { return switch (this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION)) { - case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite(); - case ACTION_TURN_LEFT_45 -> RoomUserRotation.counterClockwise(currentRotation); - case ACTION_TURN_LEFT_90 -> RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentRotation)); - case ACTION_TURN_RIGHT_45 -> RoomUserRotation.clockwise(currentRotation); - case ACTION_TURN_RIGHT_90 -> RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentRotation)); + case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentDirection.getValue()).getOpposite(); + case ACTION_TURN_LEFT_45 -> RoomUserRotation.counterClockwise(currentDirection); + case ACTION_TURN_LEFT_90 -> RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentDirection)); + case ACTION_TURN_RIGHT_45 -> RoomUserRotation.clockwise(currentDirection); + case ACTION_TURN_RIGHT_90 -> RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentDirection)); case ACTION_TURN_RANDOM -> RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)); - case ACTION_WAIT -> currentRotation; - default -> currentRotation; + case ACTION_WAIT -> currentDirection; + default -> currentDirection; }; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index e89ac30e..eee9e932 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java @@ -15,8 +15,8 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, userId, item, extraData, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java index 60d31f09..39966284 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java @@ -34,7 +34,7 @@ public class PermissionGroup { @Getter final Map timers; - public PermissionGroup(ResultSet set, Map commandsAvailable) throws SQLException { + public PermissionGroup(ResultSet set, Map commandsAvailable, Map rightsAvailable) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.description = set.getString("description"); @@ -50,7 +50,7 @@ public class PermissionGroup { this.timers = new HashMap<>(); this.loadCommands(commandsAvailable); - this.loadRights(); + this.loadRights(rightsAvailable); this.loadTimers(); log.info("Loaded " + this.name + " rank with " + this.commands.size() + " commands and " + this.rights.size() + " rights!"); @@ -71,12 +71,13 @@ public class PermissionGroup { } } - private void loadRights() { + private void loadRights(Map rightsAvailable) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permission_group_rights WHERE group_id = ?")) { statement.setInt(1, this.id); try(ResultSet set = statement.executeQuery()) { while (set.next()) { - PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(set.getString("name")); + String rightName = set.getString("right_name"); + PermissionRight right = rightsAvailable.values().stream().filter(rightAvailable -> rightAvailable.getName().equalsIgnoreCase(rightName)).findFirst().orElse(null); this.rights.put(right, PermissionSetting.fromString(set.getString("setting_type"))); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index e8fca734..87baed35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -43,7 +43,7 @@ public class PermissionsManager { private void loadPermissionGroups() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permission_groups ORDER BY id ASC")) { while (set.next()) { - PermissionGroup permissionGroup = new PermissionGroup(set, this.permissionCommands); + PermissionGroup permissionGroup = new PermissionGroup(set, this.permissionCommands, this.permissionRights); this.permissionGroups.put(permissionGroup.getId(), permissionGroup); } } catch (SQLException e) { diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java index de585d1d..c4844c49 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java @@ -8,7 +8,7 @@ import lombok.Setter; @Getter @AllArgsConstructor public class WiredChangeDirectionSetting { - private final int item_id; + private final int itemId; private int rotation; @Setter private RoomUserRotation direction; 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 8eeac470..ba507ce1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -47,44 +47,36 @@ public class WiredHandler { private static ObjectMapper objectMapper = null; public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { - if (triggerType == WiredTriggerType.CUSTOM) return false; - - boolean talked = false; - - if (!Emulator.isReady) - return false; - - if (room == null) - return false; - - if (!room.isLoaded()) - return false; - - if (room.getRoomSpecialTypes() == null) + if (triggerType == WiredTriggerType.CUSTOM || !Emulator.isReady || room == null || !room.isLoaded() || room.getRoomSpecialTypes() == null) { return false; + } THashSet triggers = room.getRoomSpecialTypes().getTriggers(triggerType); - if (triggers == null || triggers.isEmpty()) + if (triggers == null || triggers.isEmpty()) { return false; + } + boolean talked = false; long millis = System.currentTimeMillis(); THashSet effectsToExecute = new THashSet<>(); - List triggeredTiles = new ArrayList<>(); + for (InteractionWiredTrigger trigger : triggers) { RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY()); - if (triggeredTiles.contains(tile)) + if (triggeredTiles.contains(tile)) { continue; + } THashSet tEffectsToExecute = new THashSet<>(); if (handle(trigger, roomUnit, room, stuff, tEffectsToExecute)) { effectsToExecute.addAll(tEffectsToExecute); - if (triggerType.equals(WiredTriggerType.SAY_SOMETHING)) + if (triggerType.equals(WiredTriggerType.SAY_SOMETHING)) { talked = true; + } triggeredTiles.add(tile); } From 9ed3bfc37a85afff47d9c54bc909f8268e4c84e5 Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 20 Jun 2023 22:01:21 -0500 Subject: [PATCH 10/42] Fixed Some Wireds with new structure, patched bug with repeaters, loadWired moved to Items --- .../habbo/habbohotel/items/ItemManager.java | 8 ++++- .../WiredEffectChangeFurniDirection.java | 13 ++------ .../wired/triggers/WiredTriggerRepeater.java | 30 +++++++++++++++++ .../triggers/WiredTriggerRepeaterLong.java | 32 ++++++++++++++++++- .../com/eu/habbo/habbohotel/rooms/Room.java | 7 ++-- .../eu/habbo/habbohotel/rooms/RoomState.java | 12 +++---- .../rooms/GetGuestRoomResultComposer.java | 2 +- .../rooms/RoomSettingsDataComposer.java | 2 +- 8 files changed, 82 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index f798e0fe..47eaadf1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -685,7 +685,13 @@ public class ItemManager { Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); c.setAccessible(true); - return (HabboItem) c.newInstance(set, baseItem); + HabboItem item = (HabboItem) c.newInstance(set, baseItem); + + if (item instanceof InteractionWired interactionWired) { + interactionWired.loadWiredSettings(set); + } + + return item; } catch (Exception e) { log.error("Caught exception", e); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 1fa147ee..19e5d6cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -76,16 +76,9 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } for(HabboItem item : this.getWiredSettings().getItems(room)) { - WiredChangeDirectionSetting setting = null; - if(!this.itemsSettings.containsKey(item)) { - this.itemsSettings.put(item, new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection)); - } else { - setting = this.itemsSettings.get(item); - } - - if(setting == null) { - continue; - } + WiredChangeDirectionSetting setting = this.itemsSettings.computeIfAbsent(item, k -> + new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection) + ); RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); int count = 1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 6a298bfd..f9ccd607 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; 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.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -38,8 +39,37 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } } + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + if(room.getTriggersOnRoom().containsValue(this)) { + room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY()); + } + + super.onMove(room, oldLocation, newLocation); + } + + @Override + public void onPickUp(Room room) { + if(room.getTriggersOnRoom().containsValue(this)) { + room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY()); + } + + super.onPickUp(room); + } + @Override public void cycle(Room room) { + String key = this.getX() + ";" + this.getY(); + + if(room.getTriggersOnRoom().containsKey(key)) { + if(room.getTriggersOnRoom().get(key).getId() != this.getId()) { + if(!(room.getTriggersOnRoom().get(key) instanceof WiredTriggerRepeaterLong) && room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { + return; + } + } + } + room.getTriggersOnRoom().put(key, this); + this.counter += 500; if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) { this.counter = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index e61a170c..85b7a7d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; 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.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -37,10 +38,39 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } } + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + if(room.getTriggersOnRoom().containsValue(this)) { + room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY()); + } + + super.onMove(room, oldLocation, newLocation); + } + + @Override + public void onPickUp(Room room) { + if(room.getTriggersOnRoom().containsValue(this)) { + room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY()); + } + + super.onPickUp(room); + } + @Override public void cycle(Room room) { + String key = this.getX() + ";" + this.getY(); + + if(room.getTriggersOnRoom().containsKey(key)) { + if(room.getTriggersOnRoom().get(key).getId() != this.getId()) { + if(room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { + return; + } + } + } + room.getTriggersOnRoom().put(key, this); + this.counter += 500; - if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { + if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 5000) { this.counter = 0; if (this.getRoomId() != 0) { if (room.isLoaded()) { 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 8f9824f7..c340743e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -292,6 +292,8 @@ public class Room implements Comparable, ISerialize, Runnable { private RoomSpecialTypes roomSpecialTypes; @Getter private TraxManager traxManager; + @Getter + private HashMap triggersOnRoom; private boolean cycleOdd; @Getter private long cycleTimestamp; @@ -381,6 +383,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.activeTrades = new THashSet<>(0); this.rights = new TIntArrayList(); this.userVotes = new ArrayList<>(); + this.triggersOnRoom = new HashMap<>(); } public synchronized void loadData() { @@ -407,7 +410,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBots(connection); this.loadPets(connection); this.loadWordFilter(connection); - this.loadWiredData(connection); +// this.loadWiredData(connection); this.idleCycles = 0; this.loaded = true; @@ -1027,7 +1030,7 @@ public class Room implements Comparable, ISerialize, Runnable { message.appendInt(this.ownerId); message.appendString(this.ownerName); } - message.appendInt(this.state.getState()); + message.appendInt(this.state.ordinal()); message.appendInt(this.getUserCount()); message.appendInt(this.usersMax); message.appendString(this.description); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java index eda3e0b5..b7f0a7d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomState.java @@ -6,12 +6,8 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum RoomState { - OPEN(0), - LOCKED(1), - PASSWORD(2), - INVISIBLE(3); - - private final int state; - - + OPEN, + LOCKED, + PASSWORD, + INVISIBLE } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java index 24f06ade..0f37d218 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java @@ -29,7 +29,7 @@ public class GetGuestRoomResultComposer extends MessageComposer { this.response.appendInt(this.room.getOwnerId()); this.response.appendString(this.room.getOwnerName()); } - this.response.appendInt(this.room.getState().getState()); + this.response.appendInt(this.room.getState().ordinal()); this.response.appendInt(this.room.getUserCount()); this.response.appendInt(this.room.getUsersMax()); this.response.appendString(this.room.getDescription()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java index 6520ae16..6e461e65 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java @@ -15,7 +15,7 @@ public class RoomSettingsDataComposer extends MessageComposer { this.response.appendInt(this.room.getId()); this.response.appendString(this.room.getName()); this.response.appendString(this.room.getDescription()); - this.response.appendInt(this.room.getState().getState()); + this.response.appendInt(this.room.getState().ordinal()); this.response.appendInt(this.room.getCategory()); this.response.appendInt(this.room.getUsersMax()); this.response.appendInt(this.room.getUsersMax()); From f05fab12f4757ec8ebd32ea80d7b4e1a99d485e4 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 26 Jun 2023 11:04:18 -0500 Subject: [PATCH 11/42] Fixed Wired Match Effect with new structure --- .../items/interactions/InteractionWired.java | 18 +++------ .../interactions/InteractionWiredEffect.java | 5 --- .../interactions/wired/WiredSettings.java | 9 +++++ .../WiredConditionMatchStatePosition.java | 33 ++++++++++----- .../wired/effects/WiredEffectMatchFurni.java | 40 +++++++++++++------ .../InteractionWiredMatchFurniSettings.java | 5 ++- .../incoming/wired/ApplySnapshotEvent.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 2 +- .../incoming/wired/UpdateConditionEvent.java | 2 +- .../incoming/wired/UpdateTriggerEvent.java | 2 +- 10 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index fe8f321f..81964b85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -57,17 +57,8 @@ public abstract class InteractionWired extends InteractionDefault implements IWi */ public void loadWiredSettings(ResultSet set) throws SQLException, JsonProcessingException { String wiredData = set.getString("wired_data"); - this.wiredSettings = new WiredSettings(); - - if(wiredData.startsWith("{")) { - //TODO CHECK IF WIRED_DATA IS MS4_DATA - this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); - - //TODO CHECK IF WIRED_DATA IS MS3_DATA AND READ IT - } else { - //TODO READ MS1-MS2_DATA - } + this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); } /** @@ -107,7 +98,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi * * @param packet */ - public void saveWiredSettings(ClientMessage packet) { + public void saveWiredSettings(ClientMessage packet, Room room) { int intParamCount = packet.readInt(); List integerParams = new ArrayList<>(); @@ -134,6 +125,8 @@ public abstract class InteractionWired extends InteractionDefault implements IWi } this.wiredSettings.setSelectionType(packet.readInt()); + + saveAdditionalData(room); } /** @@ -149,7 +142,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers this.loadDefaultIntegerParams(); - String wiredData = ""; + String wiredData; try { wiredData = WiredHandler.getObjectMapper().writeValueAsString(this.wiredSettings); @@ -187,6 +180,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi } public void loadDefaultIntegerParams() {} + public void saveAdditionalData(Room room) {} public void activateBox(Room room) { this.activateBox(room, null, 0L); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index b9bef234..5b027410 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -1,14 +1,9 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredEffectInteraction; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index 7264bca5..e814e601 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import gnu.trove.set.hash.THashSet; @@ -27,11 +28,17 @@ public class WiredSettings implements IWiredSettings { @Setter @JsonInclude(JsonInclude.Include.NON_EMPTY) private List itemIds; + @Getter @Setter @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int delay; + @Getter + @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List matchParams; + @Getter @Setter @JsonIgnore @@ -42,6 +49,7 @@ public class WiredSettings implements IWiredSettings { this.integerParams = new ArrayList<>(); this.stringParam = ""; this.delay = 0; + this.matchParams = new ArrayList<>(); this.selectionType = 0; } @@ -71,6 +79,7 @@ public class WiredSettings implements IWiredSettings { this.itemIds.clear(); this.stringParam = ""; this.delay = 0; + this.matchParams.clear(); this.selectionType = 0; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 3fab95cf..08b983f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; @@ -9,20 +8,19 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import gnu.trove.set.hash.THashSet; import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings { public final int PARAM_STATE = 0; public final int PARAM_ROTATION = 1; public final int PARAM_POSITION = 2; - @Getter - private THashSet matchFurniSettings; + private List matchSettings; public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -34,33 +32,36 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if(this.getWiredSettings().getItemIds().isEmpty()) { + if(this.getWiredSettings().getItemIds().isEmpty() && this.getWiredSettings().getMatchParams().isEmpty()) { return true; } boolean state = this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; boolean position = this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; + this.matchSettings = this.getWiredSettings().getMatchParams(); for(HabboItem item : this.getWiredSettings().getItems(room)) { - WiredMatchFurniSetting setting = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + WiredMatchFurniSetting furniSettings = this.matchSettings.stream().filter(settings -> settings.getItem_id() == item.getId()).findAny().orElse(null); - this.matchFurniSettings.add(setting); + if(furniSettings == null) { + continue; + } if(state) { - if(!item.getExtradata().equals(setting.getState())) { + if(!item.getExtradata().equals(furniSettings.getState())) { return false; } } if(position) { - if (!(setting.getX() == item.getX() && setting.getY() == item.getY())) { + if (!(furniSettings.getX() == item.getX() && furniSettings.getY() == item.getY())) { return false; } } if(rotation) { - if (setting.getRotation() != item.getRotation()) { + if (furniSettings.getRotation() != item.getRotation()) { return false; } } @@ -78,6 +79,18 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } } + @Override + public void saveAdditionalData(Room room) { + List matchSettings = new ArrayList<>(); + + for (HabboItem item : this.getWiredSettings().getItems(room)) { + WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + matchSettings.add(settings); + } + + this.getWiredSettings().setMatchParams(matchSettings); + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 22031c46..598c4778 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -8,12 +8,13 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; @Slf4j public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { @@ -22,7 +23,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int public final int PARAM_ROTATION = 1; public final int PARAM_POSITION = 2; @Getter - private THashSet matchFurniSettings; + private List matchSettings; public WiredEffectMatchFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -34,22 +35,25 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if(this.getWiredSettings().getItemIds().isEmpty()) { + if(this.getWiredSettings().getItemIds().isEmpty() && this.getWiredSettings().getMatchParams().isEmpty()) { return true; } boolean state = this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; boolean position = this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; + this.matchSettings = this.getWiredSettings().getMatchParams(); for(HabboItem item : this.getWiredSettings().getItems(room)) { - WiredMatchFurniSetting setting = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + WiredMatchFurniSetting furniSettings = this.matchSettings.stream().filter(settings -> settings.getItem_id() == item.getId()).findAny().orElse(null); - this.matchFurniSettings.add(setting); + if(furniSettings == null) { + continue; + } if (state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { - if (!setting.getState().equals(" ") && !item.getExtradata().equals(setting.getState())) { - item.setExtradata(setting.getState()); + if (!furniSettings.getState().equals(" ") && !item.getExtradata().equals(furniSettings.getState())) { + item.setExtradata(furniSettings.getState()); room.updateItemState(item); } } @@ -58,14 +62,14 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int double oldZ = item.getZ(); if(rotation && !position) { - if(item.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, item, setting.getRotation(), false) == FurnitureMovementError.NONE) { - room.moveFurniTo(item, oldLocation, setting.getRotation(), null, true); + if(item.getRotation() != furniSettings.getRotation() && room.furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) { + room.moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true); } } else if(position) { - boolean slideAnimation = !rotation || item.getRotation() == setting.getRotation(); - RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); - int newRotation = rotation ? setting.getRotation() : item.getRotation(); + boolean slideAnimation = !rotation || item.getRotation() == furniSettings.getRotation(); + RoomTile newLocation = room.getLayout().getTile((short) furniSettings.getX(), (short) furniSettings.getY()); + int newRotation = rotation ? furniSettings.getRotation() : item.getRotation(); if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { @@ -89,6 +93,18 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } } + @Override + public void saveAdditionalData(Room room) { + List matchSettings = new ArrayList<>(); + + for (HabboItem item : this.getWiredSettings().getItems(room)) { + WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY()); + matchSettings.add(settings); + } + + this.getWiredSettings().setMatchParams(matchSettings); + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java index 9f631c9d..c0cd89fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java @@ -1,10 +1,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import gnu.trove.set.hash.THashSet; + +import java.util.List; public interface InteractionWiredMatchFurniSettings { - THashSet getMatchFurniSettings(); + List getMatchSettings(); boolean shouldMatchState(); boolean shouldMatchRotation(); boolean shouldMatchPosition(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 5f9aebd7..6971d6ca 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -61,7 +61,7 @@ public class ApplySnapshotEvent extends MessageHandler { if (wiredItem instanceof InteractionWiredMatchFurniSettings wired) { // Try to apply the set settings to each item - wired.getMatchFurniSettings().forEach(setting -> { + wired.getMatchSettings().forEach(setting -> { HabboItem matchItem = room.getHabboItem(setting.getItem_id()); // Match state diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index 2c86e59f..80c3d987 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -26,7 +26,7 @@ public class UpdateActionEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId)); } - effect.saveWiredSettings(this.packet); + effect.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); effect.needsUpdate(true); Emulator.getThreading().run(effect); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index 55f95f27..24ce1cb6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -24,7 +24,7 @@ public class UpdateConditionEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired condition with item id %s not found in room", itemId)); } - condition.saveWiredSettings(this.packet); + condition.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); condition.needsUpdate(true); Emulator.getThreading().run(condition); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index b251c097..7f3d0ff7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -24,7 +24,7 @@ public class UpdateTriggerEvent extends MessageHandler { throw new WiredSaveException(String.format("Wired trigger with item id %s not found in room", itemId)); } - trigger.saveWiredSettings(this.packet); + trigger.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); trigger.needsUpdate(true); Emulator.getThreading().run(trigger); From 13e882021b17065377ef263f238913975fe3be89 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 26 Jun 2023 20:26:44 -0500 Subject: [PATCH 12/42] Changed Periodical Wired Cycle to Room --- .../wired/interfaces/IWiredPeriodical.java | 12 +++ .../wired/triggers/WiredTriggerRepeater.java | 50 +++++------- .../triggers/WiredTriggerRepeaterLong.java | 52 +++++------- .../com/eu/habbo/habbohotel/rooms/Room.java | 81 ++++++++++++++++++- .../habbohotel/rooms/RoomSpecialTypes.java | 19 ++--- .../habbo/habbohotel/wired/WiredHandler.java | 4 +- 6 files changed, 138 insertions(+), 80 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java new file mode 100644 index 00000000..41a8ac98 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java @@ -0,0 +1,12 @@ +package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; + +import com.eu.habbo.habbohotel.rooms.RoomTile; + +public interface IWiredPeriodical { + int getInterval(); + void setInterval(int value); + boolean isTriggerTileUpdated(); + void setTriggerTileUpdated(boolean value); + RoomTile getOldTile(); + void setOldTile(RoomTile value); +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index f9ccd607..c8f4e1b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -4,21 +4,33 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredPeriodical; 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.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.Getter; +import lombok.Setter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { +public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset { public final int PARAM_REPEAT_TIME = 0; protected int counter = 0; + @Getter + @Setter + private boolean triggerTileUpdated; + @Getter + @Setter + private RoomTile oldTile; + @Setter + private int interval; + public WiredTriggerRepeater(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -41,44 +53,20 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - if(room.getTriggersOnRoom().containsValue(this)) { - room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY()); - } - + this.triggerTileUpdated = true; + this.oldTile = oldLocation; super.onMove(room, oldLocation, newLocation); } @Override public void onPickUp(Room room) { - if(room.getTriggersOnRoom().containsValue(this)) { - room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY()); - } - + this.triggerTileUpdated = true; + this.oldTile = room.getLayout().getTile(this.getX(), this.getY()); super.onPickUp(room); } - @Override - public void cycle(Room room) { - String key = this.getX() + ";" + this.getY(); - - if(room.getTriggersOnRoom().containsKey(key)) { - if(room.getTriggersOnRoom().get(key).getId() != this.getId()) { - if(!(room.getTriggersOnRoom().get(key) instanceof WiredTriggerRepeaterLong) && room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { - return; - } - } - } - room.getTriggersOnRoom().put(key, this); - - this.counter += 500; - if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) { - this.counter = 0; - if (this.getRoomId() != 0) { - if (room.isLoaded()) { - WiredHandler.handle(this, null, room, new Object[]{this}); - } - } - } + public int getInterval() { + return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 85b7a7d7..33ce55bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -4,20 +4,30 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredPeriodical; 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.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import lombok.Getter; +import lombok.Setter; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { +public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset { public final int PARAM_REPEAT_TIME = 0; - private int counter = 0; - + protected int counter = 0; + @Getter + @Setter + private boolean triggerTileUpdated; + @Getter + @Setter + private RoomTile oldTile; + @Setter + private int interval; public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -40,44 +50,20 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - if(room.getTriggersOnRoom().containsValue(this)) { - room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY()); - } - + this.triggerTileUpdated = true; + this.oldTile = oldLocation; super.onMove(room, oldLocation, newLocation); } @Override public void onPickUp(Room room) { - if(room.getTriggersOnRoom().containsValue(this)) { - room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY()); - } - + this.triggerTileUpdated = true; + this.oldTile = room.getLayout().getTile(this.getX(), this.getY()); super.onPickUp(room); } - @Override - public void cycle(Room room) { - String key = this.getX() + ";" + this.getY(); - - if(room.getTriggersOnRoom().containsKey(key)) { - if(room.getTriggersOnRoom().get(key).getId() != this.getId()) { - if(room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { - return; - } - } - } - room.getTriggersOnRoom().put(key, this); - - this.counter += 500; - if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 5000) { - this.counter = 0; - if (this.getRoomId() != 0) { - if (room.isLoaded()) { - WiredHandler.handle(this, null, room, new Object[]{this}); - } - } - } + public int getInterval() { + return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500; } @Override 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 c340743e..2356b437 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -22,6 +22,8 @@ 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.items.interactions.wired.interfaces.IWiredPeriodical; +import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerRepeaterLong; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; @@ -292,11 +294,18 @@ public class Room implements Comparable, ISerialize, Runnable { private RoomSpecialTypes roomSpecialTypes; @Getter private TraxManager traxManager; - @Getter - private HashMap triggersOnRoom; private boolean cycleOdd; @Getter private long cycleTimestamp; + @Getter + @Setter + private ScheduledFuture wiredPeriodicalCycle; + @Getter + @Setter + final HashMap triggersOnRoom; + @Getter + @Setter + private int periodicalTick; public Room(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -383,7 +392,9 @@ public class Room implements Comparable, ISerialize, Runnable { this.activeTrades = new THashSet<>(0); this.rights = new TIntArrayList(); this.userVotes = new ArrayList<>(); + this.triggersOnRoom = new HashMap<>(); + this.periodicalTick = 0; } public synchronized void loadData() { @@ -410,7 +421,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBots(connection); this.loadPets(connection); this.loadWordFilter(connection); -// this.loadWiredData(connection); + this.startPeriodicalCycle(); this.idleCycles = 0; this.loaded = true; @@ -908,6 +919,10 @@ public class Room implements Comparable, ISerialize, Runnable { if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) return; + if(this.wiredPeriodicalCycle != null) { + this.wiredPeriodicalCycle.cancel(true); + } + if (this.loaded) { try { @@ -4356,4 +4371,64 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet roomUnits = getRoomUnits(); return roomUnits.stream().filter(unit -> unit.getCurrentLocation() == tile).collect(Collectors.toSet()); } + + private void startPeriodicalCycle() { + this.wiredPeriodicalCycle = Emulator.getThreading().run(() -> { + if(Emulator.isShuttingDown) { + return; + } + + this.startPeriodicalCycle(); + + List periodicals = new ArrayList<>(); + + if(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY) != null) { + periodicals.addAll(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY)); + } + + if(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG) != null) { + periodicals.addAll(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG)); + } + + if(periodicals.isEmpty()) { + return; + } + + periodicals.parallelStream().forEach(trigger -> { + if(!(trigger instanceof IWiredPeriodical)) { + return; + } + + if(((IWiredPeriodical) trigger).isTriggerTileUpdated()) { + if(this.triggersOnRoom.containsKey(((IWiredPeriodical) trigger).getOldTile())) { + if(this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()).getId() == trigger.getId() || this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()) == null) { + this.triggersOnRoom.remove(((IWiredPeriodical) trigger).getOldTile()); + } + } + ((IWiredPeriodical) trigger).setTriggerTileUpdated(false); + ((IWiredPeriodical) trigger).setOldTile(null); + } + + RoomTile triggerTile = this.layout.getTile(trigger.getX(), trigger.getY()); + + if (this.triggersOnRoom.containsKey(triggerTile)) { + if (this.triggersOnRoom.get(triggerTile) == null || (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) trigger).getInterval() <= ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval())) { + this.triggersOnRoom.put(triggerTile, trigger); + } else if (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) { + return; + } + } else { + this.triggersOnRoom.put(triggerTile, trigger); + } + + if(this.periodicalTick % (((IWiredPeriodical) trigger).getInterval() / 500) != 0) { + return; + } + + WiredHandler.handle(trigger, null, this, new Object[]{trigger}); + }); + + ++this.periodicalTick; + }, 500L); + } } 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 3ce54325..c6bd6345 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -27,10 +27,8 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; +import java.util.*; import java.util.List; -import java.util.Map; public class RoomSpecialTypes { private final THashMap banzaiTeleporters; @@ -40,7 +38,7 @@ public class RoomSpecialTypes { private final THashMap petToys; private final THashMap rollers; - private final THashMap> wiredTriggers; + private final HashMap> wiredTriggers; private final THashMap> wiredEffects; private final THashMap> wiredConditions; private final THashMap wiredExtras; @@ -61,7 +59,7 @@ public class RoomSpecialTypes { this.petToys = new THashMap<>(0); this.rollers = new THashMap<>(0); - this.wiredTriggers = new THashMap<>(0); + this.wiredTriggers = new HashMap<>(0); this.wiredEffects = new THashMap<>(0); this.wiredConditions = new THashMap<>(0); this.wiredExtras = new THashMap<>(0); @@ -229,7 +227,7 @@ public class RoomSpecialTypes { public InteractionWiredTrigger getTrigger(int itemId) { synchronized (this.wiredTriggers) { - for (Map.Entry> map : this.wiredTriggers.entrySet()) { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { for (InteractionWiredTrigger trigger : map.getValue()) { if (trigger.getId() == itemId) return trigger; @@ -244,7 +242,7 @@ public class RoomSpecialTypes { synchronized (this.wiredTriggers) { THashSet triggers = new THashSet<>(); - for (Map.Entry> map : this.wiredTriggers.entrySet()) { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { triggers.addAll(map.getValue()); } @@ -252,7 +250,7 @@ public class RoomSpecialTypes { } } - public THashSet getTriggers(WiredTriggerType type) { + public List getTriggers(WiredTriggerType type) { return this.wiredTriggers.get(type); } @@ -260,7 +258,7 @@ public class RoomSpecialTypes { synchronized (this.wiredTriggers) { THashSet triggers = new THashSet<>(); - for (Map.Entry> map : this.wiredTriggers.entrySet()) { + for (Map.Entry> map : this.wiredTriggers.entrySet()) { for (InteractionWiredTrigger trigger : map.getValue()) { if (trigger.getX() == x && trigger.getY() == y) triggers.add(trigger); @@ -274,7 +272,7 @@ public class RoomSpecialTypes { public void addTrigger(InteractionWiredTrigger trigger) { synchronized (this.wiredTriggers) { if (!this.wiredTriggers.containsKey(trigger.getType())) - this.wiredTriggers.put(trigger.getType(), new THashSet<>()); + this.wiredTriggers.put(trigger.getType(), new ArrayList<>()); this.wiredTriggers.get(trigger.getType()).add(trigger); } @@ -354,7 +352,6 @@ public class RoomSpecialTypes { } } - public InteractionWiredCondition getCondition(int itemId) { synchronized (this.wiredConditions) { for (Map.Entry> map : this.wiredConditions.entrySet()) { 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 ba507ce1..28a7351f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -51,7 +51,7 @@ public class WiredHandler { return false; } - THashSet triggers = room.getRoomSpecialTypes().getTriggers(triggerType); + List triggers = room.getRoomSpecialTypes().getTriggers(triggerType); if (triggers == null || triggers.isEmpty()) { return false; @@ -102,7 +102,7 @@ public class WiredHandler { if (room.getRoomSpecialTypes() == null) return false; - THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.CUSTOM); + List triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.CUSTOM); if (triggers == null || triggers.isEmpty()) return false; From 88c4e0b28873d8868804ecce587cb75da326c673 Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 27 Jun 2023 00:04:47 -0500 Subject: [PATCH 13/42] Fixed overcomplicated implementation --- .../wired/interfaces/IWiredPeriodical.java | 4 --- .../wired/triggers/WiredTriggerRepeater.java | 24 ++++++++++------- .../triggers/WiredTriggerRepeaterLong.java | 26 +++++++++++-------- .../com/eu/habbo/habbohotel/rooms/Room.java | 20 +++++--------- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java index 41a8ac98..bea5fbd0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredPeriodical.java @@ -5,8 +5,4 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; public interface IWiredPeriodical { int getInterval(); void setInterval(int value); - boolean isTriggerTileUpdated(); - void setTriggerTileUpdated(boolean value); - RoomTile getOldTile(); - void setOldTile(RoomTile value); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index c8f4e1b9..9338718c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -22,12 +22,6 @@ import java.sql.SQLException; public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset { public final int PARAM_REPEAT_TIME = 0; protected int counter = 0; - @Getter - @Setter - private boolean triggerTileUpdated; - @Getter - @Setter - private RoomTile oldTile; @Setter private int interval; @@ -53,15 +47,25 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWi @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - this.triggerTileUpdated = true; - this.oldTile = oldLocation; + if(room.getTriggersOnRoom().containsKey(oldLocation)) { + if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { + room.getTriggersOnRoom().remove(oldLocation); + } + } + super.onMove(room, oldLocation, newLocation); } @Override public void onPickUp(Room room) { - this.triggerTileUpdated = true; - this.oldTile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY()); + + if(room.getTriggersOnRoom().containsKey(oldLocation)) { + if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { + room.getTriggersOnRoom().remove(oldLocation); + } + } + super.onPickUp(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 33ce55bb..273c5018 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -20,12 +20,6 @@ import java.sql.SQLException; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset { public final int PARAM_REPEAT_TIME = 0; protected int counter = 0; - @Getter - @Setter - private boolean triggerTileUpdated; - @Getter - @Setter - private RoomTile oldTile; @Setter private int interval; public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { @@ -50,20 +44,30 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - this.triggerTileUpdated = true; - this.oldTile = oldLocation; + if(room.getTriggersOnRoom().containsKey(oldLocation)) { + if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { + room.getTriggersOnRoom().remove(oldLocation); + } + } + super.onMove(room, oldLocation, newLocation); } @Override public void onPickUp(Room room) { - this.triggerTileUpdated = true; - this.oldTile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY()); + + if(room.getTriggersOnRoom().containsKey(oldLocation)) { + if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { + room.getTriggersOnRoom().remove(oldLocation); + } + } + super.onPickUp(room); } public int getInterval() { - return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500; + return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 5000; } @Override 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 2356b437..3646cb86 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4399,23 +4399,15 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - if(((IWiredPeriodical) trigger).isTriggerTileUpdated()) { - if(this.triggersOnRoom.containsKey(((IWiredPeriodical) trigger).getOldTile())) { - if(this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()).getId() == trigger.getId() || this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()) == null) { - this.triggersOnRoom.remove(((IWiredPeriodical) trigger).getOldTile()); - } - } - ((IWiredPeriodical) trigger).setTriggerTileUpdated(false); - ((IWiredPeriodical) trigger).setOldTile(null); - } - RoomTile triggerTile = this.layout.getTile(trigger.getX(), trigger.getY()); if (this.triggersOnRoom.containsKey(triggerTile)) { - if (this.triggersOnRoom.get(triggerTile) == null || (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) trigger).getInterval() <= ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval())) { - this.triggersOnRoom.put(triggerTile, trigger); - } else if (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) { - return; + if(this.triggersOnRoom.get(triggerTile).getId() != trigger.getId()) { + if(((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) { + return; + } else { + this.triggersOnRoom.put(triggerTile, trigger); + } } } else { this.triggersOnRoom.put(triggerTile, trigger); From a871e91cfcbb3e790d3c76a7dd8eb411182d8311 Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 27 Jun 2023 09:35:32 -0500 Subject: [PATCH 14/42] Fixed Issue 1997 --- .../java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 7 ++++++- .../messages/incoming/rooms/items/UseFurnitureEvent.java | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) 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 28a7351f..7fcdcb29 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -148,9 +148,14 @@ public class WiredHandler { } public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff, final THashSet effectsToExecute) { + if(!Emulator.isReady) { + return false; + } + long millis = System.currentTimeMillis(); int roomUnitId = roomUnit != null ? roomUnit.getId() : -1; - if (Emulator.isReady && ((Emulator.getConfig().getBoolean("wired.custom.enabled", false) && (trigger.canExecute(millis) || roomUnitId > -1) && trigger.userCanExecute(roomUnitId, millis)) || (!Emulator.getConfig().getBoolean("wired.custom.enabled", false) && trigger.canExecute(millis))) && trigger.execute(roomUnit, room, stuff)) { + if (((Emulator.getConfig().getBoolean("wired.custom.enabled", false) && (trigger.canExecute(millis) || roomUnitId > -1) && trigger.userCanExecute(roomUnitId, millis)) || (!Emulator.getConfig().getBoolean("wired.custom.enabled", false) && trigger.canExecute(millis))) && trigger.execute(roomUnit, room, stuff)) { + //DUNNO IF YOU HAVE TO SET EXTRADATA TO 1 IN HERE (In case of Repeaters) trigger.activateBox(room, roomUnit, millis); THashSet conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index e500c8c7..e6fd0d84 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -56,10 +56,6 @@ public class UseFurnitureEvent extends MessageHandler { } item.onClick(this.client, room, new Object[]{state}); - - if (item instanceof InteractionWired) { - this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); - } } catch (Exception e) { log.error("Caught exception", e); } From a077912e9c52b53dc3e0bfe26477d17b96448569 Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 5 Jul 2023 10:04:19 -0500 Subject: [PATCH 15/42] Fixed wireds not appearing because can't parse correctly --- .../items/interactions/wired/WiredSettings.java | 9 ++++++--- .../habbohotel/wired/WiredMatchFurniSetting.java | 16 +++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index e814e601..7f720678 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -6,11 +6,11 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; -import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; public class WiredSettings implements IWiredSettings { @@ -53,8 +53,8 @@ public class WiredSettings implements IWiredSettings { this.selectionType = 0; } - public THashSet getItems(Room room) { - THashSet items = new THashSet<>(); + public HashSet getItems(Room room) { + HashSet items = new HashSet<>(); if(this.itemIds.size() == 0) { return items; @@ -65,6 +65,9 @@ public class WiredSettings implements IWiredSettings { if(item == null || item.getRoomId() == 0) { this.itemIds.remove(i); + if(!matchParams.isEmpty()) { + this.matchParams.removeIf(setting -> setting.getItem_id() == item.getId()); + } continue; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java index 2e45f17a..43a108b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredMatchFurniSetting.java @@ -1,17 +1,19 @@ package com.eu.habbo.habbohotel.wired; import lombok.Getter; +import lombok.NoArgsConstructor; @Getter +@NoArgsConstructor public class WiredMatchFurniSetting { - private final int item_id; - private final String state; - private final int rotation; - private final int x; - private final int y; + private int item_id; + private String state; + private int rotation; + private int x; + private int y; - public WiredMatchFurniSetting(int itemId, String state, int rotation, int x, int y) { - this.item_id = itemId; + public WiredMatchFurniSetting(int item_id, String state, int rotation, int x, int y) { + this.item_id = item_id; this.state = state.replace("\t\t\t", " "); this.rotation = rotation; this.x = x; From f08278b5d53b30dc0ef9a567f93d69ed7cf31c3e Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 6 Jul 2023 10:20:43 -0500 Subject: [PATCH 16/42] Wired Data not read if empty --- .../habbohotel/items/interactions/InteractionWired.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 81964b85..095b905a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -58,7 +58,10 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public void loadWiredSettings(ResultSet set) throws SQLException, JsonProcessingException { String wiredData = set.getString("wired_data"); this.wiredSettings = new WiredSettings(); - this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); + + if(wiredData.startsWith("{")) { + this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class); + } } /** From 9fe1fd593e88bafeba319bec36b0b0b69e3075e4 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 17 Jul 2023 12:09:56 -0500 Subject: [PATCH 17/42] Supernova --- .../com/eu/habbo/core/CreditsScheduler.java | 2 +- src/main/java/com/eu/habbo/core/Easter.java | 2 +- .../eu/habbo/core/GotwPointsScheduler.java | 2 +- .../com/eu/habbo/core/PixelScheduler.java | 2 +- .../com/eu/habbo/core/PointsScheduler.java | 2 +- .../eu/habbo/core/RoomUserPetComposer.java | 8 +- .../eu/habbo/database/DatabaseConstants.java | 2 +- .../achievements/AchievementManager.java | 13 +- .../com/eu/habbo/habbohotel/bots/Bot.java | 96 +- .../eu/habbo/habbohotel/bots/BotManager.java | 65 +- .../eu/habbo/habbohotel/bots/ButlerBot.java | 16 +- .../eu/habbo/habbohotel/bots/VisitorBot.java | 4 +- .../campaign/CalendarRewardObject.java | 8 +- .../catalog/CatalogLimitedConfiguration.java | 4 +- .../habbohotel/catalog/CatalogManager.java | 20 +- .../catalog/layouts/RoomBundleLayout.java | 50 +- .../catalog/marketplace/MarketPlace.java | 8 +- .../catalog/marketplace/MarketPlaceOffer.java | 4 +- .../habbohotel/commands/CommandsManager.java | 39 +- .../commands/list/ArcturusCommand.java | 2 +- .../commands/list/BlockAlertCommand.java | 2 +- .../habbohotel/commands/list/BotsCommand.java | 6 +- .../commands/list/ControlCommand.java | 2 +- .../commands/list/CoordsCommand.java | 18 +- .../commands/list/DiagonalCommand.java | 6 +- .../commands/list/EjectAllCommand.java | 10 +- .../list/EmptyBotsInventoryCommand.java | 4 +- .../commands/list/EmptyInventoryCommand.java | 8 +- .../list/EmptyPetsInventoryCommand.java | 4 +- .../commands/list/EnableCommand.java | 4 +- .../commands/list/EventCommand.java | 6 +- .../commands/list/FacelessCommand.java | 4 +- .../commands/list/FastwalkCommand.java | 6 +- .../commands/list/FreezeBotsCommand.java | 8 +- .../commands/list/FreezeCommand.java | 2 +- .../commands/list/HabnamCommand.java | 4 +- .../commands/list/HandItemCommand.java | 4 +- .../commands/list/HideWiredCommand.java | 8 +- .../commands/list/InvisibleCommand.java | 4 +- .../habbohotel/commands/list/LayCommand.java | 16 +- .../commands/list/MimicCommand.java | 4 +- .../commands/list/MoonwalkCommand.java | 4 +- .../habbohotel/commands/list/MuteCommand.java | 4 +- .../commands/list/PetInfoCommand.java | 8 +- .../commands/list/PickallCommand.java | 4 +- .../habbohotel/commands/list/PullCommand.java | 12 +- .../habbohotel/commands/list/PushCommand.java | 12 +- .../commands/list/RedeemCommand.java | 10 +- .../commands/list/ReloadRoomCommand.java | 8 +- .../commands/list/RoomAlertCommand.java | 2 +- .../commands/list/RoomBundleCommand.java | 6 +- .../commands/list/RoomDanceCommand.java | 4 +- .../commands/list/RoomEffectCommand.java | 4 +- .../commands/list/RoomItemCommand.java | 4 +- .../commands/list/RoomKickCommand.java | 6 +- .../commands/list/RoomMuteCommand.java | 2 +- .../commands/list/RoomSitCommand.java | 4 +- .../commands/list/SayAllCommand.java | 2 +- .../habbohotel/commands/list/SayCommand.java | 4 +- .../commands/list/SetMaxCommand.java | 2 +- .../commands/list/SetPollCommand.java | 4 +- .../commands/list/SetSpeedCommand.java | 6 +- .../commands/list/ShoutAllCommand.java | 2 +- .../commands/list/ShoutCommand.java | 4 +- .../habbohotel/commands/list/SitCommand.java | 2 +- .../commands/list/SoftKickCommand.java | 6 +- .../commands/list/StalkCommand.java | 8 +- .../commands/list/StandCommand.java | 2 +- .../commands/list/SummonCommand.java | 14 +- .../commands/list/SummonRankCommand.java | 12 +- .../commands/list/SuperPullCommand.java | 8 +- .../commands/list/TeleportCommand.java | 6 +- .../commands/list/TransformCommand.java | 8 +- .../commands/list/UnloadRoomCommand.java | 4 +- .../commands/list/UnmuteCommand.java | 6 +- .../commands/list/UpdateItemsCommand.java | 2 +- .../commands/list/UserInfoCommand.java | 2 +- .../commands/list/WordQuizCommand.java | 4 +- .../commands/list/badge/RoomBadgeCommand.java | 2 +- .../commands/list/badge/TakeBadgeCommand.java | 4 +- .../commands/list/credits/CreditsCommand.java | 2 +- .../list/credits/MassCreditsCommand.java | 2 +- .../list/credits/RoomCreditsCommand.java | 2 +- .../commands/list/gift/BaseGiftCommand.java | 4 +- .../commands/list/gift/GiftCommand.java | 4 +- .../commands/list/gift/RoomGiftCommand.java | 2 +- .../list/pixels/MassPixelsCommand.java | 2 +- .../commands/list/pixels/PixelCommand.java | 2 +- .../list/pixels/RoomPixelsCommand.java | 2 +- .../list/points/MassPointsCommand.java | 2 +- .../commands/list/points/PointsCommand.java | 2 +- .../list/points/RoomPointsCommand.java | 2 +- .../com/eu/habbo/habbohotel/games/Game.java | 16 +- .../eu/habbo/habbohotel/games/GamePlayer.java | 4 +- .../games/battlebanzai/BattleBanzaiGame.java | 42 +- .../battlebanzai/BattleBanzaiGameTeam.java | 21 +- .../games/football/FootballGame.java | 6 +- .../habbohotel/games/freeze/FreezeGame.java | 14 +- .../games/freeze/FreezeGamePlayer.java | 8 +- .../games/freeze/FreezeGameTeam.java | 19 +- .../habbo/habbohotel/games/tag/TagGame.java | 55 +- .../habbohotel/games/wired/WiredGame.java | 13 +- .../habbo/habbohotel/guilds/GuildManager.java | 4 +- .../habbohotel/items/IEventTriggers.java | 2 +- .../com/eu/habbo/habbohotel/items/Item.java | 4 +- .../habbohotel/items/ItemInteraction.java | 4 +- .../habbo/habbohotel/items/ItemManager.java | 82 +- .../habbo/habbohotel/items/NewUserGift.java | 4 +- .../InteractionBackgroundToner.java | 12 +- .../interactions/InteractionBadgeDisplay.java | 6 +- .../interactions/InteractionBlackHole.java | 2 +- .../interactions/InteractionBuildArea.java | 22 +- .../items/interactions/InteractionCannon.java | 12 +- .../interactions/InteractionClothing.java | 6 +- .../interactions/InteractionColorPlate.java | 2 +- .../interactions/InteractionColorWheel.java | 6 +- .../interactions/InteractionCrackable.java | 10 +- .../interactions/InteractionCustomValues.java | 6 +- .../interactions/InteractionDefault.java | 50 +- .../items/interactions/InteractionDice.java | 8 +- .../interactions/InteractionEffectGate.java | 10 +- .../interactions/InteractionEffectGiver.java | 10 +- .../interactions/InteractionEffectTile.java | 8 +- .../InteractionEffectVendingMachine.java | 6 +- ...nteractionEffectVendingMachineNoSides.java | 6 +- .../InteractionExternalImage.java | 6 +- .../items/interactions/InteractionFXBox.java | 4 +- .../interactions/InteractionFireworks.java | 8 +- .../items/interactions/InteractionGate.java | 8 +- .../items/interactions/InteractionGift.java | 10 +- .../interactions/InteractionGuildFurni.java | 2 +- .../interactions/InteractionGuildGate.java | 2 +- .../interactions/InteractionGymEquipment.java | 35 +- .../interactions/InteractionHanditem.java | 19 +- .../interactions/InteractionHanditemTile.java | 4 +- .../items/interactions/InteractionHopper.java | 22 +- .../InteractionInformationTerminal.java | 2 +- .../interactions/InteractionJukeBox.java | 6 +- .../interactions/InteractionLoveLock.java | 12 +- .../interactions/InteractionMannequin.java | 6 +- .../InteractionMonsterCrackable.java | 2 +- .../interactions/InteractionMoodLight.java | 9 +- .../interactions/InteractionMultiHeight.java | 26 +- .../interactions/InteractionMusicDisc.java | 6 +- .../interactions/InteractionMuteArea.java | 10 +- .../interactions/InteractionObstacle.java | 48 +- .../interactions/InteractionOneWayGate.java | 80 +- .../items/interactions/InteractionPostIt.java | 6 +- .../items/interactions/InteractionPoster.java | 6 +- .../InteractionPressurePlate.java | 6 +- .../interactions/InteractionPushable.java | 36 +- .../interactions/InteractionPuzzleBox.java | 42 +- .../interactions/InteractionPyramid.java | 9 +- .../InteractionRentableSpace.java | 16 +- .../items/interactions/InteractionRoller.java | 10 +- .../interactions/InteractionRoomAds.java | 2 +- ...Gate.java => InteractionRoomClubGate.java} | 8 +- ...er.java => InteractionRoomClubHopper.java} | 6 +- ...a => InteractionRoomClubTeleportTile.java} | 8 +- .../InteractionSnowboardSlope.java | 19 +- .../InteractionSpinningBottle.java | 8 +- .../interactions/InteractionStackHelper.java | 6 +- .../items/interactions/InteractionSwitch.java | 6 +- .../InteractionSwitchRemoteControl.java | 2 +- .../interactions/InteractionTeleport.java | 85 +- .../interactions/InteractionTeleportTile.java | 4 +- .../InteractionTileEffectProvider.java | 11 +- .../items/interactions/InteractionTrap.java | 6 +- .../InteractionVendingMachine.java | 38 +- .../interactions/InteractionVoteCounter.java | 6 +- .../items/interactions/InteractionWater.java | 29 +- .../interactions/InteractionWaterItem.java | 8 +- .../items/interactions/InteractionWired.java | 4 +- .../interactions/InteractionWiredExtra.java | 2 +- .../InteractionWiredHighscore.java | 6 +- .../interactions/InteractionYoutubeTV.java | 7 +- .../games/InteractionGameGate.java | 2 +- .../games/InteractionGameTeamItem.java | 4 +- .../games/InteractionGameTimer.java | 6 +- .../InteractionBattleBanzaiPuck.java | 78 +- .../InteractionBattleBanzaiSphere.java | 6 +- .../InteractionBattleBanzaiTeleporter.java | 10 +- .../InteractionBattleBanzaiTile.java | 10 +- .../gates/InteractionBattleBanzaiGate.java | 4 +- .../InteractionBattleBanzaiScoreboard.java | 2 +- .../games/football/InteractionFootball.java | 98 +- .../football/InteractionFootballGate.java | 10 +- .../goals/InteractionFootballGoal.java | 2 +- .../InteractionFootballScoreboard.java | 6 +- .../games/freeze/InteractionFreezeBlock.java | 12 +- .../freeze/InteractionFreezeExitTile.java | 6 +- .../games/freeze/InteractionFreezeTile.java | 12 +- .../freeze/gates/InteractionFreezeGate.java | 4 +- .../InteractionFreezeScoreboard.java | 2 +- .../games/tag/InteractionTagField.java | 6 +- .../games/tag/InteractionTagPole.java | 6 +- .../tag/icetag/InteractionIceTagField.java | 2 +- .../InteractionRollerskateField.java | 2 +- .../interfaces/ConditionalGate.java | 2 +- .../pets/InteractionMonsterPlantSeed.java | 6 +- .../interactions/pets/InteractionNest.java | 10 +- .../pets/InteractionPetBreedingNest.java | 28 +- .../pets/InteractionPetDrink.java | 23 +- .../interactions/pets/InteractionPetFood.java | 10 +- .../interactions/pets/InteractionPetToy.java | 33 +- .../pets/InteractionPetTrampoline.java | 14 +- .../interactions/pets/InteractionPetTree.java | 39 +- .../totems/InteractionTotemHead.java | 4 +- .../totems/InteractionTotemLegs.java | 4 +- .../totems/InteractionTotemPlanet.java | 8 +- .../interactions/wired/WiredSettings.java | 8 +- .../WiredConditionDateRangeActive.java | 2 +- .../WiredConditionFurniHaveFurni.java | 8 +- ....java => WiredConditionFurniHaveRoom.java} | 25 +- .../WiredConditionFurniTypeMatch.java | 11 +- .../conditions/WiredConditionGroupMember.java | 8 +- .../WiredConditionLessTimeElapsed.java | 5 +- .../WiredConditionMatchStatePosition.java | 8 +- .../WiredConditionMoreTimeElapsed.java | 4 +- .../WiredConditionNotFurniHaveFurni.java | 7 +- ...va => WiredConditionNotFurniHaveRoom.java} | 25 +- .../WiredConditionNotFurniTypeMatch.java | 12 +- .../conditions/WiredConditionNotInGroup.java | 8 +- .../conditions/WiredConditionNotInTeam.java | 5 +- .../WiredConditionNotMatchStatePosition.java | 2 +- ...t.java => WiredConditionNotRoomCount.java} | 12 +- ...va => WiredConditionNotRoomHasEffect.java} | 12 +- ...a => WiredConditionNotRoomWearsBadge.java} | 8 +- .../WiredConditionNotTriggerOnFurni.java | 2 +- ...ount.java => WiredConditionRoomCount.java} | 13 +- ....java => WiredConditionRoomHasEffect.java} | 16 +- ...ava => WiredConditionRoomHasHandItem.java} | 13 +- ...java => WiredConditionRoomWearsBadge.java} | 11 +- .../conditions/WiredConditionTeamMember.java | 5 +- .../WiredConditionTriggerOnFurni.java | 10 +- .../wired/effects/WiredEffectAlert.java | 2 +- .../wired/effects/WiredEffectBotClothes.java | 10 +- ...bbo.java => WiredEffectBotFollowRoom.java} | 17 +- .../effects/WiredEffectBotGiveHandItem.java | 25 +- .../wired/effects/WiredEffectBotTalk.java | 15 +- ...bbo.java => WiredEffectBotTalkToRoom.java} | 22 +- .../wired/effects/WiredEffectBotTeleport.java | 44 +- .../effects/WiredEffectBotWalkToFurni.java | 22 +- .../WiredEffectChangeFurniDirection.java | 33 +- .../wired/effects/WiredEffectGiveEffect.java | 2 +- .../effects/WiredEffectGiveHandItem.java | 6 +- ...redEffectGiveHotelviewBonusRarePoints.java | 10 +- .../WiredEffectGiveHotelviewHofPoints.java | 8 +- .../wired/effects/WiredEffectGiveRespect.java | 8 +- .../wired/effects/WiredEffectGiveReward.java | 12 +- .../wired/effects/WiredEffectGiveScore.java | 5 +- .../effects/WiredEffectGiveScoreToTeam.java | 5 +- .../wired/effects/WiredEffectJoinTeam.java | 10 +- ...ickHabbo.java => WiredEffectKickRoom.java} | 17 +- .../wired/effects/WiredEffectLeaveTeam.java | 10 +- .../wired/effects/WiredEffectMatchFurni.java | 7 +- .../effects/WiredEffectMoveFurniAway.java | 50 +- .../wired/effects/WiredEffectMoveFurniTo.java | 16 +- .../effects/WiredEffectMoveFurniTowards.java | 78 +- .../effects/WiredEffectMoveRotateFurni.java | 36 +- ...uteHabbo.java => WiredEffectMuteRoom.java} | 8 +- .../wired/effects/WiredEffectResetTimers.java | 3 +- .../wired/effects/WiredEffectTeleport.java | 29 +- .../wired/effects/WiredEffectToggleFurni.java | 10 +- .../effects/WiredEffectToggleRandom.java | 13 +- .../effects/WiredEffectTriggerStacks.java | 11 +- .../wired/effects/WiredEffectWhisper.java | 4 +- .../interactions/wired/extra/WiredBlob.java | 2 +- .../wired/extra/WiredExtraRandom.java | 4 +- .../wired/extra/WiredExtraUnseen.java | 4 +- .../wired/interfaces/IWiredInteraction.java | 2 +- .../wired/triggers/WiredTriggerAtSetTime.java | 7 +- .../triggers/WiredTriggerAtTimeLong.java | 7 +- .../triggers/WiredTriggerBotReachedFurni.java | 13 +- ...o.java => WiredTriggerBotReachedRoom.java} | 13 +- .../wired/triggers/WiredTriggerCollision.java | 9 +- .../WiredTriggerFurniStateToggled.java | 12 +- .../wired/triggers/WiredTriggerGameEnds.java | 6 +- .../triggers/WiredTriggerGameStarts.java | 6 +- .../wired/triggers/WiredTriggerRepeater.java | 8 +- .../triggers/WiredTriggerRepeaterLong.java | 6 +- ...m.java => WiredTriggerRoomEntersRoom.java} | 8 +- ....java => WiredTriggerRoomSaysKeyword.java} | 13 +- ...java => WiredTriggerRoomWalkOffFurni.java} | 17 +- ....java => WiredTriggerRoomWalkOnFurni.java} | 12 +- .../triggers/WiredTriggerScoreAchieved.java | 5 +- .../habbohotel/messenger/MessengerBuddy.java | 4 +- .../habbohotel/modtool/ModToolIssue.java | 4 +- .../habbohotel/modtool/ModToolManager.java | 15 +- .../navigation/NavigatorManager.java | 2 +- .../navigation/NavigatorPublicCategory.java | 2 +- .../navigation/SearchResultList.java | 2 +- .../habbohotel/pets/MonsterplantPet.java | 25 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 149 +- .../eu/habbo/habbohotel/pets/PetCommand.java | 2 +- .../com/eu/habbo/habbohotel/pets/PetData.java | 32 +- .../eu/habbo/habbohotel/pets/PetManager.java | 14 +- .../habbohotel/pets/actions/ActionBreed.java | 4 +- .../habbohotel/pets/actions/ActionCroak.java | 4 +- .../habbohotel/pets/actions/ActionDip.java | 6 +- .../habbohotel/pets/actions/ActionDown.java | 6 +- .../habbohotel/pets/actions/ActionHang.java | 2 +- .../habbohotel/pets/actions/ActionHere.java | 2 +- .../pets/actions/ActionMoveForward.java | 2 +- .../pets/actions/ActionPlayDead.java | 2 +- .../pets/actions/ActionPlayFootball.java | 6 +- .../habbohotel/pets/actions/ActionRelax.java | 2 +- .../pets/actions/ActionRingOfFire.java | 2 +- .../habbohotel/pets/actions/ActionRoll.java | 2 +- .../habbohotel/pets/actions/ActionSit.java | 6 +- .../habbohotel/pets/actions/ActionSwing.java | 2 +- .../pets/actions/ActionTurnLeft.java | 6 +- .../pets/actions/ActionTurnRight.java | 6 +- .../habbohotel/pets/actions/ActionWave.java | 2 +- .../habbohotel/rooms/CustomRoomLayout.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 1783 +++++------------ .../habbohotel/rooms/RoomChatMessage.java | 15 +- .../eu/habbo/habbohotel/rooms/RoomInfo.java | 242 +++ .../habbohotel/rooms/RoomItemManager.java | 72 + .../eu/habbo/habbohotel/rooms/RoomLayout.java | 12 +- .../habbo/habbohotel/rooms/RoomManager.java | 521 ++--- .../habbo/habbohotel/rooms/RoomPromotion.java | 2 +- .../habbohotel/rooms/RoomSpecialTypes.java | 22 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 25 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 32 +- .../habbo/habbohotel/rooms/RoomTradeUser.java | 12 +- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 752 ------- .../habbohotel/rooms/RoomUnitManager.java | 439 ++++ .../habbohotel/rooms/RoomUserRotation.java | 56 - .../habbo/habbohotel/rooms/TraxManager.java | 24 +- .../rooms/entities/IRoomEntity.java | 31 + .../habbohotel/rooms/entities/RoomEntity.java | 58 + .../rooms/entities/RoomRotation.java | 56 + .../rooms/entities/items/ItemLimitedData.java | 13 + .../entities/items/RoomItem.java} | 44 +- .../entities/items/types/RoomFloorItem.java | 30 + .../entities/items/types/RoomWallItem.java | 30 + .../rooms/entities/units/IRoomUnit.java | 4 + .../rooms/entities/units/RoomUnit.java | 433 ++++ .../{ => entities/units}/RoomUnitType.java | 5 +- .../entities/units/types/RoomAvatar.java | 322 +++ .../rooms/entities/units/types/RoomBot.java | 15 + .../rooms/entities/units/types/RoomHabbo.java | 64 + .../rooms/entities/units/types/RoomPet.java | 208 ++ .../com/eu/habbo/habbohotel/units/Unit.java | 11 + .../com/eu/habbo/habbohotel/users/Habbo.java | 48 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 28 +- .../users/inventory/EffectsComponent.java | 4 +- .../users/inventory/ItemsComponent.java | 36 +- .../subscriptions/SubscriptionHabboClub.java | 4 +- .../wired/WiredChangeDirectionSetting.java | 4 +- .../habbo/habbohotel/wired/WiredHandler.java | 14 +- .../WiredHighscoreMidnightUpdater.java | 6 +- .../ambassadors/AmbassadorAlertEvent.java | 2 +- .../ambassadors/FollowFriendEvent.java | 4 +- .../incoming/camera/PurchasePhotoEvent.java | 6 +- .../incoming/camera/RenderRoomEvent.java | 6 +- .../camera/RenderRoomThumbnailEvent.java | 4 +- .../PurchaseFromCatalogAsGiftEvent.java | 18 +- .../catalog/marketplace/MakeOfferEvent.java | 4 +- .../catalog/recycler/PresentOpenEvent.java | 10 +- .../catalog/recycler/RecycleItemsEvent.java | 10 +- .../incoming/crafting/CraftEvent.java | 14 +- .../incoming/crafting/CraftSecretEvent.java | 22 +- .../crafting/GetCraftingRecipeEvent.java | 4 +- .../GetCraftingRecipesAvailableEvent.java | 14 +- .../GetOccupiedTilesEvent.java | 4 +- .../GetRoomEntryTileEvent.java | 6 +- .../UpdateFloorPropertiesEvent.java | 20 +- .../incoming/friends/FindNewFriendsEvent.java | 6 +- .../incoming/friends/VisitUserEvent.java | 6 +- .../GuideSessionGetRequesterRoomEvent.java | 2 +- .../GuideSessionInviteRequesterEvent.java | 2 +- .../guilds/AddAdminRightsToMemberEvent.java | 8 +- .../guilds/ApproveMembershipRequestEvent.java | 8 +- .../incoming/guilds/CreateGuildEvent.java | 16 +- .../incoming/guilds/DeactivateGuildEvent.java | 12 +- .../DeselectFavouriteHabboGroupEvent.java | 4 +- .../guilds/GetGuildCreationInfoEvent.java | 2 +- .../GetGuildFurniContextMenuInfoEvent.java | 6 +- .../guilds/GetMemberGuildItemCountEvent.java | 2 +- .../incoming/guilds/JoinHabboGroupEvent.java | 4 +- .../incoming/guilds/KickMemberEvent.java | 10 +- .../guilds/RejectMembershipRequestEvent.java | 4 +- .../RemoveAdminRightsFromMemberEvent.java | 4 +- .../SelectFavouriteHabboGroupEvent.java | 6 +- .../guilds/UpdateGuildBadgeEvent.java | 4 +- .../guilds/UpdateGuildColorsEvent.java | 10 +- .../guilds/UpdateGuildIdentityEvent.java | 8 +- .../guilds/UpdateGuildSettingsEvent.java | 2 +- .../incoming/hotelview/QuitEvent.java | 17 +- ...questFurniInventoryWhenNotInRoomEvent.java | 6 +- .../incoming/modtool/CallForHelpEvent.java | 4 +- .../modtool/CallForHelpFromPhotoEvent.java | 6 +- .../modtool/ChatReviewSessionCreateEvent.java | 4 +- .../incoming/modtool/GetCfhChatlogEvent.java | 4 +- .../modtool/GetModeratorRoomInfoEvent.java | 2 +- .../incoming/modtool/GetRoomChatlogEvent.java | 4 +- .../ModToolRequestRoomUserChatlogEvent.java | 4 +- .../incoming/modtool/ModerateRoomEvent.java | 2 +- .../modtool/ModeratorActionEvent.java | 2 +- .../incoming/navigator/CreateFlatEvent.java | 8 +- .../incoming/navigator/DeleteRoomEvent.java | 24 +- .../navigator/ForwardToSomeRoomEvent.java | 3 +- .../navigator/NewNavigatorSearchEvent.java | 2 +- .../navigator/PopularRoomsSearchEvent.java | 2 +- .../incoming/polls/AnswerPollEvent.java | 2 +- .../incoming/rooms/AddFavouriteRoomEvent.java | 2 +- .../rooms/DeleteFavouriteRoomEvent.java | 2 +- .../rooms/GetBannedUsersFromRoomEvent.java | 2 +- .../rooms/GetCustomRoomFilterEvent.java | 2 +- .../rooms/GetFlatControllersEvent.java | 4 +- .../incoming/rooms/GetGuestRoomEvent.java | 5 +- .../incoming/rooms/GetRoomEntryDataEvent.java | 4 +- .../incoming/rooms/GetRoomSettingsEvent.java | 2 +- .../incoming/rooms/LetUserInEvent.java | 22 +- .../incoming/rooms/MuteAllInRoomEvent.java | 4 +- .../rooms/OpenFlatConnectionEvent.java | 21 +- .../incoming/rooms/RateFlatEvent.java | 2 +- .../incoming/rooms/RemoveAllRightsEvent.java | 8 +- .../rooms/RemoveOwnRoomRightsRoomEvent.java | 2 +- .../incoming/rooms/RequestHeightmapEvent.java | 5 +- .../rooms/RequestRoomPropertySet.java | 16 +- .../incoming/rooms/SaveRoomSettingsEvent.java | 81 +- .../SetRoomBackgroundColorDataEvent.java | 6 +- .../rooms/SubmitRoomToCompetitionEvent.java | 9 +- .../incoming/rooms/ToggleStaffPickEvent.java | 9 +- .../incoming/rooms/UpdateRoomFilterEvent.java | 6 +- .../incoming/rooms/bots/CommandBotEvent.java | 8 +- .../GetBotCommandConfigurationDataEvent.java | 6 +- .../incoming/rooms/bots/PlaceBotEvent.java | 10 +- .../rooms/bots/RemoveBotFromFlatEvent.java | 4 +- .../rooms/items/AddSpamWallPostItEvent.java | 10 +- .../rooms/items/CreditFurniRedeemEvent.java | 6 +- .../items/CustomizeAvatarWithFurniEvent.java | 18 +- .../incoming/rooms/items/DiceOffEvent.java | 8 +- .../rooms/items/EnterOneWayDoorEvent.java | 8 +- .../rooms/items/GetItemDataEvent.java | 6 +- .../incoming/rooms/items/MoveObjectEvent.java | 6 +- .../rooms/items/MoveWallItemEvent.java | 14 +- .../rooms/items/PickupObjectEvent.java | 14 +- .../rooms/items/PlaceObjectEvent.java | 16 +- .../rooms/items/PlacePostItEvent.java | 12 +- .../incoming/rooms/items/RemoveItemEvent.java | 6 +- .../items/RoomDimmerChangeStateEvent.java | 11 +- .../items/RoomDimmerGetPresetsEvent.java | 6 +- .../items/RoomDimmerSavePresetEvent.java | 13 +- .../items/SetClothingChangeDataEvent.java | 8 +- .../items/SetCustomStackingHeightEvent.java | 18 +- .../rooms/items/SetItemDataEvent.java | 6 +- .../rooms/items/SetMannequinFigureEvent.java | 8 +- .../rooms/items/SetMannequinNameEvent.java | 8 +- .../rooms/items/SetObjectDataEvent.java | 6 +- .../rooms/items/SetRandomStateEvent.java | 6 +- .../rooms/items/SpinWheelOfFortuneEvent.java | 6 +- .../incoming/rooms/items/ThrowDiceEvent.java | 8 +- .../rooms/items/UseFurnitureEvent.java | 21 +- .../rooms/items/UseWallItemEvent.java | 6 +- .../items/jukebox/AddJukeboxDiskEvent.java | 8 +- .../rooms/items/jukebox/JukeboxEvent.java | 4 +- .../items/jukebox/RemoveJukeboxDiskEvent.java | 4 +- .../lovelock/FriendFurniConfirmLockEvent.java | 10 +- .../RentableSpaceCancelRentEvent.java | 8 +- .../rentablespace/RentableSpaceRentEvent.java | 6 +- .../ControlYoutubeDisplayPlaybackEvent.java | 8 +- .../youtube/GetYoutubeDisplayStatusEvent.java | 6 +- .../SetYoutubeDisplayPlaylistEvent.java | 8 +- .../rooms/items/youtube/YoutubeEvent.java | 4 +- .../incoming/rooms/pets/BreedPetsEvent.java | 6 +- .../rooms/pets/CancelPetBreedingEvent.java | 4 +- .../rooms/pets/CompostPlantEvent.java | 14 +- .../rooms/pets/ConfirmPetBreedingEvent.java | 4 +- .../pets/CustomizePetWithFurniEvent.java | 46 +- .../rooms/pets/GetPetCommandsEvent.java | 4 +- .../incoming/rooms/pets/GetPetInfoEvent.java | 4 +- .../incoming/rooms/pets/MountPetEvent.java | 15 +- .../incoming/rooms/pets/MovePetEvent.java | 13 +- .../rooms/pets/OpenPetPackageEvent.java | 10 +- .../incoming/rooms/pets/PlacePetEvent.java | 33 +- .../rooms/pets/RemovePetFromFlatEvent.java | 8 +- .../rooms/pets/RemoveSaddleFromPetEvent.java | 11 +- .../incoming/rooms/pets/RespectPetEvent.java | 12 +- .../TogglePetBreedingPermissionEvent.java | 2 +- .../pets/TogglePetRidingPermissionEvent.java | 6 +- .../rooms/promotions/EditEventEvent.java | 4 +- .../rooms/promotions/PurchaseRoomAdEvent.java | 4 +- .../rooms/users/AssignRightsEvent.java | 6 +- .../rooms/users/AvatarExpressionEvent.java | 4 +- .../rooms/users/CancelTypingEvent.java | 4 +- .../rooms/users/ChangePostureEvent.java | 6 +- .../incoming/rooms/users/ChatEvent.java | 2 +- .../incoming/rooms/users/DanceEvent.java | 8 +- .../rooms/users/DropCarryItemEvent.java | 2 +- .../rooms/users/GetUserTagsEvent.java | 4 +- .../incoming/rooms/users/IgnoreUserEvent.java | 2 +- .../incoming/rooms/users/LookToEvent.java | 19 +- .../incoming/rooms/users/MoveAvatarEvent.java | 202 +- .../rooms/users/PassCarryItemEvent.java | 6 +- .../rooms/users/RemoveRightsEvent.java | 4 +- .../rooms/users/RespectUserEvent.java | 2 +- .../rooms/users/RoomUserKickEvent.java | 6 +- .../rooms/users/RoomUserMuteEvent.java | 4 +- .../incoming/rooms/users/ShoutEvent.java | 4 +- .../incoming/rooms/users/SignEvent.java | 8 +- .../rooms/users/StartTypingEvent.java | 4 +- .../rooms/users/UnbanUserFromRoomEvent.java | 4 +- .../rooms/users/UnignoreUserEvent.java | 2 +- .../incoming/rooms/users/WhisperEvent.java | 4 +- .../incoming/trading/AcceptTradingEvent.java | 4 +- .../incoming/trading/AddItemToTradeEvent.java | 8 +- .../trading/AddItemsToTradeEvent.java | 10 +- .../trading/ConfirmAcceptTradingEvent.java | 2 +- .../incoming/trading/OpenTradingEvent.java | 6 +- .../trading/RemoveItemFromTradeEvent.java | 6 +- .../incoming/trading/TradingEvent.java | 2 +- .../trading/UnacceptTradingEvent.java | 2 +- .../users/AvatarEffectSelectedEvent.java | 4 +- .../incoming/users/ChangeMottoEvent.java | 4 +- .../incoming/users/ChangeUserNameEvent.java | 9 +- .../users/SetActivatedBadgesEvent.java | 4 +- .../incoming/users/UpdateFigureDataEvent.java | 4 +- .../incoming/wired/ApplySnapshotEvent.java | 14 +- .../incoming/wired/UpdateActionEvent.java | 4 +- .../incoming/wired/UpdateConditionEvent.java | 4 +- .../incoming/wired/UpdateTriggerEvent.java | 4 +- ...sionInvitedToGuideRoomMessageComposer.java | 4 +- ...deSessionRequesterRoomMessageComposer.java | 2 +- ...voriteMembershipUpdateMessageComposer.java | 4 +- .../GuildCreationInfoMessageComposer.java | 4 +- ...ldFurniContextMenuInfoMessageComposer.java | 4 +- .../FurniListAddOrUpdateComposer.java | 34 +- .../outgoing/inventory/FurniListComposer.java | 48 +- .../inventory/UnseenItemsComposer.java | 14 +- .../outgoing/modtool/CfhChatlogComposer.java | 4 +- .../modtool/ModeratorRoomInfoComposer.java | 20 +- .../outgoing/modtool/RoomChatlogComposer.java | 4 +- .../navigator/FlatCreatedComposer.java | 4 +- .../rooms/BannedUsersFromRoomComposer.java | 2 +- .../rooms/FlatControllerAddedComposer.java | 2 +- .../rooms/FlatControllerRemovedComposer.java | 2 +- .../rooms/FlatControllersComposer.java | 2 +- .../rooms/FloorHeightMapComposer.java | 2 +- .../rooms/GamePlayerValueMessageComposer.java | 2 +- .../rooms/GetGuestRoomResultComposer.java | 93 +- .../RoomChatSettingsMessageComposer.java | 10 +- .../outgoing/rooms/RoomEntryInfoComposer.java | 4 +- .../rooms/RoomEntryInfoMessageComposer.java | 2 +- .../RoomFloorThicknessUpdatedComposer.java | 6 +- .../rooms/RoomInfoUpdatedComposer.java | 2 +- .../rooms/RoomReadyMessageComposer.java | 2 +- .../rooms/RoomSettingsDataComposer.java | 50 +- .../rooms/RoomSettingsSavedComposer.java | 2 +- .../RoomVisualizationSettingsComposer.java | 6 +- .../items/FloorItemOnRollerComposer.java | 8 +- .../rooms/items/ItemAddMessageComposer.java | 4 +- .../items/ItemRemoveMessageComposer.java | 4 +- .../items/ItemUpdateMessageComposer.java | 4 +- .../outgoing/rooms/items/ItemsComposer.java | 6 +- .../rooms/items/ItemsDataUpdateComposer.java | 6 +- .../rooms/items/ObjectAddMessageComposer.java | 4 +- .../ObjectDataUpdateMessageComposer.java | 4 +- .../items/ObjectUpdateMessageComposer.java | 4 +- .../rooms/items/ObjectsMessageComposer.java | 6 +- .../OneWayDoorStatusMessageComposer.java | 4 +- .../items/PresentOpenedMessageComposer.java | 4 +- .../rooms/items/RemoveFloorItemComposer.java | 6 +- .../RequestSpamWallPostItMessageComposer.java | 4 +- .../UpdateStackHeightTileHeightComposer.java | 4 +- .../RentableSpaceStatusMessageComposer.java | 4 +- ...penPetPackageRequestedMessageComposer.java | 4 +- .../rooms/pets/PetExperienceComposer.java | 2 +- .../rooms/pets/PetFigureUpdateComposer.java | 2 +- .../rooms/pets/PetLevelUpdatedComposer.java | 2 +- .../rooms/pets/PetStatusUpdateComposer.java | 2 +- .../outgoing/rooms/pets/RoomPetComposer.java | 22 +- .../RoomAdPurchaseInfoComposer.java | 4 +- .../rooms/promotions/RoomEventComposer.java | 8 +- .../users/AvatarEffectMessageComposer.java | 12 +- .../users/CarryObjectMessageComposer.java | 8 +- .../rooms/users/DanceMessageComposer.java | 4 +- .../users/ExpressionMessageComposer.java | 4 +- .../HandItemReceivedMessageComposer.java | 4 +- .../rooms/users/NoSuchFlatComposer.java | 2 +- .../rooms/users/RoomUnitOnRollerComposer.java | 28 +- .../rooms/users/RoomUsersComposer.java | 32 +- .../rooms/users/SleepMessageComposer.java | 4 +- .../users/UserChangeMessageComposer.java | 2 +- .../users/UserNameChangedMessageComposer.java | 2 +- .../users/UserRemoveMessageComposer.java | 4 +- .../rooms/users/UserTagsMessageComposer.java | 2 +- .../users/UserTypingMessageComposer.java | 4 +- .../users/UserUnbannedFromRoomComposer.java | 2 +- .../rooms/users/UserUpdateComposer.java | 14 +- .../trading/TradingItemListComposer.java | 4 +- .../unknown/PostItPlacedComposer.java | 4 +- ...oomMessageNotificationMessageComposer.java | 4 +- .../messages/outgoing/wired/OpenComposer.java | 4 +- .../habbo/messages/rcon/ChangeRoomOwner.java | 22 +- .../eu/habbo/messages/rcon/ForwardUser.java | 6 +- .../com/eu/habbo/messages/rcon/SendGift.java | 4 +- .../com/eu/habbo/messages/rcon/SetMotto.java | 2 +- .../com/eu/habbo/messages/rcon/StalkUser.java | 6 +- .../eu/habbo/messages/rcon/UpdateUser.java | 4 +- .../furniture/FurnitureBuildheightEvent.java | 4 +- .../furniture/FurnitureDiceRolledEvent.java | 4 +- .../events/furniture/FurnitureEvent.java | 6 +- .../events/furniture/FurnitureMovedEvent.java | 4 +- .../furniture/FurniturePickedUpEvent.java | 4 +- .../furniture/FurniturePlacedEvent.java | 4 +- .../furniture/FurnitureRedeemedEvent.java | 4 +- .../furniture/FurnitureRolledEvent.java | 6 +- .../furniture/FurnitureRoomTonerEvent.java | 4 +- .../furniture/FurnitureRotatedEvent.java | 4 +- .../furniture/FurnitureToggleEvent.java | 4 +- .../events/furniture/FurnitureUserEvent.java | 4 +- .../wired/WiredConditionFailedEvent.java | 2 +- .../wired/WiredStackExecutedEvent.java | 2 +- .../wired/WiredStackTriggeredEvent.java | 2 +- .../inventory/InventoryItemAddedEvent.java | 4 +- .../events/inventory/InventoryItemEvent.java | 6 +- .../inventory/InventoryItemRemovedEvent.java | 4 +- .../inventory/InventoryItemsAddedEvent.java | 6 +- .../MarketPlaceItemOfferedEvent.java | 6 +- .../marketplace/MarketPlaceItemSoldEvent.java | 6 +- .../events/rooms/RoomFloorItemsLoadEvent.java | 10 +- .../plugin/events/roomunit/RoomUnitEvent.java | 2 +- .../roomunit/RoomUnitLookAtPointEvent.java | 2 +- .../events/roomunit/RoomUnitSetGoalEvent.java | 2 +- .../plugin/events/users/UserRolledEvent.java | 6 +- .../UserCatalogFurnitureBoughtEvent.java | 6 +- .../UserCatalogItemPurchasedEvent.java | 6 +- .../runnables/BackgroundAnimation.java | 4 +- .../runnables/BanzaiRandomTeleport.java | 18 +- .../runnables/BattleBanzaiTilesFlicker.java | 8 +- .../threading/runnables/BotFollowHabbo.java | 8 +- .../threading/runnables/CannonKickAction.java | 10 +- .../threading/runnables/ClearRentedSpace.java | 8 +- .../habbo/threading/runnables/CloseGate.java | 15 +- .../threading/runnables/CrackableExplode.java | 6 +- .../runnables/HabboGiveHandItemToHabbo.java | 12 +- .../runnables/HabboItemNewState.java | 6 +- .../threading/runnables/KickBallAction.java | 10 +- .../runnables/OneWayGateActionOne.java | 6 +- .../habbo/threading/runnables/OpenGift.java | 12 +- .../threading/runnables/PetFollowHabbo.java | 6 +- .../runnables/QueryDeleteHabboItem.java | 4 +- .../runnables/QueryDeleteHabboItems.java | 6 +- .../threading/runnables/RandomDiceNumber.java | 8 +- .../runnables/RandomSpinningBottleNumber.java | 8 +- .../runnables/RemoveFloorItemTask.java | 4 +- .../threading/runnables/RoomTrashing.java | 18 +- .../runnables/RoomUnitGiveHanditem.java | 10 +- .../threading/runnables/RoomUnitKick.java | 3 +- .../threading/runnables/RoomUnitRidePet.java | 20 +- .../threading/runnables/RoomUnitTeleport.java | 18 +- .../RoomUnitTeleportWalkToAction.java | 12 +- .../RoomUnitVendingMachineAction.java | 12 +- .../runnables/RoomUnitWalkToLocation.java | 6 +- .../runnables/RoomUnitWalkToRoomUnit.java | 6 +- .../threading/runnables/SaveScoreForTeam.java | 4 +- .../runnables/SendRoomUnitEffectComposer.java | 8 +- .../runnables/TeleportInteraction.java | 38 +- .../runnables/WiredCollissionRunnable.java | 2 +- .../threading/runnables/WiredExecuteTask.java | 20 +- .../runnables/WiredRepeatEffectTask.java | 8 +- .../threading/runnables/YouAreAPirate.java | 2 +- .../runnables/YoutubeAdvanceVideo.java | 2 +- .../runnables/freeze/FreezeClearEffects.java | 7 +- .../freeze/FreezeHandleSnowballExplosion.java | 9 +- .../freeze/FreezeResetExplosionTiles.java | 4 +- .../runnables/freeze/FreezeThrowSnowball.java | 4 +- .../threading/runnables/games/GameTimer.java | 2 +- .../runnables/hopper/HopperActionFive.java | 4 +- .../runnables/hopper/HopperActionFour.java | 4 +- .../runnables/hopper/HopperActionOne.java | 10 +- .../runnables/hopper/HopperActionThree.java | 16 +- .../runnables/hopper/HopperActionTwo.java | 4 +- .../teleport/TeleportActionFive.java | 12 +- .../teleport/TeleportActionFour.java | 6 +- .../runnables/teleport/TeleportActionOne.java | 12 +- .../teleport/TeleportActionThree.java | 24 +- .../runnables/teleport/TeleportActionTwo.java | 8 +- 682 files changed, 6196 insertions(+), 5707 deletions(-) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{InteractionHabboClubGate.java => InteractionRoomClubGate.java} (86%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{InteractionHabboClubHopper.java => InteractionRoomClubHopper.java} (79%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{InteractionHabboClubTeleportTile.java => InteractionRoomClubTeleportTile.java} (70%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionFurniHaveHabbo.java => WiredConditionFurniHaveRoom.java} (62%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionNotFurniHaveHabbo.java => WiredConditionNotFurniHaveRoom.java} (62%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionNotHabboCount.java => WiredConditionNotRoomCount.java} (52%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionNotHabboHasEffect.java => WiredConditionNotRoomHasEffect.java} (52%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionNotHabboWearsBadge.java => WiredConditionNotRoomWearsBadge.java} (67%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionHabboCount.java => WiredConditionRoomCount.java} (70%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionHabboHasEffect.java => WiredConditionRoomHasEffect.java} (63%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionHabboHasHandItem.java => WiredConditionRoomHasHandItem.java} (66%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/{WiredConditionHabboWearsBadge.java => WiredConditionRoomWearsBadge.java} (73%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/{WiredEffectBotFollowHabbo.java => WiredEffectBotFollowRoom.java} (65%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/{WiredEffectBotTalkToHabbo.java => WiredEffectBotTalkToRoom.java} (79%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/{WiredEffectKickHabbo.java => WiredEffectKickRoom.java} (73%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/{WiredEffectMuteHabbo.java => WiredEffectMuteRoom.java} (84%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/{WiredTriggerBotReachedHabbo.java => WiredTriggerBotReachedRoom.java} (51%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/{WiredTriggerHabboEntersRoom.java => WiredTriggerRoomEntersRoom.java} (74%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/{WiredTriggerHabboSaysKeyword.java => WiredTriggerRoomSaysKeyword.java} (69%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/{WiredTriggerHabboWalkOffFurni.java => WiredTriggerRoomWalkOffFurni.java} (58%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/{WiredTriggerHabboWalkOnFurni.java => WiredTriggerRoomWalkOnFurni.java} (64%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java delete mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java delete mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomRotation.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/ItemLimitedData.java rename src/main/java/com/eu/habbo/habbohotel/{users/HabboItem.java => rooms/entities/items/RoomItem.java} (91%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java create 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/rooms/entities/units/IRoomUnit.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java rename src/main/java/com/eu/habbo/habbohotel/rooms/{ => entities/units}/RoomUnitType.java (73%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/units/Unit.java diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java index 2c691133..62e2cffd 100644 --- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java @@ -45,7 +45,7 @@ public class CreditsScheduler extends Scheduler { try { if (habbo != null) { - if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) + if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW) continue; if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) diff --git a/src/main/java/com/eu/habbo/core/Easter.java b/src/main/java/com/eu/habbo/core/Easter.java index 40b57a6c..0c0007bf 100644 --- a/src/main/java/com/eu/habbo/core/Easter.java +++ b/src/main/java/com/eu/habbo/core/Easter.java @@ -15,7 +15,7 @@ public class Easter { if (Emulator.getConfig().getBoolean("easter_eggs.enabled") && event.getNewMotto().equalsIgnoreCase("crickey!")) { event.habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getNewMotto(), event.habbo, event.habbo, RoomChatMessageBubbles.ALERT))); - Room room = event.habbo.getHabboInfo().getCurrentRoom(); + Room room = event.habbo.getRoomUnit().getRoom(); room.sendComposer(new UserRemoveMessageComposer(event.habbo.getRoomUnit()).compose()); room.sendComposer(new RoomUserPetComposer(2, 1, "FFFFFF", event.habbo).compose()); diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java index 8b19429c..66c70e8b 100644 --- a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java @@ -45,7 +45,7 @@ public class GotwPointsScheduler extends Scheduler { try { if (habbo != null) { - if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) + if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW) continue; if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java index ac36ec14..0bd440bf 100644 --- a/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java @@ -40,7 +40,7 @@ public class PixelScheduler extends Scheduler { habbo = map.getValue(); try { if (habbo != null) { - if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) + if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW) continue; if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java index 1fce2860..664026f3 100644 --- a/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java @@ -44,7 +44,7 @@ public class PointsScheduler extends Scheduler { try { if (habbo != null) { - if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) + if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW) continue; if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) diff --git a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java index 515334d5..0b6926e5 100644 --- a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java +++ b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java @@ -22,10 +22,10 @@ public class RoomUserPetComposer extends MessageComposer { this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendString(""); this.response.appendString(this.petType + " " + this.race + " " + this.color + " 2 2 -1 0 3 -1 0"); - this.response.appendInt(this.habbo.getRoomUnit().getId()); - this.response.appendInt(this.habbo.getRoomUnit().getX()); - this.response.appendInt(this.habbo.getRoomUnit().getY()); - this.response.appendString(this.habbo.getRoomUnit().getZ() + ""); + this.response.appendInt(this.habbo.getRoomUnit().getVirtualId()); + this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(this.habbo.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(2); this.response.appendInt(this.petType); diff --git a/src/main/java/com/eu/habbo/database/DatabaseConstants.java b/src/main/java/com/eu/habbo/database/DatabaseConstants.java index 5b4a706f..4a55cb3f 100644 --- a/src/main/java/com/eu/habbo/database/DatabaseConstants.java +++ b/src/main/java/com/eu/habbo/database/DatabaseConstants.java @@ -4,4 +4,4 @@ public class DatabaseConstants { public static final String CAUGHT_SQL_EXCEPTION = "Caught SQL exception"; public final static String USER_ID = "user_id"; -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java index a7c23ace..37e1e048 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.achievements; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.achievements.AchievementComposer; import com.eu.habbo.messages.outgoing.achievements.AchievementUnlockedComposer; import com.eu.habbo.messages.outgoing.achievements.talenttrack.TalentLevelUpComposer; @@ -17,7 +17,6 @@ import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.users.achievements.UserAchievementLeveledEvent; import com.eu.habbo.plugin.events.users.achievements.UserAchievementProgressEvent; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TObjectIntProcedure; import lombok.extern.slf4j.Slf4j; import java.sql.*; @@ -155,8 +154,8 @@ public class AchievementManager { Emulator.getThreading().run(badge); - if (badge.getSlot() > 0 && habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); + if (badge.getSlot() > 0 && habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); } habbo.getClient().sendResponse(new UnseenItemsComposer(badge.getId(), UnseenItemsComposer.AddHabboItemCategory.BADGE)); @@ -167,8 +166,8 @@ public class AchievementManager { habbo.givePoints(newLevel.getRewardType(), newLevel.getRewardAmount()); } - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } } } @@ -339,7 +338,7 @@ public class AchievementManager { if (level != null) { if (level.items != null && !level.items.isEmpty()) { for (Item item : level.items) { - HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); + RoomItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); habbo.getInventory().getItemsComponent().addItem(rewardItem); habbo.getClient().sendResponse(new UnseenItemsComposer(rewardItem)); habbo.getClient().sendResponse(new FurniListInvalidateComposer()); diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index b10086cf..6eb9d81d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -3,6 +3,9 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; +import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -13,6 +16,9 @@ import com.eu.habbo.plugin.events.bots.BotShoutEvent; import com.eu.habbo.plugin.events.bots.BotTalkEvent; import com.eu.habbo.plugin.events.bots.BotWhisperEvent; import com.eu.habbo.threading.runnables.BotFollowHabbo; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; @@ -24,7 +30,7 @@ import java.util.Arrays; import java.util.List; @Slf4j -public class Bot implements Runnable { +public class Bot extends Unit implements Runnable { public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); @@ -37,7 +43,6 @@ public class Bot implements Runnable { private int ownerId; private String ownerName; private Room room; - private RoomUnit roomUnit; private boolean chatAuto; private boolean chatRandom; private short chatDelay; @@ -45,19 +50,15 @@ public class Bot implements Runnable { private int chatTimestamp; private short lastChatIndex; private final int bubble; - - private final String type; - - private int effect; - private transient boolean canWalk = true; - private boolean needsUpdate; - - private transient int followingHabboId; + @Getter + @Setter + @Accessors(chain = true) + private RoomBot roomUnit; public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) { this.id = id; @@ -92,10 +93,11 @@ public class Bot implements Runnable { this.effect = set.getInt("effect"); this.canWalk = set.getString("freeroam").equals("1"); this.room = null; - this.roomUnit = null; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.needsUpdate = false; this.bubble = set.getInt("bubble_id"); + + this.roomUnit = new RoomBot(); } public Bot(Bot bot) { @@ -141,9 +143,9 @@ public class Bot implements Runnable { statement.setString(3, this.figure); statement.setString(4, this.gender.toString()); statement.setInt(5, this.ownerId); - statement.setInt(6, this.room == null ? 0 : this.room.getId()); - statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue()); - statement.setInt(8, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType()); + statement.setInt(6, this.room == null ? 0 : this.room.getRoomInfo().getId()); + statement.setInt(7, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getBodyRotation().getValue()); + statement.setInt(8, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getDanceType().getType()); statement.setString(9, this.canWalk ? "1" : "0"); StringBuilder text = new StringBuilder(); for (String s : this.chatLines) { @@ -165,18 +167,18 @@ public class Bot implements Runnable { } public void cycle(boolean allowBotsWalk) { - if (this.roomUnit != null) { + if (this.getRoomUnit() != null) { if (allowBotsWalk && this.canWalk) { - if (!this.roomUnit.isWalking()) { - if (this.roomUnit.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) { - this.roomUnit.setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.room.getLayout().getRandomWalkableTilesAround(this.roomUnit, this.room.getLayout().getTile(this.roomUnit.getBotStartLocation().getX(), this.roomUnit.getBotStartLocation().getY()), this.room, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.room.getRandomWalkableTile()); + if (!this.getRoomUnit().isWalking()) { + if (this.getRoomUnit().getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) { + this.getRoomUnit().setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.room.getLayout().getRandomWalkableTilesAround(this.getRoomUnit(), this.room.getLayout().getTile(this.getRoomUnit().getBotStartLocation().getX(), this.getRoomUnit().getBotStartLocation().getY()), this.room, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.room.getRandomWalkableTile()); int timeOut = Emulator.getRandom().nextInt(20) * 2; - this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); + this.getRoomUnit().setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); } }/* else { for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) { - WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray()); + WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.getRoomUnit(), this.room, this.room.getItemsAt(t).toArray()); } }*/ } @@ -190,11 +192,11 @@ public class Bot implements Runnable { } String message = this.chatLines.get(this.lastChatIndex) - .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getOwnerName()) + .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getRoomInfo().getOwnerInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name) - .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + ""); + .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getRoomInfo().getName()) + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getRoomUnitManager().getRoomHabbosCount() + ""); if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) { this.talk(message); @@ -213,10 +215,10 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); + this.room.botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { - this.room.sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose()); + this.room.sendComposer(new ExpressionMessageComposer(this.getRoomUnit(), RoomUserAction.WAVE).compose()); } } } @@ -228,10 +230,10 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); + this.room.botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { - this.room.sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose()); + this.room.sendComposer(new ExpressionMessageComposer(this.getRoomUnit(), RoomUserAction.WAVE).compose()); } } } @@ -243,13 +245,13 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - event.getTarget().getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId())))); + event.getTarget().getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId())))); } } public void onPlace(Habbo habbo, Room room) { - if (this.roomUnit != null) { - room.giveEffect(this.roomUnit, this.effect, -1); + if (this.getRoomUnit() != null) { + room.giveEffect(this.getRoomUnit(), this.effect, -1); } if(PLACEMENT_MESSAGES.length > 0) { @@ -357,14 +359,6 @@ public class Bot implements Runnable { this.room = room; } - public RoomUnit getRoomUnit() { - return this.roomUnit; - } - - public void setRoomUnit(RoomUnit roomUnit) { - this.roomUnit = roomUnit; - } - public boolean isChatAuto() { return this.chatAuto; } @@ -420,9 +414,9 @@ public class Bot implements Runnable { this.effect = effect; this.needsUpdate = true; - if (this.roomUnit != null) { + if (this.getRoomUnit() != null) { if (this.room != null) { - this.room.giveEffect(this.roomUnit, this.effect, duration); + this.room.giveEffect(this.getRoomUnit(), this.effect, duration); } } } @@ -452,7 +446,7 @@ public class Bot implements Runnable { public void startFollowingHabbo(Habbo habbo) { this.followingHabboId = habbo.getHabboInfo().getId(); - Emulator.getThreading().run(new BotFollowHabbo(this, habbo, habbo.getHabboInfo().getCurrentRoom())); + Emulator.getThreading().run(new BotFollowHabbo(this, habbo, habbo.getRoomUnit().getRoom())); } public void stopFollowingHabbo() { @@ -468,16 +462,16 @@ public class Bot implements Runnable { } public void lookAt(Habbo habbo) { - this.lookAt(habbo.getRoomUnit().getCurrentLocation()); + this.lookAt(habbo.getRoomUnit().getCurrentPosition()); } public void lookAt(RoomUnit roomUnit) { - this.lookAt(roomUnit.getCurrentLocation()); + this.lookAt(roomUnit.getCurrentPosition()); } public void lookAt(RoomTile tile) { - this.roomUnit.lookAtPoint(tile); - this.roomUnit.statusUpdate(true); + this.getRoomUnit().lookAtPoint(tile); + this.getRoomUnit().setStatusUpdateNeeded(true); } public void onPlaceUpdate() { @@ -487,12 +481,12 @@ public class Bot implements Runnable { statement.setString(3, this.figure); statement.setString(4, this.gender.toString()); statement.setInt(5, this.ownerId); - statement.setInt(6, this.room == null ? 0 : this.room.getId()); - statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getX()); - statement.setInt(8, this.roomUnit == null ? 0 : this.roomUnit.getY()); - statement.setDouble(9, this.roomUnit == null ? 0 : this.roomUnit.getZ()); - statement.setInt(10, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue()); - statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType()); + statement.setInt(6, this.room == null ? 0 : this.room.getRoomInfo().getId()); + statement.setInt(7, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentPosition().getX()); + statement.setInt(8, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentPosition().getY()); + statement.setDouble(9, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentZ()); + statement.setInt(10, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getBodyRotation().getValue()); + statement.setInt(11, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getDanceType().getType()); statement.setString(12, this.canWalk ? "1" : "0"); StringBuilder text = new StringBuilder(); for (String s : this.chatLines) { diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 2d5e03b8..53261255 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -2,10 +2,16 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -21,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; import java.sql.*; import java.util.Map; + @Slf4j public class BotManager { @@ -98,41 +105,44 @@ public class BotManager { public void placeBot(Bot bot, Habbo habbo, Room room, RoomTile location) { BotPlacedEvent event = new BotPlacedEvent(bot, location, habbo); + Emulator.getPluginManager().fireEvent(event); if (event.isCancelled()) return; if (room != null && bot != null && habbo != null) { - if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_PLACEFURNI)) { - if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS)) { + if (room.getRoomInfo().isRoomOwner(habbo) || habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomUnitManager().getCurrentRoomBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS)) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } - if (room.hasHabbosAt(location.getX(), location.getY()) || (!location.isWalkable() && location.getState() != RoomTileState.SIT && location.getState() != RoomTileState.LAY)) + if (room.getRoomUnitManager().hasHabbosAt(location) || (!location.isWalkable() && location.getState() != RoomTileState.SIT && location.getState() != RoomTileState.LAY)) return; - if (room.hasBotsAt(location.getX(), location.getY())) { + if (!room.getRoomUnitManager().getBotsAt(location).isEmpty()) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); return; } - RoomUnit roomUnit = new RoomUnit(); - roomUnit.setRotation(RoomUserRotation.SOUTH); - roomUnit.setLocation(location); + bot.setRoomUnit(new RoomBot()); + RoomBot roomBot = bot.getRoomUnit(); + roomBot.setRotation(RoomRotation.SOUTH); + roomBot.setLocation(location); double stackHeight = room.getTopHeightAt(location.getX(), location.getY()); - roomUnit.setPreviousLocationZ(stackHeight); - roomUnit.setZ(stackHeight); + roomBot.setPreviousLocationZ(stackHeight); + roomBot.setCurrentZ(stackHeight); + roomBot.setRoom(room); + roomBot.setRoomUnitType(RoomUnitType.BOT); + roomBot.setCanWalk(room.isAllowBotsWalk()); - roomUnit.setPathFinderRoom(room); - roomUnit.setRoomUnitType(RoomUnitType.BOT); - roomUnit.setCanWalk(room.isAllowBotsWalk()); - bot.setRoomUnit(roomUnit); bot.setRoom(room); + bot.onPlaceUpdate(); - room.addBot(bot); + + room.getRoomUnitManager().addRoomUnit(bot); Emulator.getThreading().run(bot); room.sendComposer(new RoomUsersComposer(bot).compose()); room.sendComposer(new UserUpdateComposer(bot.getRoomUnit()).compose()); @@ -140,7 +150,7 @@ public class BotManager { habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); bot.onPlace(habbo, room); - HabboItem topItem = room.getTopItemAt(location.getX(), location.getY()); + RoomItem topItem = room.getTopItemAt(location.getX(), location.getY()); if (topItem != null) { try { @@ -157,14 +167,15 @@ public class BotManager { } } - public void pickUpBot(int botId, Habbo habbo) { - if (habbo.getHabboInfo().getCurrentRoom() != null) { - this.pickUpBot(habbo.getHabboInfo().getCurrentRoom().getBot(Math.abs(botId)), habbo); + public void pickUpBot(int botId, Habbo habbo, Room room) { + if (habbo.getRoomUnit().getRoom() != null) { + this.pickUpBot(habbo.getRoomUnit().getRoom().getRoomUnitManager().getRoomBotById(Math.abs(botId)), habbo, room); } } - public void pickUpBot(Bot bot, Habbo habbo) { - HabboInfo receiverInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo(); + public void pickUpBot(Bot bot, Habbo habbo, Room room) { + HabboInfo botOwnerInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo(); + if (bot != null) { BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo); @@ -179,15 +190,15 @@ public class BotManager { return; } - bot.onPickUp(habbo, receiverInfo.getCurrentRoom()); - receiverInfo.getCurrentRoom().removeBot(bot); + bot.onPickUp(habbo, room); + room.getRoomUnitManager().removeBot(bot); bot.stopFollowingHabbo(); - bot.setOwnerId(receiverInfo.getId()); - bot.setOwnerName(receiverInfo.getUsername()); + bot.setOwnerId(botOwnerInfo.getId()); + bot.setOwnerName(botOwnerInfo.getUsername()); bot.needsUpdate(true); Emulator.getThreading().run(bot); - Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(receiverInfo.getId()) : habbo; + Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : habbo; if (receiver != null) { receiver.getInventory().getBotsComponent().addBot(bot); receiver.getClient().sendResponse(new BotAddedToInventoryComposer(bot)); diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index b3e992aa..c5148bc4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import com.eu.habbo.plugin.events.bots.BotServerItemEvent; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit; @@ -61,7 +62,7 @@ public class ButlerBot extends Bot { return; } - double distanceBetweenBotAndHabbo = this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()); + double distanceBetweenBotAndHabbo = this.getRoomUnit().getCurrentPosition().distance(message.getHabbo().getRoomUnit().getCurrentPosition()); if (distanceBetweenBotAndHabbo <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance")) { @@ -80,7 +81,7 @@ public class ButlerBot extends Bot { } // Start give handitem process - if (this.getRoomUnit().canWalk()) { + if (this.getRoomUnit().isCanWalk()) { final String key = keyword; final Bot bot = this; @@ -89,8 +90,8 @@ public class ButlerBot extends Bot { // Step 2: Prepare tasks for when the Bot (carrying the handitem) reaches the Habbo final List tasks = new ArrayList<>(); - tasks.add(new RoomUnitGiveHanditem(serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), serveEvent.getItemId())); - tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), 0)); + tasks.add(new RoomUnitGiveHanditem(serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId())); + tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), 0)); tasks.add(() -> { if (this.getRoom() != null) { @@ -115,16 +116,17 @@ public class ButlerBot extends Bot { }); // Give bot the handitem that it's going to give the Habbo - Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), serveEvent.getItemId())); + Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId())); if (distanceBetweenBotAndHabbo > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) { - Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3))); + Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3))); } else { Emulator.getThreading().run(failedReached.get(0), 1000); } } else { if (this.getRoom() != null) { - this.getRoom().giveHandItem(serveEvent.getHabbo(), serveEvent.getItemId()); + serveEvent.getHabbo().getRoomUnit().setHandItem(serveEvent.getItemId()); + this.getRoom().sendComposer(new CarryObjectMessageComposer(serveEvent.getHabbo().getRoomUnit()).compose()); String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.getHabbo().getHabboInfo().getUsername()); if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) { diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java index 130ff3b1..672dfff2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java @@ -55,8 +55,8 @@ public class VisitorBot extends Bot { public void onUserEnter(Habbo habbo) { if (!this.showedLog) { - if (habbo.getHabboInfo().getCurrentRoom() != null) { - this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getHabboInfo().getCurrentRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp(), habbo.getHabboInfo().getCurrentRoom().getOwnerName()); + if (habbo.getRoomUnit().getRoom() != null) { + this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getRoomUnit().getRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp(), habbo.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getUsername()); if (this.visits.isEmpty()) { this.talk(Emulator.getTexts().getValue("bots.visitor.no_visits")); diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java index d8b74fa3..e2832ab5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.campaign; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -71,14 +71,14 @@ public class CalendarRewardObject { Item item = getItem(); if (item != null) { - HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem( + RoomItem roomItem = Emulator.getGameEnvironment().getItemManager().createItem( habbo.getHabboInfo().getId(), item, 0, 0, ""); - habbo.getInventory().getItemsComponent().addItem(habboItem); - habbo.getClient().sendResponse(new UnseenItemsComposer(habboItem)); + habbo.getInventory().getItemsComponent().addItem(roomItem); + habbo.getClient().sendResponse(new UnseenItemsComposer(roomItem)); habbo.getClient().sendResponse(new FurniListInvalidateComposer()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java index babec10e..a29ef6d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -53,7 +53,7 @@ public class CatalogLimitedConfiguration implements Runnable { } } - public void limitedSold(int catalogItemId, Habbo habbo, HabboItem item) { + public void limitedSold(int catalogItemId, Habbo habbo, RoomItem item) { synchronized (lock) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items_limited SET user_id = ?, timestamp = ?, item_id = ? WHERE catalog_item_id = ? AND number = ? AND user_id = 0 LIMIT 1")) { statement.setInt(1, habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 33fb7916..81b32f9c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -17,7 +17,7 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -846,7 +846,7 @@ public class CatalogManager { } } - THashSet itemsList = new THashSet<>(); + THashSet itemsList = new THashSet<>(); if (amount > 1 && !CatalogItem.haveOffer(item)) { @@ -980,13 +980,13 @@ public class CatalogManager { } if (InteractionTeleport.class.isAssignableFrom(baseItem.getInteractionType().getType())) { - HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); - HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); + RoomItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); + RoomItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId()); itemsList.add(teleportOne); itemsList.add(teleportTwo); } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) { - HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); + RoomItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); Emulator.getGameEnvironment().getItemManager().insertHopper(hopper); @@ -1034,8 +1034,8 @@ public class CatalogManager { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicCollector")); } else { - HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); - itemsList.add(habboItem); + RoomItem roomItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); + itemsList.add(roomItem); } } } @@ -1062,12 +1062,12 @@ public class CatalogManager { if (purchasedEvent.itemsList != null && !purchasedEvent.itemsList.isEmpty()) { habbo.getClient().getHabbo().getInventory().getItemsComponent().addItems(purchasedEvent.itemsList); - unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(HabboItem::getId).toList()); + unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(RoomItem::getId).toList()); Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList)); if (limitedConfiguration != null) { - for (HabboItem itm : purchasedEvent.itemsList) { + for (RoomItem itm : purchasedEvent.itemsList) { limitedConfiguration.limitedSold(item.getId(), habbo, itm); } } @@ -1098,7 +1098,7 @@ public class CatalogManager { THashSet itemIds = new THashSet<>(); - for (HabboItem ix : purchasedEvent.itemsList) { + for (RoomItem ix : purchasedEvent.itemsList) { itemIds.add(ix.getId() + ""); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index de366cad..7d4de245 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomManager; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; @@ -40,7 +40,7 @@ public class RoomBundleLayout extends SingleBundle { if (this.room == null) { if (this.roomId > 0) { - this.room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId); + this.room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.roomId); if (this.room != null) this.room.preventUnloading = true; @@ -73,7 +73,7 @@ public class RoomBundleLayout extends SingleBundle { THashMap items = new THashMap<>(); - for (HabboItem i : this.room.getFloorItems()) { + for (RoomItem i : this.room.getFloorItems()) { if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } @@ -81,7 +81,7 @@ public class RoomBundleLayout extends SingleBundle { items.put(i.getBaseItem(), items.get(i.getBaseItem()) + 1); } - for (HabboItem i : this.room.getWallItems()) { + for (RoomItem i : this.room.getWallItems()) { if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } @@ -123,7 +123,7 @@ public class RoomBundleLayout extends SingleBundle { public void buyRoom(Habbo habbo, int userId, String userName) { if (!this.loaded) { - this.loadItems(Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId)); + this.loadItems(Emulator.getGameEnvironment().getRoomManager().getRoom(this.roomId)); } if (habbo != null) { @@ -141,11 +141,11 @@ public class RoomBundleLayout extends SingleBundle { this.room.save(); - for (HabboItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getFloorItems()) { item.run(); } - for (HabboItem item : this.room.getWallItems()) { + for (RoomItem item : this.room.getWallItems()) { item.run(); } @@ -156,7 +156,7 @@ public class RoomBundleLayout extends SingleBundle { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model) (SELECT ?, ?, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model FROM rooms WHERE id = ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, userId); statement.setString(2, userName); - statement.setInt(3, this.room.getId()); + statement.setInt(3, this.room.getRoomInfo().getId()); statement.execute(); try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) { @@ -173,15 +173,15 @@ public class RoomBundleLayout extends SingleBundle { statement.setInt(2, roomId); statement.setString(3, "0:0"); statement.setInt(4, 0); - statement.setInt(5, this.room.getId()); + statement.setInt(5, this.room.getRoomInfo().getId()); statement.execute(); } - if (this.room.hasCustomLayout()) { + if (this.room.getRoomInfo().isModelOverridden()) { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) (SELECT ?, ?, door_x, door_y, door_dir, heightmap FROM room_models_custom WHERE id = ? LIMIT 1)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, roomId); statement.setString(2, "custom_" + roomId); - statement.setInt(3, this.room.getId()); + statement.setInt(3, this.room.getRoomInfo().getId()); statement.execute(); } catch (SQLException e) { log.error("Caught SQL exception", e); @@ -190,17 +190,17 @@ public class RoomBundleLayout extends SingleBundle { if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { - synchronized (this.room.getCurrentBots()) { + synchronized (this.room.getRoomUnitManager().getCurrentRoomBots()) { statement.setInt(1, userId); statement.setInt(2, roomId); - for (Bot bot : this.room.getCurrentBots().valueCollection()) { + for (Bot bot : this.room.getRoomUnitManager().getCurrentRoomBots().values()) { statement.setString(3, bot.getName()); statement.setString(4, bot.getMotto()); statement.setString(5, bot.getFigure()); statement.setString(6, bot.getGender().name()); - statement.setInt(7, bot.getRoomUnit().getX()); - statement.setInt(8, bot.getRoomUnit().getY()); - statement.setDouble(9, bot.getRoomUnit().getZ()); + statement.setInt(7, bot.getRoomUnit().getCurrentPosition().getX()); + statement.setInt(8, bot.getRoomUnit().getCurrentPosition().getY()); + statement.setDouble(9, bot.getRoomUnit().getCurrentZ()); StringBuilder text = new StringBuilder(); for (String s : bot.getChatLines()) { text.append(s).append("\r"); @@ -221,17 +221,17 @@ public class RoomBundleLayout extends SingleBundle { log.error("Caught SQL exception", e); } - Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId); - r.setWallHeight(this.room.getWallHeight()); - r.setFloorSize(this.room.getFloorSize()); - r.setWallPaint(this.room.getWallPaint()); - r.setFloorPaint(this.room.getFloorPaint()); - r.setScore(0); + Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + r.getRoomInfo().setWallHeight(this.room.getRoomInfo().getWallHeight()); + r.getRoomInfo().setFloorThickness(this.room.getRoomInfo().getFloorThickness()); + r.getRoomInfo().setWallPaint(this.room.getRoomInfo().getWallPaint()); + r.getRoomInfo().setFloorPaint(this.room.getRoomInfo().getFloorPaint()); + r.getRoomInfo().setScore(0); r.setNeedsUpdate(true); THashMap keys = new THashMap<>(); - keys.put("ROOMNAME", r.getName()); - keys.put("ROOMID", r.getId() + ""); - keys.put("OWNER", r.getOwnerName()); + keys.put("ROOMNAME", r.getRoomInfo().getName()); + keys.put("ROOMID", r.getRoomInfo().getId() + ""); + keys.put("OWNER", r.getRoomInfo().getOwnerInfo().getUsername()); keys.put("image", "${image.library.url}/notifications/room_bundle_" + this.getId() + ".png"); if (habbo != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index e425f6ab..e0acb682 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.catalog.marketplace.GetMarketplaceOffersEvent; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceBuyOfferResultComposer; @@ -97,7 +97,7 @@ public class MarketPlace { selectItem.setInt(1, offer.getSoldItemId()); try (ResultSet set = selectItem.executeQuery()) { while (set.next()) { - HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); + RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); habbo.getInventory().getItemsComponent().addItem(item); habbo.getClient().sendResponse(new MarketplaceCancelOfferResultComposer(offer, true)); habbo.getClient().sendResponse(new UnseenItemsComposer(item)); @@ -273,7 +273,7 @@ public class MarketPlace { updateOffer.execute(); } Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(set.getInt(DatabaseConstants.USER_ID)); - HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet); + RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet); MarketPlaceItemSoldEvent event = new MarketPlaceItemSoldEvent(habbo, client.getHabbo(), item, set.getInt("price")); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { @@ -340,7 +340,7 @@ public class MarketPlace { } - public static boolean sellItem(GameClient client, HabboItem item, int price) { + public static boolean sellItem(GameClient client, RoomItem item, int price) { if (item == null || client == null) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java index cada0040..481a79a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -60,7 +60,7 @@ public class MarketPlaceOffer implements Runnable { } } - public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) { + public MarketPlaceOffer(RoomItem item, int price, Habbo habbo) { this.price = price; this.baseItem = item.getBaseItem(); this.itemId = item.getId(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java index 160a354c..8a996d27 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java @@ -3,12 +3,25 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.core.CommandLog; import com.eu.habbo.habbohotel.commands.list.*; -import com.eu.habbo.habbohotel.commands.list.badge.*; -import com.eu.habbo.habbohotel.commands.list.bans.*; -import com.eu.habbo.habbohotel.commands.list.credits.*; -import com.eu.habbo.habbohotel.commands.list.gift.*; -import com.eu.habbo.habbohotel.commands.list.pixels.*; -import com.eu.habbo.habbohotel.commands.list.points.*; +import com.eu.habbo.habbohotel.commands.list.badge.BadgeCommand; +import com.eu.habbo.habbohotel.commands.list.badge.MassBadgeCommand; +import com.eu.habbo.habbohotel.commands.list.badge.RoomBadgeCommand; +import com.eu.habbo.habbohotel.commands.list.badge.TakeBadgeCommand; +import com.eu.habbo.habbohotel.commands.list.bans.BanCommand; +import com.eu.habbo.habbohotel.commands.list.bans.IPBanCommand; +import com.eu.habbo.habbohotel.commands.list.bans.MachineBanCommand; +import com.eu.habbo.habbohotel.commands.list.bans.SuperbanCommand; +import com.eu.habbo.habbohotel.commands.list.credits.CreditsCommand; +import com.eu.habbo.habbohotel.commands.list.credits.MassCreditsCommand; +import com.eu.habbo.habbohotel.commands.list.credits.RoomCreditsCommand; +import com.eu.habbo.habbohotel.commands.list.gift.GiftCommand; +import com.eu.habbo.habbohotel.commands.list.gift.MassGiftCommand; +import com.eu.habbo.habbohotel.commands.list.pixels.MassPixelsCommand; +import com.eu.habbo.habbohotel.commands.list.pixels.PixelCommand; +import com.eu.habbo.habbohotel.commands.list.pixels.RoomPixelsCommand; +import com.eu.habbo.habbohotel.commands.list.points.MassPointsCommand; +import com.eu.habbo.habbohotel.commands.list.points.PointsCommand; +import com.eu.habbo.habbohotel.commands.list.points.RoomPointsCommand; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.PermissionCommand; @@ -73,11 +86,11 @@ public class CommandsManager { } String commandKey = parts[0]; - Room currentRoom = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room currentRoom = gameClient.getHabbo().getRoomUnit().getRoom(); boolean hasRights = currentRoom != null && (currentRoom.hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasRight(Permission.ACC_PLACEFURNI) || - currentRoom.getGuildId() > 0 && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS); + currentRoom.getRoomInfo().getGuild().getId() > 0 && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS); if (!gameClient.getHabbo().canExecuteCommand(commandKey, hasRights)) { @@ -127,17 +140,17 @@ public class CommandsManager { private boolean handlePetCommand(GameClient gameClient, String commandLine) { String[] args = commandLine.split(" "); - if (args.length <= 1 || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) { + if (args.length <= 1 || gameClient.getHabbo().getRoomUnit().getRoom() == null) { return false; } - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room.getCurrentPets().isEmpty()) { + if (room.getRoomUnitManager().getCurrentRoomPets().isEmpty()) { return false; } - for(Pet pet : room.getCurrentPets().valueCollection()) { + for(Pet pet : room.getRoomUnitManager().getCurrentRoomPets().values()) { if (pet != null && pet.getName().equalsIgnoreCase(args[0])) { StringBuilder commandBuilder = new StringBuilder(); @@ -150,7 +163,7 @@ public class CommandsManager { for (PetCommand command : pet.getPetData().getPetCommands()) { if (command.getKey().equalsIgnoreCase(commandKey)) { if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) { - rideablePet.getRider().getHabboInfo().dismountPet(); + rideablePet.getRider().getHabboInfo().dismountPet(room); break; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java index 6b3d8c94..d020247a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java @@ -11,7 +11,7 @@ public class ArcturusCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { gameClient.getHabbo().whisper("This hotel is powered by Arcturus Emulator! \r" + "Cet hôtel est alimenté par Arcturus émulateur! \r" + "Dit hotel draait op Arcturus Emulator! \r" + diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java index e7163ca4..bd95efcf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java @@ -11,7 +11,7 @@ public class BlockAlertCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { gameClient.getHabbo().getHabboStats().setBlockStaffAlerts(!gameClient.getHabbo().getHabboStats().isBlockStaffAlerts()); gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_blockalert").replace("%state%", (gameClient.getHabbo().getHabboStats().isBlockStaffAlerts() ? getTextsValue("generic.on") : getTextsValue("generic.off"))), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java index a5e8ac1d..7db71e8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java @@ -12,12 +12,12 @@ public class BotsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) + if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) return false; - StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values().length); + StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomBots().values().size()); - for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) { + for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomBots().values()) { data.append("\r"); data.append(""); data.append(Emulator.getTexts().getValue("generic.bot.name")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java index 76442da4..537e80bc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java @@ -12,7 +12,7 @@ public class ControlCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { if (params.length == 2) { Habbo target = getHabbo(params[1]); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java index 0bbac1d8..0cb80a4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java @@ -12,24 +12,24 @@ public class CoordsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getRoomUnit().getRoom() == null) return false; if (params.length == 1) { gameClient.getHabbo().alert(getTextsValue("commands.generic.cmd_coords.title") + "\r\n" + - "x: " + gameClient.getHabbo().getRoomUnit().getX() + "\r" + - "y: " + gameClient.getHabbo().getRoomUnit().getY() + "\r" + - "z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getZ()) + "\r" + + "x: " + gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX() + "\r" + + "y: " + gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY() + "\r" + + "z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getCurrentZ()) + "\r" + getTextsValue("generic.rotation.head") + ": " + gameClient.getHabbo().getRoomUnit().getHeadRotation() + "-" + gameClient.getHabbo().getRoomUnit().getHeadRotation().getValue() + "\r" + getTextsValue("generic.rotation.body") + ": " + gameClient.getHabbo().getRoomUnit().getBodyRotation() + "-" + gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() + "\r" + getTextsValue("generic.sitting") + ": " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" + - "Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getState().name() + "\r" + - "Tile Walkable: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).isWalkable() + "\r" + - "Tile relative height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).relativeHeight() + "\r" + - "Tile stack height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getStackHeight()); + "Tile State: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getState().name() + "\r" + + "Tile Walkable: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).isWalkable() + "\r" + + "Tile relative height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).relativeHeight() + "\r" + + "Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight()); } else { - RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2])); + RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2])); if (tile != null) { gameClient.getHabbo().alert(getTextsValue("commands.generic.cmd_coords.title") + "\r\n" + diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java index 6b841eea..7e1ca0f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java @@ -11,10 +11,10 @@ public class DiagonalCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()); + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) { + gameClient.getHabbo().getRoomUnit().getRoom().setDiagonalMoveEnabled(!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled()); - if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()) { + if (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled()) { gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_diagonal.disabled"), RoomChatMessageBubbles.ALERT); } else { gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_diagonal.enabled"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java index b68e8c12..f0927824 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java @@ -12,11 +12,13 @@ public class EjectAllCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room != null && (room.isOwner(gameClient.getHabbo()) - || (room.hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN)))) { - room.ejectAll(gameClient.getHabbo()); + if (room != null) { + if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) + || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { + room.ejectAll(gameClient.getHabbo()); + } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java index 316c5421..d2364227 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java @@ -19,8 +19,8 @@ public class EmptyBotsInventoryCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length == 1 || (params.length >= 2 && !params[1].equals(getTextsValue("generic.yes")))) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) { gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", getTextsValue("generic.yes"))); } else { gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java index 4298201e..d6dd555b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.FurniListComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; @@ -21,8 +21,8 @@ public class EmptyInventoryCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length == 1 || (params.length == 2 && !params[1].equals(getTextsValue("generic.yes")))) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) { gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", getTextsValue("generic.yes"))); } else { gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT); @@ -37,7 +37,7 @@ public class EmptyInventoryCommand extends Command { Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); if (habbo != null) { - TIntObjectMap items = new TIntObjectHashMap<>(); + TIntObjectMap items = new TIntObjectHashMap<>(); items.putAll(habbo.getInventory().getItemsComponent().getItems()); habbo.getInventory().getItemsComponent().getItems().clear(); Emulator.getThreading().run(new QueryDeleteHabboItems(items)); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java index d1679b9c..7c74e237 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java @@ -19,8 +19,8 @@ public class EmptyPetsInventoryCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length == 1 || (params.length >= 2 && !params[1].equals(getTextsValue("generic.yes")))) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) { gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", getTextsValue("generic.yes"))); } else { gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java index d1ea3825..87af068d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java @@ -33,13 +33,13 @@ public class EnableCommand extends Command { } if (target == gameClient.getHabbo() || gameClient.getHabbo().hasRight(Permission.ACC_ENABLE_OTHERS)) { try { - if (target.getHabboInfo().getCurrentRoom() != null && target.getHabboInfo().getRiding() == null) { + if (target.getRoomUnit().getRoom() != null && target.getHabboInfo().getRiding() == null) { if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT); return true; } - target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1); + target.getRoomUnit().getRoom().giveEffect(target, effectId, -1); } } catch (Exception e) { log.error("Caught exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java index 1ea5bf86..ed363e35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java @@ -18,14 +18,14 @@ public class EventCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || params.length < 2) { + if (gameClient.getHabbo().getRoomUnit().getRoom() == null || params.length < 2) { return false; } String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); THashMap codes = new THashMap<>(); - codes.put("ROOMNAME", gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName()); - codes.put("ROOMID", gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId() + ""); + codes.put("ROOMNAME", gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getName()); + codes.put("ROOMID", gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId() + ""); codes.put("USERNAME", gameClient.getHabbo().getHabboInfo().getUsername()); codes.put("LOOK", gameClient.getHabbo().getHabboInfo().getLook()); codes.put("TIME", Emulator.getDate().toString()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java index 88d9a95e..dbb4c7bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java @@ -13,7 +13,7 @@ public class FacelessCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() == null) { return false; } @@ -34,7 +34,7 @@ public class FacelessCommand extends Command { gameClient.getHabbo().getHabboInfo().setLook(gameClient.getHabbo().getHabboInfo().getLook().replace(part, newHead)); gameClient.sendResponse(new FigureUpdateComposer(gameClient.getHabbo())); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose()); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java index fc790173..65c9e5f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java @@ -11,9 +11,9 @@ public class FastwalkCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { //TODO Make this an event plugin which fires that can be cancelled - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getRiding() != null) + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getHabboInfo().getRiding() != null) return true; Habbo habbo = gameClient.getHabbo(); @@ -26,7 +26,7 @@ public class FastwalkCommand extends Command { if (habbo == null) return false; } - habbo.getRoomUnit().setFastWalk(!habbo.getRoomUnit().isFastWalk()); + habbo.getRoomUnit().setFastWalkEnabled(!habbo.getRoomUnit().isFastWalkEnabled()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java index 3e579fa8..ced95a10 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java @@ -12,14 +12,14 @@ public class FreezeBotsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() == null) { return false; } - if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() + if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().setAllowBotsWalk(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk()); - gameClient.getHabbo().whisper(gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk() ? getTextsValue("commands.succes.cmd_freeze_bots.unfrozen") : getTextsValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().getRoomUnit().getRoom().setAllowBotsWalk(!gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk()); + gameClient.getHabbo().whisper(gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk() ? getTextsValue("commands.succes.cmd_freeze_bots.unfrozen") : getTextsValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT); } else { gameClient.getHabbo().whisper(getTextsValue("generic.cannot_do_that"), RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java index de2ed0b0..ac9e3895 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java @@ -18,7 +18,7 @@ public class FreezeCommand extends Command { if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_freeze.not_found"), params[1]), RoomChatMessageBubbles.ALERT); } else { - if (habbo.getRoomUnit().canWalk()) { + if (habbo.getRoomUnit().isCanWalk()) { habbo.getRoomUnit().setCanWalk(false); habbo.whisper(getTextsValue("commands.succes.cmd_freeze.frozen"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_freeze.user_frozen"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java index 7c637fd4..e089d6ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java @@ -10,8 +10,8 @@ public class HabnamCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), 140, 30); + if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getRoomUnit().getRoom() != null) { + gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), 140, 30); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java index c14fba16..a2cd6844 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java @@ -13,10 +13,10 @@ public class HandItemCommand extends Command { public boolean handle(GameClient gameClient, String[] params) { if (params.length == 2) { try { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { int effectId = Integer.parseInt(params[1]); gameClient.getHabbo().getRoomUnit().setHandItem(effectId); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(gameClient.getHabbo().getRoomUnit()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(gameClient.getHabbo().getRoomUnit()).compose()); } } catch (Exception e) { //Don't handle incorrect parse exceptions :P diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java index a1a37ac0..1c1246e4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java @@ -11,14 +11,14 @@ public class HideWiredCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room == null) { return true; } - if (room.isOwner(gameClient.getHabbo())) { - room.setHideWired(!room.isHideWired()); - gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_hidewired." + (room.isHideWired() ? "hidden" : "shown"))); + if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) { + room.setHideWired(!room.getRoomInfo().isHiddenWiredEnabled()); + gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_hidewired." + (room.getRoomInfo().isHiddenWiredEnabled() ? "hidden" : "shown"))); } else { gameClient.getHabbo().whisper(getTextsValue("commands.errors.cmd_hidewired.permission")); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java index a89cf853..3d58cd98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; @@ -41,7 +41,7 @@ public class InvisibleCommand extends Command { roomUnit.setInvisible(true); gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_invisible.updated")); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserRemoveMessageComposer(roomUnit).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(roomUnit).compose()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java index 0961d2ba..62b402bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import java.util.stream.IntStream; @@ -19,24 +19,24 @@ public class LayCommand extends Command { if (gameClient.getHabbo().getRoomUnit() == null || !gameClient.getHabbo().getRoomUnit().canForcePosture()) return true; - gameClient.getHabbo().getRoomUnit().setCmdLay(true); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo()); - gameClient.getHabbo().getRoomUnit().setCmdSit(true); - gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomUserRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]); + gameClient.getHabbo().getRoomUnit().setCmdLayEnabled(true); + gameClient.getHabbo().getRoomUnit().getRoom().updateHabbo(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().setCmdSitEnabled(true); + gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]); - RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); + RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentPosition(); if (tile == null) { return false; } if (IntStream.range(0, 3) - .mapToObj(i -> gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(tile, gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue(), i)) + .mapToObj(i -> gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(tile, gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue(), i)) .anyMatch(t -> t == null || !t.isWalkable())) { return false; } gameClient.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.LAY, 0.5 + ""); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(gameClient.getHabbo().getRoomUnit()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(gameClient.getHabbo().getRoomUnit()).compose()); return true; } } \ No newline at end of file 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 91be1f99..110c1d9a 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().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.not_found"), ""), RoomChatMessageBubbles.ALERT); @@ -39,7 +39,7 @@ public class MimicCommand extends Command { gameClient.getHabbo().getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_MIMIC ? ClothingValidationManager.validateLook(gameClient.getHabbo(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getGender().name()) : habbo.getHabboInfo().getLook()); gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender()); gameClient.sendResponse(new UserObjectComposer(gameClient.getHabbo())); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose()); gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_mimic.copied"), params[1]).replace("%gender_name%", getGenderName(habbo)), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java index 5c03d536..e21db613 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java @@ -10,12 +10,12 @@ public class MoonwalkCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) { int effect = 136; if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136) effect = 0; - gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), effect, -1); + gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), effect, -1); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java index b92589b8..da3a6ab1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java @@ -46,8 +46,8 @@ public class MuteCommand extends Command { habbo.mute(duration, false); - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED } gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_mute.muted"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java index 5ffafb07..b7e27792 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java @@ -16,12 +16,12 @@ public class PetInfoCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pet_info.pet_not_found"), RoomChatMessageBubbles.ALERT); return true; } - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gameClient.getHabbo().getRoomUnit().getRoom() == null) return false; String name = params[1]; - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry((a, pet) -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomPets().forEach((a, pet) -> { if (pet.getName().equalsIgnoreCase(name)) { gameClient.getHabbo().alert("" + getTextsValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + @@ -37,11 +37,9 @@ public class PetInfoCommand extends Command { getTextsValue("generic.pet.level.thirst") + ": " + pet.levelThirst + "\r" + getTextsValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" + getTextsValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? getTextsValue("generic.nothing") : pet.getTask().name()) + "\r" + - getTextsValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "" + getTextsValue("generic.can.walk") + ": " + (pet.getRoomUnit().isCanWalk() ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "" ); } - - return true; }); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java index cd0d6887..9e7037fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java @@ -11,13 +11,13 @@ public class PickallCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room == null) { return true; } - if (room.isOwner(gameClient.getHabbo())) { + if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) { room.ejectAll(); return true; } 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 3b78f9db..bee583fa 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().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT); @@ -27,22 +27,22 @@ public class PullCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT); return true; } - int distanceX = habbo.getRoomUnit().getX() - gameClient.getHabbo().getRoomUnit().getX(); - int distanceY = habbo.getRoomUnit().getY() - gameClient.getHabbo().getRoomUnit().getY(); + int distanceX = habbo.getRoomUnit().getCurrentPosition().getX() - gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(); + int distanceY = habbo.getRoomUnit().getCurrentPosition().getY() - gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY(); if (distanceX < -2 || distanceX > 2 || distanceY < -2 || distanceY > 2) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.cant_reach"), params[1]), RoomChatMessageBubbles.ALERT); return true; } - RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); + RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); if (tile != null && tile.isWalkable()) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tile) { + if (gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile() == tile) { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1])); return true; } habbo.getRoomUnit().setGoalLocation(tile); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); } 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 e440af6f..f9679b42 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().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_push.not_found"), params[1]), RoomChatMessageBubbles.ALERT); @@ -29,19 +29,19 @@ public class PushCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_push.push_self"), RoomChatMessageBubbles.ALERT); return true; } - RoomTile tFront = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); + RoomTile tFront = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); if (tFront != null && tFront.isWalkable()) { - if (tFront.getX() == habbo.getRoomUnit().getX() && tFront.getY() == habbo.getRoomUnit().getY()) { - RoomTile tFrontTarget = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); + if (tFront.getX() == habbo.getRoomUnit().getCurrentPosition().getX() && tFront.getY() == habbo.getRoomUnit().getCurrentPosition().getY()) { + RoomTile tFrontTarget = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); if (tFrontTarget != null && tFrontTarget.isWalkable()) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tFrontTarget) { + if (gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile() == tFrontTarget) { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_push.invalid"), params[1])); return true; } habbo.getRoomUnit().setGoalLocation(tFrontTarget); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer( + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer( new ChatMessageComposer( new RoomChatMessage( replaceUser(getTextsValue("commands.succes.cmd_push.push"), params[1]) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java index a0b32f1c..91e9a483 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; import gnu.trove.map.TIntIntMap; @@ -20,16 +20,16 @@ public class RedeemCommand extends Command { @Override public boolean handle(final GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null) + if (gameClient.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null) return false; - ArrayList items = new ArrayList<>(); + ArrayList items = new ArrayList<>(); int credits = 0; int pixels = 0; TIntIntMap points = new TIntIntHashMap(); - for (HabboItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) { + for (RoomItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) { if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getUserId() == gameClient.getHabbo().getHabboInfo().getId()) { items.add(item); if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { @@ -63,7 +63,7 @@ public class RedeemCommand extends Command { } } - TIntObjectHashMap deleted = new TIntObjectHashMap<>(); + TIntObjectHashMap deleted = new TIntObjectHashMap<>(); items.forEach(item -> { gameClient.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); deleted.put(item.getId(), item); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java index 0dbd9e8c..371a0e7d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java @@ -19,12 +19,12 @@ public class ReloadRoomCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { Emulator.getThreading().run(() -> { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { - Collection habbos = new ArrayList<>(room.getHabbos()); + Collection habbos = new ArrayList<>(room.getRoomUnitManager().getRoomHabbos()); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); - room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); - ServerMessage message = new RoomForwardMessageComposer(room.getId()).compose(); + room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); + ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); habbos.forEach(habbo -> habbo.getClient().sendResponse(message)); } }, 100); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java index 36fff7ee..5a542b86 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java @@ -28,7 +28,7 @@ public class RoomAlertCommand extends Command { return true; } - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { room.sendComposer(new IssueCloseNotificationMessageComposer(message).compose()); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java index 958be816..f59d01c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java @@ -30,7 +30,7 @@ public class RoomBundleCommand extends Command { return true; } - if (Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()) != null) { + if (Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()) != null) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_bundle.duplicate"), RoomChatMessageBubbles.ALERT); return true; } @@ -40,7 +40,7 @@ public class RoomBundleCommand extends Command { points = Integer.parseInt(params[3]); pointsType = Integer.parseInt(params[4]); - CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName(), "room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId(), parentId); + CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getName(), "room_bundle_" + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId(), parentId); if (page instanceof RoomBundleLayout roomBundleLayout) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type ) VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { @@ -67,7 +67,7 @@ public class RoomBundleCommand extends Command { } catch (SQLException e) { log.error("Caught SQL exception", e); } - roomBundleLayout.loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); + roomBundleLayout.loadItems(gameClient.getHabbo().getRoomUnit().getRoom()); gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_bundle").replace("%id%", roomBundleLayout.getId() + ""), RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java index bf39fef0..90ef6b57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java @@ -28,9 +28,9 @@ public class RoomDanceCommand extends Command { return true; } - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { habbo.getRoomUnit().setDanceType(DanceType.values()[danceId]); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose()); }); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_danceall.no_dance"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java index d164a3a0..ebecd5fc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java @@ -21,8 +21,8 @@ public class RoomEffectCommand extends Command { int effectId = Integer.parseInt(params[1]); if (effectId >= 0) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - room.getHabbos().forEach(habbo -> room.giveEffect(habbo, effectId, -1)); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); + room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> room.giveEffect(habbo, effectId, -1)); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java index 0fd9b203..d58b7e89 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java @@ -29,9 +29,9 @@ public class RoomItemCommand extends Command { } } - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { habbo.getRoomUnit().setHandItem(itemId); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose()); } if (itemId > 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java index 6b0e8ae9..924d5c52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java @@ -17,15 +17,15 @@ public class RoomKickCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + final Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { if (params.length > 1) { String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); room.sendComposer(new HabboBroadcastMessageComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose()); } - for (Habbo habbo : room.getHabbos()) { - if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { + for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { + if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java index 3e97d0e6..d07c0bdc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java @@ -13,7 +13,7 @@ public class RoomMuteCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { room.setMuted(!room.isMuted()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java index 0f375fbe..0938a9eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java @@ -11,13 +11,13 @@ public class RoomSitCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { if (habbo.getRoomUnit().isWalking()) { habbo.getRoomUnit().stopWalking(); } else if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { return; } - gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(habbo); + gameClient.getHabbo().getRoomUnit().getRoom().makeSit(habbo); }); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java index 262a6ee0..ed798452 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java @@ -21,7 +21,7 @@ public class SayAllCommand extends Command { String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> habbo.talk(message)); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> habbo.talk(message)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java index 3320b9d3..70dbe876 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java @@ -28,7 +28,7 @@ public class SayCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_say.user_not_found"), RoomChatMessageBubbles.ALERT); return true; } else { - if (target.getHabboInfo().getCurrentRoom() == null) { + if (target.getRoomUnit().getRoom() == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_say.hotel_view"), params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -39,7 +39,7 @@ public class SayCommand extends Command { message = IntStream.range(2, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); } - target.getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); + target.getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_say"), params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java index c512e42d..2081a269 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java @@ -20,7 +20,7 @@ public class SetMaxCommand extends Command { } if (max > 0 && max < 9999) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().setUsersMax(max); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().setMaxUsers(max); gameClient.getHabbo().whisper(getTextsValue("commands.success.cmd_setmax").replace("%value%", max + ""), RoomChatMessageBubbles.ALERT); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_setmax.invalid_number"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java index 3682b784..cc2e030f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java @@ -17,7 +17,7 @@ public class SetPollCommand extends Command { return true; } - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { int pollId = -1; try { pollId = Integer.parseInt(params[1]); @@ -25,7 +25,7 @@ public class SetPollCommand extends Command { if (pollId >= 0) { if (Emulator.getGameEnvironment().getPollManager().getPoll(pollId) != null) { - gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPollId(pollId); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().setPollId(pollId); gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_set_poll"), RoomChatMessageBubbles.ALERT); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_set_poll.not_found"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java index 9525c6fc..b8bbffea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java @@ -13,10 +13,10 @@ public class SetSpeedCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) { + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - int oldSpeed = room.getRollerSpeed(); + int oldSpeed = room.getRoomInfo().getRollerSpeed(); int newSpeed; try { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java index 128339ac..73befe08 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java @@ -22,7 +22,7 @@ public class ShoutAllCommand extends Command { String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { habbo.shout(message); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java index a19529e2..32bb8a85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java @@ -29,7 +29,7 @@ public class ShoutCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_shout.user_not_found"), RoomChatMessageBubbles.ALERT); return true; } else { - if (target.getHabboInfo().getCurrentRoom() == null) { + if (target.getRoomUnit().getRoom() == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_shout.hotel_view"), params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -40,7 +40,7 @@ public class ShoutCommand extends Command { message = IntStream.range(2, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); } - target.getHabboInfo().getCurrentRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); + target.getRoomUnit().getRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_shout"), params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java index 0e8703f0..5994315a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java @@ -11,7 +11,7 @@ public class SitCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled - gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().getRoom().makeSit(gameClient.getHabbo()); return true; } } 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 8bd98051..e9cf4562 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().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.keys.cmd_softkick_error"), params[1]), RoomChatMessageBubbles.ALERT); @@ -27,9 +27,9 @@ public class SoftKickCommand extends Command { return true; } - final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + final Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room != null && (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo)))) { + if (room != null && (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo)))) { room.kickHabbo(habbo, false); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java index 928a1d55..e1b41502 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java @@ -13,7 +13,7 @@ public class StalkCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gameClient.getHabbo().getRoomUnit().getRoom() == null) return true; if (params.length >= 2) { @@ -24,7 +24,7 @@ public class StalkCommand extends Command { return true; } - if (habbo.getHabboInfo().getCurrentRoom() == null) { + if (habbo.getRoomUnit().getRoom() == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_stalk.not_room"), params[1]), RoomChatMessageBubbles.ALERT); return true; } @@ -34,12 +34,12 @@ public class StalkCommand extends Command { return true; } - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { + if (gameClient.getHabbo().getRoomUnit().getRoom() == habbo.getRoomUnit().getRoom()) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.generic.cmd_stalk.same_room"), params[1]), RoomChatMessageBubbles.ALERT); return true; } - gameClient.sendResponse(new GetGuestRoomResultComposer(habbo.getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false)); + gameClient.sendResponse(new GetGuestRoomResultComposer(habbo.getRoomUnit().getRoom(), gameClient.getHabbo(), true, false)); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_stalk.forgot_username"), RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java index f14e36b6..7d47c562 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java @@ -11,7 +11,7 @@ public class StandCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) - gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeStand(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().getRoom().makeStand(gameClient.getHabbo()); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java index f889259b..83c9c42c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java @@ -15,7 +15,7 @@ public class SummonCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gameClient.getHabbo().getRoomUnit().getRoom() == null) return true; if (params.length < 2) { @@ -35,23 +35,21 @@ public class SummonCommand extends Command { return true; } - if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { + if (gameClient.getHabbo().getRoomUnit().getRoom() == habbo.getRoomUnit().getRoom()) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.generic.cmd_summon.same_room"), params[1]), RoomChatMessageBubbles.ALERT); return true; } - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room != null) { Emulator.getGameEnvironment().getRoomManager().logExit(habbo); - room.removeHabbo(habbo, true); - - habbo.getHabboInfo().setCurrentRoom(null); + room.getRoomUnitManager().removeHabbo(habbo, true); } - Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); + Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), "", true); - habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId())); + habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId())); gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_summon.summoned"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java index efc1ef4b..07e38c0b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java @@ -30,21 +30,19 @@ public class SummonRankCommand extends Command { if (habbo == gameClient.getHabbo()) continue; - if (habbo.getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom()) + if (habbo.getRoomUnit().getRoom() == gameClient.getHabbo().getRoomUnit().getRoom()) continue; - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room != null) { Emulator.getGameEnvironment().getRoomManager().logExit(habbo); - room.removeHabbo(habbo, true); - - habbo.getHabboInfo().setCurrentRoom(null); + room.getRoomUnitManager().removeHabbo(habbo, true); } - Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); + Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), "", true); - habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId())); + habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId())); } } 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 a783adea..400ef81c 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().getHabboInfo().getCurrentRoom().getHabbo(params[1]); + Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]); if (habbo == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT); @@ -29,15 +29,15 @@ public class SuperPullCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT); return true; } else { - RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); + RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); if (tile != null && tile.isWalkable()) { - if (tile == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile()) { + if (tile == gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile()) { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]), RoomChatMessageBubbles.ALERT); return true; } habbo.getRoomUnit().setGoalLocation(tile); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java index b39d024a..d1f67b33 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java @@ -16,12 +16,12 @@ public class TeleportCommand extends Command { return true; } - if (gameClient.getHabbo().getRoomUnit().isCmdTeleport()) { - gameClient.getHabbo().getRoomUnit().setCmdTeleport(false); + if (gameClient.getHabbo().getRoomUnit().isCmdTeleportEnabled()) { + gameClient.getHabbo().getRoomUnit().setCmdTeleportEnabled(false); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.disabled"), RoomChatMessageBubbles.ALERT); return true; } else { - gameClient.getHabbo().getRoomUnit().setCmdTeleport(true); + gameClient.getHabbo().getRoomUnit().setCmdTeleportEnabled(true); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.enabled"), RoomChatMessageBubbles.ALERT); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java index f59c6498..5f6f0b8d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java @@ -5,8 +5,8 @@ import com.eu.habbo.core.RoomUserPetComposer; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.pets.PetData; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.messages.outgoing.generic.alerts.MOTDNotificationComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; @@ -57,8 +57,8 @@ public class TransformCommand extends Command { gameClient.getHabbo().getHabboStats().getCache().put("pet_type", petData); gameClient.getHabbo().getHabboStats().getCache().put("pet_race", race); gameClient.getHabbo().getHabboStats().getCache().put("pet_color", color); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserRemoveMessageComposer(gameClient.getHabbo().getRoomUnit()).compose()); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(gameClient.getHabbo().getRoomUnit()).compose()); + gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose()); } else { //Pet Not Found return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java index 99c157f5..31245b31 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java @@ -13,9 +13,9 @@ public class UnloadRoomCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room != null && (room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room != null && (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { room.dispose(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java index 29b65f1d..cb0c4e42 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java @@ -25,13 +25,13 @@ public class UnmuteCommand extends Command { return true; } - if (!habbo.getHabboStats().allowTalk() || (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo))) { + if (!habbo.getHabboStats().allowTalk() || (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo))) { if (!habbo.getHabboStats().allowTalk()) { habbo.unMute(); } - if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { - habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1); + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo)) { + habbo.getRoomUnit().getRoom().muteHabbo(habbo, 1); } gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_unmute"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java index ccfeae37..b2e1be1c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java @@ -19,7 +19,7 @@ public class UpdateItemsCommand extends Command { synchronized (Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) { Emulator.getGameEnvironment().getRoomManager().getActiveRooms().stream() - .filter(room -> room.isLoaded() && room.getUserCount() > 0 && room.getLayout() != null) + .filter(room -> room.isLoaded() && room.getRoomUnitManager().getRoomHabbosCount() > 0 && room.getLayout() != null) .forEach(room -> room.sendComposer(new HeightMapComposer(room).compose())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java index 39cb7f8f..6b89e602 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java @@ -71,7 +71,7 @@ public class UserInfoCommand extends Command { message.append(getTextsValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r"); } - message.append("\r").append(onlineHabbo != null ? "" + getTextsValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().getRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().getPetRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().isBlockFollowing()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().isBlockFriendRequests()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : ""); + message.append("\r").append(onlineHabbo != null ? "" + getTextsValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getRoomUnit().getRoom() != null ? onlineHabbo.getRoomUnit().getRoom().getRoomInfo().getName() + "(" + onlineHabbo.getRoomUnit().getRoom().getRoomInfo().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().getRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().getPetRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().isBlockFollowing()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().isBlockFriendRequests()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java index 8c5b8508..f3954e0b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java @@ -13,7 +13,7 @@ public class WordQuizCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) { + if (!gameClient.getHabbo().getRoomUnit().getRoom().hasActiveWordQuiz()) { if(params.length == 1) { gameClient.getHabbo().whisper(getTextsValue("commands.description.cmd_word_quiz"), RoomChatMessageBubbles.ALERT); return true; @@ -31,7 +31,7 @@ public class WordQuizCommand extends Command { question.append(" ").append(params[i]); } - gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000); + gameClient.getHabbo().getRoomUnit().getRoom().startWordQuiz(question.toString(), duration * 1000); } return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java index 45b38c4b..ee2ee8c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java @@ -20,7 +20,7 @@ public class RoomBadgeCommand extends BaseBadgeCommand { if (!badge.isEmpty()) { ServerMessage message = createServerMessage(badge); - gameClient.getHabbo().getRoomUnit().getRoom().getHabbos() + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos() .forEach(habbo -> sendBadgeToClient(badge, message, habbo)); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java index 9ed7ffe4..923ca3e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java @@ -41,8 +41,8 @@ public class TakeBadgeCommand extends BaseBadgeCommand { } habbo.getClient().sendResponse(new BadgesComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java index def03e2a..8b362593 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java @@ -32,7 +32,7 @@ public class CreditsCommand extends BaseCreditsCommand { if (habbo != null) { if (credits != 0) { habbo.giveCredits(credits); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), params[2]), RoomChatMessageBubbles.ALERT); else habbo.alert(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), params[2])); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java index 74f1ed68..7a68c283 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java @@ -32,7 +32,7 @@ public class MassCreditsCommand extends BaseCreditsCommand { habbo.giveCredits(amount); habbo.getClient().sendResponse(new CreditBalanceComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), amount + ""), RoomChatMessageBubbles.ALERT); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java index cb895fbb..d3193eb5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java @@ -22,7 +22,7 @@ public class RoomCreditsCommand extends BaseCreditsCommand { if (amount != 0) { final String message = replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), amount + ""); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { habbo.giveCredits(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java index efd07557..da9a9040 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import java.util.stream.Collectors; @@ -49,7 +49,7 @@ public abstract class BaseGiftCommand extends Command { } protected void createGift(String finalMessage, Habbo habbo, String[] params) { - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, getBaseItem(params), 0, 0, ""); + RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, getBaseItem(params), 0, 0, ""); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java index c360e3d6..9ea0bad4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -55,7 +55,7 @@ public class GiftCommand extends BaseGiftCommand { String message = params.length > 3 ? IntStream.range(3, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()) : ""; - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); + RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId() + "\t0\t0\t0\t" + message + "\t0\t0"; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java index f36f9886..a590effb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java @@ -17,7 +17,7 @@ public class RoomGiftCommand extends BaseGiftCommand { final String finalMessage = getFinalMessage(params); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { createGift(finalMessage, habbo, params); habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_ITEM)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java index 447f8cea..fd9eb5f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java @@ -30,7 +30,7 @@ public class MassPixelsCommand extends BasePixelsCommand { habbo.givePixels(amount); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), amount + ""), RoomChatMessageBubbles.ALERT); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java index ec4c0a28..2cbc0f4f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java @@ -21,7 +21,7 @@ public class PixelCommand extends BasePixelsCommand { try { if (Integer.parseInt(params[2]) != 0) { habbo.givePixels(Integer.parseInt(params[2])); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), params[2]), RoomChatMessageBubbles.ALERT); else habbo.alert(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), params[2])); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java index ef838f7f..518e3bb4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java @@ -22,7 +22,7 @@ public class RoomPixelsCommand extends BasePixelsCommand { if (amount != 0) { final String message = replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), amount + ""); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { habbo.givePixels(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java index c8890cdc..71ccb991 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java @@ -58,7 +58,7 @@ public class MassPointsCommand extends BasePointsCommand { for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) { habbo.givePoints(type, amount); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(message, RoomChatMessageBubbles.ALERT); else habbo.alert(message); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java index 23b3451b..dce20efb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java @@ -48,7 +48,7 @@ public class PointsCommand extends BasePointsCommand { if (amount != 0) { habbo.givePoints(type, amount); - if (habbo.getHabboInfo().getCurrentRoom() != null) + if (habbo.getRoomUnit().getRoom() != null) habbo.whisper(replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT); else habbo.alert(replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type))); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java index 40f82a89..e431be43 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java @@ -55,7 +55,7 @@ public class RoomPointsCommand extends BasePointsCommand { if (amount != 0) { final String message = replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type)); - for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { habbo.givePoints(type, amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index aa50cea7..e9acec7b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry; import com.eu.habbo.messages.outgoing.guides.YouArePlayingGameMessageComposer; @@ -120,7 +120,7 @@ public abstract class Game implements Runnable { Emulator.getPluginManager().fireEvent(gameStartedEvent); } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { ((WiredBlob) item).onGameStart(this.room); } @@ -136,7 +136,7 @@ public abstract class Game implements Runnable { int totalPointsGained = this.teams.values().stream().mapToInt(GameTeam::getTotalScore).sum(); - Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getOwnerId()); + Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getRoomInfo().getOwnerInfo().getId()); if (roomOwner != null) { AchievementManager.progressAchievement(roomOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GameAuthorExperience"), totalPointsGained); } @@ -161,7 +161,7 @@ public abstract class Game implements Runnable { } if (winningTeam.getMembers().size() > 0) { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp())); } } @@ -174,19 +174,19 @@ public abstract class Game implements Runnable { } if (team.getMembers().size() > 0 && team.getTotalScore() > 0) { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), team.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), team.getTotalScore(), false, Emulator.getIntUnixTimestamp())); } } } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { ((InteractionWiredHighscore) item).reloadData(); this.room.updateItem(item); } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { ((WiredBlob) item).onGameEnd(this.room); } } @@ -209,7 +209,7 @@ public abstract class Game implements Runnable { this.state = GameState.IDLE; boolean gamesActive = false; - for (HabboItem timer : room.getFloorItems()) { + for (RoomItem timer : room.getFloorItems()) { if (timer instanceof InteractionGameTimer) { if (((InteractionGameTimer) timer).isRunning()) gamesActive = true; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index b3653c11..781bd3ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -24,7 +24,7 @@ public class GamePlayer { } public synchronized void addScore(int amount, boolean isWired) { - if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { + if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getRoomUnit().getRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { this.score += amount; if (this.score < 0) this.score = 0; @@ -33,7 +33,7 @@ public class GamePlayer { this.wiredScore += amount; } - WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); + WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getRoomUnit().getRoom(), new Object[]{this.habbo.getRoomUnit().getRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index 33f83e3b..27b98156 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -12,7 +12,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker; import gnu.trove.map.hash.THashMap; @@ -35,8 +35,8 @@ public class BattleBanzaiGame extends Game { public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock", 1); private static final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Emulator.getConfig().getInt("hotel.banzai.fill.threads", 2)); - private final THashMap> lockedTiles; - private final THashMap gameTiles; + private final THashMap> lockedTiles; + private final THashMap gameTiles; private int tileCount; private int countDown; private int countDown2; @@ -69,7 +69,7 @@ public class BattleBanzaiGame extends Game { } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("1"); this.room.updateItemState(item); } @@ -104,7 +104,7 @@ public class BattleBanzaiGame extends Game { this.countDown--; if (this.countDown == 0) { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("1"); this.room.updateItemState(item); if(this.countDown2 > 0) { @@ -130,7 +130,7 @@ public class BattleBanzaiGame extends Game { int total = 0; synchronized (this.lockedTiles) { - for (Map.Entry> set : this.lockedTiles.entrySet()) { + for (Map.Entry> set : this.lockedTiles.entrySet()) { total += set.getValue().size(); } } @@ -146,7 +146,7 @@ public class BattleBanzaiGame extends Game { } if (highestScore != null) { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata((highestScore.teamColor.type + 2) + ""); this.room.updateItemState(item); } @@ -194,7 +194,7 @@ public class BattleBanzaiGame extends Game { } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata((6 + winningTeam.teamColor.type) + ""); this.room.updateItemState(item); } @@ -212,7 +212,7 @@ public class BattleBanzaiGame extends Game { this.refreshGates(); - for (HabboItem tile : this.gameTiles.values()) { + for (RoomItem tile : this.gameTiles.values()) { if (tile.getExtradata().equals("1")) { tile.setExtradata("0"); this.room.updateItem(tile); @@ -226,7 +226,7 @@ public class BattleBanzaiGame extends Game { private synchronized void resetMap() { this.tileCount = 0; - for (HabboItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getFloorItems()) { if (item instanceof InteractionBattleBanzaiTile) { item.setExtradata("1"); this.room.updateItemState(item); @@ -242,11 +242,11 @@ public class BattleBanzaiGame extends Game { } - public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) { + public void tileLocked(GameTeamColors teamColor, RoomItem item, Habbo habbo) { this.tileLocked(teamColor, item, habbo, false); } - public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) { + public void tileLocked(GameTeamColors teamColor, RoomItem item, Habbo habbo, boolean doNotCheckFill) { synchronized (this.lockedTiles) { if (item instanceof InteractionBattleBanzaiTile) { if (!this.lockedTiles.containsKey(teamColor)) { @@ -266,7 +266,7 @@ public class BattleBanzaiGame extends Game { final int y = item.getY(); final List> filledAreas = new ArrayList<>(); - final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); + final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); executor.execute(() -> { filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor)); @@ -278,7 +278,7 @@ public class BattleBanzaiGame extends Game { if (largestAreaOfAll.isPresent()) { for (RoomTile tile : largestAreaOfAll.get()) { - Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.getX() && i.getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny(); + Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.getX() && i.getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny(); tileItem.ifPresent(habboItem -> { this.tileLocked(teamColor, habboItem, habbo, true); @@ -297,7 +297,7 @@ public class BattleBanzaiGame extends Game { } } - private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) { + private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) { if (this.isOutOfBounds(x, y) || this.isForeignLockedTile(x, y, color)) return null; RoomTile tile = this.room.getLayout().getTile((short) x, (short) y); @@ -320,8 +320,8 @@ public class BattleBanzaiGame extends Game { } - private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) { - for (HabboItem item : lockedTiles) { + private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) { + for (RoomItem item : lockedTiles) { if (item.getX() == x && item.getY() == y) return true; } @@ -329,7 +329,7 @@ public class BattleBanzaiGame extends Game { } private boolean isOutOfBounds(int x, int y) { - for (HabboItem item : this.gameTiles.values()) { + for (RoomItem item : this.gameTiles.values()) { if (item.getX() == x && item.getY() == y) return false; } @@ -337,10 +337,10 @@ public class BattleBanzaiGame extends Game { } private boolean isForeignLockedTile(int x, int y, GameTeamColors color) { - for (HashMap.Entry> lockedTilesForColor : this.lockedTiles.entrySet()) { + for (HashMap.Entry> lockedTilesForColor : this.lockedTiles.entrySet()) { if (lockedTilesForColor.getKey() == color) continue; - for (HabboItem item : lockedTilesForColor.getValue()) { + for (RoomItem item : lockedTilesForColor.getValue()) { if (item.getX() == x && item.getY() == y) return true; } } @@ -383,7 +383,7 @@ public class BattleBanzaiGame extends Game { private void refreshGates() { Collection gates = this.room.getRoomSpecialTypes().getBattleBanzaiGates().values(); THashSet tilesToUpdate = new THashSet<>(gates.size()); - for (HabboItem item : gates) { + for (RoomItem item : gates) { tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java index 94725332..c061c627 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java @@ -7,10 +7,11 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; public class BattleBanzaiGameTeam extends GameTeam { public BattleBanzaiGameTeam(GameTeamColors teamColor) { @@ -20,25 +21,27 @@ public class BattleBanzaiGameTeam extends GameTeam { @Override public void addMember(GamePlayer gamePlayer) { super.addMember(gamePlayer); - RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit(); - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit(); + if (roomHabbo.getEffectId() > 0) { + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId()); + roomHabbo.setPreviousEffectEndTimestamp(roomHabbo.getPreviousEffectEndTimestamp()); + } - gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true); + gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true); } @Override public void removeMember(GamePlayer gamePlayer) { super.removeMember(gamePlayer); - if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getRoomUnit().getRoom() == null) return; Habbo habbo = gamePlayer.getHabbo(); - Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); + Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class); RoomUnit roomUnit = habbo.getRoomUnit(); Room room = roomUnit.getRoom(); if(room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); + RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; 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 4039feb9..279969e2 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 @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.InteractionFootballScoreboard; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserAction; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; @@ -38,8 +38,8 @@ public class FootballGame extends Game { Habbo habbo = this.room.getHabbo(kicker); if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored")); - if (habbo.getHabboInfo().getId() != this.room.getOwnerId()) { - AchievementManager.progressAchievement(this.room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom")); + if (habbo.getHabboInfo().getId() != this.room.getRoomInfo().getOwnerInfo().getId()) { + AchievementManager.progressAchievement(this.room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom")); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 262f48db..292c95a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -13,8 +13,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; @@ -78,7 +78,7 @@ public class FreezeGame extends Game { } synchronized void resetMap() { - for (HabboItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getFloorItems()) { if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) { item.setExtradata("0"); this.room.updateItemState(item); @@ -93,7 +93,7 @@ public class FreezeGame extends Game { if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty()) return; - if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), this.room.getLayout().getTile(item.getX(), item.getY()))) { + if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentPosition(), this.room.getLayout().getTile(item.getX(), item.getY()))) { if (((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) { Emulator.getThreading().run(new FreezeThrowSnowball(habbo, item, this.room)); } @@ -189,11 +189,11 @@ public class FreezeGame extends Game { super.start(); if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { - for (Habbo habbo : this.room.getHabbos()) { + for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { if (this.getTeamForHabbo(habbo) == null) { - for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation())) { + for (RoomItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { if (item instanceof InteractionFreezeTile) { - HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); + RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY())); } } @@ -304,7 +304,7 @@ public class FreezeGame extends Game { private void refreshGates() { THashSet tilesToUpdate = new THashSet<>(); - for (HabboItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) { + for (RoomItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) { tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java index 7c14d9cb..67a21c88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java @@ -52,7 +52,7 @@ public class FreezeGamePlayer extends GamePlayer { public void addLife() { if (this.lives < FreezeGame.MAX_LIVES) { this.lives++; - super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose()); + super.getHabbo().getRoomUnit().getRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose()); } } @@ -61,13 +61,13 @@ public class FreezeGamePlayer extends GamePlayer { if (this.lives == 0) { this.dead = true; - FreezeGame game = (FreezeGame) super.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); + FreezeGame game = (FreezeGame) super.getHabbo().getRoomUnit().getRoom().getGame(FreezeGame.class); if (game != null) { game.playerDies(this); } } else { - super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose()); + super.getHabbo().getRoomUnit().getRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose()); } } @@ -208,6 +208,6 @@ public class FreezeGamePlayer extends GamePlayer { if (this.dead) return; - super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true); + super.getHabbo().getRoomUnit().getRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index 845a9bb6..9a4e764d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -6,10 +6,11 @@ import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; public class FreezeGameTeam extends GameTeam { public FreezeGameTeam(GameTeamColors teamColor) { @@ -19,16 +20,16 @@ public class FreezeGameTeam extends GameTeam { @Override public void removeMember(GamePlayer gamePlayer) { super.removeMember(gamePlayer); - if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getRoomUnit().getRoom() == null) return; Habbo habbo = gamePlayer.getHabbo(); - Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); + Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class); RoomUnit roomUnit = habbo.getRoomUnit(); Room room = roomUnit.getRoom(); if(room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); + RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -64,9 +65,9 @@ public class FreezeGameTeam extends GameTeam { public void addMember(GamePlayer gamePlayer) { super.addMember(gamePlayer); - RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit(); - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true); + RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit(); + if (roomHabbo.getEffectId() > 0) + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true); } } 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 bd612428..df080a9f 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 @@ -9,10 +9,11 @@ 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.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.users.UserTakeStepEvent; @@ -34,7 +35,7 @@ public abstract class TagGame extends Game { public static void onUserLookAtPoint(RoomUnitLookAtPointEvent event) { if (event.room == null || event.roomUnit == null || event.location == null) return; - if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentLocation(), event.location)) { + if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentPosition(), event.location)) { Habbo habbo = event.room.getHabbo(event.roomUnit); if (habbo != null) { @@ -44,7 +45,7 @@ public abstract class TagGame extends Game { if (game != null) { if (game.isTagger(habbo)) { - for (Habbo tagged : event.room.getHabbosAt(event.location)) { + for (Habbo tagged : event.room.getRoomUnitManager().getHabbosAt(event.location)) { if (tagged == habbo || tagged.getHabboInfo().getCurrentGame() == null || tagged.getHabboInfo().getCurrentGame() != habbo.getHabboInfo().getCurrentGame()) { continue; } @@ -63,15 +64,15 @@ public abstract class TagGame extends Game { @EventHandler public static void onUserWalkEvent(UserTakeStepEvent event) { if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) { - THashSet items = event.habbo.getHabboInfo().getCurrentRoom().getItemsAt(event.toLocation); + THashSet items = event.habbo.getRoomUnit().getRoom().getItemsAt(event.toLocation); - TagGame game = (TagGame) event.habbo.getHabboInfo().getCurrentRoom().getGame(event.habbo.getHabboInfo().getCurrentGame()); + TagGame game = (TagGame) event.habbo.getRoomUnit().getRoom().getGame(event.habbo.getHabboInfo().getCurrentGame()); if (game != null) { - for (HabboItem item : items) { + for (RoomItem item : items) { if (item instanceof InteractionTagField && ((InteractionTagField) item).gameClazz == event.habbo.getHabboInfo().getCurrentGame()) { if (game.taggers.isEmpty()) { - game.tagged(event.habbo.getHabboInfo().getCurrentRoom(), null, event.habbo); + game.tagged(event.habbo.getRoomUnit().getRoom(), null, event.habbo); } return; } @@ -97,7 +98,7 @@ public abstract class TagGame extends Game { return; } - THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole()); + THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole()); InteractionTagPole pole = this.taggers.get(tagger); room.giveEffect(tagged, this.getTaggedEffect(tagged), -1); @@ -106,8 +107,8 @@ public abstract class TagGame extends Game { poles.remove(set.getValue()); } - for (HabboItem item : poles) { - tagged.getHabboInfo().getCurrentRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1); + for (RoomItem item : poles) { + tagged.getRoomUnit().getRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1); this.taggers.put(tagged, (InteractionTagPole) item); } } else { @@ -130,39 +131,39 @@ public abstract class TagGame extends Game { public synchronized boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { super.addHabbo(habbo, GameTeamColors.RED); - RoomUnit roomUnit = habbo.getRoomUnit(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); if (this.getTagPole() != null) { - THashSet poles = habbo.getHabboInfo().getCurrentRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole()); + THashSet poles = habbo.getRoomUnit().getRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole()); if (poles.size() > this.taggers.size()) { for (Map.Entry set : this.taggers.entrySet()) { poles.remove(set.getValue()); } - TObjectHashIterator iterator = poles.iterator(); + TObjectHashIterator iterator = poles.iterator(); if ((iterator.hasNext())) { - HabboItem item = iterator.next(); - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); - this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); + RoomItem item = iterator.next(); + if (roomHabbo.getEffectId() > 0) + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); + this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); this.taggers.put(habbo, (InteractionTagPole) item); return true; } } } else { if (this.taggers.isEmpty()) { - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); - this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); + if (roomHabbo.getEffectId() > 0) + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); + this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); this.taggers.put(habbo, null); return true; } } - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); + if (roomHabbo.getEffectId() > 0) + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); return true; } @@ -176,7 +177,7 @@ public abstract class TagGame extends Game { Room room = roomUnit.getRoom(); if (room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); + RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 9cb2a072..78886dc2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -3,10 +3,11 @@ package com.eu.habbo.habbohotel.games.wired; import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; public class WiredGame extends Game { public GameState state = GameState.RUNNING; @@ -31,9 +32,9 @@ public class WiredGame extends Game { @Override public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) { - RoomUnit roomUnit = habbo.getRoomUnit(); - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + RoomHabbo roomHabbo = habbo.getRoomUnit(); + if (roomHabbo.getEffectId() > 0) + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true); return super.addHabbo(habbo, teamColor); } @@ -45,7 +46,7 @@ public class WiredGame extends Game { Room room = this.room; if (room == null) return; - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); + RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index 06827a70..93217ee5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -152,10 +152,10 @@ public class GuildManager { statement.execute(); } - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); if (room != null) { - room.setGuildId(0); + room.getRoomInfo().setGuild(null); } } catch (SQLException e) { log.error("Caught SQL exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java index 788f92d8..57dd19c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; public interface IEventTriggers { void onClick(GameClient client, Room room, Object[] objects) throws Exception; 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 bfb3c6a7..1d9ffce7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import gnu.trove.list.array.TIntArrayList; @@ -66,7 +66,7 @@ public class Item implements ISerialize { return item.getName().toLowerCase().startsWith("a0 pet"); } - public static double getCurrentHeight(HabboItem item) { + public static double getCurrentHeight(RoomItem item) { if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) { if (item.getExtradata().isEmpty()) { item.setExtradata("0"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java index fd32de85..2f830413 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java @@ -1,6 +1,6 @@ package com.eu.habbo.habbohotel.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; import lombok.Getter; @@ -9,5 +9,5 @@ public class ItemInteraction { @Getter private final String name; @Getter - private final Class type; + private final Class type; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 47eaadf1..00240bbc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -52,7 +52,7 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent; @@ -147,9 +147,9 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class)); this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class)); this.interactionsList.add(new ItemInteraction("effect_gate", InteractionEffectGate.class)); - this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class)); - this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class)); - this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class)); + this.interactionsList.add(new ItemInteraction("club_hopper", InteractionRoomClubHopper.class)); + this.interactionsList.add(new ItemInteraction("club_gate", InteractionRoomClubGate.class)); + this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionRoomClubTeleportTile.class)); this.interactionsList.add(new ItemInteraction("onewaygate", InteractionOneWayGate.class)); this.interactionsList.add(new ItemInteraction("love_lock", InteractionLoveLock.class)); this.interactionsList.add(new ItemInteraction("clothing", InteractionClothing.class)); @@ -198,10 +198,10 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerHabboEntersRoom.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerHabboSaysKeyword.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerRoomWalkOnFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerRoomWalkOffFurni.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerRoomEntersRoom.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerRoomSaysKeyword.class)); this.interactionsList.add(new ItemInteraction("wf_trg_periodically", WiredTriggerRepeater.class)); this.interactionsList.add(new ItemInteraction("wf_trg_period_long", WiredTriggerRepeaterLong.class)); this.interactionsList.add(new ItemInteraction("wf_trg_state_changed", WiredTriggerFurniStateToggled.class)); @@ -211,7 +211,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_trg_game_starts", WiredTriggerGameStarts.class)); this.interactionsList.add(new ItemInteraction("wf_trg_game_ends", WiredTriggerGameEnds.class)); this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_stf", WiredTriggerBotReachedFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedRoom.class)); this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class)); this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class)); this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class)); @@ -234,43 +234,43 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_act_move_furni_to", WiredEffectMoveFurniTo.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_reward", WiredEffectGiveReward.class)); this.interactionsList.add(new ItemInteraction("wf_act_call_stacks", WiredEffectTriggerStacks.class)); - this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickHabbo.class)); - this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickRoom.class)); + this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteRoom.class)); this.interactionsList.add(new ItemInteraction("wf_act_bot_teleport", WiredEffectBotTeleport.class)); this.interactionsList.add(new ItemInteraction("wf_act_bot_move", WiredEffectBotWalkToFurni.class)); this.interactionsList.add(new ItemInteraction("wf_act_bot_talk", WiredEffectBotTalk.class)); this.interactionsList.add(new ItemInteraction("wf_act_bot_give_handitem", WiredEffectBotGiveHandItem.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowRoom.class)); this.interactionsList.add(new ItemInteraction("wf_act_bot_clothes", WiredEffectBotClothes.class)); - this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToRoom.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_respect", WiredEffectGiveRespect.class)); this.interactionsList.add(new ItemInteraction("wf_act_alert", WiredEffectAlert.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveRoom.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_stuff_is", WiredConditionFurniTypeMatch.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_group", WiredConditionGroupMember.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionHabboCount.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionHabboHasEffect.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionHabboWearsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionRoomCount.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionRoomHasEffect.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionRoomWearsBadge.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_time_less_than", WiredConditionLessTimeElapsed.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_match_snapshot", WiredConditionMatchStatePosition.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_time_more_than", WiredConditionMoreTimeElapsed.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_furni_on", WiredConditionNotFurniHaveFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveHabbo.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveRoom.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_stuff_is", WiredConditionNotFurniTypeMatch.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotHabboCount.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotHabboHasEffect.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotHabboWearsBadge.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotRoomCount.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotRoomHasEffect.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotRoomWearsBadge.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_group", WiredConditionNotInGroup.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_team", WiredConditionNotInTeam.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_match_snap", WiredConditionNotMatchStatePosition.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_not_trggrer_on", WiredConditionNotTriggerOnFurni.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_team", WiredConditionTeamMember.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class)); - this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class)); + this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionRoomHasHandItem.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class)); @@ -363,7 +363,7 @@ public class ItemManager { } - public ItemInteraction getItemInteraction(Class type) { + public ItemInteraction getItemInteraction(Class type) { for (ItemInteraction interaction : this.interactionsList) { if (interaction.getType() == type) return interaction; @@ -477,7 +477,7 @@ public class ItemManager { return null; } - public HabboItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) { + public RoomItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, habboId); statement.setInt(2, item.getId()); @@ -487,7 +487,7 @@ public class ItemManager { try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) { - Class itemClass = item.getInteractionType().getType(); + Class itemClass = item.getInteractionType().getType(); if (itemClass != null) { try { @@ -537,7 +537,7 @@ public class ItemManager { return new ArrayList<>(this.newuserGifts.values()); } - public void deleteItem(HabboItem item) { + public void deleteItem(RoomItem item) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { statement.setInt(1, item.getId()); statement.execute(); @@ -546,10 +546,10 @@ public class ItemManager { } } - public HabboItem handleRecycle(Habbo habbo, String itemId) { + public RoomItem handleRecycle(Habbo habbo, String itemId) { String extradata = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR); - HabboItem item = null; + RoomItem item = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getGameEnvironment().getCatalogManager().ecotronItem.getId()); @@ -575,9 +575,9 @@ public class ItemManager { return item; } - public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box) { + public RoomItem handleOpenRecycleBox(Habbo habbo, RoomItem box) { Emulator.getThreading().run(new QueryDeleteHabboItem(box.getId())); - HabboItem item = null; + RoomItem item = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1")) { statement.setInt(1, box.getId()); try (ResultSet rewardSet = statement.executeQuery()) { @@ -627,7 +627,7 @@ public class ItemManager { } } - public void insertHopper(HabboItem hopper) { + public void insertHopper(RoomItem hopper) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_hoppers VALUES (?, ?)")) { statement.setInt(1, hopper.getId()); statement.setInt(2, hopper.getBaseItem().getId()); @@ -637,7 +637,7 @@ public class ItemManager { } } - public int[] getTargetTeleportRoomId(HabboItem item) { + public int[] getTargetTeleportRoomId(RoomItem item) { int[] a = new int[]{}; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_teleports INNER JOIN items ON items_teleports.teleport_one_id = items.id OR items_teleports.teleport_two_id = items.id WHERE items.id != ? AND items.room_id > 0 LIMIT 1")) { @@ -654,8 +654,8 @@ public class ItemManager { return a; } - public HabboItem loadHabboItem(int itemId) { - HabboItem item = null; + public RoomItem loadHabboItem(int itemId) { + RoomItem item = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { statement.setInt(1, itemId); try (ResultSet set = statement.executeQuery()) { @@ -672,20 +672,20 @@ public class ItemManager { return item; } - public HabboItem loadHabboItem(ResultSet set) throws SQLException { + public RoomItem loadHabboItem(ResultSet set) throws SQLException { Item baseItem = this.getItem(set.getInt("item_id")); if (baseItem == null) return null; - Class itemClass = baseItem.getInteractionType().getType(); + Class itemClass = baseItem.getInteractionType().getType(); if (itemClass != null) { try { - Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); + Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); c.setAccessible(true); - HabboItem item = (HabboItem) c.newInstance(set, baseItem); + RoomItem item = (RoomItem) c.newInstance(set, baseItem); if (item instanceof InteractionWired interactionWired) { interactionWired.loadWiredSettings(set); @@ -700,7 +700,7 @@ public class ItemManager { return null; } - public HabboItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) { + public RoomItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); int userId = 0; @@ -728,7 +728,7 @@ public class ItemManager { return null; } - public HabboItem createGift(int userId, Item item, String extraData, int limitedStack, int limitedSells) { + public RoomItem createGift(int userId, Item item, String extraData, int limitedStack, int limitedSells) { if (userId == 0) return null; @@ -737,7 +737,7 @@ public class ItemManager { extraData = extraData.substring(0, 1000); } - HabboItem gift = this.createItem(userId, item, limitedStack, limitedSells, extraData); + RoomItem gift = this.createItem(userId, item, limitedStack, limitedSells, extraData); if (gift != null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java index eda6da13..6420116a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import lombok.Getter; @@ -52,7 +52,7 @@ public class NewUserGift implements ISerialize { Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getKey()); if (item != null) { - HabboItem createdItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); + RoomItem createdItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, ""); if (createdItem != null) { habbo.addFurniture(createdItem); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java index 890738e6..3fb3dc39 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java @@ -5,15 +5,15 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.BackgroundAnimation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBackgroundToner extends HabboItem { +public class InteractionBackgroundToner extends RoomItem { public InteractionBackgroundToner(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -65,13 +65,13 @@ public class InteractionBackgroundToner extends HabboItem { ScripterManager.scripterDetected( client, Emulator.getTexts().getValue("scripter.warning.item.bgtoner.permission").replace("%username%", client.getHabbo().getHabboInfo().getUsername()) - .replace("%room%", room.getName()) - .replace("%owner%", room.getOwnerName()) + .replace("%room%", room.getRoomInfo().getName()) + .replace("%owner%", room.getRoomInfo().getOwnerInfo().getUsername()) ); return; } - if (client.getHabbo().getRoomUnit().isCmdSit() && client.getHabbo().getRoomUnit().getEffectId() == 1337) { + if (client.getHabbo().getRoomUnit().isCmdSitEnabled() && client.getHabbo().getRoomUnit().getEffectId() == 1337) { new BackgroundAnimation(this, room).run(); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java index c34be7e5..aa9d223a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java @@ -3,14 +3,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBadgeDisplay extends HabboItem { +public class InteractionBadgeDisplay extends RoomItem { public InteractionBadgeDisplay(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java index f669479a..7fcfeace 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java @@ -24,7 +24,7 @@ public class InteractionBlackHole extends InteractionGate { Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount"); int holesCountProgress = 0; - Habbo owner = room.getHabbo(this.getUserId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getUserId()); if (owner == null) { holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), holeCountAchievement); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index f6877649..998193a9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -6,9 +6,9 @@ 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.RoomTileState; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; @@ -78,8 +78,8 @@ public class InteractionBuildArea extends InteractionCustomValues { if (!canBuild.isEmpty()) { for (RoomTile tile : this.tiles) { - THashSet tileItems = room.getItemsAt(tile); - for (HabboItem tileItem : tileItems) { + THashSet tileItems = room.getItemsAt(tile); + for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { room.pickUpItem(tileItem, null); } @@ -127,9 +127,9 @@ public class InteractionBuildArea extends InteractionCustomValues { if (!canBuild.isEmpty()) { for (RoomTile tile : this.tiles) { - THashSet tileItems = room.getItemsAt(tile); + THashSet tileItems = room.getItemsAt(tile); if (newTiles.contains(tile)) continue; - for (HabboItem tileItem : tileItems) { + for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { room.pickUpItem(tileItem, null); } @@ -140,7 +140,7 @@ public class InteractionBuildArea extends InteractionCustomValues { } public boolean inSquare(RoomTile location) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null && this.tiles.size() == 0) { regenAffectedTiles(room); @@ -202,8 +202,8 @@ public class InteractionBuildArea extends InteractionCustomValues { } if (!canBuild.isEmpty()) { for (RoomTile tile : oldTiles) { - THashSet tileItems = room.getItemsAt(tile); - for (HabboItem tileItem : tileItems) { + THashSet tileItems = room.getItemsAt(tile); + for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { room.pickUpItem(tileItem, null); } @@ -217,12 +217,12 @@ public class InteractionBuildArea extends InteractionCustomValues { if (effectItem != null) { TIntObjectMap ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); ownerNames.put(-1, "System"); - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); int id = 0; for (RoomTile tile : this.tiles) { id--; - HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); + RoomItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); item.setX(tile.getX()); item.setY(tile.getY()); item.setZ(tile.relativeHeight()); @@ -231,7 +231,7 @@ public class InteractionBuildArea extends InteractionCustomValues { client.sendResponse(new ObjectsMessageComposer(ownerNames, items)); Emulator.getThreading().run(() -> { - for (HabboItem item : items) { + for (RoomItem item : items) { client.sendResponse(new RemoveFloorItemComposer(item, true)); } }, 3000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java index b1223794..a2f3a65e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java @@ -5,8 +5,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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +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 com.eu.habbo.threading.runnables.CannonKickAction; import com.eu.habbo.threading.runnables.CannonResetCooldownAction; @@ -15,7 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionCannon extends HabboItem { +public class InteractionCannon extends RoomItem { public boolean cooldown = false; public InteractionCannon(ResultSet set, Item baseItem) throws SQLException { @@ -61,12 +61,12 @@ public class InteractionCannon extends HabboItem { tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8)); tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? 5 : 4)) % 8)); - if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) { + if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentPosition())) && client.getHabbo().getRoomUnit().isCanWalk()) && !this.cooldown) { if (client != null) { client.getHabbo().getRoomUnit().setCanWalk(false); - client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation()); + client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentPosition()); client.getHabbo().getRoomUnit().lookAtPoint(fuseTile); - client.getHabbo().getRoomUnit().statusUpdate(true); + client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true); } this.cooldown = true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java index 9bcd0794..bfd245bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionClothing extends HabboItem { +public class InteractionClothing extends RoomItem { public InteractionClothing(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index 9d181a92..d530ba7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java index 2f57bec8..34d511f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer; import com.eu.habbo.threading.runnables.RandomDiceNumber; @@ -13,7 +13,7 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionColorWheel extends HabboItem { +public class InteractionColorWheel extends RoomItem { private Runnable rollTaks; public InteractionColorWheel(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index 2ccdb52e..e6b6664e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -6,10 +6,10 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.CrackableReward; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +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.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.CrackableExplode; @@ -18,7 +18,7 @@ import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionCrackable extends HabboItem { +public class InteractionCrackable extends RoomItem { private final Object lock = new Object(); public boolean cracked = false; protected int ticks = 0; @@ -69,8 +69,8 @@ public class InteractionCrackable extends HabboItem { if (this.cracked) return; - if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) { - client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY()))); + if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) { + client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getX(), this.getY()))); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java index 8f39af73..ed124f97 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.map.hash.THashMap; @@ -12,7 +12,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -public abstract class InteractionCustomValues extends HabboItem { +public abstract class InteractionCustomValues extends RoomItem { public final THashMap values = new THashMap<>(); public InteractionCustomValues(ResultSet set, Item baseItem, THashMap defaultValues) throws SQLException { 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 255054ba..b0a17a3d 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 @@ -3,10 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; @@ -15,7 +20,7 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public class InteractionDefault extends HabboItem { +public class InteractionDefault extends RoomItem { public InteractionDefault(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -48,7 +53,7 @@ public class InteractionDefault extends HabboItem { super.onMove(room, oldLocation, newLocation); if (room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { - for (RoomUnit unit : room.getRoomUnits()) { + for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) { if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // If the unit was previously on the furni... if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore... @@ -100,39 +105,42 @@ public class InteractionDefault extends HabboItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (roomUnit == null || (this.getBaseItem().getEffectF() == 0 && this.getBaseItem().getEffectM() == 0)) return; - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + if (roomUnit == null || (this.getBaseItem().getEffectF() == 0 && this.getBaseItem().getEffectM() == 0)) { + return; + } + + if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { Habbo habbo = room.getHabbo(roomUnit); if (habbo == null) return; if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + if (((RoomAvatar) roomUnit).getEffectId() > 0) + roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + if (((RoomAvatar) roomUnit).getEffectId() > 0) + roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); } } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getBot(roomUnit); + Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); if (bot == null) return; - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) { - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectM()) { + if (((RoomAvatar) roomUnit).getEffectId() > 0) + roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); return; } - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) { - if (roomUnit.getEffectId() > 0) - roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectF()) { + if (((RoomAvatar) roomUnit).getEffectId() > 0) + roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); } } @@ -150,7 +158,7 @@ public class InteractionDefault extends HabboItem { if (objects != null && objects.length == 2) { if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) { - HabboItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null); + RoomItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null); if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { return; @@ -167,7 +175,7 @@ public class InteractionDefault extends HabboItem { } } - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { @@ -182,7 +190,7 @@ public class InteractionDefault extends HabboItem { } } } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getBot(roomUnit); + Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); if (bot != null) { if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { @@ -204,7 +212,7 @@ public class InteractionDefault extends HabboItem { if (!habbo.getHabboStats().isRentingSpace()) return false; - HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().getRentedItemId()); + RoomItem rentSpace = room.getHabboItem(habbo.getHabboStats().getRentedItemId()); return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java index 896cf046..6a9cdffe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java @@ -5,8 +5,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.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +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 com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent; import com.eu.habbo.threading.runnables.RandomDiceNumber; @@ -14,7 +14,7 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionDice extends HabboItem { +public class InteractionDice extends RoomItem { public InteractionDice(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -46,7 +46,7 @@ public class InteractionDice extends HabboItem { super.onClick(client, room, objects); if (client != null) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { if (!this.getExtradata().equalsIgnoreCase("-1")) { FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java index eb0e8b19..d4138670 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java @@ -5,7 +5,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; @@ -43,17 +44,16 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - if (roomUnit == null || room == null) + if (roomUnit == null || room == null || !(roomUnit instanceof RoomHabbo roomHabbo)) return false; String customparams = this.getBaseItem().getCustomParams().trim(); if (!customparams.isEmpty()) { - return Arrays.asList(customparams.split(";")) - .contains(String.valueOf(roomUnit.getEffectId())); + return Arrays.asList(customparams.split(";")).contains(String.valueOf(roomHabbo.getEffectId())); } - return defaultAllowedEnables.contains(roomUnit.getEffectId()); + return defaultAllowedEnables.contains(roomHabbo.getEffectId()); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java index 4d8d011a..b662f8e8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java @@ -5,8 +5,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.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +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; @@ -26,8 +26,8 @@ public class InteractionEffectGiver extends InteractionDefault { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY())) || + (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } @@ -37,7 +37,7 @@ public class InteractionEffectGiver extends InteractionDefault { if (!this.getExtradata().equals("0")) return; - HabboItem instance = this; + RoomItem instance = this; room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem(), -1); if (this.getBaseItem().getStateCount() > 1) { 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 ac10dcc7..e03b75a5 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 @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -51,14 +51,14 @@ public class InteractionEffectTile extends InteractionPressurePlate { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (roomUnit.getRoomUnitType() == RoomUnitType.USER) { + if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender()); } } else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT) { - Bot bot = room.getBot(roomUnit); + Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); if (bot != null) { this.giveEffect(room, roomUnit, bot.getGender()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java index 49261af4..3cb7e9de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import java.sql.ResultSet; import java.sql.SQLException; @@ -19,7 +19,7 @@ public class InteractionEffectVendingMachine extends InteractionVendingMachine { } @Override - public void giveVendingMachineItem(Room room, RoomUnit unit) { - room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30); + public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) { + room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java index 84f91edc..59d8e0f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -21,8 +21,8 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa } @Override - public void giveVendingMachineItem(Room room, RoomUnit unit) { - room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30); + public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) { + room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java index f6fa36e8..7be45959 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java @@ -3,14 +3,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionExternalImage extends HabboItem { +public class InteractionExternalImage extends RoomItem { public InteractionExternalImage(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index daf5ab50..59bcf230 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -5,7 +5,7 @@ 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.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -55,7 +55,7 @@ public class InteractionFXBox extends InteractionDefault { this.setExtradata("1"); room.updateItemState(this); room.removeHabboItem(this); - HabboItem item = this; + RoomItem item = this; Emulator.getThreading().run(() -> { new QueryDeleteHabboItem(item.getId()).run(); room.sendComposer(new RemoveFloorItemComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 22f4071d..6fa14604 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -71,12 +71,12 @@ public class InteractionFireworks extends InteractionDefault { if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { - if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } } - if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) { List onSuccess = new ArrayList<>(); onSuccess.add(() -> { try { @@ -117,7 +117,7 @@ public class InteractionFireworks extends InteractionDefault { public boolean canToggle(Habbo habbo, Room room) { return room.hasRights(habbo) || RoomLayout.tilesAdjecent( room.getLayout().getTile(this.getX(), this.getY()), - habbo.getRoomUnit().getCurrentLocation() + habbo.getRoomUnit().getCurrentPosition() ); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index 9646940b..c0fdc759 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -4,15 +4,15 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionGate extends HabboItem { +public class InteractionGate extends RoomItem { public InteractionGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -46,7 +46,7 @@ public class InteractionGate extends HabboItem { // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) - if (room.hasHabbosAt(tile.getX(), tile.getY())) + if (room.getRoomUnitManager().hasHabbosAt(tile)) return; // Gate closed = 0, open = 1 diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java index 712c6c4d..42bc59a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -15,7 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public class InteractionGift extends HabboItem { +public class InteractionGift extends RoomItem { public boolean explode = false; private int[] itemId; @Getter @@ -121,8 +121,8 @@ public class InteractionGift extends HabboItem { } } - public THashSet loadItems() { - THashSet items = new THashSet<>(); + public THashSet loadItems() { + THashSet items = new THashSet<>(); for (int anItemId : this.itemId) { if (anItemId == 0) continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java index 3ba1afc6..cc34a193 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; 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 7e836dab..f7a5d4b0 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 @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.CloseGate; 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 008b4279..307f2fd6 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 @@ -2,13 +2,16 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; -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.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.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import java.sql.ResultSet; import java.sql.SQLException; @@ -27,7 +30,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.USER) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)); + return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)); } @Override @@ -40,12 +43,12 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC super.onWalkOn(roomUnit, room, objects); if (this.forceRotation()) { - roomUnit.setRotation(RoomUserRotation.fromValue(this.getRotation())); + roomUnit.setRotation(RoomRotation.fromValue(this.getRotation())); roomUnit.setCanRotate(false); } - this.roomUnitId = roomUnit.getId(); + this.roomUnitId = roomUnit.getVirtualId(); - if (roomUnit.getRoomUnitType() == RoomUnitType.USER) { + if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { @@ -64,7 +67,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC if (roomUnit != null) { Habbo habbo = room.getHabbo(roomUnit); - HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY()); + RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -126,12 +129,12 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC super.setRotation(rotation); if (this.forceRotation() && this.roomUnitId != -1) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { RoomUnit roomUnit = this.getCurrentRoomUnit(room); if (roomUnit != null) { - roomUnit.setRotation(RoomUserRotation.fromValue(rotation)); + roomUnit.setRotation(RoomRotation.fromValue(rotation)); room.updateRoomUnit(roomUnit); } } @@ -172,16 +175,6 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC } private RoomUnit getCurrentRoomUnit(Room room) { - Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId); - if (habbo != null) { - return habbo.getRoomUnit(); - } else { - Bot bot = room.getBotByRoomUnitId(this.roomUnitId); - if (bot != null) { - return bot.getRoomUnit(); - } - } - - return null; + return room.getRoomUnitManager().getCurrentRoomUnits().get(this.roomUnitId); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java index 7c7599f0..181698a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java @@ -5,8 +5,10 @@ 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.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; @@ -24,8 +26,8 @@ public class InteractionHanditem extends InteractionDefault { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY())) || + (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } @@ -35,8 +37,13 @@ public class InteractionHanditem extends InteractionDefault { if (!this.getExtradata().equals("0")) return; - HabboItem instance = this; - room.giveHandItem(roomUnit, this.getBaseItem().getRandomVendingItem()); + if(!(roomUnit instanceof RoomAvatar roomAvatar)) { + return; + } + + RoomItem instance = this; + roomAvatar.setHandItem(this.getBaseItem().getRandomVendingItem()); + room.sendComposer(new CarryObjectMessageComposer(roomAvatar).compose()); if (this.getBaseItem().getStateCount() > 1) { this.setExtradata("1"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java index aa1eb152..13e5d5d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; @@ -21,7 +21,7 @@ public class InteractionHanditemTile extends InteractionHanditem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { InteractionHanditemTile instance = this; Emulator.getThreading().run(() -> { - if (roomUnit.getCurrentLocation().getX() == instance.getX() && roomUnit.getCurrentLocation().getY() == instance.getY()) { + if (roomUnit.getCurrentPosition().getX() == instance.getX() && roomUnit.getCurrentPosition().getY() == instance.getY()) { instance.handle(room, roomUnit); } }, 3000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java index f20c26d6..9e3ab63a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java @@ -5,15 +5,15 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.hopper.HopperActionOne; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHopper extends HabboItem { +public class InteractionHopper extends RoomItem { public InteractionHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -52,7 +52,7 @@ public class InteractionHopper extends HabboItem { super.onClick(client, room, objects); if (room != null) { - RoomTile loc = HabboItem.getSquareInFront(room.getLayout(), this); + RoomTile loc = RoomItem.getSquareInFront(room.getLayout(), this); if (loc != null) { if (this.canUseTeleport(client, loc, room)) { client.getHabbo().getRoomUnit().setTeleporting(true); @@ -77,7 +77,7 @@ public class InteractionHopper extends HabboItem { if (!this.getExtradata().equals("0")) { this.setExtradata("0"); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItemState(this); } @@ -86,16 +86,22 @@ public class InteractionHopper extends HabboItem { } protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) { - if (client.getHabbo().getRoomUnit().getX() != front.getX()) + if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() != front.getX()) return false; - if (client.getHabbo().getRoomUnit().getY() != front.getY()) + if (client.getHabbo().getRoomUnit().getCurrentPosition().getY() != front.getY()) return false; if (client.getHabbo().getRoomUnit().isTeleporting()) return false; - if (!room.getHabbosAt(this.getX(), this.getY()).isEmpty()) + RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + + if(tile == null) { + return false; + } + + if (room.getRoomUnitManager().hasHabbosAt(tile)) return false; return this.getExtradata().equals("0"); 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 d8e5fa5c..a8c215f7 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 @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.habboway.nux.InClientLinkMessageComposer; import gnu.trove.map.hash.THashMap; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index dec7b52a..32550f6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -3,14 +3,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionJukeBox extends HabboItem { +public class InteractionJukeBox extends RoomItem { public InteractionJukeBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java index 2369b288..c676a9a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java @@ -6,9 +6,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.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.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.FriendFurniStartConfirmationMessageComposer; @@ -16,7 +16,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; -public class InteractionLoveLock extends HabboItem { +public class InteractionLoveLock extends RoomItem { public int userOneId; public int userTwoId; @@ -77,13 +77,13 @@ public class InteractionLoveLock extends HabboItem { if (client == null) return; - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY()))) { if (this.userOneId == 0) { this.userOneId = client.getHabbo().getHabboInfo().getId(); client.sendResponse(new FriendFurniStartConfirmationMessageComposer(this)); } else { if (this.userOneId != client.getHabbo().getHabboInfo().getId()) { - Habbo habbo = room.getHabbo(this.userOneId); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(this.userOneId); if (habbo != null) { this.userTwoId = client.getHabbo().getHabboInfo().getId(); @@ -96,7 +96,7 @@ public class InteractionLoveLock extends HabboItem { public boolean lock(Habbo userOne, Habbo userTwo, Room room) { RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); - if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentLocation(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentLocation(), tile)) { + if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentPosition(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentPosition(), tile)) { String data = "1"; data += "\t"; data += userOne.getHabboInfo().getUsername(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java index 84adbbb1..18a26b93 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; @@ -14,7 +14,7 @@ import com.eu.habbo.messages.outgoing.users.UserObjectComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMannequin extends HabboItem { +public class InteractionMannequin extends RoomItem { public InteractionMannequin(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java index 44f024db..9940030a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java @@ -33,7 +33,7 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if (room.isPublicRoom()) this.respawn = true; + if (room.getRoomInfo().isPublicRoom()) this.respawn = true; super.onClick(client, room, objects); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java index 0830cad5..bd2c79cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java @@ -4,14 +4,15 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +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.map.TIntObjectMap; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMoodLight extends HabboItem { +public class InteractionMoodLight extends RoomItem { public InteractionMoodLight(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -46,7 +47,7 @@ public class InteractionMoodLight extends HabboItem { @Override public void onPlace(Room room) { if (room != null) { - for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) { if (data.isEnabled()) { this.setExtradata(data.toString()); this.needsUpdate(true); 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 ddce7f99..29582b62 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 @@ -2,10 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -14,7 +18,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -public class InteractionMultiHeight extends HabboItem { +public class InteractionMultiHeight extends RoomItem { public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -53,7 +57,7 @@ public class InteractionMultiHeight extends HabboItem { } if (objects[0] instanceof Integer && room != null) { - HabboItem topItem = room.getTopItemAt(this.getX(), this.getY()); + RoomItem topItem = room.getTopItemAt(this.getX(), this.getY()); if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top return; } @@ -76,7 +80,7 @@ public class InteractionMultiHeight extends HabboItem { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for(RoomTile tile : occupiedTiles) { - Collection unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY())); + Collection unitsOnItem = room.getRoomUnitManager().getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY())); for (RoomUnit unit : unitsOnItem) { if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoalLocation() != tile) @@ -84,11 +88,11 @@ public class InteractionMultiHeight extends HabboItem { if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) { unit.setSitUpdate(true); - unit.statusUpdate(true); + unit.setStatusUpdateNeeded(true); } else { - unit.setZ(unit.getCurrentLocation().getStackHeight()); - unit.setPreviousLocationZ(unit.getZ()); - unit.statusUpdate(true); + unit.setCurrentZ(unit.getCurrentPosition().getStackHeight()); + unit.setPreviousLocationZ(unit.getCurrentZ()); + unit.setStatusUpdateNeeded(true); } } } @@ -105,7 +109,7 @@ public class InteractionMultiHeight extends HabboItem { if (roomUnit != null && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - && roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { @@ -127,7 +131,7 @@ public class InteractionMultiHeight extends HabboItem { if (roomUnit != null && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - && roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index 39eb0b27..4781c84d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -2,8 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; @@ -11,7 +11,7 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public class InteractionMusicDisc extends HabboItem { +public class InteractionMusicDisc extends RoomItem { private int songId; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index e5fbd80b..7199df40 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -6,7 +6,7 @@ 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.RoomTileState; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.ObjectDataUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; @@ -73,7 +73,7 @@ public class InteractionMuteArea extends InteractionCustomValues { } public boolean inSquare(RoomTile location) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if(!this.values.get("state").equals("1")) return false; @@ -124,12 +124,12 @@ public class InteractionMuteArea extends InteractionCustomValues { if(effectItem != null) { TIntObjectMap ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); ownerNames.put(-1, "System"); - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); int id = 0; for(RoomTile tile : this.tiles) { id--; - HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); + RoomItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); item.setX(tile.getX()); item.setY(tile.getY()); item.setZ(tile.relativeHeight()); @@ -138,7 +138,7 @@ public class InteractionMuteArea extends InteractionCustomValues { client.sendResponse(new ObjectsMessageComposer(ownerNames, items)); Emulator.getThreading().run(() -> { - for(HabboItem item : items) { + for(RoomItem item : items) { client.sendResponse(new RemoveFloorItemComposer(item, true)); } }, 3000); 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 a782efd5..b1627e31 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 @@ -5,9 +5,15 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.Pet; -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.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; +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.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -15,7 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Objects; -public class InteractionObstacle extends HabboItem implements ICycleable { +public class InteractionObstacle extends RoomItem implements ICycleable { private final THashSet middleTiles; @@ -91,21 +97,21 @@ public class InteractionObstacle extends HabboItem implements ICycleable { Habbo habbo = room.getHabbo(roomUnit); if (habbo == null) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { if (roomUnit.getBodyRotation().getValue() % 2 == 0) { if (this.getRotation() == 2) { - if (roomUnit.getBodyRotation().equals(RoomUserRotation.WEST)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() - 3), roomUnit.getY())); - } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.EAST)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() + 3), roomUnit.getY())); + if (roomUnit.getBodyRotation().equals(RoomRotation.WEST)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY())); + } else if (roomUnit.getBodyRotation().equals(RoomRotation.EAST)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY())); } } else if (this.getRotation() == 4) { - if (roomUnit.getBodyRotation().equals(RoomUserRotation.NORTH)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() - 3))); - } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.SOUTH)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() + 3))); + if (roomUnit.getBodyRotation().equals(RoomRotation.NORTH)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3))); + } else if (roomUnit.getBodyRotation().equals(RoomRotation.SOUTH)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3))); } } } @@ -120,7 +126,7 @@ public class InteractionObstacle extends HabboItem implements ICycleable { Habbo habbo = room.getHabbo(roomUnit); if (habbo == null) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); @@ -174,18 +180,24 @@ public class InteractionObstacle extends HabboItem implements ICycleable { } for(RoomTile tile : this.middleTiles) { - for(RoomUnit unit : tile.getUnits()) { + for(RoomEntity entity : tile.getEntities()) { + if(!(entity instanceof RoomUnit)) { + continue; + } + + RoomUnit unit = (RoomUnit) entity; + if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) { if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation()) continue; - RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentLocation(), unit.getBodyRotation().getValue()); - if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) { + RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentPosition(), unit.getBodyRotation().getValue()); + if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) { unit.setGoalLocation(tileInfront); } else { - RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentLocation(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); - if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) { + RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentPosition(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); + if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) { unit.setGoalLocation(tileBehind); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index d2f559cb..365a566c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -5,8 +5,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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; @@ -18,7 +18,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionOneWayGate extends HabboItem { +public class InteractionOneWayGate extends RoomItem { private boolean walkable = false; public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException { @@ -76,48 +76,50 @@ public class InteractionOneWayGate extends HabboItem { if (unit == null) return; - if (tileInfront.getX() == unit.getX() && tileInfront.getY() == unit.getY()) { - if (!currentLocation.hasUnits()) { - List onSuccess = new ArrayList<>(); - List onFail = new ArrayList<>(); + if (tileInfront.getX() == unit.getCurrentPosition().getX()) { + if (tileInfront.getY() == unit.getCurrentPosition().getY()) { + if (!currentLocation.hasUnits()) { + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); - onSuccess.add(() -> { - unit.setCanLeaveRoomByDoor(false); - walkable = this.getBaseItem().allowWalk(); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4); - unit.setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); + onSuccess.add(() -> { + unit.setCanLeaveRoomByDoor(false); + walkable = this.getBaseItem().allowWalk(); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4); + unit.setGoalLocation(tile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); - Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500); - }); + Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500); + }); - onFail.add(() -> { - unit.setCanLeaveRoomByDoor(true); - walkable = this.getBaseItem().allowWalk(); + onFail.add(() -> { + unit.setCanLeaveRoomByDoor(true); + walkable = this.getBaseItem().allowWalk(); + room.updateTile(currentLocation); + room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose()); + unit.removeOverrideTile(currentLocation); + }); + + walkable = true; room.updateTile(currentLocation); - room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose()); - unit.removeOverrideTile(currentLocation); - }); + unit.addOverrideTile(currentLocation); + unit.setGoalLocation(currentLocation); + Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); + room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose()); - walkable = true; - room.updateTile(currentLocation); - unit.addOverrideTile(currentLocation); - unit.setGoalLocation(currentLocation); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); - room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose()); - - /* - room.scheduledTasks.add(new Runnable() - { - @Override - public void run() + /* + room.scheduledTasks.add(new Runnable() { - gate.roomUnitID = client.getHabbo().getRoomUnit().getId(); - room.updateTile(gatePosition); - client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4)); - } - }); - */ + @Override + public void run() + { + gate.roomUnitID = client.getHabbo().getRoomUnit().getId(); + room.updateTile(gatePosition); + client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4)); + } + }); + */ + } } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java index ae9b8872..94e2dd3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPostIt extends HabboItem { +public class InteractionPostIt extends RoomItem { public static String STICKYPOLE_PREFIX_TEXT = ""; public InteractionPostIt(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java index bdb3afd4..c58d0a40 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPoster extends HabboItem { +public class InteractionPoster extends RoomItem { public InteractionPoster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java index 04491166..137466af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java @@ -5,11 +5,12 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashSet; public class InteractionPressurePlate extends InteractionDefault { public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException { @@ -82,7 +83,8 @@ public class InteractionPressurePlate extends InteractionDefault { if (tiles == null) return; for (RoomTile tile : tiles) { - THashSet tileHasHabboOrBot = room.getHabbosAndBotsAt(tile.getX(), tile.getY()); + HashSet tileHasHabboOrBot = (HashSet) room.getRoomUnitManager().getAvatarsAt(tile); + if (tileHasHabboOrBot.isEmpty() && this.requiresAllTilesOccupied()) { occupied = false; break; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java index 008370b8..6e8a1d67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java @@ -3,7 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.threading.runnables.KickBallAction; import java.sql.ResultSet; @@ -43,7 +47,7 @@ public abstract class InteractionPushable extends InteractionDefault { return; int velocity = this.getWalkOffVelocity(roomUnit, room); - RoomUserRotation direction = this.getWalkOffDirection(roomUnit, room); + RoomRotation direction = this.getWalkOffDirection(roomUnit, room); this.onKick(room, roomUnit, velocity, direction); if (velocity > 0) { @@ -60,9 +64,9 @@ public abstract class InteractionPushable extends InteractionDefault { super.onClick(client, room, objects); if (client == null) return; - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY()))) { int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room); - RoomUserRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room); + RoomRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room); this.onTackle(room, client.getHabbo().getRoomUnit(), velocity, direction); if (velocity > 0) { @@ -81,7 +85,7 @@ public abstract class InteractionPushable extends InteractionDefault { int velocity; boolean isDrag = false; - RoomUserRotation direction; + RoomRotation direction; if (this.getX() == roomUnit.getGoalLocation().getX() && this.getY() == roomUnit.getGoalLocation().getY()) //User clicked on the tile the ball is on, they want to kick it { @@ -109,54 +113,54 @@ public abstract class InteractionPushable extends InteractionDefault { public abstract int getWalkOnVelocity(RoomUnit roomUnit, Room room); - public abstract RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room); + public abstract RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room); public abstract int getWalkOffVelocity(RoomUnit roomUnit, Room room); - public abstract RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room); + public abstract RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room); public abstract int getDragVelocity(RoomUnit roomUnit, Room room); - public abstract RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room); + public abstract RoomRotation getDragDirection(RoomUnit roomUnit, Room room); public abstract int getTackleVelocity(RoomUnit roomUnit, Room room); - public abstract RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room); + public abstract RoomRotation getTackleDirection(RoomUnit roomUnit, Room room); public abstract int getNextRollDelay(int currentStep, int totalSteps); //The length in milliseconds when the ball should next roll - public abstract RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection); //Returns the new direction to move the ball when the ball cannot move + public abstract RoomRotation getBounceDirection(Room room, RoomRotation currentDirection); //Returns the new direction to move the ball when the ball cannot move public abstract boolean validMove(Room room, RoomTile from, RoomTile to); //Checks if the next move is valid - public abstract void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction); + public abstract void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction); - public abstract void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction); + public abstract void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction); - public abstract void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction); + public abstract void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction); - public abstract void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps); + public abstract void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps); - public abstract void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker); + public abstract void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker); public abstract void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps); - public abstract boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps); + public abstract boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps); } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 36250f87..c56f3287 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -2,15 +2,19 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +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.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPuzzleBox extends HabboItem { +public class InteractionPuzzleBox extends RoomItem { public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -22,19 +26,23 @@ public class InteractionPuzzleBox extends HabboItem { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY()); - RoomUserRotation rotation = null; + RoomRotation rotation = null; - if (this.getX() == client.getHabbo().getRoomUnit().getX()) { - if (this.getY() == client.getHabbo().getRoomUnit().getY() + 1) { - rotation = RoomUserRotation.SOUTH; - } else if (this.getY() == client.getHabbo().getRoomUnit().getY() - 1) { - rotation = RoomUserRotation.NORTH; + if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX()) { + if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() + 1) { + rotation = RoomRotation.SOUTH; + } else { + if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() - 1) { + rotation = RoomRotation.NORTH; + } } - } else if (this.getY() == client.getHabbo().getRoomUnit().getY()) { - if (this.getX() == client.getHabbo().getRoomUnit().getX() + 1) { - rotation = RoomUserRotation.EAST; - } else if (this.getX() == client.getHabbo().getRoomUnit().getX() - 1) { - rotation = RoomUserRotation.WEST; + } else { + if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY()) { + if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() + 1) { + rotation = RoomRotation.EAST; + } else if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() - 1) { + rotation = RoomRotation.WEST; + } } } @@ -49,14 +57,14 @@ public class InteractionPuzzleBox extends HabboItem { RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); - if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.getX(), tile.getY())) { + if (tile == null || tile.getState() == RoomTileState.INVALID || room.getRoomUnitManager().hasHabbosAt(tile)) { return; } - if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue()))) + if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentPosition(), rotation.getValue()))) return; - HabboItem item = room.getTopItemAt(tile.getX(), tile.getY()); + RoomItem item = room.getTopItemAt(tile.getX(), tile.getY()); if (item != null && !room.getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java index 0ec3ce19..d9998149 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; 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 java.sql.ResultSet; import java.sql.SQLException; @@ -24,7 +25,13 @@ public class InteractionPyramid extends InteractionGate { this.setExtradata("0"); if (room != null) { - if (room.getHabbosAt(this.getX(), this.getY()).isEmpty()) { + RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + + if(tile == null) { + return; + } + + if (!room.getRoomUnitManager().hasHabbosAt(tile)) { int state = Integer.parseInt(this.getExtradata()); state = Math.abs(state - 1); 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 73e4053c..f3caa812 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 @@ -5,9 +5,9 @@ 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.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +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.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceStatusMessageComposer; import com.eu.habbo.threading.runnables.ClearRentedSpace; @@ -21,7 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public class InteractionRentableSpace extends HabboItem { +public class InteractionRentableSpace extends RoomItem { private int renterId; private String renterName; @@ -58,7 +58,7 @@ public class InteractionRentableSpace extends HabboItem { } } else { if (this.getRoomId() > 0) { - Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()))); + Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()))); this.renterId = 0; } } @@ -82,7 +82,7 @@ public class InteractionRentableSpace extends HabboItem { if (habbo == null) return true; - if (habbo.getHabboInfo().getId() == room.getId()) + if (habbo.getHabboInfo().getId() == room.getRoomInfo().getId()) return true; if (this.endTimestamp > Emulator.getIntUnixTimestamp()) { @@ -151,21 +151,21 @@ public class InteractionRentableSpace extends HabboItem { public void endRent() { this.setEndTimestamp(0); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room == null) return; Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { items.addAll(room.getItemsAt(i, j, this.getZ())); } } - for (HabboItem item : items) { + for (RoomItem item : items) { if (item.getUserId() == this.renterId) { room.pickUpItem(item, null); } 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 c2e7ea41..b72c0a3f 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +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; @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionRoller extends HabboItem { +public class InteractionRoller extends RoomItem { public static boolean NO_RULES = false; public static final int DELAY = 400; @@ -68,11 +68,11 @@ public class InteractionRoller extends HabboItem { @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(Room room, List>> itemsAtLocation) { if (NO_RULES) return true; if (itemsAtLocation.isEmpty()) return false; - for (Pair> set : itemsAtLocation) { + for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) { if (set.getValue().size() > 1) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java index 3a977194..a09f2fd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java similarity index 86% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java index fe76c514..0ed3e3ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer; import com.eu.habbo.threading.runnables.CloseGate; @@ -13,13 +13,13 @@ import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubGate extends InteractionDefault implements ConditionalGate { - public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException { +public class InteractionRoomClubGate extends InteractionDefault implements ConditionalGate { + public InteractionRoomClubGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); } - public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public InteractionRoomClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java similarity index 79% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java index e4b03e71..51936c4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java @@ -9,12 +9,12 @@ import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessa import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubHopper extends InteractionHopper { - public InteractionHabboClubHopper(ResultSet set, Item baseItem) throws SQLException { +public class InteractionRoomClubHopper extends InteractionHopper { + public InteractionRoomClubHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHabboClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public InteractionRoomClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java similarity index 70% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java index 9d1bfb1b..853bf7f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java @@ -3,18 +3,18 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubTeleportTile extends InteractionTeleportTile { - public InteractionHabboClubTeleportTile(ResultSet set, Item baseItem) throws SQLException { +public class InteractionRoomClubTeleportTile extends InteractionTeleportTile { + public InteractionRoomClubTeleportTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public InteractionHabboClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public InteractionRoomClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java index 987bea3a..724a4b00 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java @@ -7,9 +7,10 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; import java.awt.*; @@ -34,34 +35,34 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - if (roomUnit.getEffectId() == 97) { - room.giveEffect(roomUnit, 0, -1); + if (roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.getEffectId() == 97) { + room.giveEffect(roomAvatar, 0, -1); } } @Override public void onPlace(Room room) { super.onPlace(room); - THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class); + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class); Achievement snowboardBuild = Emulator.getGameEnvironment().getAchievementManager().getAchievement("snowBoardBuild"); if (snowboardBuild == null) return; int progress; - Habbo habbo = room.getHabbo(room.getOwnerId()); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(room.getRoomInfo().getOwnerInfo().getId()); if (habbo != null) { progress = habbo.getHabboStats().getAchievementProgress(snowboardBuild); } else { - progress = AchievementManager.getAchievementProgressForHabbo(room.getOwnerId(), snowboardBuild); + progress = AchievementManager.getAchievementProgressForHabbo(room.getRoomInfo().getOwnerInfo().getId(), snowboardBuild); } progress = Math.max(items.size() - progress, 0); if (progress > 0) { - AchievementManager.progressAchievement(room.getOwnerId(), snowboardBuild); + AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), snowboardBuild); } } @@ -79,7 +80,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { Rectangle newRect = RoomLayout.getRectangle(newLocation.getX(), newLocation.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for (Habbo habbo : room.getHabbosOnItem(this)) { - if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().getX(), habbo.getRoomUnit().getCurrentLocation().getY())) { + if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY())) { room.giveEffect(habbo, 0, -1); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java index e3e62bbb..b47baa1b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java @@ -5,8 +5,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.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +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 com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent; import com.eu.habbo.threading.runnables.RandomSpinningBottleNumber; @@ -14,7 +14,7 @@ import com.eu.habbo.threading.runnables.RandomSpinningBottleNumber; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionSpinningBottle extends HabboItem { +public class InteractionSpinningBottle extends RoomItem { public InteractionSpinningBottle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -46,7 +46,7 @@ public class InteractionSpinningBottle extends HabboItem { super.onClick(client, room, objects); if (client != null) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { if (!this.getExtradata().equalsIgnoreCase("-1")) { FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java index 669a5a69..7c6cd846 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionStackHelper extends HabboItem { +public class InteractionStackHelper extends RoomItem { public InteractionStackHelper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java index e1761878..5bac0dc9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java @@ -25,7 +25,7 @@ public class InteractionSwitch extends InteractionDefault { @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override @@ -46,12 +46,12 @@ public class InteractionSwitch extends InteractionDefault { if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { - if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } } - if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) { List onSuccess = new ArrayList<>(); onSuccess.add(() -> { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java index 37fbce36..2bc51667 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java @@ -22,7 +22,7 @@ public class InteractionSwitchRemoteControl extends InteractionDefault { @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 5e152373..87fda1d2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -5,9 +5,10 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.threading.runnables.teleport.TeleportActionOne; @@ -17,7 +18,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionTeleport extends HabboItem { +public class InteractionTeleport extends RoomItem { private int targetId; private int targetRoomId; private int roomUnitID = -1; @@ -45,7 +46,7 @@ public class InteractionTeleport extends HabboItem { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return this.getBaseItem().allowWalk() || roomUnit.getId() == this.roomUnitID; + return this.getBaseItem().allowWalk() || roomUnit.getVirtualId() == this.roomUnitID; } @Override @@ -62,67 +63,73 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); - if (habbo == null) + if (habbo == null) { return; + } - RoomUnit unit = habbo.getRoomUnit(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); - if (unit == null) + if (roomHabbo == null) { return; + } - RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile currentItemLocation = room.getLayout().getTile(this.getX(), this.getY()); - if (currentLocation == null) + if (currentItemLocation == null) { return; + } - RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); + RoomTile inFrontTile = room.getLayout().getTileInFront(currentItemLocation, this.getRotation()); - if (!canUseTeleport(client, room)) + if (!canUseTeleport(client, room)) { return; + } - if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { - startTeleport(room, habbo); - walkable = true; + if (this.roomUnitID == roomHabbo.getVirtualId() && roomHabbo.getCurrentPosition().equals(currentItemLocation)) { + this.startTeleport(room, habbo); + this.walkable = true; try { super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } catch (Exception e) { e.printStackTrace(); } - } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { + } else if (roomHabbo.getCurrentPosition().equals(currentItemLocation) || roomHabbo.getCurrentPosition().equals(inFrontTile)) { // set state 1 and walk on item - this.roomUnitID = unit.getId(); + this.roomUnitID = roomHabbo.getVirtualId(); this.setExtradata("1"); room.updateItemState(this); - unit.setGoalLocation(infrontTile); + roomHabbo.setGoalLocation(inFrontTile); List onSuccess = new ArrayList<>(); List onFail = new ArrayList<>(); onSuccess.add(() -> { - room.updateTile(currentLocation); - tryTeleport(client, room); - unit.removeOverrideTile(currentLocation); - unit.setCanLeaveRoomByDoor(true); - walkable = this.getBaseItem().allowWalk(); + room.updateTile(currentItemLocation); + this.tryTeleport(client, room); + roomHabbo.removeOverrideTile(currentItemLocation); + roomHabbo.setCanLeaveRoomByDoor(true); + this.walkable = this.getBaseItem().allowWalk(); }); onFail.add(() -> { - walkable = this.getBaseItem().allowWalk(); - room.updateTile(currentLocation); + this.walkable = this.getBaseItem().allowWalk(); + room.updateTile(currentItemLocation); this.setExtradata("0"); room.updateItemState(this); this.roomUnitID = -1; - unit.removeOverrideTile(currentLocation); - unit.setCanLeaveRoomByDoor(true); + roomHabbo.removeOverrideTile(currentItemLocation); + roomHabbo.setCanLeaveRoomByDoor(true); }); - walkable = true; - room.updateTile(currentLocation); - unit.addOverrideTile(currentLocation); - unit.setGoalLocation(currentLocation); - unit.setCanLeaveRoomByDoor(false); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); + this.walkable = true; + + room.updateTile(currentItemLocation); + roomHabbo.addOverrideTile(currentItemLocation); + roomHabbo.setGoalLocation(currentItemLocation); + roomHabbo.setCanLeaveRoomByDoor(false); + + Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, currentItemLocation, room, onSuccess, onFail)); } else { // walk to teleport and interact List onSuccess = new ArrayList<>(); @@ -130,8 +137,8 @@ public class InteractionTeleport extends HabboItem { onSuccess.add(() -> tryTeleport(client, room)); - unit.setGoalLocation(infrontTile); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, infrontTile, room, onSuccess, onFail)); + roomHabbo.setGoalLocation(inFrontTile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, inFrontTile, room, onSuccess, onFail)); } } @@ -151,7 +158,7 @@ public class InteractionTeleport extends HabboItem { if (!this.getExtradata().equals("0")) { this.setExtradata("0"); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItem(this); } @@ -192,13 +199,15 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); - if (habbo == null) + if (habbo == null) { return false; + } RoomUnit unit = habbo.getRoomUnit(); - if (unit == null) + if (unit == null) { return false; + } return habbo.getHabboInfo().getRiding() == null; } @@ -209,7 +218,7 @@ public class InteractionTeleport extends HabboItem { public void startTeleport(Room room, Habbo habbo, int delay) { if (habbo.getRoomUnit().isTeleporting()) { - walkable = this.getBaseItem().allowWalk(); + this.walkable = this.getBaseItem().allowWalk(); return; } 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 e8b90bbf..c81a255f 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 @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; @@ -37,7 +37,7 @@ public class InteractionTeleportTile extends InteractionTeleport { return; if (!habbo.getRoomUnit().isTeleporting()) { - habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation()); + habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentPosition()); this.startTeleport(room, habbo, 1000); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java index b8c1d313..3b642d99 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java @@ -3,7 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; @@ -37,9 +38,13 @@ public class InteractionTileEffectProvider extends InteractionCustomValues { public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); + if(!(roomUnit instanceof RoomHabbo roomHabbo)) { + return; + } + int effectId = Integer.parseInt(this.values.get("effectId")); - if (roomUnit.getEffectId() == effectId) { + if (roomHabbo.getEffectId() == effectId) { effectId = 0; } @@ -52,6 +57,6 @@ public class InteractionTileEffectProvider extends InteractionCustomValues { room.updateItem(proxy); }, 500); - room.giveEffect(roomUnit, effectId, -1); + room.giveEffect(roomHabbo, effectId, -1); } } 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 1ea1eb16..3ba91af7 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 @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -35,7 +35,7 @@ public class InteractionTrap extends InteractionDefault { } if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 6bccfc83..a8b1dd04 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -3,9 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -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.RoomUnitStatus; +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.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -17,7 +23,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionVendingMachine extends HabboItem { +public class InteractionVendingMachine extends RoomItem { public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -56,7 +62,7 @@ public class InteractionVendingMachine extends HabboItem { boolean inActivatorSpace = false; for(RoomTile ignored : activatorTiles) { - if(unit.getCurrentLocation().is(unit.getX(), unit.getY())) { + if(unit.getCurrentPosition().is(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY())) { inActivatorSpace = true; } } @@ -67,6 +73,10 @@ public class InteractionVendingMachine extends HabboItem { } private void useVendingMachine(GameClient client, Room room, RoomUnit unit) { + if(!(unit instanceof RoomAvatar roomAvatar)) { + return; + } + this.setExtradata("1"); room.updateItem(this); @@ -76,13 +86,13 @@ public class InteractionVendingMachine extends HabboItem { e.printStackTrace(); } - if(!unit.isWalking() && !unit.hasStatus(RoomUnitStatus.SIT) && !unit.hasStatus(RoomUnitStatus.LAY)) { - this.rotateToMachine(unit); + if(!roomAvatar.isWalking() && !roomAvatar.hasStatus(RoomUnitStatus.SIT) && !roomAvatar.hasStatus(RoomUnitStatus.LAY)) { + this.rotateToMachine(roomAvatar); } Emulator.getThreading().run(() -> { - giveVendingMachineItem(room, unit); + giveVendingMachineItem(room, roomAvatar); if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); @@ -93,8 +103,8 @@ public class InteractionVendingMachine extends HabboItem { }, 1500); } - public void giveVendingMachineItem(Room room, RoomUnit unit) { - Emulator.getThreading().run(new RoomUnitGiveHanditem(unit, room, this.getBaseItem().getRandomVendingItem())); + public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) { + Emulator.getThreading().run(new RoomUnitGiveHanditem(roomAvatar, room, this.getBaseItem().getRandomVendingItem())); } @Override @@ -113,7 +123,7 @@ public class InteractionVendingMachine extends HabboItem { boolean inActivatorSpace = false; for(RoomTile tile : activatorTiles) { - if(unit.getCurrentLocation().is(tile.getX(), tile.getY())) { + if(unit.getCurrentPosition().is(tile.getX(), tile.getY())) { inActivatorSpace = true; } } @@ -121,7 +131,7 @@ public class InteractionVendingMachine extends HabboItem { if(!inActivatorSpace) { RoomTile tileToWalkTo = null; for(RoomTile tile : activatorTiles) { - if((tile.getState() == RoomTileState.OPEN || tile.getState() == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) { + if((tile.getState() == RoomTileState.OPEN || tile.getState() == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentPosition()) > tile.distance(unit.getCurrentPosition()))) { tileToWalkTo = tile; } } @@ -151,7 +161,7 @@ public class InteractionVendingMachine extends HabboItem { super.run(); if (this.getExtradata().equals("1")) { this.setExtradata("0"); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItem(this); } @@ -174,11 +184,11 @@ public class InteractionVendingMachine extends HabboItem { } private void rotateToMachine(RoomUnit unit) { - RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())]; + RoomRotation rotation = RoomRotation.values()[Rotation.Calculate(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY(), this.getX(), this.getY())]; if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) { unit.setRotation(rotation); - unit.statusUpdate(true); + unit.setStatusUpdateNeeded(true); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java index a28b30b4..e15150a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; @@ -13,7 +13,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionVoteCounter extends HabboItem { +public class InteractionVoteCounter extends RoomItem { private boolean frozen; private int votes; 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 062e4034..438bf391 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 @@ -3,9 +3,14 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -78,7 +83,7 @@ public class InteractionWater extends InteractionDefault { if(roomUnit == null) return; roomUnit.setSwimming(true); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet == null) return; @@ -95,7 +100,7 @@ public class InteractionWater extends InteractionDefault { super.onWalkOff(roomUnit, room, objects); if ( roomUnit.getRoomUnitType() != RoomUnitType.PET) return; - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet == null) return; @@ -113,9 +118,9 @@ public class InteractionWater extends InteractionDefault { } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { - for (Pair> set : itemsAtLocation) { - for (HabboItem item : set.getValue()) { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { + for (RoomItem item : set.getValue()) { if(item != this) return false; } @@ -128,7 +133,7 @@ public class InteractionWater extends InteractionDefault { public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { if (!super.canWalkOn(roomUnit, room, objects)) return false; - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); return pet == null || pet.getPetData().isCanSwim(); } @@ -151,7 +156,7 @@ public class InteractionWater extends InteractionDefault { } // Update neighbouring water. - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) { + for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) { // We already updated ourself. if (item == this) { continue; @@ -168,7 +173,7 @@ public class InteractionWater extends InteractionDefault { // Update water items we might have missed in the old location. if (targetOld != null) { - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) { + for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) { if (targetOld.intersects(item.getRectangle())) { ((InteractionWaterItem) item).update(); } @@ -180,7 +185,7 @@ public class InteractionWater extends InteractionDefault { Rectangle target = this.getRectangle(); // Only update water item furnis that are intersecting with us. - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) { + for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) { if (target.intersects(item.getRectangle())) { ((InteractionWaterItem) item).update(); } @@ -280,7 +285,7 @@ public class InteractionWater extends InteractionDefault { } private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) { - for (HabboItem item : room.getItemsAt(x, y, z)) { + for (RoomItem item : room.getItemsAt(x, y, z)) { if (item instanceof InteractionWater water) { // Take out picked up water from the recalculation. diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java index 404e1f32..d479c4ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java @@ -5,7 +5,7 @@ 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.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import java.awt.*; @@ -46,7 +46,7 @@ public class InteractionWaterItem extends InteractionMultiHeight { } public void update() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room == null) { return; @@ -60,9 +60,9 @@ public class InteractionWaterItem extends InteractionMultiHeight { for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) { for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) { boolean tile = false; - THashSet items = room.getItemsAt(room.getLayout().getTile(x, y)); + THashSet items = room.getItemsAt(room.getLayout().getTile(x, y)); - for (HabboItem item : items) { + for (RoomItem item : items) { if (item instanceof InteractionWater) { tile = true; break; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 095b905a..5b8824e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -193,7 +193,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose()); if (roomUnit != null) { - this.addUserExecutionCache(roomUnit.getId(), millis); + this.addUserExecutionCache(roomUnit.getVirtualId(), millis); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java index c29cf0a6..9259b857 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index d8b3a9dc..a98b9245 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -20,7 +20,7 @@ import java.sql.SQLException; import java.util.List; @Slf4j -public class InteractionWiredHighscore extends HabboItem { +public class InteractionWiredHighscore extends RoomItem { public WiredHighscoreScoreType scoreType; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java index 4da6bb8f..d3555cb0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java @@ -5,17 +5,16 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; -import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; import java.sql.ResultSet; import java.sql.SQLException; import java.util.concurrent.ScheduledFuture; -public class InteractionYoutubeTV extends HabboItem { +public class InteractionYoutubeTV extends RoomItem { public YoutubeManager.YoutubePlaylist currentPlaylist = null; public YoutubeManager.YoutubeVideo currentVideo = null; public int startedWatchingAt = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java index b56491bd..10615da4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java index f52ff6b8..adf89c03 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java @@ -2,12 +2,12 @@ package com.eu.habbo.habbohotel.items.interactions.games; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionGameTeamItem extends HabboItem { +public abstract class InteractionGameTeamItem extends RoomItem { public final GameTeamColors teamColor; protected InteractionGameTeamItem(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 161cea9b..0cb454db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -24,7 +24,7 @@ import java.sql.SQLException; import java.util.Arrays; @Slf4j -public class InteractionGameTimer extends HabboItem implements Runnable { +public class InteractionGameTimer extends RoomItem implements Runnable { private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; 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 0882cb0b..9a718558 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 @@ -6,8 +6,10 @@ 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.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import java.sql.ResultSet; import java.sql.SQLException; @@ -27,7 +29,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @@ -37,7 +39,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @@ -47,7 +49,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getDragDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @@ -57,7 +59,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getTackleDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @@ -67,52 +69,52 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) { + public RoomRotation getBounceDirection(Room room, RoomRotation currentDirection) { switch (currentDirection) { default: case NORTH: - return RoomUserRotation.SOUTH; + return RoomRotation.SOUTH; case NORTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) - return RoomUserRotation.NORTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) - return RoomUserRotation.SOUTH_EAST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + return RoomRotation.NORTH_WEST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + return RoomRotation.SOUTH_EAST; else - return RoomUserRotation.SOUTH_WEST; + return RoomRotation.SOUTH_WEST; case EAST: - return RoomUserRotation.WEST; + return RoomRotation.WEST; case SOUTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) - return RoomUserRotation.SOUTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) - return RoomUserRotation.NORTH_EAST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + return RoomRotation.SOUTH_WEST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + return RoomRotation.NORTH_EAST; else - return RoomUserRotation.NORTH_WEST; + return RoomRotation.NORTH_WEST; case SOUTH: - return RoomUserRotation.NORTH; + return RoomRotation.NORTH; case SOUTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) - return RoomUserRotation.SOUTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) - return RoomUserRotation.NORTH_WEST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + return RoomRotation.SOUTH_EAST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + return RoomRotation.NORTH_WEST; else - return RoomUserRotation.NORTH_EAST; + return RoomRotation.NORTH_EAST; case WEST: - return RoomUserRotation.EAST; + return RoomRotation.EAST; case NORTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) - return RoomUserRotation.NORTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) - return RoomUserRotation.SOUTH_WEST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + return RoomRotation.NORTH_EAST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + return RoomRotation.SOUTH_WEST; else - return RoomUserRotation.SOUTH_EAST; + return RoomRotation.SOUTH_EAST; } } @@ -124,29 +126,29 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { if (to == null) return false; - HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); } @Override - public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { + public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { Habbo habbo = room.getHabbo(kicker); if (habbo != null) { @@ -154,7 +156,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { if (game != null) { GameTeam team = game.getTeamForHabbo(habbo); if (team != null) { - HabboItem item = room.getTopItemAt(to.getX(), to.getY()); + RoomItem item = room.getTopItemAt(to.getX(), to.getY()); try { item.onWalkOn(kicker, room, null); } catch (Exception e) { @@ -169,7 +171,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) { + public void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker) { } @@ -179,7 +181,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } @Override - public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { + public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { return to.getState() == RoomTileState.OPEN && to.isWalkable(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java index 77954520..0009d8b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiSphere extends HabboItem { +public class InteractionBattleBanzaiSphere extends RoomItem { public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index 5b7580a7..11109f6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -4,16 +4,16 @@ import com.eu.habbo.Emulator; 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.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +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 com.eu.habbo.threading.runnables.BanzaiRandomTeleport; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionBattleBanzaiTeleporter extends HabboItem { +public class InteractionBattleBanzaiTeleporter extends RoomItem { public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -57,13 +57,13 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem { super.onWalkOn(roomUnit, room, objects); if(objects.length < 3) { - HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this); + RoomItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this); if (target == null) return; this.setExtradata("1"); room.updateItemState(this); roomUnit.removeStatus(RoomUnitStatus.MOVE); - roomUnit.setGoalLocation(roomUnit.getCurrentLocation()); + roomUnit.setGoalLocation(roomUnit.getCurrentPosition()); roomUnit.setCanWalk(false); Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500); } 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 d2583d9e..96d55a83 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +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; @@ -16,7 +16,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionBattleBanzaiTile extends HabboItem { +public class InteractionBattleBanzaiTile extends RoomItem { public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -92,8 +92,8 @@ public class InteractionBattleBanzaiTile extends HabboItem { } @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { - for (Pair> set : itemsAtLocation) { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) return false; } 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 cbc343df..f6ec238e 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 @@ -9,7 +9,7 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; @@ -35,7 +35,7 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { @Override public boolean isWalkable() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room == null) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java index f34584b4..ffb02954 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java index 09a45a03..aae57b11 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java @@ -6,8 +6,12 @@ import com.eu.habbo.habbohotel.games.football.FootballGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionPushable; import com.eu.habbo.habbohotel.items.interactions.games.football.goals.InteractionFootballGoal; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +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.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import com.eu.habbo.util.pathfinding.Rotation; @@ -29,10 +33,10 @@ public class InteractionFootball extends InteractionPushable { @Override public int getWalkOnVelocity(RoomUnit roomUnit, Room room) { - if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2 && this.getExtradata().equals("1")) + if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2 && this.getExtradata().equals("1")) return 0; - if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 1) + if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 1) return 6; return 1; @@ -40,7 +44,7 @@ public class InteractionFootball extends InteractionPushable { @Override public int getWalkOffVelocity(RoomUnit roomUnit, Room room) { - if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 0) + if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 0) return 6; return 1; @@ -48,7 +52,7 @@ public class InteractionFootball extends InteractionPushable { @Override public int getDragVelocity(RoomUnit roomUnit, Room room) { - if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2) + if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2) return 0; return 1; @@ -61,22 +65,22 @@ public class InteractionFootball extends InteractionPushable { @Override - public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @Override - public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { RoomTile peek = roomUnit.getPath().peek(); RoomTile nextWalkTile = peek != null ? room.getLayout().getTile(peek.getX(), peek.getY()) : roomUnit.getGoalLocation(); - return RoomUserRotation.values()[(RoomUserRotation.values().length + Rotation.Calculate(roomUnit.getX(), roomUnit.getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8]; + return RoomRotation.values()[(RoomRotation.values().length + Rotation.Calculate(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8]; } - public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getDragDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } - public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) { + public RoomRotation getTackleDirection(RoomUnit roomUnit, Room room) { return roomUnit.getBodyRotation(); } @@ -92,52 +96,52 @@ public class InteractionFootball extends InteractionPushable { } @Override - public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) { + public RoomRotation getBounceDirection(Room room, RoomRotation currentDirection) { switch (currentDirection) { default: case NORTH: - return RoomUserRotation.SOUTH; + return RoomRotation.SOUTH; case NORTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) - return RoomUserRotation.NORTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) - return RoomUserRotation.SOUTH_EAST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + return RoomRotation.NORTH_WEST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + return RoomRotation.SOUTH_EAST; else - return RoomUserRotation.SOUTH_WEST; + return RoomRotation.SOUTH_WEST; case EAST: - return RoomUserRotation.WEST; + return RoomRotation.WEST; case SOUTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) - return RoomUserRotation.SOUTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) - return RoomUserRotation.NORTH_EAST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + return RoomRotation.SOUTH_WEST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + return RoomRotation.NORTH_EAST; else - return RoomUserRotation.NORTH_WEST; + return RoomRotation.NORTH_WEST; case SOUTH: - return RoomUserRotation.NORTH; + return RoomRotation.NORTH; case SOUTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue()))) - return RoomUserRotation.SOUTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue()))) - return RoomUserRotation.NORTH_WEST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + return RoomRotation.SOUTH_EAST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + return RoomRotation.NORTH_WEST; else - return RoomUserRotation.NORTH_EAST; + return RoomRotation.NORTH_EAST; case WEST: - return RoomUserRotation.EAST; + return RoomRotation.EAST; case NORTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue()))) - return RoomUserRotation.NORTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue()))) - return RoomUserRotation.SOUTH_WEST; + if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + return RoomRotation.NORTH_EAST; + else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + return RoomRotation.SOUTH_WEST; else - return RoomUserRotation.SOUTH_EAST; + return RoomRotation.SOUTH_EAST; } } @@ -145,7 +149,7 @@ public class InteractionFootball extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { if (to == null || to.getState() == RoomTileState.INVALID) return false; - HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); // Move is valid if there isnt any furni yet if (topItem == null) { @@ -186,22 +190,22 @@ public class InteractionFootball extends InteractionPushable { //Events @Override - public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) { + public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) { } @Override - public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { + public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { FootballGame game = (FootballGame) room.getGame(FootballGame.class); if (game == null) { try { @@ -211,8 +215,8 @@ public class InteractionFootball extends InteractionPushable { return; } } - HabboItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this); - HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this); + RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) { GameTeamColors color = interactionFootballGoal.teamColor; game.onScore(kicker, color); @@ -223,7 +227,7 @@ public class InteractionFootball extends InteractionPushable { } @Override - public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) { + public void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker) { } @@ -234,9 +238,9 @@ public class InteractionFootball extends InteractionPushable { } @Override - public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { - HabboItem topItem = room.getTopItemAt(from.getX(), from.getY(), this); - return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.getX(), to.getY())) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); + public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { + RoomItem topItem = room.getTopItemAt(from.getX(), from.getY(), this); + return !((Emulator.getRandom().nextInt(10) >= 3 && room.getRoomUnitManager().hasHabbosAt(to)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); } @Override 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 50a232ec..f18d6e7d 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 @@ -3,10 +3,10 @@ package com.eu.habbo.habbohotel.items.interactions.games.football; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +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.HabboGender; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; @@ -20,7 +20,7 @@ import com.eu.habbo.util.figure.FigureUtil; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFootballGate extends HabboItem { +public class InteractionFootballGate extends RoomItem { private static final String CACHE_KEY = "fball_gate_look"; private String figureM; private String figureF; @@ -67,8 +67,8 @@ public class InteractionFootballGate extends HabboItem { habbo.getHabboInfo().setLook((String) habbo.getHabboStats().getCache().get(CACHE_KEY)); habbo.getHabboStats().getCache().remove(CACHE_KEY); habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java index 443bb720..e50163c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java index dba5f039..ed3862e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -61,7 +61,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { this.setExtradata(this.score + ""); this.needsUpdate(true); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItem(this); } @@ -87,7 +87,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { this.setExtradata(this.score + ""); this.needsUpdate(true); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItem(this); } 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 673e6e83..59942cf4 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,16 +8,16 @@ 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeBlock extends HabboItem { +public class InteractionFreezeBlock extends RoomItem { public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -33,10 +33,10 @@ public class InteractionFreezeBlock extends HabboItem { if (client == null) return; - HabboItem item = null; - THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); + RoomItem item = null; + THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); - for (HabboItem i : items) { + for (RoomItem i : items) { if (i instanceof InteractionFreezeTile) { if (item == null || i.getZ() <= item.getZ()) { item = i; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java index de76eeef..52337257 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionFreezeExitTile extends HabboItem { +public class InteractionFreezeExitTile extends RoomItem { public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); 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 d46b3c82..2c768abf 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 @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.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; @@ -15,7 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -public class InteractionFreezeTile extends HabboItem { +public class InteractionFreezeTile extends RoomItem { public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -41,7 +41,7 @@ public class InteractionFreezeTile extends HabboItem { if (client == null) return; - if (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY()) { + if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY()) { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); if (game != null) @@ -74,8 +74,8 @@ public class InteractionFreezeTile extends HabboItem { @Override - public boolean canStackAt(Room room, List>> itemsAtLocation) { - for (Pair> set : itemsAtLocation) { + public boolean canStackAt(Room room, List>> itemsAtLocation) { + for (Pair> set : itemsAtLocation) { if (set.getValue() != null && !set.getValue().isEmpty()) return false; } 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 e135e7d1..38ab21f9 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 @@ -9,7 +9,7 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; @@ -34,7 +34,7 @@ public class InteractionFreezeGate extends InteractionGameGate { @Override public boolean isWalkable() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room == null) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java index 5f8d510d..66cab607 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; 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 53c8dd7b..3fffa883 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,15 +4,15 @@ 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public abstract class InteractionTagField extends HabboItem { +public abstract class InteractionTagField extends RoomItem { public Class gameClazz; public InteractionTagField(ResultSet set, Item baseItem, Class gameClazz) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java index d9aa71c6..e1f04890 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java @@ -2,14 +2,14 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTagPole extends HabboItem { +public class InteractionTagPole extends RoomItem { public InteractionTagPole(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } 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 75d25b2b..7e5c6855 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 @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.games.tag.IceTagGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; 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 c25374c9..ed035ad4 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 @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.games.tag.RollerskateGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java index 58eea046..6672f7ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java @@ -1,7 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.interfaces; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; public interface ConditionalGate { void onRejected(RoomUnit roomUnit, Room room, Object[] objects); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java index b92511cd..b3304ea5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java @@ -4,14 +4,14 @@ import com.eu.habbo.Emulator; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionMonsterPlantSeed extends HabboItem { +public class InteractionMonsterPlantSeed extends RoomItem { public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java index 9cd0adf5..dcd7e9a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java @@ -6,16 +6,16 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +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 com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionNest extends HabboItem { +public class InteractionNest extends RoomItem { public InteractionNest(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -56,7 +56,7 @@ public class InteractionNest extends HabboItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet == null) return; @@ -72,7 +72,7 @@ public class InteractionNest extends HabboItem { pet.setTask(PetTasks.NEST); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getX(), this.getY(), false) + ""); room.sendComposer(new UserUpdateComposer(roomUnit).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index 87eabfe3..e23d338e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -7,9 +7,9 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +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.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.pets.PerkAllowancesComposer; import com.eu.habbo.messages.outgoing.rooms.pets.breeding.ConfirmBreedingRequestComposer; @@ -19,7 +19,7 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionPetBreedingNest extends HabboItem { +public class InteractionPetBreedingNest extends RoomItem { private Pet petOne = null; private Pet petTwo = null; @@ -33,7 +33,7 @@ public class InteractionPetBreedingNest extends HabboItem { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return room.getPet(roomUnit) != null && !this.boxFull(); + return room.getRoomUnitManager().getPetByRoomUnit(roomUnit) != null && !this.boxFull(); } @Override @@ -57,14 +57,14 @@ public class InteractionPetBreedingNest extends HabboItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && !this.boxFull()) { this.addPet(pet); if (this.boxFull()) { - Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId()); - Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId()); + Habbo ownerPetOne = room.getRoomUnitManager().getRoomHabboById(this.petOne.getUserId()); + Habbo ownerPetTwo = room.getRoomUnitManager().getRoomHabboById(this.petTwo.getUserId()); if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) { ownerPetTwo.getClient().sendResponse(new ConfirmBreedingRequestComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername())); @@ -109,13 +109,13 @@ public class InteractionPetBreedingNest extends HabboItem { public void stopBreeding(Habbo habbo) { this.setExtradata("0"); - habbo.getHabboInfo().getCurrentRoom().updateItem(this); + habbo.getRoomUnit().getRoom().updateItem(this); if (this.petOne != null) { habbo.getClient().sendResponse(new PerkAllowancesComposer(this.getId(), PerkAllowancesComposer.CLOSE_WIDGET, "")); } if (this.petTwo.getUserId() != habbo.getHabboInfo().getId()) { - Habbo owner = this.petTwo.getRoom().getHabbo(this.petTwo.getUserId()); + Habbo owner = this.petTwo.getRoom().getRoomUnitManager().getRoomHabboById(this.petTwo.getUserId()); if (owner != null) { owner.getClient().sendResponse(new PerkAllowancesComposer(this.getId(), PerkAllowancesComposer.CLOSE_WIDGET, "")); } @@ -143,18 +143,20 @@ public class InteractionPetBreedingNest extends HabboItem { Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId())); this.setExtradata("2"); - habbo.getHabboInfo().getCurrentRoom().updateItem(this); + habbo.getRoomUnit().getRoom().updateItem(this); - HabboItem box = this; + RoomItem box = this; Emulator.getThreading().run(() -> { Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient()); - habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ()); + + + habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getX(), box.getY(), box.getZ()); offspring.setNeedsUpdate(true); offspring.run(); InteractionPetBreedingNest.this.freePets(); - habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box); + habbo.getRoomUnit().getRoom().removeHabboItem(box); habbo.getClient().sendResponse(new NestBreedingSuccessComposer(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring))); if (box.getBaseItem().getName().startsWith("pet_breeding_")) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index 96a0932e..e5762342 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -6,7 +6,12 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -32,7 +37,7 @@ public class InteractionPetDrink extends InteractionDefault { @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override @@ -43,12 +48,12 @@ public class InteractionPetDrink extends InteractionDefault { if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { - if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { + if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } } - if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) { List onSuccess = new ArrayList<>(); onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1)); @@ -66,20 +71,20 @@ public class InteractionPetDrink extends InteractionDefault { if (this.getExtradata() == null || this.getExtradata().isEmpty()) this.setExtradata("0"); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) { pet.clearPosture(); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); Emulator.getThreading().run(() -> { pet.addThirst(-75); this.change(room, -1); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); new PetClearPosture(pet, RoomUnitStatus.EAT, null, true); pet.setPacketUpdate(true); }, 1000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java index 92bf9bc3..8b9e5388 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java @@ -6,9 +6,9 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.PetEatAction; @@ -31,15 +31,15 @@ public class InteractionPetFood extends InteractionDefault { if (this.getExtradata().length() == 0) this.setExtradata("0"); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { if (pet.getPetData().haveFoodItem(this)) { if (pet.levelHunger >= 35) { pet.setTask(PetTasks.EAT); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, "0"); room.sendComposer(new UserUpdateComposer(roomUnit).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index fef842ea..a3af6600 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -6,8 +6,13 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +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.rooms.entities.units.RoomUnitType; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -31,8 +36,8 @@ public class InteractionPetToy extends InteractionDefault { this.setExtradata("0"); room.updateItem(this); - for (Pet pet : room.getPetsAt(oldLocation)) { - pet.getRoomUnit().clearStatus(); + for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @@ -41,7 +46,7 @@ public class InteractionPetToy extends InteractionDefault { this.setExtradata("0"); for (Pet pet : room.getPetsOnItem(this)) { - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @@ -50,7 +55,7 @@ public class InteractionPetToy extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { if (pet.getEnergy() <= 35) { @@ -59,16 +64,16 @@ public class InteractionPetToy extends InteractionDefault { pet.setTask(PetTasks.PLAY); pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); - HabboItem item = this; + RoomItem item = this; Emulator.getThreading().run(() -> { pet.addHappiness(25); item.setExtradata("0"); room.updateItem(item); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run(); pet.setPacketUpdate(true); }, ((long)(Emulator.getRandom().nextInt(20) * 500) + 2500)); @@ -81,19 +86,19 @@ public class InteractionPetToy extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { this.setExtradata("0"); room.updateItem(this); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java index 9c16421f..cadb17a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -6,7 +6,11 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; -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.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -31,7 +35,7 @@ public class InteractionPetTrampoline extends InteractionDefault { this.setExtradata("0"); room.updateItem(this); - for (Pet pet : room.getPetsAt(oldLocation)) { + for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); pet.setPacketUpdate(true); } @@ -51,7 +55,7 @@ public class InteractionPetTrampoline extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { if (pet.getEnergy() <= 35) { @@ -78,7 +82,7 @@ public class InteractionPetTrampoline extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { this.setExtradata("0"); @@ -90,7 +94,7 @@ public class InteractionPetTrampoline extends InteractionDefault { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index 7ff78077..2be0541d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -4,7 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; -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.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -21,15 +26,15 @@ public class InteractionPetTree extends InteractionDefault { @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - for (Pet pet : room.getPetsAt(oldLocation)) { - pet.getRoomUnit().clearStatus(); + for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @Override public void onPickUp(Room room) { for (Pet pet : room.getPetsOnItem(this)) { - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @@ -38,7 +43,7 @@ public class InteractionPetTree extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { RoomUnitStatus task = switch (pet.getTask()) { case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE; @@ -49,17 +54,17 @@ public class InteractionPetTree extends InteractionDefault { if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); RoomUnitStatus finalTask = task; Emulator.getThreading().run(() -> { pet.addHappiness(25); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); new PetClearPosture(pet, finalTask, null, true); - if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) { - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentPosition())) { + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); } else { pet.clearPosture(); } @@ -67,9 +72,9 @@ public class InteractionPetTree extends InteractionDefault { pet.setPacketUpdate(true); }, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500)); } else { - pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatus(); - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); } } @@ -79,17 +84,17 @@ public class InteractionPetTree extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } } @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getPet(roomUnit); + Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index a016a1a2..ff39f9ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -50,7 +50,7 @@ public class InteractionTotemHead extends InteractionDefault { private void update(Room room, RoomTile tile) { InteractionTotemLegs legs = null; - for(HabboItem item : room.getItemsAt(tile)) { + for(RoomItem item : room.getItemsAt(tile)) { if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) legs = (InteractionTotemLegs)item; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index f12a5193..1dcf58f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -41,7 +41,7 @@ public class InteractionTotemLegs extends InteractionDefault { } private void updateHead(Room room, RoomTile tile) { - for(HabboItem item : room.getItemsAt(tile)) { + for(RoomItem item : room.getItemsAt(tile)) { if(item instanceof InteractionTotemHead && item.getZ() > this.getZ()) ((InteractionTotemHead)item).updateTotemState(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index 6c9ddb3f..52103f5f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -39,9 +39,9 @@ public class InteractionTotemPlanet extends InteractionDefault { InteractionTotemLegs legs = null; InteractionTotemHead head = null; - THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); + THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); - for(HabboItem item : items) { + for(RoomItem item : items) { if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) legs = (InteractionTotemLegs)item; } @@ -51,7 +51,7 @@ public class InteractionTotemPlanet extends InteractionDefault { return; } - for(HabboItem item : items) { + for(RoomItem item : items) { if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ()) head = (InteractionTotemHead)item; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index 7f720678..a4e799bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; @@ -53,15 +53,15 @@ public class WiredSettings implements IWiredSettings { this.selectionType = 0; } - public HashSet getItems(Room room) { - HashSet items = new HashSet<>(); + public HashSet getItems(Room room) { + HashSet items = new HashSet<>(); if(this.itemIds.size() == 0) { return items; } for(int i = 0; i < this.itemIds.size(); i++) { - HabboItem item = room.getHabboItem(this.itemIds.get(i)); + RoomItem item = room.getHabboItem(this.itemIds.get(i)); if(item == null || item.getRoomId() == 0) { this.itemIds.remove(i); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index ccf676b8..ceb229a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 04df4150..97bab4d9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -1,21 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { public final int PARAM_ALL_FURNI = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java similarity index 62% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java index be5d9169..96732a4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java @@ -1,31 +1,26 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; -public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { - public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { +public class WiredConditionFurniHaveRoom extends InteractionWiredCondition { + public WiredConditionFurniHaveRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionFurniHaveRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -35,15 +30,15 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { return true; } - Collection habbos = room.getHabbos(); - Collection bots = room.getCurrentBots().valueCollection(); - Collection pets = room.getCurrentPets().valueCollection(); + Collection habbos = room.getRoomUnitManager().getRoomHabbos(); + Collection bots = room.getRoomUnitManager().getCurrentRoomBots().values(); + Collection pets = room.getRoomUnitManager().getCurrentRoomPets().values(); return this.getWiredSettings().getItems(room).stream().allMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || - bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || - pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())); + return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || + bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || + pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())); }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index ee9721db..cf5f08b3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java @@ -1,19 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { @@ -34,7 +29,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { return true; } - if (stuff[0] instanceof HabboItem triggeringItem) { + if (stuff[0] instanceof RoomItem triggeringItem) { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> item == triggeringItem); } 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 af4e452f..42513d4b 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 @@ -2,12 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; @@ -23,13 +21,13 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (room.getGuildId() == 0) { + if (room.getRoomInfo().getGuild().getId() == 0) { return false; } Habbo habbo = room.getHabbo(roomUnit); - return habbo != null && habbo.getHabboStats().hasGuild(room.getGuildId()); + return habbo != null && habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId()); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index 71868641..f3de4bfe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -3,12 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 08b983f8..d5d4c95a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -4,8 +4,8 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import lombok.Getter; @@ -41,7 +41,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; this.matchSettings = this.getWiredSettings().getMatchParams(); - for(HabboItem item : this.getWiredSettings().getItems(room)) { + for(RoomItem item : this.getWiredSettings().getItems(room)) { WiredMatchFurniSetting furniSettings = this.matchSettings.stream().filter(settings -> settings.getItem_id() == item.getId()).findAny().orElse(null); if(furniSettings == null) { @@ -83,7 +83,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition public void saveAdditionalData(Room room) { List matchSettings = new ArrayList<>(); - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); matchSettings.add(settings); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index e8bf6b64..e22a6d4e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -4,10 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index bc9a9e1b..a79043d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -1,21 +1,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { public final int PARAM_ALL_FURNI = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java similarity index 62% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java index 912c1d71..cd64c515 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java @@ -1,31 +1,26 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; -public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { - public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { +public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition { + public WiredConditionNotFurniHaveRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionNotFurniHaveRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -35,15 +30,15 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { return true; } - Collection habbos = room.getHabbos(); - Collection bots = room.getCurrentBots().valueCollection(); - Collection pets = room.getCurrentPets().valueCollection(); + Collection habbos = room.getRoomUnitManager().getRoomHabbos(); + Collection bots = room.getRoomUnitManager().getCurrentRoomBots().values(); + Collection pets = room.getRoomUnitManager().getCurrentRoomPets().values(); return this.getWiredSettings().getItems(room).stream().noneMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || - bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) || - pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())); + return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || + bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || + pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())); }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index c5252b66..41a5c697 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java @@ -1,23 +1,19 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS; - private final THashSet items = new THashSet<>(); + private final THashSet items = new THashSet<>(); public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -37,7 +33,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { return true; } - if (stuff[0] instanceof HabboItem triggeringItem) { + if (stuff[0] instanceof RoomItem triggeringItem) { return this.getWiredSettings().getItems(room).stream().noneMatch(item -> item == triggeringItem); } 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 c9f6e0c3..c5e3e487 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 @@ -2,12 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; @@ -23,12 +21,12 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (room.getGuildId() == 0) + if (room.getRoomInfo().getGuild().getId() == 0) return false; Habbo habbo = room.getHabbo(roomUnit); - return habbo == null || !habbo.getHabboStats().hasGuild(room.getGuildId()); + return habbo == null || !habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId()); } @Override 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 54e33e17..50023f9f 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 @@ -3,13 +3,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java index 1586a471..9f0378d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java similarity index 52% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java index 134623ff..0573a042 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java @@ -1,23 +1,19 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboCount extends WiredConditionHabboCount { - public WiredConditionNotHabboCount(ResultSet set, Item baseItem) throws SQLException { +public class WiredConditionNotRoomCount extends WiredConditionRoomCount { + public WiredConditionNotRoomCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionNotRoomCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java similarity index 52% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java index 5f77d51d..68b0983d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java @@ -1,23 +1,19 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboHasEffect extends WiredConditionHabboHasEffect { - public WiredConditionNotHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { +public class WiredConditionNotRoomHasEffect extends WiredConditionRoomHasEffect { + public WiredConditionNotRoomHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionNotRoomHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java similarity index 67% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java index 7d02d83c..f95791d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java @@ -2,22 +2,22 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionNotHabboWearsBadge extends WiredConditionHabboWearsBadge { +public class WiredConditionNotRoomWearsBadge extends WiredConditionRoomWearsBadge { public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_BADGE; protected String badge = ""; - public WiredConditionNotHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException { + public WiredConditionNotRoomWearsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionNotHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionNotRoomWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java index c00d00c3..54fd82c7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java similarity index 70% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java index 6ac364e6..227e5ff0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java @@ -2,25 +2,22 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboCount extends InteractionWiredCondition { +public class WiredConditionRoomCount extends InteractionWiredCondition { public final int PARAM_LOWER_LIMIT = 0; public final int PARAM_UPPER_LIMIT = 1; - public WiredConditionHabboCount(ResultSet set, Item baseItem) throws SQLException { + public WiredConditionRoomCount(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionRoomCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -28,7 +25,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { int lowerLimit = this.getWiredSettings().getIntegerParams().get(PARAM_LOWER_LIMIT); int upperLimit = this.getWiredSettings().getIntegerParams().get(PARAM_UPPER_LIMIT); - int userCount = room.getUserCount(); + int userCount = room.getRoomUnitManager().getRoomHabbosCount(); return userCount >= lowerLimit && userCount <= upperLimit; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java similarity index 63% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java index 77026560..a9dcf93d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java @@ -2,36 +2,34 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboHasEffect extends InteractionWiredCondition { +public class WiredConditionRoomHasEffect extends InteractionWiredCondition { public final int PARAM_EFFECT_ID = 0; - public WiredConditionHabboHasEffect(ResultSet set, Item baseItem) throws SQLException { + public WiredConditionRoomHasEffect(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionRoomHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) { + if (roomUnit == null || !(roomUnit instanceof RoomAvatar roomAvatar)) { return false; } int effectId = this.getWiredSettings().getIntegerParams().get(PARAM_EFFECT_ID); - return roomUnit.getEffectId() == effectId; + return roomAvatar.getEffectId() == effectId; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java similarity index 66% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java index 6e725e58..63a4f242 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java @@ -3,7 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.wired.WiredConditionType; import lombok.extern.slf4j.Slf4j; @@ -11,26 +12,26 @@ import java.sql.ResultSet; import java.sql.SQLException; @Slf4j -public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { +public class WiredConditionRoomHasHandItem extends InteractionWiredCondition { public final int PARAM_HAND_ITEM_ID = 0; - public WiredConditionHabboHasHandItem(ResultSet set, Item baseItem) throws SQLException { + public WiredConditionRoomHasHandItem(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionRoomHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null) { + if (roomUnit == null || !(roomUnit instanceof RoomAvatar roomAvatar)) { return false; } int handItemId = this.getWiredSettings().getIntegerParams().get(PARAM_HAND_ITEM_ID); - return roomUnit.getHandItem() == handItemId; + return roomAvatar.getHandItem() == handItemId; } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java similarity index 73% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java index 14035fa3..0a627c63 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java @@ -2,24 +2,21 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { - public WiredConditionHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException { +public class WiredConditionRoomWearsBadge extends InteractionWiredCondition { + public WiredConditionRoomWearsBadge(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredConditionHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredConditionRoomWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } 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 7ad53922..d51889bd 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 @@ -3,13 +3,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index 802325e2..63957d88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -1,20 +1,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException { @@ -35,7 +31,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { return false; } - THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); + THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentPosition()); return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains); } 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 2bedaa9f..ac823641 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 @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index 2eceb51b..37718273 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -2,21 +2,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -import java.util.regex.Pattern; public class WiredEffectBotClothes extends InteractionWiredEffect { public WiredEffectBotClothes(ResultSet set, Item baseItem) throws SQLException { @@ -34,7 +28,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); String botLook = stringParams[1]; - List bots = room.getBots(botName); + List bots = room.getRoomUnitManager().getBotsByName(botName); if(bots.size() == 0) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java similarity index 65% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java index d6d63d88..498c1fa3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java @@ -1,39 +1,32 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; -public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { +public class WiredEffectBotFollowRoom extends InteractionWiredEffect { public final int PARAM_MODE = 0; - public WiredEffectBotFollowHabbo(ResultSet set, Item baseItem) throws SQLException { + public WiredEffectBotFollowRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotFollowHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredEffectBotFollowRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { Habbo habbo = room.getHabbo(roomUnit); - List bots = room.getBots(this.getWiredSettings().getStringParam()); + List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()); if (habbo != null && bots.size() == 1) { Bot bot = bots.get(0); 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 044bc6c0..1cf87079 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 @@ -2,19 +2,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -35,23 +32,29 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Habbo habbo = room.getHabbo(roomUnit); - List bots = room.getBots(this.getWiredSettings().getStringParam()); + if(!(roomUnit instanceof RoomAvatar roomAvatar)) { + return false; + } + + Habbo habbo = room.getHabbo(roomAvatar); + List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()); int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID); if (habbo != null && bots.size() == 1) { Bot bot = bots.get(0); List tasks = new ArrayList<>(); - tasks.add(new RoomUnitGiveHanditem(roomUnit, room, itemId)); + tasks.add(new RoomUnitGiveHanditem(roomAvatar, room, itemId)); tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0)); tasks.add(() -> { - if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) { - WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{}); + if(roomAvatar.getRoom() != null) { + if (roomAvatar.getRoom().getRoomInfo().getId() == room.getRoomInfo().getId() && roomAvatar.getCurrentPosition().distance(bot.getRoomUnit().getCurrentPosition()) < 2) { + WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{}); + } } }); - RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomUnit.getX(), roomUnit.getY(), true); + RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY(), true); if(tile != null) { bot.getRoomUnit().setGoalLocation(tile); 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 cf8a33e5..606cf4cc 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 @@ -2,23 +2,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -import java.util.regex.Pattern; public class WiredEffectBotTalk extends InteractionWiredEffect { public final int PARAM_MODE = 0; @@ -45,14 +40,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "") .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "") .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") - .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName()) + .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) - .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + ""); + .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName()) + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + ""); } - List bots = room.getBots(botName); + List bots = room.getRoomUnitManager().getBotsByName(botName); if (bots.size() == 1) { Bot bot = bots.get(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java similarity index 79% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java index a70db984..1e4d63c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java @@ -2,33 +2,27 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; -public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { +public class WiredEffectBotTalkToRoom extends InteractionWiredEffect { public final int PARAM_MODE = 0; - public WiredEffectBotTalkToHabbo(ResultSet set, Item baseItem) throws SQLException { + public WiredEffectBotTalkToRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectBotTalkToHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredEffectBotTalkToRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -46,13 +40,13 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "") .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "") .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") - .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName()) + .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername()) .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) - .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + ""); + .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName()) + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + ""); - List bots = room.getBots(botName); + List bots = room.getRoomUnitManager().getBotsByName(botName); if (bots.size() != 1) { return false; 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 2b0f48f9..74dab41b 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 @@ -7,15 +7,14 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; @@ -38,7 +37,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } String botName = this.getWiredSettings().getStringParam(); - List bots = room.getBots(botName); + List bots = room.getRoomUnitManager().getBotsByName(botName); if (bots.size() == 0) { return false; @@ -49,13 +48,16 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { int i = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()) + 1; int j = 1; - for (HabboItem item : this.getWiredSettings().getItems(room)) { - if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) { - if (i == j) { - teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY())); - return true; - } else { - j++; + for (RoomItem item : this.getWiredSettings().getItems(room)) { + if (item.getRoomId() != 0) { + Room room1 = bot.getRoom(); + if (item.getRoomId() == room1.getRoomInfo().getId()) { + if (i == j) { + teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY())); + return true; + } else { + j++; + } } } } @@ -64,22 +66,20 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { - if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting()) + if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting() || !(roomUnit instanceof RoomBot roomBot)) return; - Room room = roomUnit.getRoom(); + Room room = roomBot.getRoom(); if (room == null) { return; } - // makes a temporary effect + roomBot.getRoom().unIdle(roomBot.getRoom().getHabbo(roomBot)); + room.sendComposer(new AvatarEffectMessageComposer(roomBot, 4).compose()); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomBot), (long) WiredHandler.TELEPORT_DELAY + 1000); - roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); - room.sendComposer(new AvatarEffectMessageComposer(roomUnit, 4).compose()); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), (long) WiredHandler.TELEPORT_DELAY + 1000); - - if (tile == roomUnit.getCurrentLocation()) { + if (tile == roomBot.getCurrentPosition()) { return; } @@ -100,8 +100,8 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } } - Emulator.getThreading().run(() -> roomUnit.setWiredTeleporting(true), Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); - Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); + Emulator.getThreading().run(() -> roomBot.setWiredTeleporting(true), Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); + Emulator.getThreading().run(new RoomUnitTeleport(roomBot, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomBot.getEffectId()), WiredHandler.TELEPORT_DELAY); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index f0905b3f..2e3d0dc9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -5,15 +5,12 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.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.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -33,26 +30,29 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } String botName = this.getWiredSettings().getStringParam(); - List bots = room.getBots(botName); + List bots = room.getRoomUnitManager().getBotsByName(botName); if (bots.size() == 0) { return false; } Bot bot = bots.get(0); - this.getWiredSettings().getItems(room).removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); + this.getWiredSettings().getItems(room).removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()).getHabboItem(item.getId()) == null); // Bots shouldn't walk to the tile they are already standing on - List possibleItems = this.getWiredSettings().getItems(room).stream() + List possibleItems = this.getWiredSettings().getItems(room).stream() .filter(item -> !room.getBotsOnItem(item).contains(bot)) .collect(Collectors.toList()); // Get a random tile of possible tiles to walk to if (possibleItems.size() > 0) { - HabboItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size())); + RoomItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size())); - if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) { - bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY())); + if (item.getRoomId() != 0) { + Room room1 = bot.getRoom(); + if (item.getRoomId() == room1.getRoomInfo().getId()) { + bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY())); + } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 19e5d6cc..faea7fe6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -3,8 +3,13 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.wired.WiredChangeDirectionSetting; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -32,7 +37,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { private int defaultBlockActionValue; private boolean requiresUpdate = false; - private final HashMap itemsSettings; + private final HashMap itemsSettings; public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -66,7 +71,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { this.requiresUpdate = true; } - RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionValue); + RoomRotation startDirection = RoomRotation.fromValue(startDirectionValue); if(this.requiresUpdate) { for (WiredChangeDirectionSetting setting : this.itemsSettings.values()) { @@ -75,7 +80,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { this.requiresUpdate = false; } - for(HabboItem item : this.getWiredSettings().getItems(room)) { + for(RoomItem item : this.getWiredSettings().getItems(room)) { WiredChangeDirectionSetting setting = this.itemsSettings.computeIfAbsent(item, k -> new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection) ); @@ -108,9 +113,9 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { THashSet newOccupiedTiles = room.getLayout().getTilesAt(newTargetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); for(RoomTile tile : newOccupiedTiles) { - for (RoomUnit _roomUnit : room.getRoomUnits(tile)) { + for (RoomUnit _roomUnit : room.getRoomUnitManager().getRoomUnitsAt(tile)) { hasRoomUnits = true; - if(_roomUnit.getCurrentLocation() == newTargetTile) { + if(_roomUnit.getCurrentPosition() == newTargetTile) { Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{item})); break; } @@ -139,14 +144,14 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } } - private RoomUserRotation nextDirection(RoomUserRotation currentDirection) { + private RoomRotation nextDirection(RoomRotation currentDirection) { return switch (this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION)) { - case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentDirection.getValue()).getOpposite(); - case ACTION_TURN_LEFT_45 -> RoomUserRotation.counterClockwise(currentDirection); - case ACTION_TURN_LEFT_90 -> RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentDirection)); - case ACTION_TURN_RIGHT_45 -> RoomUserRotation.clockwise(currentDirection); - case ACTION_TURN_RIGHT_90 -> RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentDirection)); - case ACTION_TURN_RANDOM -> RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8)); + case ACTION_TURN_BACK -> RoomRotation.fromValue(currentDirection.getValue()).getOpposite(); + case ACTION_TURN_LEFT_45 -> RoomRotation.counterClockwise(currentDirection); + case ACTION_TURN_LEFT_90 -> RoomRotation.counterClockwise(RoomRotation.counterClockwise(currentDirection)); + case ACTION_TURN_RIGHT_45 -> RoomRotation.clockwise(currentDirection); + case ACTION_TURN_RIGHT_90 -> RoomRotation.clockwise(RoomRotation.clockwise(currentDirection)); + case ACTION_TURN_RANDOM -> RoomRotation.fromValue(Emulator.getRandom().nextInt(8)); case ACTION_WAIT -> currentDirection; default -> currentDirection; }; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index d07674f8..8f1b71c5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; 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 1bc19834..7f09c624 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 @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; @@ -29,7 +30,8 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { Habbo habbo = room.getHabbo(roomUnit); if (habbo != null) { - room.giveHandItem(habbo, itemId); + habbo.getRoomUnit().setHandItem(itemId); + room.sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose()); } } catch (Exception ignored) { } 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 8498349e..76e955de 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 @@ -1,22 +1,14 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.hotelview.BonusRareInfoMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectGiveHotelviewBonusRarePoints extends WiredEffectWhisper { public WiredEffectGiveHotelviewBonusRarePoints(ResultSet set, Item baseItem) throws SQLException { 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 514a45ef..f723b244 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 @@ -1,21 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { public WiredEffectGiveHotelviewHofPoints(ResultSet set, Item baseItem) throws SQLException { 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 5623dfa1..b2bd2366 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 @@ -2,21 +2,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectGiveRespect extends InteractionWiredEffect { public WiredEffectGiveRespect(ResultSet set, Item baseItem) throws SQLException { 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 e9a39f32..9c7b4770 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 @@ -1,28 +1,18 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import com.eu.habbo.messages.outgoing.generic.alerts.WiredValidationErrorComposer; import gnu.trove.set.hash.THashSet; import lombok.Getter; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; @Getter public class WiredEffectGiveReward extends InteractionWiredEffect { 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 97c9c63f..a92d4ce0 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 @@ -1,15 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.iterator.TObjectIntIterator; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 2ddf195f..6df99b14 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; @@ -8,10 +7,8 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.map.hash.TIntIntHashMap; import java.sql.ResultSet; 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 5a1517db..b6605533 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 @@ -1,25 +1,17 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectJoinTeam extends InteractionWiredEffect { public final int PARAM_TEAM = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java similarity index 73% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java index 2f569106..9ba11734 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java @@ -1,34 +1,27 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitKick; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -public class WiredEffectKickHabbo extends InteractionWiredEffect { - public WiredEffectKickHabbo(ResultSet set, Item baseItem) throws SQLException { +public class WiredEffectKickRoom extends InteractionWiredEffect { + public WiredEffectKickRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectKickHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredEffectKickRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -45,7 +38,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { return true; } - if (habbo.getHabboInfo().getId() == room.getOwnerId()) { + if (habbo.getHabboInfo().getId() == room.getRoomInfo().getOwnerInfo().getId()) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.owner")); return true; } 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 fd2a6d83..8bcbbba3 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 @@ -1,24 +1,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredEffectLeaveTeam extends InteractionWiredEffect { public WiredEffectLeaveTeam(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 598c4778..db3afbff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -4,7 +4,8 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -44,7 +45,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1; this.matchSettings = this.getWiredSettings().getMatchParams(); - for(HabboItem item : this.getWiredSettings().getItems(room)) { + for(RoomItem item : this.getWiredSettings().getItems(room)) { WiredMatchFurniSetting furniSettings = this.matchSettings.stream().filter(settings -> settings.getItem_id() == item.getId()).findAny().orElse(null); if(furniSettings == null) { @@ -97,7 +98,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int public void saveAdditionalData(Room room) { List matchSettings = new ArrayList<>(); - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY()); matchSettings.add(settings); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index d5912f57..4673ffd9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -3,8 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -25,13 +29,13 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); - RoomUnit target = room.getRoomUnits().stream().min(Comparator.comparingDouble(a -> a.getCurrentLocation().distance(t))).orElse(null); + RoomUnit target = room.getRoomUnitManager().getCurrentRoomUnits().values().stream().min(Comparator.comparingDouble(a -> a.getCurrentPosition().distance(t))).orElse(null); if (target != null) { - if (target.getCurrentLocation().distance(t) <= 1) { + if (target.getCurrentPosition().distance(t) <= 1) { Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, target, room, new Object[]{item}), 500); continue; } @@ -39,26 +43,30 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { int x = 0; int y = 0; - if (target.getX() == item.getX()) { - if (item.getY() < target.getY()) + if (target.getCurrentPosition().getX() == item.getX()) { + if (item.getY() < target.getCurrentPosition().getY()) y--; else y++; - } else if (target.getY() == item.getY()) { - if (item.getX() < target.getX()) - x--; - else - x++; - } else if (target.getX() - item.getX() > target.getY() - item.getY()) { - if (target.getX() - item.getX() > 0) - x--; - else - x++; } else { - if (target.getY() - item.getY() > 0) - y--; - else - y++; + if (target.getCurrentPosition().getY() == item.getY()) { + if (item.getX() < target.getCurrentPosition().getX()) + x--; + else + x++; + } else { + if (target.getCurrentPosition().getX() - item.getX() > target.getCurrentPosition().getY() - item.getY()) { + if (target.getCurrentPosition().getX() - item.getX() > 0) + x--; + else + x++; + } else { + if (target.getCurrentPosition().getY() - item.getY() > 0) + y--; + else + y++; + } + } } RoomTile newLocation = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index cabae23c..a6bb37ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -40,12 +40,12 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { int spacing = this.getWiredSettings().getIntegerParams().get(PARAM_SPACING); for (Object object : stuff) { - if (object instanceof HabboItem) { + if (object instanceof RoomItem) { int randomItemIndex = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()); - HabboItem[] items = this.getWiredSettings().getItems(room).toArray(new HabboItem[this.getWiredSettings().getItemIds().size()]); + RoomItem[] items = this.getWiredSettings().getItems(room).toArray(new RoomItem[this.getWiredSettings().getItemIds().size()]); - HabboItem randomItem = items[randomItemIndex]; + RoomItem randomItem = items[randomItemIndex]; if (randomItem != null) { int indexOffset = 0; @@ -53,7 +53,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { RoomTile objectTile = room.getLayout().getTile(randomItem.getX(), randomItem.getY()); if (objectTile != null) { - THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()); + THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getX(), ((RoomItem) object).getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation()); RoomTile tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); if (tile == null || !tile.getAllowStack()) { @@ -61,8 +61,8 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); } - room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose()); - refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation())); + room.sendComposer(new FloorItemOnRollerComposer((RoomItem) object, null, tile, tile.getStackHeight() - ((RoomItem) object).getZ(), room).compose()); + refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getX(), ((RoomItem) object).getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation())); room.updateTiles(refreshTiles); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index a0b304a4..3e874cbe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -4,21 +4,19 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +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.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.threading.runnables.WiredCollissionRunnable; import gnu.trove.map.hash.THashMap; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; /** * Wired effect: move to closest user @@ -27,7 +25,7 @@ import java.util.stream.Collectors; * @author Beny. */ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { - private THashMap lastDirections; + private THashMap lastDirections; public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -39,15 +37,15 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { this.lastDirections = new THashMap<>(); } - public List getAvailableDirections(HabboItem item, Room room) { - List availableDirections = new ArrayList<>(); + public List getAvailableDirections(RoomItem item, Room room) { + List availableDirections = new ArrayList<>(); RoomLayout layout = room.getLayout(); RoomTile currentTile = layout.getTile(item.getX(), item.getY()); - RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST}; + RoomRotation[] rotations = new RoomRotation[]{RoomRotation.NORTH, RoomRotation.EAST, RoomRotation.SOUTH, RoomRotation.WEST}; - for (RoomUserRotation rot : rotations) { + for (RoomRotation rot : rotations) { RoomTile tile = layout.getTileInFront(currentTile, rot.getValue()); if (tile == null || tile.getState() == RoomTileState.BLOCKED || tile.getState() == RoomTileState.INVALID) @@ -59,7 +57,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if (room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE) continue; - HabboItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); + RoomItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); if (topItem != null && !topItem.getBaseItem().allowStack()) continue; @@ -77,10 +75,10 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { return false; } - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { // direction the furni will move in - RoomUserRotation moveDirection = null; - RoomUserRotation lastDirection = lastDirections.get(item.getId()); + RoomRotation moveDirection = null; + RoomRotation lastDirection = lastDirections.get(item.getId()); // 1. Check if any user is within 3 tiles from the item RoomUnit target = null; // closest found user @@ -95,9 +93,9 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if (target != null) break; - RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST}; + RoomRotation[] rotations = new RoomRotation[]{RoomRotation.NORTH, RoomRotation.EAST, RoomRotation.SOUTH, RoomRotation.WEST}; - for (RoomUserRotation rot : rotations) { + for (RoomRotation rot : rotations) { RoomTile startTile = layout.getTile(item.getX(), item.getY()); for (int ii = 0; ii <= i; ii++) { @@ -108,7 +106,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } if (startTile != null && layout.tileExists(startTile.getX(), startTile.getY())) { - Collection roomUnitsAtTile = room.getRoomUnitsAt(startTile); + Collection roomUnitsAtTile = room.getRoomUnitManager().getRoomUnitsAt(startTile); if (roomUnitsAtTile.size() > 0) { target = roomUnitsAtTile.iterator().next(); if (i == 0) { // i = 0 means right next to it @@ -125,26 +123,30 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { continue; if (target != null) { - if (target.getX() == item.getX()) { - if (item.getY() < target.getY()) - moveDirection = RoomUserRotation.SOUTH; + if (target.getCurrentPosition().getX() == item.getX()) { + if (item.getY() < target.getCurrentPosition().getY()) + moveDirection = RoomRotation.SOUTH; else - moveDirection = RoomUserRotation.NORTH; - } else if (target.getY() == item.getY()) { - if (item.getX() < target.getX()) - moveDirection = RoomUserRotation.EAST; - else - moveDirection = RoomUserRotation.WEST; - } else if (target.getX() - item.getX() > target.getY() - item.getY()) { - if (target.getX() - item.getX() > 0) - moveDirection = RoomUserRotation.EAST; - else - moveDirection = RoomUserRotation.WEST; + moveDirection = RoomRotation.NORTH; } else { - if (target.getY() - item.getY() > 0) - moveDirection = RoomUserRotation.SOUTH; - else - moveDirection = RoomUserRotation.NORTH; + if (target.getCurrentPosition().getY() == item.getY()) { + if (item.getX() < target.getCurrentPosition().getX()) + moveDirection = RoomRotation.EAST; + else + moveDirection = RoomRotation.WEST; + } else { + if (target.getCurrentPosition().getX() - item.getX() > target.getCurrentPosition().getY() - item.getY()) { + if (target.getCurrentPosition().getX() - item.getX() > 0) + moveDirection = RoomRotation.EAST; + else + moveDirection = RoomRotation.WEST; + } else { + if (target.getCurrentPosition().getY() - item.getY() > 0) + moveDirection = RoomRotation.SOUTH; + else + moveDirection = RoomRotation.NORTH; + } + } } } @@ -160,7 +162,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { 3+ available - move in random direction, but never the opposite */ - List availableDirections = this.getAvailableDirections(item, room); + List availableDirections = this.getAvailableDirections(item, room); if (moveDirection != null && !availableDirections.contains(moveDirection)) moveDirection = null; @@ -174,7 +176,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if (lastDirection == null) { moveDirection = availableDirections.get(Emulator.getRandom().nextInt(availableDirections.size())); } else { - RoomUserRotation oppositeLast = lastDirection.getOpposite(); + RoomRotation oppositeLast = lastDirection.getOpposite(); if (availableDirections.get(0) == oppositeLast) { moveDirection = availableDirections.get(1); @@ -184,7 +186,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } } else { if (lastDirection != null) { - RoomUserRotation opposite = lastDirection.getOpposite(); + RoomRotation opposite = lastDirection.getOpposite(); availableDirections.remove(opposite); } moveDirection = availableDirections.get(Emulator.getRandom().nextInt(availableDirections.size())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index b9704055..4f5b96f0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -5,10 +5,10 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -16,8 +16,6 @@ import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; @Slf4j public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable { @@ -49,17 +47,17 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement int direction = this.getWiredSettings().getIntegerParams().get(PARAM_DIRECTION); int rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION); - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { int newRotation = rotation > 0 ? this.getNewRotation(item, rotation) : item.getRotation(); RoomTile newLocation = room.getLayout().getTile(item.getX(), item.getY()); RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); if(direction > 0) { - RoomUserRotation moveDirection = this.getMovementDirection(direction); + RoomRotation moveDirection = this.getMovementDirection(direction); newLocation = room.getLayout().getTile( - (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), - (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) + (short) (item.getX() + ((moveDirection == RoomRotation.WEST || moveDirection == RoomRotation.NORTH_WEST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomRotation.EAST || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.NORTH_EAST) ? 1 : 0)))), + (short) (item.getY() + ((moveDirection == RoomRotation.NORTH || moveDirection == RoomRotation.NORTH_EAST || moveDirection == RoomRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomRotation.SOUTH || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : 0))) ); } @@ -84,7 +82,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement * @param item HabboItem * @return new rotation */ - private int getNewRotation(HabboItem item, int rotation) { + private int getNewRotation(RoomItem item, int rotation) { if(item.getMaximumRotations() == 2) { return item.getRotation() == 0 ? 4 : 0; @@ -153,26 +151,26 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement * * @return direction */ - private RoomUserRotation getMovementDirection(int direction) { - RoomUserRotation movemementDirection = RoomUserRotation.NORTH; + private RoomRotation getMovementDirection(int direction) { + RoomRotation movemementDirection = RoomRotation.NORTH; if (direction == 1) { - movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; + movemementDirection = RoomRotation.values()[Emulator.getRandom().nextInt(RoomRotation.values().length / 2) * 2]; } else if (direction == 2) { if (Emulator.getRandom().nextInt(2) == 1) { - movemementDirection = RoomUserRotation.EAST; + movemementDirection = RoomRotation.EAST; } else { - movemementDirection = RoomUserRotation.WEST; + movemementDirection = RoomRotation.WEST; } } else if (direction == 3) { if (Emulator.getRandom().nextInt(2) != 1) { - movemementDirection = RoomUserRotation.SOUTH; + movemementDirection = RoomRotation.SOUTH; } } else if (direction == 4) { - movemementDirection = RoomUserRotation.SOUTH; + movemementDirection = RoomRotation.SOUTH; } else if (direction == 5) { - movemementDirection = RoomUserRotation.EAST; + movemementDirection = RoomRotation.EAST; } else if (direction == 7) { - movemementDirection = RoomUserRotation.WEST; + movemementDirection = RoomRotation.WEST; } return movemementDirection; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java similarity index 84% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java index 1072db61..bd204fd6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; @@ -14,14 +14,14 @@ import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredEffectMuteHabbo extends InteractionWiredEffect { +public class WiredEffectMuteRoom extends InteractionWiredEffect { private final int PARAM_LENGTH = 0; - public WiredEffectMuteHabbo(ResultSet set, Item baseItem) throws SQLException { + public WiredEffectMuteRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredEffectMuteHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredEffectMuteRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index f5f626ef..85d12667 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -4,9 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.threading.runnables.WiredResetTimers; import java.sql.ResultSet; 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 17ed1868..5dabd8cb 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 @@ -6,11 +6,11 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitTeleport; import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer; @@ -20,12 +20,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; public class WiredEffectTeleport extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TELEPORT; - protected List items; + protected List items; public WiredEffectTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -45,9 +44,9 @@ public class WiredEffectTeleport extends InteractionWiredEffect { int randomItemIndex = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()); - HabboItem[] items = this.getWiredSettings().getItems(room).toArray(new HabboItem[this.getWiredSettings().getItemIds().size()]); + RoomItem[] items = this.getWiredSettings().getItems(room).toArray(new RoomItem[this.getWiredSettings().getItemIds().size()]); - HabboItem randomItem = items[randomItemIndex]; + RoomItem randomItem = items[randomItemIndex]; teleportUnitToTile(roomUnit, room.getLayout().getTile(randomItem.getX(), randomItem.getY())); @@ -55,10 +54,10 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { - if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting()) + if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting() || !(roomUnit instanceof RoomHabbo roomHabbo)) return; - Room room = roomUnit.getRoom(); + Room room = roomHabbo.getRoom(); if (room == null) { return; @@ -66,11 +65,11 @@ public class WiredEffectTeleport extends InteractionWiredEffect { // makes a temporary effect - roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); - room.sendComposer(new AvatarEffectMessageComposer(roomUnit, 4).compose()); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), (long) WiredHandler.TELEPORT_DELAY + 1000); + roomHabbo.getRoom().unIdle(roomHabbo.getRoom().getHabbo(roomHabbo)); + room.sendComposer(new AvatarEffectMessageComposer(roomHabbo, 4).compose()); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomHabbo), (long) WiredHandler.TELEPORT_DELAY + 1000); - if (tile == roomUnit.getCurrentLocation()) { + if (tile == roomHabbo.getCurrentPosition()) { return; } @@ -91,8 +90,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } } - Emulator.getThreading().run(() -> { roomUnit.setWiredTeleporting(true); }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); - Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); + Emulator.getThreading().run(() -> { roomHabbo.setWiredTeleporting(true); }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500)); + Emulator.getThreading().run(new RoomUnitTeleport(roomHabbo, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomHabbo.getEffectId()), WiredHandler.TELEPORT_DELAY); } @Override 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 b35a7630..9ff7ba88 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,12 +14,10 @@ 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; @@ -29,7 +27,7 @@ import java.util.List; @Slf4j public class WiredEffectToggleFurni extends InteractionWiredEffect { - private static final List> FORBIDDEN_TYPES = new ArrayList<>() { + private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); this.add(InteractionTeleport.class); @@ -87,7 +85,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { Habbo habbo = room.getHabbo(roomUnit); - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { if (item == null || item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index 5337bab9..d5e0394a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.items.Item; 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.InteractionBattleBanzaiTeleporter; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; @@ -15,23 +14,19 @@ 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Slf4j public class WiredEffectToggleRandom extends InteractionWiredEffect { - private static final List> FORBIDDEN_TYPES = new ArrayList<>() { + private static final List> FORBIDDEN_TYPES = new ArrayList<>() { { this.add(InteractionWired.class); this.add(InteractionTeleport.class); @@ -81,7 +76,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { if (item.getRoomId() == 0 || FORBIDDEN_TYPES.stream().anyMatch(a -> a.isAssignableFrom(item.getClass()))) { continue; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java index 69afc0fb..db60860e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java @@ -1,22 +1,17 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; public class WiredEffectTriggerStacks extends InteractionWiredEffect { public WiredEffectTriggerStacks(ResultSet set, Item baseItem) throws SQLException { @@ -41,7 +36,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { boolean found; - for (HabboItem item : this.getWiredSettings().getItems(room)) { + for (RoomItem item : this.getWiredSettings().getItems(room)) { //if(item instanceof InteractionWiredTrigger) { found = false; 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 a131fb72..4cad5227 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 @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -45,7 +45,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { return true; } } else { - for (Habbo h : room.getHabbos()) { + for (Habbo h : room.getRoomUnitManager().getRoomHabbos()) { h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); } 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 730abc0c..abfd4af5 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 @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java index a3788f1f..9bf933fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java @@ -3,9 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.extra; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java index 6a9b4a01..d986d04f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java @@ -5,9 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.Getter; import java.sql.ResultSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java index fc6f20f9..2653f315 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/IWiredInteraction.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.interfaces; import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; public interface IWiredInteraction { WiredSettings getWiredSettings(); void setWiredSettings(WiredSettings value); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index c03adbdf..67369e34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.threading.runnables.WiredExecuteTask; @@ -28,7 +27,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); return true; } @@ -42,7 +41,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi @Override public void resetTimer() { this.taskId++; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME) * 500); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 3e95a175..270e9f98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -5,8 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.threading.runnables.WiredExecuteTask; @@ -28,7 +27,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { this.taskId = 1; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); return true; } @@ -42,7 +41,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W @Override public void resetTimer() { this.taskId++; - Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); + Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())), this.getWiredSettings().getIntegerParams().get(PARAM_EXECUTE_TIME)); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index 8fab5b26..1ff5b7ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -1,20 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; @Slf4j public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { @@ -32,8 +27,8 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { return false; } - if (stuff[0] instanceof HabboItem) { - return this.getWiredSettings().getItems(room).contains(stuff[0]) && room.getBots(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); + if (stuff[0] instanceof RoomItem) { + return this.getWiredSettings().getItems(room).contains(stuff[0]) && room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java similarity index 51% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java index 8269cef8..2d469a3a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java @@ -2,28 +2,25 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { - public WiredTriggerBotReachedHabbo(ResultSet set, Item baseItem) throws SQLException { +public class WiredTriggerBotReachedRoom extends InteractionWiredTrigger { + public WiredTriggerBotReachedRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerBotReachedHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredTriggerBotReachedRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return room.getBots(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); + return room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index d221039a..bd6233b6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -2,13 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; @@ -26,7 +23,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - return stuff.length > 0 && stuff[0] instanceof HabboItem; + return stuff.length > 0 && stuff[0] instanceof RoomItem; } @Override 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 5bd49045..539efefe 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 @@ -1,21 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException { @@ -32,7 +26,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { return false; } - if (stuff[0] instanceof HabboItem && !(stuff[0] instanceof WiredEffectType)) { + if (stuff[0] instanceof RoomItem && !(stuff[0] instanceof WiredEffectType)) { return this.getWiredSettings().getItems(room).contains(stuff[0]); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index 107eb428..875cece9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -2,16 +2,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerGameEnds extends InteractionWiredTrigger { public WiredTriggerGameEnds(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 1a377dd5..8f199f99 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -2,16 +2,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; public class WiredTriggerGameStarts extends InteractionWiredTrigger { public WiredTriggerGameStarts(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 9338718c..183a13b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -1,21 +1,17 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredPeriodical; 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import lombok.Getter; import lombok.Setter; -import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -77,7 +73,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWi public void resetTimer() { this.counter = 0; if (this.getRoomId() != 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null && room.isLoaded()) { WiredHandler.handle(this, null, room, new Object[]{this}); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 273c5018..f4691557 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -1,17 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredPeriodical; 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import lombok.Getter; import lombok.Setter; import java.sql.ResultSet; @@ -74,7 +72,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements public void resetTimer() { this.counter = 0; if (this.getRoomId() != 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null && room.isLoaded()) { WiredHandler.handle(this, null, room, new Object[]{this}); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java similarity index 74% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java index a28b781c..ce382315 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomEntersRoom.java @@ -3,19 +3,19 @@ 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.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { - public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { +public class WiredTriggerRoomEntersRoom extends InteractionWiredTrigger { + public WiredTriggerRoomEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboEntersRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredTriggerRoomEntersRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java similarity index 69% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java index 02c9e9c2..af5897a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomSaysKeyword.java @@ -2,25 +2,22 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { +public class WiredTriggerRoomSaysKeyword extends InteractionWiredTrigger { public int PARAM_OWNER_ONLY = 0; - public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { + public WiredTriggerRoomSaysKeyword(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + public WiredTriggerRoomSaysKeyword(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { super(id, userId, item, extraData, limitedStack, limitedSells); } @@ -35,7 +32,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { if (stuff[0] instanceof String) { if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) { Habbo habbo = room.getHabbo(roomUnit); - return !ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId()); + return !ownerOnly || (habbo != null && room.getRoomInfo().getOwnerInfo().getId() == habbo.getHabboInfo().getId()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java similarity index 58% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java index fb9a92c2..8c944f28 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java @@ -1,26 +1,21 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; -public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { - public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException { +public class WiredTriggerRoomWalkOffFurni extends InteractionWiredTrigger { + public WiredTriggerRoomWalkOffFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public WiredTriggerRoomWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -30,7 +25,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { return false; } - if (stuff[0] instanceof HabboItem) { + if (stuff[0] instanceof RoomItem) { return this.getWiredSettings().getItems(room).contains(stuff[0]); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java similarity index 64% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java index eee9e932..b17b3179 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java @@ -3,19 +3,19 @@ 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.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; import java.sql.SQLException; -public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { - public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException { +public class WiredTriggerRoomWalkOnFurni extends InteractionWiredTrigger { + public WiredTriggerRoomWalkOnFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } - public WiredTriggerHabboWalkOnFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { + public WiredTriggerRoomWalkOnFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { super(id, userId, item, extraData, limitedStack, limitedSells); } @@ -25,7 +25,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { return false; } - if (stuff[0] instanceof HabboItem) { + if (stuff[0] instanceof RoomItem) { return this.getWiredSettings().getItems(room).contains(stuff[0]); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index 24ff6810..a580c991 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -2,12 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 05ccdc3a..aacaedbc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -57,7 +57,7 @@ public class MessengerBuddy implements Runnable, ISerialize { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(this.username); if (habbo != null) { - this.inRoom = habbo.getHabboInfo().getCurrentRoom() != null; + this.inRoom = habbo.getRoomUnit().getRoom() != null; } } } catch (SQLException e) { @@ -98,7 +98,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.look = habbo.getHabboInfo().getLook(); this.relation = 0; this.userOne = userOne; - this.inRoom = habbo.getHabboInfo().getCurrentRoom() != null; + this.inRoom = habbo.getRoomUnit().getRoom() != null; } public void setOnline(boolean value) { diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index a3dfbd23..b0b25d56 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -1,7 +1,7 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.UpdateModToolIssue; @@ -29,7 +29,7 @@ public class ModToolIssue implements ISerialize { public int groupId = -1; public int threadId = -1; public int commentId = -1; - public HabboItem photoItem = null; + public RoomItem photoItem = null; public ModToolIssue(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 96ea6976..651513a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -320,7 +320,7 @@ public class ModToolManager { "DESC LIMIT ?) x " + (groupUser ? "GROUP BY user_id" : "") + ";")) { - statement.setInt(1, room.getId()); + statement.setInt(1, room.getRoomInfo().getId()); if (fromTimestamp > 0) statement.setInt(2, fromTimestamp); @@ -402,8 +402,8 @@ public class ModToolManager { public void kick(Habbo moderator, Habbo target, String message) { if (moderator.hasRight(Permission.ACC_SUPPORTTOOL) && !target.hasRight(Permission.ACC_UNKICKABLE)) { - if (target.getHabboInfo().getCurrentRoom() != null) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getHabboInfo().getCurrentRoom()); + if (target.getRoomUnit().getRoom() != null) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getRoomUnit().getRoom()); } this.alert(moderator, target, message, SupportUserAlertedReason.KICKED); } @@ -472,18 +472,19 @@ public class ModToolManager { Emulator.getPluginManager().fireEvent(roomActionEvent); if (roomActionEvent.isChangeTitle()) { - room.setName(Emulator.getTexts().getValue("hotel.room.inappropriate.title")); + String name = Emulator.getTexts().getValue("hotel.room.inappropriate.title"); + room.getRoomInfo().setName(name); room.setNeedsUpdate(true); } if (roomActionEvent.isLockDoor()) { - room.setState(RoomState.LOCKED); + room.getRoomInfo().setState(RoomState.LOCKED); room.setNeedsUpdate(true); } if (roomActionEvent.isKickUsers()) { - for (Habbo habbo : room.getHabbos()) { - if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { + for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { + if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, false); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index daccc52f..f69b33a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -56,7 +56,7 @@ public class NavigatorManager { NavigatorPublicCategory category = this.publicCategories.get(set.getInt("public_cat_id")); if (category != null) { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(set.getInt("room_id")); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id")); if (room != null) { category.addRoom(room); diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java index 02ae1c44..f433d227 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicCategory.java @@ -31,6 +31,6 @@ public class NavigatorPublicCategory { public void removeRoom(Room room) { this.rooms.remove(room); - room.preventUncaching = room.isPublicRoom(); + room.preventUncaching = room.getRoomInfo().isPublicRoom(); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java index 0419d7c8..511597e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/SearchResultList.java @@ -38,7 +38,7 @@ public class SearchResultList implements ISerialize, Comparable toRemove = new ArrayList<>(); for (Room room : this.rooms) { - if (room.getState() == RoomState.INVISIBLE) { + if (room.getRoomInfo().getState() == RoomState.INVISIBLE) { toRemove.add(room); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index daee7dab..2b378fa4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -19,7 +19,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; @@ -146,9 +145,9 @@ public class MonsterplantPet extends Pet implements IPetLook { @Override public void cycle() { - if (this.room != null && this.roomUnit != null) { + if (this.room != null && this.getRoomUnit() != null) { if (this.isDead()) { - this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); + this.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); if (!this.hasDied) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath")); @@ -157,15 +156,15 @@ public class MonsterplantPet extends Pet implements IPetLook { this.setNeedsUpdate(true); } - this.roomUnit.clearStatus(); - this.roomUnit.setStatus(RoomUnitStatus.RIP, ""); + this.getRoomUnit().clearStatuses(); + this.getRoomUnit().setStatus(RoomUnitStatus.RIP, ""); this.setPacketUpdate(true); } else { int difference = Emulator.getIntUnixTimestamp() - this.created + 1; if (difference >= GROW_TIME) { this.growthStage = 7; boolean clear = false; - for (RoomUnitStatus s : this.roomUnit.getStatus().keySet()) { + for (RoomUnitStatus s : this.getRoomUnit().getStatuses().keySet()) { if (s.equals(RoomUnitStatus.GROW)) { clear = true; break; @@ -173,7 +172,7 @@ public class MonsterplantPet extends Pet implements IPetLook { } if (clear) { - this.roomUnit.clearStatus(); + this.getRoomUnit().clearStatuses(); this.setPacketUpdate(true); } } else { @@ -181,8 +180,8 @@ public class MonsterplantPet extends Pet implements IPetLook { if (g > this.growthStage) { this.growthStage = g; - this.roomUnit.clearStatus(); - this.roomUnit.setStatus(RoomUnitStatus.fromString("grw" + this.growthStage), ""); + this.getRoomUnit().clearStatuses(); + this.getRoomUnit().setStatus(RoomUnitStatus.fromString("grw" + this.growthStage), ""); this.setPacketUpdate(true); } } @@ -315,11 +314,11 @@ public class MonsterplantPet extends Pet implements IPetLook { this.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); - Habbo ownerOne = this.room.getHabbo(this.getUserId()); + Habbo ownerOne = this.room.getRoomUnitManager().getRoomHabboById(this.getUserId()); Habbo ownerTwo = null; if (this.getUserId() != pet.getUserId()) { - ownerTwo = this.room.getHabbo(pet.getUserId()); + ownerTwo = this.room.getRoomUnitManager().getRoomHabboById(pet.getUserId()); } Item seedBase; @@ -331,7 +330,7 @@ public class MonsterplantPet extends Pet implements IPetLook { } if (seedBase != null) { - HabboItem seed; + RoomItem seed; if (ownerOne != null) { AchievementManager.progressAchievement(ownerOne, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantBreeder"), 1); seed = Emulator.getGameEnvironment().getItemManager().createItem(ownerOne.getHabboInfo().getId(), seedBase, 0, 0, ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 56cd7ceb..8b804076 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -4,8 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.pets.PetExperienceComposer; @@ -27,7 +28,7 @@ import java.util.TimeZone; import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; @Slf4j -public class Pet implements ISerialize, Runnable { +public class Pet extends Unit implements ISerialize, Runnable { @Getter @Setter @@ -83,9 +84,6 @@ public class Pet implements ISerialize, Runnable { @Getter @Setter protected int level; - @Getter - @Setter - RoomUnit roomUnit; /** * The chat timeout of the pet. @@ -137,7 +135,6 @@ public class Pet implements ISerialize, Runnable { * @throws SQLException if an error occurs while reading from the result set */ public Pet(ResultSet set) throws SQLException { - super(); this.id = set.getInt("id"); this.userId = set.getInt(DatabaseConstants.USER_ID); this.room = null; @@ -197,8 +194,8 @@ public class Pet implements ISerialize, Runnable { * @param message the message to be said */ protected void say(String message) { - if (this.roomUnit != null && this.room != null && !message.isEmpty()) { - RoomChatMessage chatMessage = new RoomChatMessage(message, this.roomUnit, RoomChatMessageBubbles.NORMAL); + if (this.getRoomUnit() != null && this.room != null && !message.isEmpty()) { + RoomChatMessage chatMessage = new RoomChatMessage(message, this.getRoomUnit(), RoomChatMessageBubbles.NORMAL); PetTalkEvent talkEvent = new PetTalkEvent(this, chatMessage); if (!Emulator.getPluginManager().fireEvent(talkEvent).isCancelled()) { this.room.petChat(new ChatMessageComposer(chatMessage).compose()); @@ -285,14 +282,14 @@ public class Pet implements ISerialize, Runnable { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { if (this.id > 0) { try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happiness = ?, created = ? WHERE id = ?")) { - statement.setInt(1, (this.room == null ? 0 : this.room.getId())); + statement.setInt(1, (this.room == null ? 0 : this.room.getRoomInfo().getId())); statement.setInt(2, this.experience); statement.setInt(3, this.energy); statement.setInt(4, this.respect); - statement.setInt(5, this.roomUnit != null ? this.roomUnit.getX() : 0); - statement.setInt(6, this.roomUnit != null ? this.roomUnit.getY() : 0); - statement.setDouble(7, this.roomUnit != null ? this.roomUnit.getZ() : 0.0); - statement.setInt(8, this.roomUnit != null ? this.roomUnit.getBodyRotation().getValue() : 0); + statement.setInt(5, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getX() : 0); + statement.setInt(6, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getY() : 0); + statement.setDouble(7, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentZ() : 0.0); + statement.setInt(8, this.getRoomUnit() != null ? this.getRoomUnit().getBodyRotation().getValue() : 0); statement.setInt(9, this.levelHunger); statement.setInt(10, this.levelThirst); statement.setInt(11, this.happiness); @@ -338,9 +335,9 @@ public class Pet implements ISerialize, Runnable { this.idleCommandTicks++; int time = Emulator.getIntUnixTimestamp(); - if (this.roomUnit != null && this.task != PetTasks.RIDE) { - if (time - this.gestureTickTimeout > 5 && this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) { - this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); + if (this.getRoomUnit() != null && this.task != PetTasks.RIDE) { + if (time - this.gestureTickTimeout > 5 && this.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { + this.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); this.setPacketUpdate(true); } @@ -357,12 +354,12 @@ public class Pet implements ISerialize, Runnable { } } - if (!this.roomUnit.isWalking()) { - if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) { + if (!this.getRoomUnit().isWalking()) { + if (this.getRoomUnit().getWalkTimeOut() < time && this.canWalk()) { RoomTile tile = this.room.getRandomWalkableTile(); if (tile != null) { - this.roomUnit.setGoalLocation(tile); + this.getRoomUnit().setGoalLocation(tile); } } @@ -377,11 +374,11 @@ public class Pet implements ISerialize, Runnable { this.addHappiness(1); if (this.energy == PetManager.maxEnergy(this.level)) { - this.roomUnit.removeStatus(RoomUnitStatus.LAY); - this.roomUnit.setCanWalk(true); - this.roomUnit.setGoalLocation(this.room.getRandomWalkableTile()); + this.getRoomUnit().removeStatus(RoomUnitStatus.LAY); + this.getRoomUnit().setCanWalk(true); + this.getRoomUnit().setGoalLocation(this.room.getRandomWalkableTile()); this.task = null; - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); this.gestureTickTimeout = time; } } /* this is regeneration, add back if needed @@ -404,7 +401,7 @@ public class Pet implements ISerialize, Runnable { this.getRoomUnit().setCanWalk(true); } } else { - this.roomUnit.setWalkTimeOut(20 + time); + this.getRoomUnit().setWalkTimeOut(20 + time); if (this.energy >= 2) this.addEnergy(-1); @@ -495,26 +492,26 @@ public class Pet implements ISerialize, Runnable { public void clearPosture() { THashMap keys = new THashMap<>(); - if (this.roomUnit.hasStatus(RoomUnitStatus.MOVE)) - keys.put(RoomUnitStatus.MOVE, this.roomUnit.getStatus(RoomUnitStatus.MOVE)); + if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + keys.put(RoomUnitStatus.MOVE, this.getRoomUnit().getStatus(RoomUnitStatus.MOVE)); - if (this.roomUnit.hasStatus(RoomUnitStatus.SIT)) - keys.put(RoomUnitStatus.SIT, this.roomUnit.getStatus(RoomUnitStatus.SIT)); + if (this.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) + keys.put(RoomUnitStatus.SIT, this.getRoomUnit().getStatus(RoomUnitStatus.SIT)); - if (this.roomUnit.hasStatus(RoomUnitStatus.LAY)) - keys.put(RoomUnitStatus.LAY, this.roomUnit.getStatus(RoomUnitStatus.LAY)); + if (this.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) + keys.put(RoomUnitStatus.LAY, this.getRoomUnit().getStatus(RoomUnitStatus.LAY)); - if (this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) - keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE)); + if (this.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) + keys.put(RoomUnitStatus.GESTURE, this.getRoomUnit().getStatus(RoomUnitStatus.GESTURE)); if (this.task == null) { - boolean isDead = this.roomUnit.hasStatus(RoomUnitStatus.RIP); + boolean isDead = this.getRoomUnit().hasStatus(RoomUnitStatus.RIP); - this.roomUnit.clearStatus(); + this.getRoomUnit().clearStatuses(); - if (isDead) this.roomUnit.setStatus(RoomUnitStatus.RIP, ""); + if (isDead) this.getRoomUnit().setStatus(RoomUnitStatus.RIP, ""); for (Map.Entry entry : keys.entrySet()) { - this.roomUnit.setStatus(entry.getKey(), entry.getValue()); + this.getRoomUnit().setStatus(entry.getKey(), entry.getValue()); } if (!keys.isEmpty()) this.setPacketUpdate(true); @@ -529,26 +526,26 @@ public class Pet implements ISerialize, Runnable { public void updateGesture(int time) { this.gestureTickTimeout = time; if (this.energy < 30) { - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); this.findNest(); } else if (this.happiness == 100) { - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); } else if (this.happiness >= 90) { this.randomHappyAction(); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); } else if (this.happiness <= 5) { this.randomSadAction(); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); } else if (this.levelHunger > 80) { - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey()); this.eat(); } else if (this.levelThirst > 80) { - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey()); this.drink(); } else if (this.idleCommandTicks > 240) { this.idleCommandTicks = 0; - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey()); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey()); } } @@ -578,12 +575,12 @@ public class Pet implements ISerialize, Runnable { */ public void findNest() { - HabboItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests()); - this.roomUnit.setCanWalk(true); + RoomItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests()); + this.getRoomUnit().setCanWalk(true); if (item != null) { - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } else { - this.roomUnit.setStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.roomUnit.getX(), this.roomUnit.getY(), false) + ""); + this.getRoomUnit().setStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.getRoomUnit().getCurrentPosition().getX(), this.getRoomUnit().getCurrentPosition().getY(), false) + ""); this.say(this.petData.randomVocal(PetVocalsType.SLEEPING)); this.task = PetTasks.DOWN; } @@ -593,16 +590,16 @@ public class Pet implements ISerialize, Runnable { * Makes the pet drink. */ public boolean drink() { - HabboItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks()); + RoomItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks()); if (item != null) { - this.roomUnit.setCanWalk(true); - if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + this.getRoomUnit().setCanWalk(true); + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } } else { - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } } return item != null; @@ -612,10 +609,10 @@ public class Pet implements ISerialize, Runnable { * Makes the pet eat. */ public void eat() { - HabboItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods()); + RoomItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods()); if (item != null) { - this.roomUnit.setCanWalk(true); - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setCanWalk(true); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); } } @@ -625,17 +622,17 @@ public class Pet implements ISerialize, Runnable { * @return true if a toy was found, false otherwise */ public boolean findToy() { - HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys()); + RoomItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys()); if (item != null) { - this.roomUnit.setCanWalk(true); - if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + this.getRoomUnit().setCanWalk(true); + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } return true; } - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); return true; } @@ -649,20 +646,20 @@ public class Pet implements ISerialize, Runnable { * @param type the type of item to search for * @return true if an item was found, false otherwise */ - public boolean findPetItem(PetTasks task, Class type) { - HabboItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type)); + public boolean findPetItem(PetTasks task, Class type) { + RoomItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type)); if (item != null) { - this.roomUnit.setCanWalk(true); + this.getRoomUnit().setCanWalk(true); this.setTask(task); - if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } return true; } - this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); return true; } return false; @@ -673,7 +670,7 @@ public class Pet implements ISerialize, Runnable { */ public void randomHappyAction() { if (this.petData.getActionsHappy().length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsHappy()[Emulator.getRandom().nextInt(this.petData.getActionsHappy().length)]), ""); + this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsHappy()[Emulator.getRandom().nextInt(this.petData.getActionsHappy().length)]), ""); } } @@ -682,7 +679,7 @@ public class Pet implements ISerialize, Runnable { */ public void randomSadAction() { if (this.petData.getActionsTired().length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsTired()[Emulator.getRandom().nextInt(this.petData.getActionsTired().length)]), ""); + this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsTired()[Emulator.getRandom().nextInt(this.petData.getActionsTired().length)]), ""); } } @@ -691,7 +688,7 @@ public class Pet implements ISerialize, Runnable { */ public void randomAction() { if (this.petData.getActionsRandom().length > 0) { - this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.getActionsRandom()[Emulator.getRandom().nextInt(this.petData.getActionsRandom().length)]), ""); + this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsRandom()[Emulator.getRandom().nextInt(this.petData.getActionsRandom().length)]), ""); } } @@ -726,7 +723,7 @@ public class Pet implements ISerialize, Runnable { this.level++; this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); this.addHappiness(100); - this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); + this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "exp"); this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); @@ -767,9 +764,9 @@ public class Pet implements ISerialize, Runnable { */ public void freeCommand() { this.task = null; - this.roomUnit.setGoalLocation(this.getRoomUnit().getCurrentLocation()); - this.roomUnit.clearStatus(); - this.roomUnit.setCanWalk(true); + this.getRoomUnit().setGoalLocation(this.getRoomUnit().getCurrentPosition()); + this.getRoomUnit().clearStatuses(); + this.getRoomUnit().setCanWalk(true); this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL)); } @@ -786,7 +783,7 @@ public class Pet implements ISerialize, Runnable { if (habbo != null) { habbo.getHabboStats().decreasePetRespectPointsToGive(); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new PetRespectNotificationComposer(this).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new PetRespectNotificationComposer(this).compose()); AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetRespectGiver")); } @@ -810,16 +807,16 @@ public class Pet implements ISerialize, Runnable { */ public void removeFromRoom(boolean dontSendPackets) { - if (this.roomUnit != null && this.roomUnit.getCurrentLocation() != null) { - this.roomUnit.getCurrentLocation().removeUnit(this.roomUnit); + if (this.getRoomUnit() != null && this.getRoomUnit().getCurrentPosition() != null) { + this.getRoomUnit().getCurrentPosition().removeUnit(this.getRoomUnit()); } if (!dontSendPackets) { - room.sendComposer(new UserRemoveMessageComposer(this.roomUnit).compose()); - room.removePet(this.id); + room.sendComposer(new UserRemoveMessageComposer(this.getRoomUnit()).compose()); + room.getRoomUnitManager().removePet(this.id); } - this.roomUnit = null; + this.setRoomUnit(null); this.room = null; this.setNeedsUpdate(true); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index 3fb62674..b09f2bf3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -59,7 +59,7 @@ public class PetCommand implements Comparable { if (this.action != null && pet.energy > this.energyCost && pet.happiness > this.happinessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) { if (this.action.petTask != pet.getTask()) { if (this.action.stopsPetWalking) { - pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentLocation()); + pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentPosition()); } if (this.action.apply(pet, habbo, data)) { for (RoomUnitStatus status : this.action.statusToRemove) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java index b9d621b2..5694128f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -6,7 +6,7 @@ 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.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -93,7 +93,7 @@ public class PetData implements Comparable { } - public boolean haveNest(HabboItem nest) { + public boolean haveNest(RoomItem nest) { return this.haveNest(nest.getBaseItem()); } @@ -103,8 +103,8 @@ public class PetData implements Comparable { } - public HabboItem randomNest(THashSet items) { - List nestList = new ArrayList<>(); + public RoomItem randomNest(THashSet items) { + List nestList = new ArrayList<>(); for (InteractionNest nest : items) { if (this.haveNest(nest)) { @@ -132,7 +132,7 @@ public class PetData implements Comparable { } - public boolean haveFoodItem(HabboItem food) { + public boolean haveFoodItem(RoomItem food) { return this.haveFoodItem(food.getBaseItem()); } @@ -142,8 +142,8 @@ public class PetData implements Comparable { } - public HabboItem randomFoodItem(THashSet items) { - List foodList = new ArrayList<>(); + public RoomItem randomFoodItem(THashSet items) { + List foodList = new ArrayList<>(); for (InteractionPetFood food : items) { if (this.haveFoodItem(food)) { @@ -170,7 +170,7 @@ public class PetData implements Comparable { } - public boolean haveDrinkItem(HabboItem item) { + public boolean haveDrinkItem(RoomItem item) { return this.haveDrinkItem(item.getBaseItem()); } @@ -180,8 +180,8 @@ public class PetData implements Comparable { } - public HabboItem randomDrinkItem(THashSet items) { - List drinkList = new ArrayList<>(); + public RoomItem randomDrinkItem(THashSet items) { + List drinkList = new ArrayList<>(); for (InteractionPetDrink drink : items) { if (this.haveDrinkItem(drink)) { @@ -208,7 +208,7 @@ public class PetData implements Comparable { } - public boolean haveToyItem(HabboItem toy) { + public boolean haveToyItem(RoomItem toy) { return this.haveToyItem(toy.getBaseItem()); } @@ -218,8 +218,8 @@ public class PetData implements Comparable { } - public HabboItem randomToyItem(THashSet toys) { - List toyList = new ArrayList<>(); + public RoomItem randomToyItem(THashSet toys) { + List toyList = new ArrayList<>(); for (InteractionPetToy toy : toys) { if (this.haveToyItem(toy)) { @@ -235,10 +235,10 @@ public class PetData implements Comparable { return null; } - public HabboItem randomToyHabboItem(THashSet items) { - List itemList = new ArrayList<>(); + public RoomItem randomToyHabboItem(THashSet items) { + List itemList = new ArrayList<>(); - for (HabboItem item : items) { + for (RoomItem item : items) { if (this.haveToyItem(item)) { itemList.add(item); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index ea7f570c..dbaf0664 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.pets.actions.*; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.TIntIntMap; import gnu.trove.map.hash.THashMap; @@ -443,8 +443,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomUnit()); - pet.getRoomUnit().setPathFinderRoom(room); + pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); return pet; @@ -462,8 +462,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomUnit()); - pet.getRoomUnit().setPathFinderRoom(room); + pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); @@ -482,8 +482,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomUnit()); - pet.getRoomUnit().setPathFinderRoom(room); + pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java index 7eb182de..1dc07ba1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java @@ -4,8 +4,8 @@ import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNes import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.pets.breeding.GoToBreedingNestFailureComposer; import org.apache.commons.lang3.StringUtils; @@ -17,7 +17,7 @@ public class ActionBreed extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { InteractionPetBreedingNest nest = null; - for (HabboItem item : pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetBreedingNest.class)) { + for (RoomItem item : pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetBreedingNest.class)) { if (StringUtils.containsIgnoreCase(item.getBaseItem().getName(), pet.getPetData().getName()) && !((InteractionPetBreedingNest) item).boxFull()) { nest = (InteractionPetBreedingNest) item; break; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index 1301d7e3..8ae9d0d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java @@ -2,9 +2,7 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; -import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.threading.runnables.PetClearPosture; @@ -17,7 +15,7 @@ public class ActionCroak extends ActionVocals { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java index 9e86ee9a..be7df55a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWater; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; public class ActionDip extends PetAction { @@ -16,13 +16,13 @@ public class ActionDip extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - THashSet waterItems = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionWater.class); + THashSet waterItems = pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionWater.class); if (waterItems.isEmpty()) { return false; } - HabboItem waterPatch = (HabboItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())]; + RoomItem waterPatch = (RoomItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())]; pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getX(), waterPatch.getY())); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java index dbdff378..e3cc23c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java @@ -20,11 +20,11 @@ public class ActionDown extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getTask() != PetTasks.DOWN && !pet.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { - pet.getRoomUnit().setCmdLay(true); - pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setCmdLayEnabled(true); + pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { - pet.getRoomUnit().setCmdLay(false); + pet.getRoomUnit().setCmdLayEnabled(false); pet.clearPosture(); }, this.minimumActionDuration); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java index 0d610ee5..44fcd2f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java @@ -21,7 +21,7 @@ public class ActionHang extends PetAction { boolean findTree = pet.findPetItem(PetTasks.HANG, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java index da0b5948..df982829 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java @@ -16,7 +16,7 @@ public class ActionHere extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue())); + pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); if (pet.getHappiness() > 50) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java index abaac92e..98083d2b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java @@ -13,7 +13,7 @@ public class ActionMoveForward extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentLocation(), pet.getRoomUnit().getBodyRotation().getValue())); + pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentPosition(), pet.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java index e62ef857..0a41fea3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java @@ -18,7 +18,7 @@ public class ActionPlayDead extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); if (pet.getHappiness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java index f5f12c94..10b82412 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; public class ActionPlayFootball extends PetAction { public ActionPlayFootball() { @@ -21,9 +21,9 @@ public class ActionPlayFootball extends PetAction { if(room == null || room.getLayout() == null) return false; - HabboItem foundBall = null; + RoomItem foundBall = null; - for(HabboItem item : room.getFloorItems()) { + for(RoomItem item : room.getFloorItems()) { if(item instanceof InteractionPushable) { foundBall = item; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java index 25b70b38..c9eab174 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java @@ -21,7 +21,7 @@ public class ActionRelax extends PetAction { else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); - pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java index fcaaee3f..54278617 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -21,7 +21,7 @@ public class ActionRingOfFire extends PetAction { boolean findTree = pet.findPetItem(PetTasks.RING_OF_FIRE, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java index 8a757d5f..e2cc9c71 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -21,7 +21,7 @@ public class ActionRoll extends PetAction { boolean findTree = pet.findPetItem(PetTasks.ROLL, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index b3ce2f51..905a033a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -21,11 +21,11 @@ public class ActionSit extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { - pet.getRoomUnit().setCmdSit(true); - pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setCmdSitEnabled(true); + pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { - pet.getRoomUnit().setCmdSit(false); + pet.getRoomUnit().setCmdSitEnabled(false); pet.clearPosture(); }, this.minimumActionDuration); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java index 3ca54d83..52c8706b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java @@ -21,7 +21,7 @@ public class ActionSwing extends PetAction { boolean findTree = pet.findPetItem(PetTasks.SWING, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java index a04efc81..310e89ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnLeft.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.users.Habbo; public class ActionTurnLeft extends PetAction { @@ -13,8 +13,8 @@ public class ActionTurnLeft extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getBodyRotation().getValue() - 1)]); - pet.getRoomUnit().setHeadRotation(RoomUserRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getHeadRotation().getValue() - 1)]); + pet.getRoomUnit().setBodyRotation(RoomRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getBodyRotation().getValue() - 1)]); + pet.getRoomUnit().setHeadRotation(RoomRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() - 1 < 0 ? 7 : pet.getRoomUnit().getHeadRotation().getValue() - 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java index 6bb19b73..eac44d4f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionTurnRight.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.pets.actions; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetVocalsType; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.users.Habbo; public class ActionTurnRight extends PetAction { @@ -13,8 +13,8 @@ public class ActionTurnRight extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setBodyRotation(RoomUserRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getBodyRotation().getValue() + 1)]); - pet.getRoomUnit().setHeadRotation(RoomUserRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getHeadRotation().getValue() + 1)]); + pet.getRoomUnit().setBodyRotation(RoomRotation.values()[(pet.getRoomUnit().getBodyRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getBodyRotation().getValue() + 1)]); + pet.getRoomUnit().setHeadRotation(RoomRotation.values()[(pet.getRoomUnit().getHeadRotation().getValue() + 1 > 7 ? 0 : pet.getRoomUnit().getHeadRotation().getValue() + 1)]); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java index 2675d8b6..f761f6f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java @@ -19,7 +19,7 @@ public class ActionWave extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentLocation().getStackHeight() + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), this.minimumActionDuration); if (pet.getHappiness() > 40) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java index 0399ff1a..e648cf7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -17,7 +17,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable { public CustomRoomLayout(ResultSet set, Room room) { super(set, room); - this.roomId = room.getId(); + this.roomId = room.getRoomInfo().getId(); } @Override 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 3646cb86..de340115 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -22,14 +22,20 @@ 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.items.interactions.wired.interfaces.IWiredPeriodical; -import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerRepeaterLong; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.RideablePet; -import com.eu.habbo.habbohotel.users.*; +import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; +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.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ISerialize; @@ -38,15 +44,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; -import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; -import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; import com.eu.habbo.messages.outgoing.rooms.*; import com.eu.habbo.messages.outgoing.rooms.items.*; -import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer; import com.eu.habbo.plugin.Event; @@ -67,7 +70,6 @@ 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; @@ -82,17 +84,21 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; @Slf4j public class Room implements Comparable, ISerialize, Runnable { + @Getter + private final RoomInfo roomInfo; + @Getter + private final RoomUnitManager roomUnitManager; + @Getter + private final RoomItemManager roomItemManager; + private TraxManager traxManager; private static final String CAUGHT_EXCEPTION = "Caught exception"; - - public static final Comparator SORT_SCORE = (o1, o2) -> o2.getScore() - o1.getScore(); - public static final Comparator SORT_ID = (o1, o2) -> o2.getId() - o1.getId(); - private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>(); + public static final Comparator SORT_SCORE = (o1, o2) -> o2.roomInfo.getScore() - o1.roomInfo.getScore(); + public static final Comparator SORT_ID = (o1, o2) -> o2.roomInfo.getId() - o1.roomInfo.getId(); //Configuration. Loaded from database & updated accordingly. public static boolean HABBO_CHAT_DELAY = false; public static int MAXIMUM_BOTS = 10; @@ -106,259 +112,64 @@ public class Room implements Comparable, ISerialize, Runnable { public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1; public static boolean MUTEAREA_CAN_WHISPER = false; public static final double MAXIMUM_FURNI_HEIGHT = 40d; - - - static { - for (int i = 1; i <= 3; i++) { - RoomMoodlightData data = RoomMoodlightData.fromString(""); - data.setId(i); - defaultMoodData.put(i, data); - } - } - - public final Object roomUnitLock = new Object(); - public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); + public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); public final List userVotes; - @Getter - private final ConcurrentHashMap currentHabbos = new ConcurrentHashMap<>(3); - @Getter private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - @Getter - private final TIntObjectMap currentBots = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - @Getter - private final TIntObjectMap currentPets = 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; - @Getter private final TIntIntMap furniOwnerCount; - @Getter - private final TIntObjectMap moodlightData; - @Getter private final THashSet wordFilterWords; - private final TIntObjectMap roomItems; + private final TIntObjectMap roomItems; private final Object loadLock = new Object(); //Use appropriately. Could potentially cause memory leaks when used incorrectly. public volatile boolean preventUnloading = false; 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 - private final int id; - @Getter - @Setter - private int ownerId; - @Getter - @Setter - private String ownerName; - @Getter - private String name; - @Getter - private String description; - @Getter - @Setter private RoomLayout layout; - private boolean overrideModel; private final String layoutName; - @Getter - private String password; - @Getter - @Setter - private RoomState state; - @Setter - @Getter - private int usersMax; - @Getter - @Setter - private volatile int score; - @Getter - @Setter - private volatile int category; - @Getter - @Setter - private String floorPaint; - @Getter - @Setter - private String wallPaint; - @Getter - @Setter - private String backgroundPaint; - @Getter - @Setter - private int wallSize; - @Getter - @Setter - private int wallHeight; - @Getter - @Setter - private int floorSize; - @Setter - @Getter - private int guildId; - @Getter - @Setter - private String tags; - @Setter - @Getter - private volatile boolean publicRoom; - @Setter - @Getter - private volatile boolean staffPromotedRoom; - @Getter - private volatile boolean allowPets; - @Setter - @Getter - private volatile boolean allowPetsEat; - @Setter - @Getter - private volatile boolean allowWalkthrough; - @Setter - @Getter private volatile boolean allowBotsWalk; - @Setter - @Getter private volatile boolean allowEffects; - @Setter - @Getter - private volatile boolean hideWall; - @Setter - @Getter - private volatile int chatMode; - @Setter - @Getter - private volatile int chatWeight; - @Setter - @Getter - private volatile int chatSpeed; - @Setter - @Getter - private volatile int chatDistance; - @Setter - @Getter - private volatile int chatProtection; - @Setter - @Getter - private volatile int muteOption; - @Setter - @Getter - private volatile int kickOption; - @Setter - @Getter - private volatile int banOption; - @Setter - @Getter - private volatile int pollId; - private volatile boolean promoted; - @Getter - @Setter - private volatile int tradeMode; - private volatile boolean moveDiagonally; - private volatile boolean jukeboxActive; - private volatile boolean hideWired; - @Getter private RoomPromotion promotion; - @Setter private volatile boolean needsUpdate; - @Getter private volatile boolean loaded; - @Getter private volatile boolean preLoaded; - private int idleCycles; - private volatile int unitCounter; - @Getter - private volatile int rollerSpeed; + private int roomIdleCycles; private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); private long rollerCycle = System.currentTimeMillis(); - @Setter - @Getter private volatile int lastTimerReset = Emulator.getIntUnixTimestamp(); - @Setter - @Getter private volatile boolean muted; - @Getter private RoomSpecialTypes roomSpecialTypes; - @Getter - private TraxManager traxManager; private boolean cycleOdd; - @Getter private long cycleTimestamp; - @Getter - @Setter - private ScheduledFuture wiredPeriodicalCycle; - @Getter - @Setter final HashMap triggersOnRoom; - @Getter - @Setter - private int periodicalTick; public Room(ResultSet set) throws SQLException { - this.id = set.getInt("id"); - this.ownerId = set.getInt("owner_id"); - this.ownerName = set.getString("owner_name"); - this.name = set.getString("name"); - this.description = set.getString("description"); - this.password = set.getString("password"); - this.state = RoomState.valueOf(set.getString("state").toUpperCase()); - this.usersMax = set.getInt("users_max"); - this.score = set.getInt("score"); - this.category = set.getInt("category"); - this.floorPaint = set.getString("paper_floor"); - this.wallPaint = set.getString("paper_wall"); - this.backgroundPaint = set.getString("paper_landscape"); - this.wallSize = set.getInt("thickness_wall"); - this.wallHeight = set.getInt("wall_height"); - this.floorSize = set.getInt("thickness_floor"); - this.tags = set.getString("tags"); - this.publicRoom = set.getBoolean("is_public"); - this.staffPromotedRoom = set.getBoolean("is_staff_picked"); - this.allowPets = set.getBoolean("allow_other_pets"); - this.allowPetsEat = set.getBoolean("allow_other_pets_eat"); - this.allowWalkthrough = set.getBoolean("allow_walkthrough"); - this.hideWall = set.getBoolean("allow_hidewall"); - this.chatMode = set.getInt("chat_mode"); - this.chatWeight = set.getInt("chat_weight"); - this.chatSpeed = set.getInt("chat_speed"); - this.chatDistance = set.getInt("chat_hearing_distance"); - this.chatProtection = set.getInt("chat_protection"); - this.muteOption = set.getInt("who_can_mute"); - this.kickOption = set.getInt("who_can_kick"); - this.banOption = set.getInt("who_can_ban"); - this.pollId = set.getInt("poll_id"); - this.guildId = set.getInt("guild_id"); - this.rollerSpeed = set.getInt("roller_speed"); - this.overrideModel = set.getString("override_model").equals("1"); - this.layoutName = set.getString("model"); - this.promoted = set.getString("promoted").equals("1"); - this.jukeboxActive = set.getString("jukebox_active").equals("1"); - this.hideWired = set.getString("hidewired").equals("1"); + this.roomInfo = new RoomInfo(set); + this.roomUnitManager = new RoomUnitManager(this.roomInfo.getId()); + this.roomItemManager = new RoomItemManager(); + this.layoutName = set.getString("model"); this.bannedHabbos = new TIntObjectHashMap<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) { - if (this.promoted) { - statement.setInt(1, this.id); + if (this.roomInfo.isPromoted()) { + statement.setInt(1, this.roomInfo.getId()); statement.setInt(2, Emulator.getIntUnixTimestamp()); try (ResultSet promotionSet = statement.executeQuery()) { - this.promoted = false; + this.roomInfo.setPromoted(false); if (promotionSet.next()) { - this.promoted = true; + this.roomInfo.setPromoted(true); this.promotion = new RoomPromotion(this, promotionSet); } } @@ -369,9 +180,6 @@ public class Room implements Comparable, ISerialize, Runnable { log.error(CAUGHT_SQL_EXCEPTION, e); } - this.tradeMode = set.getInt("trade_mode"); - this.moveDiagonally = set.getString("move_diagonally").equals("1"); - this.preLoaded = true; this.allowBotsWalk = true; this.allowEffects = true; @@ -379,12 +187,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.furniOwnerCount = TCollections.synchronizedMap(new TIntIntHashMap(0)); this.roomItems = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); this.wordFilterWords = new THashSet<>(0); - this.moodlightData = new TIntObjectHashMap<>(defaultMoodData); - - for (String s : set.getString("moodlight_data").split(";")) { - RoomMoodlightData data = RoomMoodlightData.fromString(s); - this.moodlightData.put(data.getId(), data); - } this.mutedHabbos = new TIntIntHashMap(); this.games = new ConcurrentSet<>(); @@ -394,7 +196,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.userVotes = new ArrayList<>(); this.triggersOnRoom = new HashMap<>(); - this.periodicalTick = 0; } public synchronized void loadData() { @@ -405,12 +206,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.preLoaded = false; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - synchronized (this.roomUnitLock) { - this.unitCounter = 0; - this.currentHabbos.clear(); - this.currentPets.clear(); - this.currentBots.clear(); - } + this.roomUnitManager.clear(); this.roomSpecialTypes = new RoomSpecialTypes(); @@ -418,12 +214,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadRights(connection); this.loadItems(connection); this.loadHeightmap(); - this.loadBots(connection); - this.loadPets(connection); + this.roomUnitManager.load(connection); this.loadWordFilter(connection); - this.startPeriodicalCycle(); - this.idleCycles = 0; + this.roomIdleCycles = 0; this.loaded = true; this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); @@ -433,14 +227,14 @@ public class Room implements Comparable, ISerialize, Runnable { this.traxManager = new TraxManager(this); - if (this.jukeboxActive) { + if (this.roomInfo.isJukeboxEnabled()) { this.traxManager.play(0); - for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) { + for (RoomItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) { this.updateItem(item.setExtradata("1")); } } - for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) { + for (RoomItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) { this.updateItem(item.setExtradata("1")); } } @@ -451,7 +245,7 @@ public class Room implements Comparable, ISerialize, Runnable { private synchronized void loadLayout() { try { if (this.layout == null) { - if (this.overrideModel) { + if (this.roomInfo.isModelOverridden()) { this.layout = Emulator.getGameEnvironment().getRoomManager().loadCustomLayout(this); } else { this.layout = Emulator.getGameEnvironment().getRoomManager().loadLayout(this.layoutName, this); @@ -474,7 +268,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } else { - log.error("Unknown Room Layout for Room (ID: {})", this.id); + log.error("Unknown Room Layout for Room (ID: {})", this.roomInfo.getId()); } } catch (Exception e) { log.error(CAUGHT_EXCEPTION, e); @@ -485,7 +279,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomItems.clear(); try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { this.addHabboItem(Emulator.getGameEnvironment().getItemManager().loadHabboItem(set)); @@ -498,105 +292,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.itemCount() > Room.MAXIMUM_FURNI) { - log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); - } - } - - private synchronized void loadWiredData(Connection connection) { - try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) { - statement.setInt(1, this.id); - - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - try { - HabboItem item = this.getHabboItem(set.getInt("id")); - - if (item instanceof InteractionWired interactionWired) { - interactionWired.loadWiredSettings(set); - } - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - - private synchronized void loadBots(Connection connection) { - this.currentBots.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.id); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - Bot b = Emulator.getGameEnvironment().getBotManager().loadBot(set); - - if (b != null) { - b.setRoom(this); - b.setRoomUnit(new RoomUnit()); - b.getRoomUnit().setPathFinderRoom(this); - b.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { - b.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); - b.getRoomUnit().setLocation(this.getLayout().getDoorTile()); - b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } else { - b.getRoomUnit().setZ(set.getDouble("z")); - b.getRoomUnit().setPreviousLocationZ(set.getDouble("z")); - b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); - } - b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); - b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); - b.getRoomUnit().setInRoom(true); - this.giveEffect(b.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE); - this.addBot(b); - } - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - - private synchronized void loadPets(Connection connection) { - - this.currentPets.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.id); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - Pet pet = PetManager.loadPet(set); - pet.setRoom(this); - pet.setRoomUnit(new RoomUnit()); - pet.getRoomUnit().setPathFinderRoom(this); - pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { - pet.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); - pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); - pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } else { - pet.getRoomUnit().setZ(set.getDouble("z")); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); - } - pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); - pet.getRoomUnit().setCanWalk(true); - this.addPet(pet); - - this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); - - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.itemCount(), Room.MAXIMUM_FURNI); } } @@ -604,7 +300,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.wordFilterWords.clear(); try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { this.wordFilterWords.add(set.getString("word")); @@ -638,18 +334,18 @@ public class Room implements Comparable, ISerialize, Runnable { return this.calculateTileState(tile, null); } - private RoomTileState calculateTileState(RoomTile tile, HabboItem exclude) { + private RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) { if (tile == null || tile.getState() == RoomTileState.INVALID) return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; - THashSet items = this.getItemsAt(tile); + THashSet items = this.getItemsAt(tile); if (items == null) return RoomTileState.INVALID; - HabboItem tallestItem = null; + RoomItem tallestItem = null; - for (HabboItem item : items) { + for (RoomItem item : items) { if (exclude != null && item == exclude) continue; if (item.getBaseItem().allowLay()) { @@ -666,7 +362,7 @@ public class Room implements Comparable, ISerialize, Runnable { return result; } - private RoomTileState checkStateForItem(HabboItem item, RoomTile tile) { + private RoomTileState checkStateForItem(RoomItem item, RoomTile tile) { RoomTileState result = RoomTileState.BLOCKED; if (item.isWalkable()) { @@ -693,14 +389,14 @@ public class Room implements Comparable, ISerialize, Runnable { boolean walkable = this.layout.tileWalkable(x, y); RoomTile tile = this.getLayout().getTile(x, y); - if ((walkable && tile != null) && (tile.hasUnits() && !this.allowWalkthrough)) { + if ((walkable && tile != null) && (tile.hasUnits() && !this.roomInfo.isAllowWalkthrough())) { walkable = false; } return walkable; } - public void pickUpItem(HabboItem item, Habbo picker) { + public void pickUpItem(RoomItem item, Habbo picker) { if (item == null) return; @@ -737,7 +433,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new HeightMapUpdateMessageComposer(this, updatedTiles).compose()); this.updateTiles(updatedTiles); updatedTiles.forEach(tile -> { - this.updateHabbosAt(tile.getX(), tile.getY()); + this.updateHabbosAt(tile); this.updateBotsAt(tile.getX(), tile.getY()); }); } else if (item.getBaseItem().getType() == FurnitureType.WALL) { @@ -753,34 +449,26 @@ public class Room implements Comparable, ISerialize, Runnable { Emulator.getThreading().run(item); } - public void updateHabbosAt(Rectangle rectangle) { - for (short i = (short) rectangle.x; i < rectangle.x + rectangle.width; i++) { - for (short j = (short) rectangle.y; j < rectangle.y + rectangle.height; j++) { - this.updateHabbosAt(i, j); - } - } - } - public void updateHabbo(Habbo habbo) { this.updateRoomUnit(habbo.getRoomUnit()); } public void updateRoomUnit(RoomUnit roomUnit) { - HabboItem item = this.getTopItemAt(roomUnit.getX(), roomUnit.getY()); + RoomItem item = this.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); - if ((item == null && !roomUnit.isCmdSit()) || (item != null && !item.getBaseItem().allowSit())) + if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit())) roomUnit.removeStatus(RoomUnitStatus.SIT); - double oldZ = roomUnit.getZ(); + double oldZ = roomUnit.getCurrentZ(); if (item != null) { if (item.getBaseItem().allowSit()) { - roomUnit.setZ(item.getZ()); + roomUnit.setCurrentZ(item.getZ()); } else { - roomUnit.setZ(item.getZ() + Item.getCurrentHeight(item)); + roomUnit.setCurrentZ(item.getZ() + Item.getCurrentHeight(item)); } - if (oldZ != roomUnit.getZ()) { + if (oldZ != roomUnit.getCurrentZ()) { this.scheduledTasks.add(() -> { try { item.onWalkOn(roomUnit, Room.this, null); @@ -794,66 +482,67 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new UserUpdateComposer(roomUnit).compose()); } - public void updateHabbosAt(short x, short y) { - this.updateHabbosAt(x, y, this.getHabbosAt(x, y)); + public void updateHabbosAt(RoomTile tile) { + this.updateHabbosAt(tile.getX(), tile.getY(), new ArrayList<>(this.roomUnitManager.getHabbosAt(tile))); } public void updateHabbosAt(short x, short y, List habbos) { - HabboItem item = this.getTopItemAt(x, y); + RoomItem item = this.getTopItemAt(x, y); for (Habbo habbo : habbos) { - double oldZ = habbo.getRoomUnit().getZ(); - RoomUserRotation oldRotation = habbo.getRoomUnit().getBodyRotation(); - double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight(); + double oldZ = habbo.getRoomUnit().getCurrentZ(); + RoomRotation oldRotation = habbo.getRoomUnit().getBodyRotation(); + double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight(); boolean updated = false; - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSit()) || (item != null && !item.getBaseItem().allowSit()))) { + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) { habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); updated = true; } - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLay()) || (item != null && !item.getBaseItem().allowLay()))) { + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) { habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); updated = true; } if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { - habbo.getRoomUnit().setZ(item.getZ()); + habbo.getRoomUnit().setCurrentZ(item.getZ()); habbo.getRoomUnit().setPreviousLocationZ(item.getZ()); - habbo.getRoomUnit().setRotation(RoomUserRotation.fromValue(item.getRotation())); + habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); } else { - habbo.getRoomUnit().setZ(z); + habbo.getRoomUnit().setCurrentZ(z); habbo.getRoomUnit().setPreviousLocationZ(z); } - if (habbo.getRoomUnit().getCurrentLocation().is(x, y) && (oldZ != z || updated || oldRotation != habbo.getRoomUnit().getBodyRotation())) { - habbo.getRoomUnit().statusUpdate(true); + if (habbo.getRoomUnit().getCurrentPosition().is(x, y) && (oldZ != z || updated || oldRotation != habbo.getRoomUnit().getBodyRotation())) { + habbo.getRoomUnit().setStatusUpdateNeeded(true); } } } public void updateBotsAt(short x, short y) { - HabboItem topItem = this.getTopItemAt(x, y); + RoomItem topItem = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); - this.getBotsAt(this.layout.getTile(x, y)).forEach(bot -> { + RoomTile tile = this.layout.getTile(x, y); + this.roomUnitManager.getBotsAt(tile).forEach(bot -> { if (topItem != null) { if (topItem.getBaseItem().allowSit()) { - bot.getRoomUnit().setZ(topItem.getZ()); + bot.getRoomUnit().setCurrentZ(topItem.getZ()); bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); - bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation())); + bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation())); } else { - bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem)); + bot.getRoomUnit().setCurrentZ(topItem.getZ() + Item.getCurrentHeight(topItem)); if (topItem.getBaseItem().allowLay()) { bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); } } } else { - bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); - bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); + bot.getRoomUnit().setCurrentZ(bot.getRoomUnit().getCurrentPosition().getStackHeight()); + bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentPosition().getStackHeight()); } roomUnits.add(bot.getRoomUnit()); }); @@ -863,27 +552,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void pickupPetsForHabbo(Habbo habbo) { - THashSet pets = new THashSet<>(); - - synchronized (this.currentPets) { - for (Pet pet : this.currentPets.valueCollection()) { - if (pet.getUserId() == habbo.getHabboInfo().getId()) { - pets.add(pet); - } - } - } - - for (Pet pet : pets) { - pet.removeFromRoom(); - Emulator.getThreading().run(pet); - habbo.getInventory().getPetsComponent().addPet(pet); - habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - this.currentPets.remove(pet.getId()); - } - - } - public void startTrade(Habbo userOne, Habbo userTwo) { RoomTrade trade = new RoomTrade(userOne, userTwo, this); synchronized (this.activeTrades) { @@ -919,10 +587,6 @@ public class Room implements Comparable, ISerialize, Runnable { if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) return; - if(this.wiredPeriodicalCycle != null) { - this.wiredPeriodicalCycle.cancel(true); - } - if (this.loaded) { try { @@ -950,10 +614,10 @@ public class Room implements Comparable, ISerialize, Runnable { } this.games.clear(); - removeAllPets(ownerId); + this.roomUnitManager.removeAllPetsExceptRoomOwner(); synchronized (this.roomItems) { - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { @@ -980,31 +644,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.habboQueue.clear(); } - - for (Habbo habbo : this.currentHabbos.values()) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this); - } - - this.sendComposer(new CloseConnectionMessageComposer().compose()); - - this.currentHabbos.clear(); - - - TIntObjectIterator botIterator = this.currentBots.iterator(); - - for (int i = this.currentBots.size(); i-- > 0; ) { - try { - botIterator.advance(); - botIterator.value().needsUpdate(true); - Emulator.getThreading().run(botIterator.value()); - } catch (NoSuchElementException e) { - log.error(CAUGHT_EXCEPTION, e); - break; - } - } - - this.currentBots.clear(); - this.currentPets.clear(); + this.roomUnitManager.dispose(this); } catch (Exception e) { log.error(CAUGHT_EXCEPTION, e); } @@ -1027,34 +667,36 @@ public class Room implements Comparable, ISerialize, Runnable { @Override public int compareTo(Room o) { - if (o.getUserCount() != this.getUserCount()) { - return o.getCurrentHabbos().size() - this.getCurrentHabbos().size(); + if (o.roomUnitManager.getRoomHabbosCount() != this.roomUnitManager.getRoomHabbosCount()) { + return o.roomUnitManager.getCurrentRoomHabbos().size() - this.roomUnitManager.getCurrentRoomHabbos().size(); } - return this.id - o.id; + return this.roomInfo.getId() - o.roomInfo.getId(); } @Override public void serialize(ServerMessage message) { - message.appendInt(this.id); - message.appendString(this.name); - if (this.isPublicRoom()) { + message.appendInt(this.roomInfo.getId()); + message.appendString(this.roomInfo.getName()); + + if (this.roomInfo.isPublicRoom()) { message.appendInt(0); message.appendString(""); } else { - message.appendInt(this.ownerId); - message.appendString(this.ownerName); + message.appendInt(this.roomInfo.getOwnerInfo().getId()); + message.appendString(this.roomInfo.getOwnerInfo().getUsername()); } - message.appendInt(this.state.ordinal()); - message.appendInt(this.getUserCount()); - message.appendInt(this.usersMax); - message.appendString(this.description); - message.appendInt(0); - message.appendInt(this.score); - message.appendInt(0); - message.appendInt(this.category); - String[] tags = Arrays.stream(this.tags.split(";")).filter(t -> !t.isEmpty()).toArray(String[]::new); + message.appendInt(this.roomInfo.getState().ordinal()); + message.appendInt(this.roomUnitManager.getRoomHabbosCount()); + message.appendInt(this.roomInfo.getMaxUsers()); + message.appendString(this.roomInfo.getDescription()); + message.appendInt(this.roomInfo.getTradeMode()); + message.appendInt(this.roomInfo.getScore()); + message.appendInt(0); + message.appendInt(this.roomInfo.getCategory().getId()); + + String[] tags = Arrays.stream(this.roomInfo.getTags().split(";")).filter(t -> !t.isEmpty()).toArray(String[]::new); message.appendInt(tags.length); for (String s : tags) { message.appendString(s); @@ -1062,41 +704,36 @@ public class Room implements Comparable, ISerialize, Runnable { int base = 0; - if (this.getGuildId() > 0) { + if (this.roomInfo.hasGuild()) { base = base | 2; } - if (this.isPromoted()) { + if (this.roomInfo.isPromoted()) { base = base | 4; } - if (!this.isPublicRoom()) { + if (!this.roomInfo.isPublicRoom()) { base = base | 8; } + if (this.roomInfo.isAllowPets()) { + base = base | 16; + } message.appendInt(base); - if (this.getGuildId() > 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.getGuildId()); - if (g != null) { - message.appendInt(g.getId()); - message.appendString(g.getName()); - message.appendString(g.getBadge()); - } else { - message.appendInt(0); - message.appendString(""); - message.appendString(""); - } + if (this.roomInfo.hasGuild()) { + message.appendInt(this.roomInfo.getGuild().getId()); + message.appendString(this.roomInfo.getGuild().getName()); + message.appendString(this.roomInfo.getGuild().getBadge()); } - if (this.promoted) { + if (this.roomInfo.isPromoted()) { message.appendString(this.promotion.getTitle()); message.appendString(this.promotion.getDescription()); message.appendInt((this.promotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); } - } @Override @@ -1116,57 +753,8 @@ public class Room implements Comparable, ISerialize, Runnable { public void save() { if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ? WHERE id = ?")) { - statement.setString(1, this.name); - statement.setString(2, this.description); - statement.setString(3, this.password); - statement.setString(4, this.state.name().toLowerCase()); - statement.setInt(5, this.usersMax); - statement.setInt(6, this.category); - statement.setInt(7, this.score); - statement.setString(8, this.floorPaint); - statement.setString(9, this.wallPaint); - statement.setString(10, this.backgroundPaint); - statement.setInt(11, this.wallSize); - statement.setInt(12, this.wallHeight); - statement.setInt(13, this.floorSize); - StringBuilder moodLightData = new StringBuilder(); - - int id = 1; - for (RoomMoodlightData data : this.moodlightData.valueCollection()) { - data.setId(id); - moodLightData.append(data).append(";"); - id++; - } - - statement.setString(14, moodLightData.toString()); - statement.setString(15, this.tags); - statement.setString(16, this.allowPets ? "1" : "0"); - statement.setString(17, this.allowPetsEat ? "1" : "0"); - statement.setString(18, this.allowWalkthrough ? "1" : "0"); - statement.setString(19, this.hideWall ? "1" : "0"); - statement.setInt(20, this.chatMode); - statement.setInt(21, this.chatWeight); - statement.setInt(22, this.chatSpeed); - statement.setInt(23, this.chatDistance); - statement.setInt(24, this.chatProtection); - statement.setInt(25, this.muteOption); - statement.setInt(26, this.kickOption); - statement.setInt(27, this.banOption); - statement.setInt(28, this.pollId); - statement.setInt(29, this.guildId); - statement.setInt(30, this.rollerSpeed); - statement.setString(31, this.overrideModel ? "1" : "0"); - statement.setString(32, this.staffPromotedRoom ? "1" : "0"); - statement.setString(33, this.promoted ? "1" : "0"); - statement.setInt(34, this.tradeMode); - statement.setString(35, this.moveDiagonally ? "1" : "0"); - statement.setInt(36, this.ownerId); - statement.setString(37, this.ownerName); - statement.setString(38, this.jukeboxActive ? "1" : "0"); - statement.setString(39, this.hideWired ? "1" : "0"); - statement.setInt(40, this.id); - statement.executeUpdate(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + this.roomInfo.update(connection); this.needsUpdate = false; } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -1174,10 +762,10 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private void updateDatabaseUserCount() { + public void updateDatabaseUserCount() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET users = ? WHERE id = ? LIMIT 1")) { - statement.setInt(1, this.currentHabbos.size()); - statement.setInt(2, this.id); + statement.setInt(1, this.roomUnitManager.getRoomHabbosCount()); + statement.setInt(2, this.roomInfo.getId()); statement.executeUpdate(); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -1188,8 +776,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.cycleOdd = !this.cycleOdd; this.cycleTimestamp = System.currentTimeMillis(); final boolean[] foundRightHolder = {false}; - - + boolean loaded; synchronized (this.loadLock) { loaded = this.loaded; @@ -1209,8 +796,8 @@ public class Room implements Comparable, ISerialize, Runnable { task.cycle(this); } - if (!this.currentHabbos.isEmpty()) { - this.idleCycles = 0; + if (!this.roomUnitManager.getCurrentRoomHabbos().isEmpty()) { + this.roomIdleCycles = 0; THashSet updatedUnit = new THashSet<>(); ArrayList toKick = new ArrayList<>(); @@ -1219,7 +806,7 @@ public class Room implements Comparable, ISerialize, Runnable { final long millis = System.currentTimeMillis(); - for (Habbo habbo : this.currentHabbos.values()) { + for (Habbo habbo : this.roomUnitManager.getCurrentRoomHabbos().values()) { if (!foundRightHolder[0]) { foundRightHolder[0] = habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE; } @@ -1258,7 +845,7 @@ public class Room implements Comparable, ISerialize, Runnable { } else { habbo.getRoomUnit().increaseIdleTimer(); - if (!this.isOwner(habbo) && habbo.getRoomUnit().getIdleTimer() >= Room.IDLE_CYCLES_KICK) { + if (!this.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= Room.IDLE_CYCLES_KICK) { UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE); Emulator.getPluginManager().fireEvent(event); @@ -1269,10 +856,10 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting") && this.ownerId != habbo.getHabboInfo().getId()) { + if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting") && this.roomInfo.getOwnerInfo().getId() != habbo.getHabboInfo().getId()) { //Check if the time already have 1 minute (120 / 2 = 60s) if (habbo.getRoomUnit().getTimeInRoom() >= 120) { - AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting")); + AchievementManager.progressAchievement(this.roomInfo.getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting")); habbo.getRoomUnit().resetTimeInRoom(); } else { habbo.getRoomUnit().increaseTimeInRoom(); @@ -1300,14 +887,14 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.currentBots.isEmpty()) { - TIntObjectIterator botIterator = this.currentBots.iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) { + if (!this.roomUnitManager.getCurrentRoomBots().isEmpty()) { + Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); + + while(botIterator.hasNext()) { try { final Bot bot; try { - botIterator.advance(); - bot = botIterator.value(); + bot = botIterator.next(); } catch (Exception e) { break; } @@ -1318,7 +905,7 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } - botIterator.value().cycle(this.allowBotsWalk); + bot.cycle(this.allowBotsWalk); if (this.cycleRoomUnit(bot.getRoomUnit())) { @@ -1333,17 +920,16 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.currentPets.isEmpty() && this.allowBotsWalk) { - TIntObjectIterator petIterator = this.currentPets.iterator(); - for (int i = this.currentPets.size(); i-- > 0; ) { + if (!this.roomUnitManager.getCurrentRoomPets().isEmpty() && this.allowBotsWalk) { + Iterator petIterator = this.roomUnitManager.getCurrentRoomPets().values().iterator(); + while(petIterator.hasNext()) { + final Pet pet; try { - petIterator.advance(); - } catch (NoSuchElementException e) { - log.error(CAUGHT_EXCEPTION, e); + pet = petIterator.next(); + } catch (Exception e) { break; } - Pet pet = petIterator.value(); if (this.cycleRoomUnit(pet.getRoomUnit())) { updatedUnit.add(pet.getRoomUnit()); } @@ -1363,7 +949,7 @@ public class Room implements Comparable, ISerialize, Runnable { } - if (this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed) { + if (this.roomInfo.getRollerSpeed() != -1 && this.rollerCycle >= this.roomInfo.getRollerSpeed()) { this.rollerCycle = 0; THashSet messages = new THashSet<>(); @@ -1376,16 +962,16 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.getRollers().forEachValue(roller -> { - HabboItem newRoller = null; + RoomItem newRoller = null; RoomTile rollerTile = this.getLayout().getTile(roller.getX(), roller.getY()); if (rollerTile == null) return true; - THashSet itemsOnRoller = new THashSet<>(); + THashSet itemsOnRoller = new THashSet<>(); - for (HabboItem item : getItemsAt(rollerTile)) { + for (RoomItem item : getItemsAt(rollerTile)) { if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { itemsOnRoller.add(item); } @@ -1413,19 +999,19 @@ public class Room implements Comparable, ISerialize, Runnable { if (tileInFront.hasUnits()) return true; - THashSet itemsNewTile = new THashSet<>(); + THashSet itemsNewTile = new THashSet<>(); itemsNewTile.addAll(getItemsAt(tileInFront)); itemsNewTile.removeAll(itemsOnRoller); itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); - HabboItem topItem = Room.this.getTopItemAt(tileInFront.getX(), tileInFront.getY()); + RoomItem topItem = Room.this.getTopItemAt(tileInFront.getX(), tileInFront.getY()); boolean allowUsers = true; boolean allowFurniture = true; boolean stackContainsRoller = false; - for (HabboItem item : itemsNewTile) { + for (RoomItem item : itemsNewTile) { if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1"))) { allowUsers = false; } @@ -1465,11 +1051,17 @@ public class Room implements Comparable, ISerialize, Runnable { roomUserRolledEvent = new UserRolledEvent(null, null, null); } - ArrayList unitsOnTile = new ArrayList<>(rollerTile.getUnits()); + ArrayList unitsOnTile = new ArrayList<>(rollerTile.getEntities()); + + for (RoomEntity entity : rollerTile.getEntities()) { + if(!(entity instanceof RoomUnit)) { + continue; + } + + RoomUnit unit = (RoomUnit) entity; - for (RoomUnit unit : rollerTile.getUnits()) { if (unit.getRoomUnitType() == RoomUnitType.PET) { - Pet pet = this.getPet(unit); + Pet pet = this.roomUnitManager.getPetByRoomUnit(unit); if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) { unitsOnTile.remove(unit); } @@ -1478,8 +1070,14 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet usersRolledThisTile = new THashSet<>(); - for (RoomUnit unit : unitsOnTile) { - if (rolledUnitIds.contains(unit.getId())) continue; + for (RoomEntity entity : unitsOnTile) { + if(!(entity instanceof RoomUnit)) { + continue; + } + + RoomUnit unit = (RoomUnit) entity; + + if (rolledUnitIds.contains(unit.getVirtualId())) continue; if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; @@ -1489,9 +1087,9 @@ public class Room implements Comparable, ISerialize, Runnable { if (unit.hasStatus(RoomUnitStatus.MOVE)) continue; - double newZ = unit.getZ() + zOffset; + double newZ = unit.getCurrentZ() + zOffset; - if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.USER) { + if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.HABBO) { roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tileInFront); Emulator.getPluginManager().fireEvent(roomUserRolledEvent); @@ -1501,28 +1099,28 @@ public class Room implements Comparable, ISerialize, Runnable { // horse riding boolean isRiding = false; - if (unit.getRoomUnitType() == RoomUnitType.USER) { + if (unit.getRoomUnitType() == RoomUnitType.HABBO) { Habbo rollingHabbo = this.getHabbo(unit); if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); if (riding != null) { RoomUnit ridingUnit = riding.getRoomUnit(); - newZ = ridingUnit.getZ() + zOffset; - rolledUnitIds.add(ridingUnit.getId()); + newZ = ridingUnit.getCurrentZ() + zOffset; + rolledUnitIds.add(ridingUnit.getVirtualId()); updatedUnit.remove(ridingUnit); - messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentLocation(), ridingUnit.getZ(), tileInFront, newZ, room)); + messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentPosition(), ridingUnit.getCurrentZ(), tileInFront, newZ, room)); isRiding = true; } } } - usersRolledThisTile.add(unit.getId()); - rolledUnitIds.add(unit.getId()); + usersRolledThisTile.add(unit.getVirtualId()); + rolledUnitIds.add(unit.getVirtualId()); updatedUnit.remove(unit); - messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), room)); + messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentPosition(), unit.getCurrentZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), room)); if (itemsOnRoller.isEmpty()) { - HabboItem item = room.getTopItemAt(tileInFront.getX(), tileInFront.getY()); + RoomItem item = room.getTopItemAt(tileInFront.getX(), tileInFront.getY()); if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) { Emulator.getThreading().run(() -> { @@ -1533,7 +1131,7 @@ public class Room implements Comparable, ISerialize, Runnable { log.error(CAUGHT_EXCEPTION, e); } } - }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); + }, this.roomInfo.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); } } @@ -1558,10 +1156,10 @@ public class Room implements Comparable, ISerialize, Runnable { } if (newRoller == null || topItem == newRoller) { - List sortedItems = new ArrayList<>(itemsOnRoller); + List sortedItems = new ArrayList<>(itemsOnRoller); sortedItems.sort((o1, o2) -> Double.compare(o2.getZ(), o1.getZ())); - for (HabboItem item : sortedItems) { + for (RoomItem item : sortedItems) { if ((item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) && (item != roller)) { if (furnitureRolledEvent != null) { furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront); @@ -1591,7 +1189,7 @@ public class Room implements Comparable, ISerialize, Runnable { int currentTime = (int) (this.cycleTimestamp / 1000); - for (HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class)) { + for (RoomItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class)) { if (pyramid instanceof InteractionPyramid interactionPyramid && interactionPyramid.getNextChange() < currentTime) { interactionPyramid.change(this); } @@ -1607,8 +1205,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.traxManager.cycle(); } else { - if (this.idleCycles < 60) - this.idleCycles++; + if (this.roomIdleCycles < 60) + this.roomIdleCycles++; else this.dispose(); } @@ -1617,8 +1215,10 @@ public class Room implements Comparable, ISerialize, Runnable { synchronized (this.habboQueue) { if (!this.habboQueue.isEmpty() && !foundRightHolder[0]) { this.habboQueue.forEachEntry((a, b) -> { - if (b.isOnline() && b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { - b.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); + if (b.isOnline()) { + if (b.getHabboInfo().getRoomQueueId() == this.roomInfo.getId()) { + b.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); + } } return true; }); @@ -1636,9 +1236,9 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private boolean cycleRoomUnit(RoomUnit unit) { - boolean update = unit.needsStatusUpdate(); + boolean update = unit.isStatusUpdateNeeded(); + if (unit.hasStatus(RoomUnitStatus.SIGN)) { this.sendComposer(new UserUpdateComposer(unit).compose()); unit.removeStatus(RoomUnitStatus.SIGN); @@ -1655,9 +1255,9 @@ public class Room implements Comparable, ISerialize, Runnable { update = true; } - if (!unit.isWalking() && !unit.isCmdSit()) { - RoomTile thisTile = this.getLayout().getTile(unit.getX(), unit.getY()); - HabboItem topItem = this.getTallestChair(thisTile); + if (!unit.isWalking() && !unit.isCmdSitEnabled()) { + RoomTile thisTile = this.getLayout().getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); + RoomItem topItem = this.getTallestChair(thisTile); if (topItem == null || !topItem.getBaseItem().allowSit()) { if (unit.hasStatus(RoomUnitStatus.SIT)) { @@ -1667,16 +1267,16 @@ public class Room implements Comparable, ISerialize, Runnable { } else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) { this.dance(unit, DanceType.NONE); unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + ""); - unit.setZ(topItem.getZ()); - unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); + unit.setCurrentZ(topItem.getZ()); + unit.setRotation(RoomRotation.values()[topItem.getRotation()]); unit.setSitUpdate(false); return true; } } } - if (!unit.isWalking() && !unit.isCmdLay()) { - HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY()); + if (!unit.isWalking() && !unit.isCmdLayEnabled()) { + RoomItem topItem = this.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); if (topItem == null || !topItem.getBaseItem().allowLay()) { if (unit.hasStatus(RoomUnitStatus.LAY)) { @@ -1686,12 +1286,12 @@ public class Room implements Comparable, ISerialize, Runnable { } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) + ""); - unit.setRotation(RoomUserRotation.values()[topItem.getRotation() % 4]); + unit.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { - unit.setLocation(this.layout.getTile(unit.getX(), topItem.getY())); + unit.setLocation(this.layout.getTile(unit.getCurrentPosition().getX(), topItem.getY())); } else { - unit.setLocation(this.layout.getTile(topItem.getX(), unit.getY())); + unit.setLocation(this.layout.getTile(topItem.getX(), unit.getCurrentPosition().getY())); } update = true; } @@ -1699,93 +1299,26 @@ public class Room implements Comparable, ISerialize, Runnable { } if (update) { - unit.statusUpdate(false); + unit.setStatusUpdateNeeded(false); } return update; } - public void setName(String name) { - this.name = name; - - if (this.name.length() > 50) { - this.name = this.name.substring(0, 50); - } - - if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); - - if (guild != null) { - guild.setRoomName(name); - } - } - } - - public void setDescription(String description) { - this.description = description; - - if (this.description.length() > 250) { - this.description = this.description.substring(0, 250); - } - } - - public boolean hasCustomLayout() { - return this.overrideModel; - } - - public void setHasCustomLayout(boolean overrideModel) { - this.overrideModel = overrideModel; - } - - public void setPassword(String password) { - this.password = password; - - if (this.password.length() > 20) { - this.password = this.password.substring(0, 20); - } - } - - public boolean moveDiagonally() { - return this.moveDiagonally; - } - - public void moveDiagonally(boolean moveDiagonally) { - this.moveDiagonally = moveDiagonally; - this.layout.moveDiagonally(this.moveDiagonally); + public void setDiagonalMoveEnabled(boolean moveDiagonally) { + this.roomInfo.setDiagonalMoveEnabled(moveDiagonally); + this.layout.moveDiagonally(moveDiagonally); this.needsUpdate = true; } - public boolean hasGuild() { - return this.guildId != 0; - } - - public String getGuildName() { - if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); - - if (guild != null) { - return guild.getName(); - } - } - - return ""; - } - - public void setAllowPets(boolean allowPets) { - this.allowPets = allowPets; - if (!allowPets) { - removeAllPets(ownerId); - } - } - public Color getBackgroundTonerColor() { Color color = new Color(0, 0, 0); - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i > 0; i--) { try { iterator.advance(); - HabboItem object = iterator.value(); + RoomItem object = iterator.value(); if (object instanceof InteractionBackgroundToner) { String[] extraData = object.getExtradata().split(":"); @@ -1802,67 +1335,20 @@ public class Room implements Comparable, ISerialize, Runnable { return color; } - public void removeAllPets() { - removeAllPets(-1); - } - - /** - * Removes all pets from the room except if the owner id is excludeUserId - * - * @param excludeUserId Habbo id to keep pets - */ - public void removeAllPets(int excludeUserId) { - ArrayList toRemovePets = new ArrayList<>(); - ArrayList removedPets = new ArrayList<>(); - synchronized (this.currentPets) { - for (Pet pet : this.currentPets.valueCollection()) { - try { - if (pet.getUserId() != excludeUserId) { - toRemovePets.add(pet); - } - - } catch (NoSuchElementException e) { - log.error(CAUGHT_EXCEPTION, e); - break; - } - } - } - - for (Pet pet : toRemovePets) { - removedPets.add(pet); - - pet.removeFromRoom(); - - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); - if (habbo != null) { - habbo.getInventory().getPetsComponent().addPet(pet); - habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - } - - pet.setNeedsUpdate(true); - pet.run(); - } - - for (Pet pet : removedPets) { - this.currentPets.remove(pet.getId()); - } - } - public void setRollerSpeed(int rollerSpeed) { - this.rollerSpeed = rollerSpeed; + this.roomInfo.setRollerSpeed(rollerSpeed); this.rollerCycle = 0; this.needsUpdate = true; } public String[] filterAnything() { - return new String[]{this.getOwnerName(), this.getGuildName(), this.getDescription(), this.getPromotionDesc()}; + return new String[]{this.roomInfo.getOwnerInfo().getUsername(), this.roomInfo.getGuildName(), this.roomInfo.getDescription(), this.getPromotionDesc()}; } public boolean isPromoted() { - this.promoted = this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp(); + this.roomInfo.setPromoted(this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp()); this.needsUpdate = true; - - return this.promoted; + return this.roomInfo.isPromoted(); } public String getPromotionDesc() { @@ -1874,7 +1360,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void createPromotion(String title, String description, int category) { - this.promoted = true; + this.roomInfo.setPromoted(true); if (this.promotion == null) { this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category); @@ -1886,7 +1372,7 @@ public class Room implements Comparable, ISerialize, Runnable { } try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); statement.setString(2, title); statement.setString(3, description); statement.setInt(4, this.promotion.getEndTimestamp()); @@ -1946,14 +1432,6 @@ public class Room implements Comparable, ISerialize, Runnable { return game; } - public int getUserCount() { - return this.currentHabbos.size(); - } - - public Collection getHabbos() { - return this.currentHabbos.values(); - } - public String getFurniOwnerName(int userId) { return this.furniOwnerNames.get(userId); } @@ -1978,7 +1456,7 @@ public class Room implements Comparable, ISerialize, Runnable { return true; } - public void addHabboItem(HabboItem item) { + public void addHabboItem(RoomItem item) { if (item == null) return; @@ -2089,11 +1567,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public HabboItem getHabboItem(int id) { + public RoomItem getHabboItem(int id) { if (this.roomItems == null || this.roomSpecialTypes == null) return null; // room not loaded completely - HabboItem item; + RoomItem item; synchronized (this.roomItems) { item = this.roomItems.get(id); } @@ -2141,11 +1619,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.removeHabboItem(this.getHabboItem(id)); } - - public void removeHabboItem(HabboItem item) { + public void removeHabboItem(RoomItem item) { if (item != null) { - HabboItem i; + RoomItem i; synchronized (this.roomItems) { i = this.roomItems.remove(item.getId()); } @@ -2243,27 +1720,18 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public List getFloorItems() { + public List getFloorItems() { return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getType() == FurnitureType.FLOOR).toList(); } - public List getWallItems() { + public List getWallItems() { return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getType() == FurnitureType.WALL).toList(); } - public List getPostItNotes() { + public List getPostItNotes() { return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); } - public void addHabbo(Habbo habbo) { - synchronized (this.roomUnitLock) { - habbo.getRoomUnit().setId(this.unitCounter); - this.currentHabbos.put(habbo.getHabboInfo().getId(), habbo); - this.unitCounter++; - this.updateDatabaseUserCount(); - } - } - public void kickHabbo(Habbo habbo, boolean alert) { if (alert) { habbo.getClient().sendResponse(new GenericErrorComposer(GenericErrorComposer.KICKED_OUT_OF_THE_ROOM)); @@ -2272,256 +1740,49 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().setKicked(true); habbo.getRoomUnit().setGoalLocation(this.layout.getDoorTile()); - if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.isPublicRoom()) { + if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.roomInfo.isPublicRoom()) { habbo.getRoomUnit().setCanWalk(true); Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this); } } - public void removeHabbo(Habbo habbo) { - removeHabbo(habbo, false); - } - - public void removeHabbo(Habbo habbo, boolean sendRemovePacket) { - if (habbo.getRoomUnit() != null && habbo.getRoomUnit().getCurrentLocation() != null) { - habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); - } - - synchronized (this.roomUnitLock) { - this.currentHabbos.remove(habbo.getHabboInfo().getId()); - } - - if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting()) { - this.sendComposer(new UserRemoveMessageComposer(habbo.getRoomUnit()).compose()); - } - - if (habbo.getRoomUnit().getCurrentLocation() != null) { - HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); - - if (item != null) { - try { - item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - } - - if (habbo.getHabboInfo().getCurrentGame() != null && this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) { - this.getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); - } - - RoomTrade trade = this.getActiveTradeForHabbo(habbo); - - if (trade != null) { - trade.stopTrade(habbo); - } - - if (habbo.getHabboInfo().getId() != this.ownerId) { - this.pickupPetsForHabbo(habbo); - } - - this.updateDatabaseUserCount(); - } - - public void addBot(Bot bot) { - synchronized (this.roomUnitLock) { - bot.getRoomUnit().setId(this.unitCounter); - this.currentBots.put(bot.getId(), bot); - this.unitCounter++; - } - } - - public void addPet(Pet pet) { - synchronized (this.roomUnitLock) { - pet.getRoomUnit().setId(this.unitCounter); - this.currentPets.put(pet.getId(), pet); - this.unitCounter++; - - Habbo habbo = this.getHabbo(pet.getUserId()); - if (habbo != null) { - this.furniOwnerNames.put(pet.getUserId(), this.getHabbo(pet.getUserId()).getHabboInfo().getUsername()); - } - } - } - - public Bot getBot(int botId) { - return this.currentBots.get(botId); - } - - public Bot getBot(RoomUnit roomUnit) { - return getBot(roomUnit.getId()); - } - - public Bot getBotByRoomUnitId(int id) { - synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getRoomUnit().getId() == id).findFirst().orElse(null); - } - } - - public List getBots(String name) { - synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getName().equalsIgnoreCase(name)).toList(); - - } - } - - public boolean hasBotsAt(final int x, final int y) { - final boolean[] result = {false}; - - synchronized (this.currentBots) { - this.currentBots.forEachValue(object -> { - if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { - result[0] = true; - return false; - } - - return true; - }); - } - - return result[0]; - } - - public Pet getPet(int petId) { - return this.currentPets.get(petId); - } - - public Pet getPet(RoomUnit roomUnit) { - return currentPets.valueCollection().stream().filter(p -> p.getRoomUnit() == roomUnit).findFirst().orElse(null); - } - - public boolean removeBot(Bot bot) { - synchronized (this.currentBots) { - if (this.currentBots.containsKey(bot.getId())) { - if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentLocation() != null) { - bot.getRoomUnit().getCurrentLocation().removeUnit(bot.getRoomUnit()); - } - - this.currentBots.remove(bot.getId()); - bot.getRoomUnit().setInRoom(false); - bot.setRoom(null); - this.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); - bot.setRoomUnit(null); - return true; - } - } - - return false; - } - - public void placePet(Pet pet, short x, short y, double z) { - synchronized (this.currentPets) { - RoomTile tile = this.layout.getTile(x, y); - - if (tile == null) { - tile = this.layout.getDoorTile(); - } - - pet.setRoomUnit(new RoomUnit()); - pet.setRoom(this); - pet.getRoomUnit() - .setGoalLocation(tile) - .setLocation(tile) - .setRoomUnitType(RoomUnitType.PET) - .setCanWalk(true) - .setPathFinderRoom(this) - .setPreviousLocationZ(z) - .setZ(z); - - if (pet.getRoomUnit().getCurrentLocation() == null) { - pet.getRoomUnit() - .setLocation(this.getLayout().getDoorTile()) - .setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } - - pet.setNeedsUpdate(true); - this.furniOwnerNames.put(pet.getUserId(), this.getHabbo(pet.getUserId()).getHabboInfo().getUsername()); - this.addPet(pet); - this.sendComposer(new RoomPetComposer(pet).compose()); - } - } - - public Pet removePet(int petId) { - return this.currentPets.remove(petId); - } - - public boolean hasHabbosAt(int x, int y) { - return getHabbos().stream().anyMatch(h -> h.getRoomUnit().getX() == x && h.getRoomUnit().getY() == y); - } - - public boolean hasPetsAt(int x, int y) { - synchronized (this.currentPets) { - return currentPets.valueCollection().stream().anyMatch(p -> p.getRoomUnit().getX() == x && p.getRoomUnit().getY() == y); - } - } - - public List getPetsAt(RoomTile tile) { - synchronized (this.currentPets) { - return currentPets.valueCollection().stream().filter(p -> p.getRoomUnit().getCurrentLocation().equals(tile)).toList(); - } - } - - public List getBotsAt(RoomTile tile) { - synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getRoomUnit().getCurrentLocation().equals(tile)).toList(); - } - } - - public List getHabbosAt(short x, short y) { - return this.getHabbosAt(this.layout.getTile(x, y)); - } - - public List getHabbosAt(RoomTile tile) { - return getHabbos().stream().filter(h -> h.getRoomUnit().getCurrentLocation().equals(tile)).toList(); - } - - public THashSet getHabbosAndBotsAt(short x, short y) { - return this.getHabbosAndBotsAt(this.layout.getTile(x, y)); - } - - public THashSet getHabbosAndBotsAt(RoomTile tile) { - THashSet list = new THashSet<>(); - list.addAll(getBotsAt(tile).stream().map(Bot::getRoomUnit).toList()); - list.addAll(getHabbosAt(tile).stream().map(Habbo::getRoomUnit).toList()); - - return list; - } - - public THashSet getHabbosOnItem(HabboItem item) { + public THashSet getHabbosOnItem(RoomItem item) { THashSet habbos = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - habbos.addAll(this.getHabbosAt(x, y)); + RoomTile tile = this.getLayout().getTile(x, y); + habbos.addAll(this.roomUnitManager.getHabbosAt(tile)); } } return habbos; } - public THashSet getBotsOnItem(HabboItem item) { + public THashSet getBotsOnItem(RoomItem item) { THashSet bots = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - bots.addAll(this.getBotsAt(this.getLayout().getTile(x, y))); + RoomTile tile = this.getLayout().getTile(x, y); + bots.addAll(this.roomUnitManager.getBotsAt(tile)); } } return bots; } - public THashSet getPetsOnItem(HabboItem item) { + public THashSet getPetsOnItem(RoomItem item) { THashSet pets = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - pets.addAll(this.getPetsAt(this.getLayout().getTile(x, y))); + RoomTile tile = this.getLayout().getTile(x, y); + pets.addAll(this.roomUnitManager.getPetsAt(tile)); } } return pets; } - public void teleportHabboToItem(Habbo habbo, HabboItem item) { + public void teleportHabboToItem(Habbo habbo, RoomItem item) { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } @@ -2529,7 +1790,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.teleportRoomUnitToLocation(habbo.getRoomUnit(), x, y, 0.0); } - public void teleportRoomUnitToItem(RoomUnit roomUnit, HabboItem item) { + public void teleportRoomUnitToItem(RoomUnit roomUnit, RoomItem item) { this.teleportRoomUnitToLocation(roomUnit, item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); } @@ -2547,7 +1808,7 @@ public class Room implements Comparable, ISerialize, Runnable { roomUnit.setLocation(tile); roomUnit.setGoalLocation(tile); - roomUnit.setZ(z); + roomUnit.setCurrentZ(z); roomUnit.setPreviousLocationZ(z); this.updateRoomUnit(roomUnit); @@ -2562,7 +1823,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean isMuted(Habbo habbo) { - if (this.isOwner(habbo) || this.hasRights(habbo)) + if (this.getRoomInfo().isRoomOwner(habbo) || this.hasRights(habbo)) return false; if (this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) { @@ -2581,17 +1842,17 @@ public class Room implements Comparable, ISerialize, Runnable { public void habboEntered(Habbo habbo) { habbo.getRoomUnit().setAnimateWalk(false); - synchronized (this.currentBots) { - if (habbo.getHabboInfo().getId() != this.getOwnerId()) + synchronized (this.roomUnitManager.getCurrentRoomBots()) { + if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) return; - TIntObjectIterator botIterator = this.currentBots.iterator(); + Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) { + while (botIterator.hasNext()) { try { - botIterator.advance(); + Bot bot = botIterator.next(); - if (botIterator.value() instanceof VisitorBot visitorBot) { + if (bot instanceof VisitorBot visitorBot) { visitorBot.onUserEnter(habbo); break; } @@ -2601,7 +1862,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - HabboItem doorTileTopItem = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); + RoomItem doorTileTopItem = this.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); @@ -2634,7 +1895,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - if (habbo.getHabboInfo().getCurrentRoom() != this) + if (habbo.getRoomUnit().getRoom() != this) return; long millis = System.currentTimeMillis(); @@ -2662,8 +1923,8 @@ public class Room implements Comparable, ISerialize, Runnable { return; if (!habbo.hasRight(Permission.ACC_NOMUTE) && (!MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) { - for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { - if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentLocation())) { + for (RoomItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { + if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentPosition())) { return; } } @@ -2688,13 +1949,13 @@ public class Room implements Comparable, ISerialize, Runnable { if (chatType != RoomChatType.WHISPER) { if (Emulator.getGameEnvironment().getCommandsManager().handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { - WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()}); + WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()}); roomChatMessage.isCommand = true; return; } if (!ignoreWired) { - if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()})) { + if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()})) { habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(roomChatMessage.getMessage(), habbo, habbo, roomChatMessage.getBubble()))); return; } @@ -2709,7 +1970,7 @@ public class Room implements Comparable, ISerialize, Runnable { final boolean hasRights = this.hasRights(habbo); if (floodRights || !hasRights) { - if (this.chatProtection == 0 || (this.chatProtection == 1 && chatCounter > 4) || (this.chatProtection == 2 && chatCounter > 5)) { + if (this.roomInfo.getChatProtection() == 0 || (this.roomInfo.getChatProtection() == 1 && chatCounter > 4) || (this.roomInfo.getChatProtection() == 2 && chatCounter > 5)) { this.floodMuteHabbo(habbo, muteTime); return; } @@ -2731,7 +1992,7 @@ public class Room implements Comparable, ISerialize, Runnable { } ServerMessage clearPrefixMessage = prefixMessage != null ? new UserNameChangedMessageComposer(habbo).compose() : null; - Rectangle tentRectangle = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); + Rectangle tentRectangle = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentPosition()); String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$", ""); @@ -2750,7 +2011,7 @@ public class Room implements Comparable, ISerialize, Runnable { final ServerMessage message = new WhisperMessageComposer(roomChatMessage).compose(); final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); - for (Habbo h : this.getHabbos()) { + for (Habbo h : this.roomUnitManager.getRoomHabbos()) { if (h == roomChatMessage.getTargetHabbo() || h == habbo) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { if (prefixMessage != null) { @@ -2773,11 +2034,11 @@ public class Room implements Comparable, ISerialize, Runnable { ServerMessage message = new ChatMessageComposer(roomChatMessage).compose(); boolean noChatLimit = habbo.hasRight(Permission.ACC_CHAT_NO_LIMIT); - for (Habbo h : this.getHabbos()) { - if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance || + for (Habbo h : this.roomUnitManager.getRoomHabbos()) { + if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= this.roomInfo.getChatDistance() || h.equals(habbo) || this.hasRights(h) || - noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { + noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(prefixMessage); @@ -2795,11 +2056,11 @@ public class Room implements Comparable, ISerialize, Runnable { } else if (chatType == RoomChatType.SHOUT) { ServerMessage message = new ShoutMessageComposer(roomChatMessage).compose(); - for (Habbo h : this.getHabbos()) { + for (Habbo h : this.roomUnitManager.getRoomHabbos()) { // Show the message // If the receiving Habbo has not ignored the sending Habbo // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentLocation()))) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { h.getClient().sendResponse(prefixMessage); } @@ -2815,13 +2076,12 @@ public class Room implements Comparable, ISerialize, Runnable { } if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { - synchronized (this.currentBots) { - TIntObjectIterator botIterator = this.currentBots.iterator(); + synchronized (this.roomUnitManager.getCurrentRoomBots()) { + Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); - for (int i = this.currentBots.size(); i-- > 0; ) { + while (botIterator.hasNext()) { try { - botIterator.advance(); - Bot bot = botIterator.value(); + Bot bot = botIterator.next(); bot.onUserSay(roomChatMessage); } catch (NoSuchElementException e) { @@ -2832,10 +2092,10 @@ public class Room implements Comparable, ISerialize, Runnable { } if (roomChatMessage.getBubble().triggersTalkingFurniture()) { - THashSet items = this.roomSpecialTypes.getItemsOfType(InteractionTalkingFurniture.class); + THashSet items = this.roomSpecialTypes.getItemsOfType(InteractionTalkingFurniture.class); - for (HabboItem item : items) { - if (this.layout.getTile(item.getX(), item.getY()).distance(habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("furniture.talking.range")) { + for (RoomItem item : items) { + if (this.layout.getTile(item.getX(), item.getY()).distance(habbo.getRoomUnit().getCurrentPosition()) <= Emulator.getConfig().getInt("furniture.talking.range")) { int count = Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.count", 0); if (count > 0) { @@ -2874,7 +2134,7 @@ public class Room implements Comparable, ISerialize, Runnable { * @param tentRectangle The whole tent area from where the sending Habbo is saying something */ private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) { - if (receivingHabbo != null && receivingHabbo.hasRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentLocation())) { + if (receivingHabbo != null && receivingHabbo.hasRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentPosition())) { RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage()); final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); @@ -2885,11 +2145,11 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getLockedTiles() { THashSet lockedTiles = new THashSet<>(); - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { - HabboItem item; + RoomItem item; try { iterator.advance(); item = iterator.value(); @@ -2931,7 +2191,7 @@ public class Room implements Comparable, ISerialize, Runnable { } @Deprecated - public THashSet getItemsAt(int x, int y) { + public THashSet getItemsAt(int x, int y) { RoomTile tile = this.getLayout().getTile((short) x, (short) y); if (tile != null) { @@ -2941,26 +2201,26 @@ public class Room implements Comparable, ISerialize, Runnable { return new THashSet<>(0); } - public THashSet getItemsAt(RoomTile tile) { + public THashSet getItemsAt(RoomTile tile) { return getItemsAt(tile, false); } - public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) { - THashSet items = new THashSet<>(0); + public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) { + THashSet items = new THashSet<>(0); if (tile == null) return items; if (this.loaded) { - THashSet cachedItems = this.tileCache.get(tile); + THashSet cachedItems = this.tileCache.get(tile); if (cachedItems != null) return cachedItems; } - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { - HabboItem item; + RoomItem item; try { iterator.advance(); item = iterator.value(); @@ -3001,10 +2261,10 @@ public class Room implements Comparable, ISerialize, Runnable { return items; } - public THashSet getItemsAt(int x, int y, double minZ) { - THashSet items = new THashSet<>(); + public THashSet getItemsAt(int x, int y, double minZ) { + THashSet items = new THashSet<>(); - for (HabboItem item : this.getItemsAt(x, y)) { + for (RoomItem item : this.getItemsAt(x, y)) { if (item.getZ() < minZ) continue; @@ -3013,10 +2273,10 @@ public class Room implements Comparable, ISerialize, Runnable { return items; } - public THashSet getItemsAt(Class type, int x, int y) { - THashSet items = new THashSet<>(); + public THashSet getItemsAt(Class type, int x, int y) { + THashSet items = new THashSet<>(); - for (HabboItem item : this.getItemsAt(x, y)) { + for (RoomItem item : this.getItemsAt(x, y)) { if (!item.getClass().equals(type)) continue; @@ -3034,19 +2294,27 @@ public class Room implements Comparable, ISerialize, Runnable { return !this.getItemsAt(tile, true).isEmpty(); } - public HabboItem getTopItemAt(int x, int y) { + public RoomItem getTopItemAt(RoomTile tile) { + if(tile == null) { + return null; + } + + return this.getTopItemAt(tile.getX(), tile.getY(), null); + } + + public RoomItem getTopItemAt(int x, int y) { return this.getTopItemAt(x, y, null); } - public HabboItem getTopItemAt(int x, int y, HabboItem exclude) { + public RoomItem getTopItemAt(int x, int y, RoomItem exclude) { RoomTile tile = this.getLayout().getTile((short) x, (short) y); if (tile == null) return null; - HabboItem highestItem = null; + RoomItem highestItem = null; - for (HabboItem item : this.getItemsAt(x, y)) { + for (RoomItem item : this.getItemsAt(x, y)) { if (exclude != null && exclude == item) continue; @@ -3059,14 +2327,14 @@ public class Room implements Comparable, ISerialize, Runnable { return highestItem; } - public HabboItem getTopItemAt(THashSet tiles, HabboItem exclude) { - HabboItem highestItem = null; + public RoomItem getTopItemAt(THashSet tiles, RoomItem exclude) { + RoomItem highestItem = null; for (RoomTile tile : tiles) { if (tile == null) continue; - for (HabboItem item : this.getItemsAt(tile.getX(), tile.getY())) { + for (RoomItem item : this.getItemsAt(tile.getX(), tile.getY())) { if (exclude != null && exclude == item) continue; @@ -3081,7 +2349,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public double getTopHeightAt(int x, int y) { - HabboItem item = this.getTopItemAt(x, y); + RoomItem item = this.getTopItemAt(x, y); if (item != null) { return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); } else { @@ -3089,12 +2357,12 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public HabboItem getLowestChair(RoomTile tile) { - HabboItem lowestChair = null; + public RoomItem getLowestChair(RoomTile tile) { + RoomItem lowestChair = null; - THashSet items = this.getItemsAt(tile); + THashSet items = this.getItemsAt(tile); if (items != null && !items.isEmpty()) { - for (HabboItem item : items) { + for (RoomItem item : items) { if (!item.getBaseItem().allowSit()) continue; @@ -3109,12 +2377,12 @@ public class Room implements Comparable, ISerialize, Runnable { return lowestChair; } - public HabboItem getTallestChair(RoomTile tile) { - HabboItem lowestChair = null; + public RoomItem getTallestChair(RoomTile tile) { + RoomItem lowestChair = null; - THashSet items = this.getItemsAt(tile); + THashSet items = this.getItemsAt(tile); if (items != null && !items.isEmpty()) { - for (HabboItem item : items) { + for (RoomItem item : items) { if (!item.getBaseItem().allowSit()) continue; @@ -3129,7 +2397,7 @@ public class Room implements Comparable, ISerialize, Runnable { return lowestChair; } - public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) { + public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) { if (x < 0 || y < 0 || this.layout == null) return calculateHeightmap ? Short.MAX_VALUE : 0.0; @@ -3144,16 +2412,16 @@ public class Room implements Comparable, ISerialize, Runnable { double height = this.layout.getHeightAtSquare(x, y); boolean canStack = true; - THashSet stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y); + THashSet stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y); - for (HabboItem item : stackHelpers) { + for (RoomItem item : stackHelpers) { if (item == exclude) continue; return calculateHeightmap ? item.getZ() * 256.0D : item.getZ(); } - HabboItem item = this.getTopItemAt(x, y, exclude); + RoomItem item = this.getTopItemAt(x, y, exclude); if (item != null) { canStack = item.getBaseItem().allowStack(); height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); @@ -3171,9 +2439,9 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean hasObjectTypeAt(Class type, int x, int y) { - THashSet items = this.getItemsAt(x, y); + THashSet items = this.getItemsAt(x, y); - for (HabboItem item : items) { + for (RoomItem item : items) { if (item.getClass() == type) { return true; } @@ -3183,16 +2451,28 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canSitOrLayAt(int x, int y) { - if (this.hasHabbosAt(x, y)) + RoomTile tile = this.getLayout().getTile((short) x, (short) y); + + if(tile == null) { + return false; + } + + if (this.roomUnitManager.hasHabbosAt(tile)) return false; - THashSet items = this.getItemsAt(x, y); + THashSet items = this.getItemsAt(x, y); return this.canSitAt(items) || this.canLayAt(items); } public boolean canSitAt(int x, int y) { - if (this.hasHabbosAt(x, y)) + RoomTile tile = this.getLayout().getTile((short) x, (short) y); + + if(tile == null) { + return false; + } + + if (this.roomUnitManager.hasHabbosAt(tile)) return false; return this.canSitAt(this.getItemsAt(x, y)); @@ -3206,11 +2486,11 @@ public class Room implements Comparable, ISerialize, Runnable { if (roomTile.getState() == RoomTileState.INVALID) return false; - HabboItem topItem = null; + RoomItem topItem = null; boolean canWalk = true; - THashSet items = this.getItemsAt(roomTile); + THashSet items = this.getItemsAt(roomTile); if (items != null) { - for (HabboItem item : items) { + for (RoomItem item : items) { if (topItem == null) { topItem = item; } @@ -3230,13 +2510,13 @@ public class Room implements Comparable, ISerialize, Runnable { return canWalk; } - boolean canSitAt(THashSet items) { + boolean canSitAt(THashSet items) { if (items == null) return false; - HabboItem tallestItem = null; + RoomItem tallestItem = null; - for (HabboItem item : items) { + for (RoomItem item : items) { if (tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item)) continue; @@ -3253,13 +2533,13 @@ public class Room implements Comparable, ISerialize, Runnable { return this.canLayAt(this.getItemsAt(x, y)); } - boolean canLayAt(THashSet items) { + boolean canLayAt(THashSet items) { if (items == null || items.isEmpty()) return true; - HabboItem topItem = null; + RoomItem topItem = null; - for (HabboItem item : items) { + for (RoomItem item : items) { if ((topItem == null || item.getZ() > topItem.getZ())) { topItem = item; } @@ -3280,7 +2560,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public Habbo getHabbo(String username) { - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)) return habbo; } @@ -3288,20 +2568,16 @@ public class Room implements Comparable, ISerialize, Runnable { } public Habbo getHabbo(RoomUnit roomUnit) { - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo.getRoomUnit() == roomUnit) return habbo; } return null; } - public Habbo getHabbo(int userId) { - return this.currentHabbos.get(userId); - } - public Habbo getHabboByRoomUnitId(int roomUnitId) { - for (Habbo habbo : this.getHabbos()) { - if (habbo.getRoomUnit().getId() == roomUnitId) + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + if (habbo.getRoomUnit().getVirtualId() == roomUnitId) return habbo; } @@ -3309,7 +2585,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void sendComposer(ServerMessage message) { - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo.getClient() == null) continue; habbo.getClient().sendResponse(message); @@ -3317,7 +2593,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void sendComposerToHabbosWithRights(ServerMessage message) { - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (this.hasRights(habbo)) { habbo.getClient().sendResponse(message); } @@ -3325,7 +2601,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void petChat(ServerMessage message) { - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (!habbo.getHabboStats().isIgnorePets()) habbo.getClient().sendResponse(message); } @@ -3336,7 +2612,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo == null) { return ; } if (!habbo.getHabboStats().isIgnoreBots()) habbo.getClient().sendResponse(message); @@ -3346,7 +2622,7 @@ public class Room implements Comparable, ISerialize, Runnable { private void loadRights(Connection connection) { this.rights.clear(); try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { this.rights.add(set.getInt(DatabaseConstants.USER_ID)); @@ -3364,7 +2640,7 @@ public class Room implements Comparable, ISerialize, Runnable { try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); - statement.setInt(2, this.id); + statement.setInt(2, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { if (this.bannedHabbos.containsKey(set.getInt(DatabaseConstants.USER_ID))) @@ -3379,13 +2655,15 @@ public class Room implements Comparable, ISerialize, Runnable { } public RoomRightLevels getGuildRightLevel(Habbo habbo) { - if (this.guildId > 0 && habbo.getHabboStats().hasGuild(this.guildId)) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); + if(!this.roomInfo.hasGuild()) { + return RoomRightLevels.NONE; + } - if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(habbo.getHabboInfo().getId()) != null) + if (habbo.getHabboStats().hasGuild(this.roomInfo.getGuild().getId())) { + if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(this.roomInfo.getGuild()).get(habbo.getHabboInfo().getId()) != null) return RoomRightLevels.GUILD_ADMIN; - if (guild.isRights()) { + if (this.roomInfo.getGuild().isRights()) { return RoomRightLevels.GUILD_RIGHTS; } } @@ -3393,20 +2671,8 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomRightLevels.NONE; } - /** - * @deprecated Deprecated since 2.5.0. Use {@link #getGuildRightLevel(Habbo)} instead. - */ - @Deprecated - public int guildRightLevel(Habbo habbo) { - return this.getGuildRightLevel(habbo).getLevel(); - } - - public boolean isOwner(Habbo habbo) { - return habbo.getHabboInfo().getId() == this.ownerId || habbo.hasRight(Permission.ACC_ANYROOMOWNER); - } - public boolean hasRights(Habbo habbo) { - return this.isOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())); + return this.getRoomInfo().isRoomOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())); } public void giveRights(Habbo habbo) { @@ -3421,7 +2687,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.rights.add(userId)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { @@ -3429,14 +2695,14 @@ public class Room implements Comparable, ISerialize, Runnable { } } - Habbo habbo = this.getHabbo(userId); + Habbo habbo = this.roomUnitManager.getRoomHabboById(userId); if (habbo != null) { this.refreshRightsForHabbo(habbo); this.sendComposer(new FlatControllerAddedComposer(this, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername()).compose()); } else { - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.ownerId); + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.roomInfo.getOwnerInfo().getId()); if (owner != null) { MessengerBuddy buddy = owner.getMessenger().getFriend(userId); @@ -3449,16 +2715,16 @@ public class Room implements Comparable, ISerialize, Runnable { } public void removeRights(int userId) { - Habbo habbo = this.getHabbo(userId); + Habbo habbo = this.roomUnitManager.getRoomHabboById(userId); - if (Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.getHabbo(this.getOwnerId()), userId, habbo)).isCancelled()) + if (Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.roomUnitManager.getRoomHabboById(this.roomInfo.getOwnerInfo().getId()), userId, habbo)).isCancelled()) return; this.sendComposer(new FlatControllerRemovedComposer(this, userId).compose()); if (this.rights.remove(userId)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { @@ -3482,7 +2748,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.rights.clear(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); statement.execute(); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -3493,15 +2759,15 @@ public class Room implements Comparable, ISerialize, Runnable { void refreshRightsInRoom() { Room room = this; - for (Habbo habbo : this.getHabbos()) { - if (habbo.getHabboInfo().getCurrentRoom() == room) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + if (habbo.getRoomUnit().getRoom() == room) { this.refreshRightsForHabbo(habbo); } } } public void refreshRightsForHabbo(Habbo habbo) { - HabboItem item; + RoomItem item; RoomRightLevels flatCtrl = RoomRightLevels.NONE; if (habbo.getHabboStats().isRentingSpace()) { item = this.getHabboItem(habbo.getHabboStats().getRentedItemId()); @@ -3511,19 +2777,19 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (habbo.hasRight(Permission.ACC_ANYROOMOWNER) || this.isOwner(habbo)) { + if (habbo.hasRight(Permission.ACC_ANYROOMOWNER) || this.getRoomInfo().isRoomOwner(habbo)) { habbo.getClient().sendResponse(new YouAreOwnerMessageComposer()); flatCtrl = RoomRightLevels.MODERATOR; - } else if (this.hasRights(habbo) && !this.hasGuild()) { + } else if (this.hasRights(habbo) && !this.roomInfo.hasGuild()) { flatCtrl = RoomRightLevels.RIGHTS; - } else if (this.hasGuild()) { + } else if (this.roomInfo.hasGuild()) { flatCtrl = this.getGuildRightLevel(habbo); } habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, flatCtrl.getLevel() + ""); habbo.getRoomUnit().setRightsLevel(flatCtrl); - habbo.getRoomUnit().statusUpdate(true); + habbo.getRoomUnit().setStatusUpdateNeeded(true); if (flatCtrl.equals(RoomRightLevels.MODERATOR)) { habbo.getClient().sendResponse(new FlatControllersComposer(this)); @@ -3535,7 +2801,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (!this.rights.isEmpty()) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) { - statement.setInt(1, this.id); + statement.setInt(1, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { rightsMap.put(set.getInt(DatabaseConstants.USER_ID), set.getString("username")); @@ -3587,8 +2853,8 @@ public class Room implements Comparable, ISerialize, Runnable { } this.dance(habbo, DanceType.NONE); - habbo.getRoomUnit().setCmdSit(true); - habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); + habbo.getRoomUnit().setCmdSitEnabled(true); + habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + ""); this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); } @@ -3596,23 +2862,23 @@ public class Room implements Comparable, ISerialize, Runnable { public void makeStand(Habbo habbo) { if (habbo.getRoomUnit() == null) return; - HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); + RoomItem item = this.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { - habbo.getRoomUnit().setCmdStand(true); - habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); + habbo.getRoomUnit().setCmdStandEnabled(true); + habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); } } public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) { - if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { + if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) { this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks); } } public void giveEffect(Habbo habbo, int effectId, int duration) { - if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { + if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) { this.giveEffect(habbo.getRoomUnit(), effectId, duration, false); } } @@ -3622,38 +2888,35 @@ public class Room implements Comparable, ISerialize, Runnable { } public void giveEffect(RoomUnit roomUnit, int effectId, int duration, boolean ignoreChecks) { - if (roomUnit == null || roomUnit.getRoom() == null) return; + if (roomUnit == null || !roomUnit.isInRoom() || !(roomUnit instanceof RoomAvatar roomAvatar)) { + return; + } - Habbo habbo = roomUnit.getRoom().getHabbo(roomUnit); + Habbo habbo = this.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); - if (roomUnit.getRoomUnitType() == RoomUnitType.USER && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) { return; } - if (duration == -1 || duration == Integer.MAX_VALUE) { - duration = Integer.MAX_VALUE; - } else { - duration += Emulator.getIntUnixTimestamp(); - } + if (roomAvatar.getRoomUnitType() == RoomUnitType.HABBO && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) { + return; + } - if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming()) { - roomUnit.setEffectId(effectId, duration); - this.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose()); - } + if (duration == -1 || duration == Integer.MAX_VALUE) { + duration = Integer.MAX_VALUE; + } else { + duration += Emulator.getIntUnixTimestamp(); + } + + if ((this.allowEffects || ignoreChecks) && !roomAvatar.isSwimming()) { + roomAvatar.setEffectId(effectId); + roomAvatar.setEffectEndTimestamp(duration); + this.sendComposer(new AvatarEffectMessageComposer(roomAvatar).compose()); + } } - public void giveHandItem(Habbo habbo, int handItem) { - this.giveHandItem(habbo.getRoomUnit(), handItem); - } - - public void giveHandItem(RoomUnit roomUnit, int handItem) { - roomUnit.setHandItem(handItem); - this.sendComposer(new CarryObjectMessageComposer(roomUnit).compose()); - } - - public void updateItem(HabboItem item) { + public void updateItem(RoomItem item) { if (!this.isLoaded()) { return; } - if (item != null && item.getRoomId() == this.id && item.getBaseItem() != null) { + if (item != null && item.getRoomId() == this.roomInfo.getId() && item.getBaseItem() != null) { if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.sendComposer(new ObjectUpdateMessageComposer(item).compose()); this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); @@ -3664,7 +2927,7 @@ public class Room implements Comparable, ISerialize, Runnable { } - public void updateItemState(HabboItem item) { + public void updateItemState(RoomItem item) { if (!item.isLimited()) { this.sendComposer(new OneWayDoorStatusMessageComposer(item).compose()); } else { @@ -3689,7 +2952,7 @@ public class Room implements Comparable, ISerialize, Runnable { public int getUserUniqueFurniCount(int userId) { THashSet items = new THashSet<>(); - for (HabboItem item : this.roomItems.valueCollection()) { + for (RoomItem item : this.roomItems.valueCollection()) { if (!items.contains(item.getBaseItem()) && item.getUserId() == userId) items.add(item.getBaseItem()); } @@ -3697,9 +2960,9 @@ public class Room implements Comparable, ISerialize, Runnable { } public void ejectUserFurni(int userId) { - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { try { @@ -3721,26 +2984,24 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getClient().sendResponse(new UnseenItemsComposer(items)); } - for (HabboItem i : items) { + for (RoomItem i : items) { this.pickUpItem(i, null); } } - public void ejectUserItem(HabboItem item) { + public void ejectUserItem(RoomItem item) { this.pickUpItem(item, null); } - public void ejectAll() { this.ejectAll(null); } - public void ejectAll(Habbo habbo) { - THashMap> userItemsMap = new THashMap<>(); + THashMap> userItemsMap = new THashMap<>(); synchronized (this.roomItems) { - TIntObjectIterator iterator = this.roomItems.iterator(); + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { try { @@ -3759,8 +3020,8 @@ public class Room implements Comparable, ISerialize, Runnable { } } - for (Map.Entry> entrySet : userItemsMap.entrySet()) { - for (HabboItem i : entrySet.getValue()) { + for (Map.Entry> entrySet : userItemsMap.entrySet()) { + for (RoomItem i : entrySet.getValue()) { this.pickUpItem(i, null); } @@ -3774,10 +3035,10 @@ public class Room implements Comparable, ISerialize, Runnable { } public void refreshGuild(Guild guild) { - if (guild.getRoomId() == this.id) { + if (guild.getRoomId() == this.roomInfo.getId()) { THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); - for (Habbo habbo : this.getHabbos()) { + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { Optional member = members.stream().filter(m -> m.getUserId() == habbo.getHabboInfo().getId()).findAny(); if (member.isEmpty()) continue; @@ -3790,8 +3051,8 @@ public class Room implements Comparable, ISerialize, Runnable { } public void refreshGuildColors(Guild guild) { - if (guild.getRoomId() == this.id) { - TIntObjectIterator iterator = this.roomItems.iterator(); + if (guild.getRoomId() == this.roomInfo.getId()) { + TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { try { @@ -3800,24 +3061,23 @@ public class Room implements Comparable, ISerialize, Runnable { break; } - HabboItem habboItem = iterator.value(); + RoomItem roomItem = iterator.value(); - if (habboItem instanceof InteractionGuildFurni interactionGuildFurni && interactionGuildFurni.getGuildId() == guild.getId()) { - this.updateItem(habboItem); + if (roomItem instanceof InteractionGuildFurni interactionGuildFurni && interactionGuildFurni.getGuildId() == guild.getId()) { + this.updateItem(roomItem); } } } } public void refreshGuildRightsInRoom() { - for (Habbo habbo : this.getHabbos()) { - if ((habbo.getHabboInfo().getCurrentRoom() == this && habbo.getHabboInfo().getId() != this.ownerId) + for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) && (!(habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_MOVEROTATE)))) this.refreshRightsForHabbo(habbo); } } - public void idle(Habbo habbo) { habbo.getRoomUnit().setIdle(); @@ -3861,7 +3121,7 @@ public class Room implements Comparable, ISerialize, Runnable { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO room_wordfilter VALUES (?, ?)")) { - statement.setInt(1, this.getId()); + statement.setInt(1, this.roomInfo.getId()); statement.setString(2, word); statement.execute(); } catch (SQLException e) { @@ -3878,7 +3138,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.wordFilterWords.remove(word); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ? AND word = ?")) { - statement.setInt(1, this.getId()); + statement.setInt(1, this.roomInfo.getId()); statement.setString(2, word); statement.execute(); } catch (SQLException e) { @@ -3931,32 +3191,23 @@ public class Room implements Comparable, ISerialize, Runnable { return this.roomItems.size(); } - public void setJukeBoxActive(boolean jukeBoxActive) { - this.jukeboxActive = jukeBoxActive; - this.needsUpdate = true; - } - - public boolean isHideWired() { - return this.hideWired; - } - public void setHideWired(boolean hideWired) { - this.hideWired = hideWired; + this.roomInfo.setHiddenWiredEnabled(hideWired); - if (this.hideWired) { - for (HabboItem item : this.roomSpecialTypes.getTriggers()) { + if (this.roomInfo.isHiddenWiredEnabled()) { + for (RoomItem item : this.roomSpecialTypes.getTriggers()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getEffects()) { + for (RoomItem item : this.roomSpecialTypes.getEffects()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getConditions()) { + for (RoomItem item : this.roomSpecialTypes.getConditions()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } - for (HabboItem item : this.roomSpecialTypes.getExtras()) { + for (RoomItem item : this.roomSpecialTypes.getExtras()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } } else { @@ -3967,7 +3218,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) { + public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) { if (this.itemCount() >= Room.MAXIMUM_FURNI) { return FurnitureMovementError.MAX_ITEMS; } @@ -3982,7 +3233,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (habbo.getHabboStats().isRentingSpace()) { - HabboItem rentSpace = this.getHabboItem(habbo.getHabboStats().getRentedItemId()); + RoomItem rentSpace = this.getHabboItem(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))) { @@ -3993,7 +3244,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { + for (RoomItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) { return FurnitureMovementError.NONE; } @@ -4002,11 +3253,11 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NO_RIGHTS; } - public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { + public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation) { return furnitureFitsAt(tile, item, rotation, true); } - public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation, boolean checkForUnits) { + public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; @@ -4017,20 +3268,25 @@ public class Room implements Comparable, ISerialize, Runnable { 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 && this.hasHabbosAt(t.getX(), t.getY())) - return FurnitureMovementError.TILE_HAS_HABBOS; - if (checkForUnits && this.hasBotsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_BOTS; - if (checkForUnits && this.hasPetsAt(t.getX(), t.getY())) return FurnitureMovementError.TILE_HAS_PETS; + if (checkForUnits) { + if (this.roomUnitManager.hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS; + } + if (checkForUnits) { + if (!this.roomUnitManager.getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS; + } + if (checkForUnits) { + if (this.roomUnitManager.hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS; + } } } - Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); - List>> tileFurniList = new ArrayList<>(); + List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - HabboItem topItem = this.getTopItemAt(t.getX(), t.getY(), item); + RoomItem topItem = this.getTopItemAt(t.getX(), t.getY(), item); if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { return FurnitureMovementError.CANT_STACK; } @@ -4047,7 +3303,7 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NONE; } - public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) { + public FurnitureMovementError placeFloorFurniAt(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)); @@ -4093,13 +3349,13 @@ public class Room implements Comparable, ISerialize, Runnable { item.needsUpdate(true); this.addHabboItem(item); - item.setRoomId(this.id); + item.setRoomId(this.roomInfo.getId()); item.onPlace(this); this.updateTiles(occupiedTiles); this.sendComposer(new ObjectAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t.getX(), t.getY()); + this.updateHabbosAt(t); this.updateBotsAt(t.getX(), t.getY()); } @@ -4107,7 +3363,7 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NONE; } - public FurnitureMovementError placeWallFurniAt(HabboItem item, String wallPosition, Habbo owner) { + public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) { if (!(this.hasRights(owner) || this.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { return FurnitureMovementError.NO_RIGHTS; } @@ -4127,21 +3383,21 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new ItemAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); item.needsUpdate(true); this.addHabboItem(item); - item.setRoomId(this.id); + item.setRoomId(this.roomInfo.getId()); item.onPlace(this); Emulator.getThreading().run(item); return FurnitureMovementError.NONE; } - public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) { + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) { return moveFurniTo(item, tile, rotation, actor, true, true); } - public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { return moveFurniTo(item, tile, rotation, actor, sendUpdates, true); } - public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY()); boolean pluginHelper = false; @@ -4155,18 +3411,18 @@ public class Room implements Comparable, ISerialize, Runnable { boolean magicTile = item instanceof InteractionStackHelper; - Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); THashSet newOccupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - HabboItem topItem = this.getTopItemAt(occupiedTiles, null); + RoomItem topItem = this.getTopItemAt(occupiedTiles, null); if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { if (oldLocation != tile) { for (RoomTile t : occupiedTiles) { - HabboItem tileTopItem = this.getTopItemAt(t.getX(), t.getY()); + RoomItem tileTopItem = this.getTopItemAt(t.getX(), t.getY()); if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { return FurnitureMovementError.CANT_STACK; @@ -4174,18 +3430,18 @@ public class Room implements Comparable, ISerialize, Runnable { if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { if (checkForUnits && !magicTile) { - if (this.hasHabbosAt(t.getX(), t.getY())) + if (this.roomUnitManager.hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (this.hasBotsAt(t.getX(), t.getY())) + if (!this.roomUnitManager.getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS; - if (this.hasPetsAt(t.getX(), t.getY())) + if (this.roomUnitManager.hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS; } } } } - List>> tileFurniList = new ArrayList<>(); + List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } @@ -4282,7 +3538,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.updateHabbosAt( t.getX(), t.getY(), - this.getHabbosAt(t.getX(), t.getY()) + new ArrayList<>(this.roomUnitManager.getHabbosAt(t)) /*.stream() .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t) .collect(Collectors.toCollection(THashSet::new))*/ @@ -4291,7 +3547,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (Emulator.getConfig().getBoolean("wired.place.under", false)) { for (RoomTile t : newOccupiedTiles) { - for (Habbo h : this.getHabbosAt(t.getX(), t.getY())) { + for (Habbo h : this.roomUnitManager.getHabbosAt(t)) { try { item.onWalkOn(h.getRoomUnit(), this, null); } catch (Exception ignored) { @@ -4303,13 +3559,13 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NONE; } - public FurnitureMovementError slideFurniTo(HabboItem item, RoomTile tile, int rotation) { + 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<>(); + List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } @@ -4333,94 +3589,113 @@ public class Room implements Comparable, ISerialize, Runnable { //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t.getX(), t.getY()); + this.updateHabbosAt(t); this.updateBotsAt(t.getX(), t.getY()); } return FurnitureMovementError.NONE; } - public THashSet getRoomUnits() { - return getRoomUnits(null); + public TIntObjectMap getHabboQueue() { + return this.habboQueue; } - public THashSet getRoomUnits(RoomTile atTile) { - THashSet units = new THashSet<>(); - - for (Habbo habbo : this.currentHabbos.values()) { - if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().getId() == this.getId() && (atTile == null || habbo.getRoomUnit().getCurrentLocation() == atTile)) { - units.add(habbo.getRoomUnit()); - } - } - - for (Pet pet : this.currentPets.valueCollection()) { - if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom() != null && pet.getRoomUnit().getRoom().getId() == this.getId() && (atTile == null || pet.getRoomUnit().getCurrentLocation() == atTile)) { - units.add(pet.getRoomUnit()); - } - } - - for (Bot bot : this.currentBots.valueCollection()) { - if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom() != null && bot.getRoomUnit().getRoom().getId() == this.getId() && (atTile == null || bot.getRoomUnit().getCurrentLocation() == atTile)) { - units.add(bot.getRoomUnit()); - } - } - - return units; + public TIntArrayList getRights() { + return this.rights; } - public Collection getRoomUnitsAt(RoomTile tile) { - THashSet roomUnits = getRoomUnits(); - return roomUnits.stream().filter(unit -> unit.getCurrentLocation() == tile).collect(Collectors.toSet()); + public ConcurrentSet getGames() { + return this.games; } - private void startPeriodicalCycle() { - this.wiredPeriodicalCycle = Emulator.getThreading().run(() -> { - if(Emulator.isShuttingDown) { - return; - } + public TIntObjectMap getFurniOwnerNames() { + return this.furniOwnerNames; + } - this.startPeriodicalCycle(); + public THashSet getWordFilterWords() { + return this.wordFilterWords; + } - List periodicals = new ArrayList<>(); + public String getWordQuiz() { + return this.wordQuiz; + } - if(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY) != null) { - periodicals.addAll(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY)); - } - - if(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG) != null) { - periodicals.addAll(this.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG)); - } + public int getNoVotes() { + return this.noVotes; + } - if(periodicals.isEmpty()) { - return; - } + public int getYesVotes() { + return this.yesVotes; + } - periodicals.parallelStream().forEach(trigger -> { - if(!(trigger instanceof IWiredPeriodical)) { - return; - } + public int getWordQuizEnd() { + return this.wordQuizEnd; + } - RoomTile triggerTile = this.layout.getTile(trigger.getX(), trigger.getY()); + public RoomLayout getLayout() { + return this.layout; + } - if (this.triggersOnRoom.containsKey(triggerTile)) { - if(this.triggersOnRoom.get(triggerTile).getId() != trigger.getId()) { - if(((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) { - return; - } else { - this.triggersOnRoom.put(triggerTile, trigger); - } - } - } else { - this.triggersOnRoom.put(triggerTile, trigger); - } + public boolean isAllowBotsWalk() { + return this.allowBotsWalk; + } - if(this.periodicalTick % (((IWiredPeriodical) trigger).getInterval() / 500) != 0) { - return; - } + public RoomPromotion getPromotion() { + return this.promotion; + } - WiredHandler.handle(trigger, null, this, new Object[]{trigger}); - }); + public boolean isLoaded() { + return this.loaded; + } - ++this.periodicalTick; - }, 500L); + 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 f5ae4749..9dde4a35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.core.DatabaseLoggable; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; @@ -48,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().getHabboInfo().getCurrentRoom().getHabbo(data.split(" ")[0]); + this.targetHabbo = message.client.getHabbo().getRoomUnit().getRoom().getHabbo(data.split(" ")[0]); this.message = data.substring(data.split(" ")[0].length() + 1); } else { this.message = message.packet.readString(); @@ -69,7 +70,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { } this.habbo = message.client.getHabbo(); - this.roomUnitId = this.habbo.getRoomUnit().getId(); + this.roomUnitId = this.habbo.getRoomUnit().getVirtualId(); this.unfilteredMessage = this.message; this.timestamp = Emulator.getIntUnixTimestamp(); @@ -93,7 +94,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.unfilteredMessage = message; this.habbo = null; this.bubble = bubble; - this.roomUnitId = roomUnit.getId(); + this.roomUnitId = roomUnit.getVirtualId(); } public RoomChatMessage(String message, Habbo habbo, RoomChatMessageBubbles bubble) { @@ -102,7 +103,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.habbo = habbo; this.bubble = bubble; this.checkEmotion(); - this.roomUnitId = habbo.getRoomUnit().getId(); + this.roomUnitId = habbo.getRoomUnit().getVirtualId(); this.message = this.message.replace("\r", "").replace("\n", ""); if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().getChatColor() != RoomChatMessageBubbles.NORMAL) @@ -116,7 +117,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.targetHabbo = targetHabbo; this.bubble = bubble; this.checkEmotion(); - this.roomUnitId = this.habbo.getRoomUnit().getId(); + this.roomUnitId = this.habbo.getRoomUnit().getVirtualId(); this.message = this.message.replace("\r", "").replace("\n", ""); if (this.bubble.isOverridable() && this.getHabbo().getHabboStats().getChatColor() != RoomChatMessageBubbles.NORMAL) @@ -227,8 +228,8 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { statement.setString(3, this.unfilteredMessage); statement.setInt(4, this.timestamp); - if (this.habbo.getHabboInfo().getCurrentRoom() != null) { - statement.setInt(5, this.habbo.getHabboInfo().getCurrentRoom().getId()); + if (this.habbo.getRoomUnit().getRoom() != null) { + statement.setInt(5, this.habbo.getRoomUnit().getRoom().getRoomInfo().getId()); } else { statement.setInt(5, 0); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java new file mode 100644 index 00000000..25464bb7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java @@ -0,0 +1,242 @@ +package com.eu.habbo.habbohotel.rooms; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.guilds.Guild; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Getter +@Setter +@Slf4j +public class RoomInfo { + private final int id; + private HabboInfo ownerInfo; + private volatile RoomCategory category; + private String name; + private String description; + private RoomState state; + private int maxUsers; + private String password; + private Guild guild; + private volatile int score; + private String tags; + private String floorPaint; + private String wallPaint; + private String landscapePaint; + private int wallThickness; + private int wallHeight; + private int floorThickness; + private volatile boolean hideWalls; + private volatile boolean allowPets; + private volatile boolean allowPetsEat; + private volatile boolean allowWalkthrough; + private volatile int chatMode; + private volatile int chatWeight; + private volatile int chatSpeed; + private volatile int chatDistance; + private volatile int chatProtection; + private volatile int whoCanMuteOption; + private volatile int whoCanKickOption; + private volatile int whoCanBanOption; + private volatile int tradeMode; + private volatile boolean diagonalMoveEnabled; + private volatile int rollerSpeed; + private int pollId; + private volatile boolean jukeboxEnabled; + private volatile boolean hiddenWiredEnabled; + private volatile boolean staffPicked; + private volatile boolean promoted; + private volatile boolean publicRoom; + private boolean modelOverridden; + private HashMap moodLightData; + private final HashMap defaultMoodData; + + public RoomInfo(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(set.getInt("owner_id")); + this.name = set.getString("name"); + this.description = set.getString("description"); + this.category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getInt("category")); + this.state = RoomState.valueOf(set.getString("state").toUpperCase()); + this.maxUsers = set.getInt("users_max"); + this.password = set.getString("password"); + this.guild = Emulator.getGameEnvironment().getGuildManager().getGuild(set.getInt("guild_id")); + this.score = set.getInt("score"); + this.tags = set.getString("tags"); + + this.floorPaint = set.getString("paper_floor"); + this.wallPaint = set.getString("paper_wall"); + this.landscapePaint = set.getString("paper_landscape"); + this.wallThickness = set.getInt("thickness_wall"); + this.wallHeight = set.getInt("wall_height"); + this.floorThickness = set.getInt("thickness_floor"); + this.hideWalls = set.getBoolean("allow_hidewall"); + + this.allowPets = set.getBoolean("allow_other_pets"); + this.allowPetsEat = set.getBoolean("allow_other_pets_eat"); + this.allowWalkthrough = set.getBoolean("allow_walkthrough"); + + this.chatMode = set.getInt("chat_mode"); + this.chatWeight = set.getInt("chat_weight"); + this.chatSpeed = set.getInt("chat_speed"); + this.chatDistance = set.getInt("chat_hearing_distance"); + this.chatProtection = set.getInt("chat_protection"); + + this.whoCanMuteOption = set.getInt("who_can_mute"); + this.whoCanKickOption = set.getInt("who_can_kick"); + this.whoCanBanOption = set.getInt("who_can_ban"); + this.tradeMode = set.getInt("trade_mode"); + this.diagonalMoveEnabled = set.getBoolean("move_diagonally"); + + this.rollerSpeed = set.getInt("roller_speed"); + + this.pollId = set.getInt("poll_id"); + + this.jukeboxEnabled = set.getBoolean("jukebox_active"); + this.hiddenWiredEnabled = set.getBoolean("hidewired"); + + this.staffPicked = set.getBoolean("is_staff_picked"); + this.promoted = set.getBoolean("promoted"); + this.publicRoom = set.getBoolean("is_public"); + + this.modelOverridden = set.getBoolean("override_model"); + + defaultMoodData = new HashMap<>(); + + for (int i = 1; i <= 3; i++) { + RoomMoodlightData data = RoomMoodlightData.fromString(""); + data.setId(i); + defaultMoodData.put(i, data); + } + + + this.moodLightData = new HashMap<>(); + + for (String s : set.getString("moodlight_data").split(";")) { + RoomMoodlightData data = RoomMoodlightData.fromString(s); + this.moodLightData.put(data.getId(), data); + } + + } + + public void update(Connection connection) { + try (PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET name = ?, description = ?, password = ?, state = ?, users_max = ?, category = ?, score = ?, paper_floor = ?, paper_wall = ?, paper_landscape = ?, thickness_wall = ?, wall_height = ?, thickness_floor = ?, moodlight_data = ?, tags = ?, allow_other_pets = ?, allow_other_pets_eat = ?, allow_walkthrough = ?, allow_hidewall = ?, chat_mode = ?, chat_weight = ?, chat_speed = ?, chat_hearing_distance = ?, chat_protection =?, who_can_mute = ?, who_can_kick = ?, who_can_ban = ?, poll_id = ?, guild_id = ?, roller_speed = ?, override_model = ?, is_staff_picked = ?, promoted = ?, trade_mode = ?, move_diagonally = ?, owner_id = ?, owner_name = ?, jukebox_active = ?, hidewired = ? WHERE id = ?")) { + statement.setString(1, this.name); + statement.setString(2, this.description); + statement.setString(3, this.password); + statement.setString(4, this.state.name().toLowerCase()); + statement.setInt(5, this.maxUsers); + statement.setInt(6, this.category.getId()); + statement.setInt(7, this.score); + statement.setString(8, this.floorPaint); + statement.setString(9, this.wallPaint); + statement.setString(10, this.landscapePaint); + statement.setInt(11, this.wallThickness); + statement.setInt(12, this.wallHeight); + statement.setInt(13, this.floorThickness); + StringBuilder moodLightData = new StringBuilder(); + + int moodLightId = 1; + for (RoomMoodlightData data : this.moodLightData.values()) { + data.setId(moodLightId); + moodLightData.append(data).append(";"); + moodLightId++; + } + + statement.setString(14, moodLightData.toString()); + statement.setString(15, this.tags); + statement.setString(16, this.allowPets ? "1" : "0"); + statement.setString(17, this.allowPetsEat ? "1" : "0"); + statement.setString(18, this.allowWalkthrough ? "1" : "0"); + statement.setString(19, this.hideWalls ? "1" : "0"); + statement.setInt(20, this.chatMode); + statement.setInt(21, this.chatWeight); + statement.setInt(22, this.chatSpeed); + statement.setInt(23, this.chatDistance); + statement.setInt(24, this.chatProtection); + statement.setInt(25, this.whoCanMuteOption); + statement.setInt(26, this.whoCanKickOption); + statement.setInt(27, this.whoCanBanOption); + statement.setInt(28, this.pollId); + statement.setInt(29, (this.hasGuild()) ? this.guild.getId() : 0); + statement.setInt(30, this.rollerSpeed); + statement.setString(31, this.modelOverridden ? "1" : "0"); + statement.setString(32, this.staffPicked ? "1" : "0"); + statement.setString(33, this.promoted ? "1" : "0"); + statement.setInt(34, this.tradeMode); + statement.setString(35, this.diagonalMoveEnabled ? "1" : "0"); + statement.setInt(36, this.ownerInfo.getId()); + statement.setString(37, this.ownerInfo.getUsername()); + statement.setString(38, this.jukeboxEnabled ? "1" : "0"); + statement.setString(39, this.hiddenWiredEnabled ? "1" : "0"); + statement.setInt(40, this.id); + statement.executeUpdate(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + + public boolean hasGuild() { + return this.guild != null; + } + + public String getOwnerName() { + return this.getOwnerInfo().getUsername(); + } + + public boolean isRoomOwner(Habbo owner) { + return this.ownerInfo.getId() == owner.getHabboInfo().getId() || owner.hasRight(Permission.ACC_ANYROOMOWNER); + } + + public String[] filterAnything() { + return new String[]{this.getOwnerInfo().getUsername(), this.getGuildName(), this.getDescription()}; + } + + public String getGuildName() { + if (this.guild == null) { + return ""; + } + + return this.guild.getName(); + } + + public void setName(String name) { + this.name = name; + + if (this.name.length() > 50) { + this.name = this.name.substring(0, 50); + } + + if (this.guild != null) { + this.guild.setRoomName(name); + } + } + + public void setDescription(String description) { + this.description = description; + + if (this.description.length() > 250) { + this.description = this.description.substring(0, 250); + } + } + + public void setPassword(String password) { + this.password = password; + + if (this.password.length() > 20) { + this.password = this.password.substring(0, 20); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java new file mode 100644 index 00000000..8873a7bd --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -0,0 +1,72 @@ +package com.eu.habbo.habbohotel.rooms; + +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.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.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 java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +public class RoomItemManager { + private final ConcurrentHashMap currentItems; + private final HashMap floorItems; + private final HashMap 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; + private final HashMap petToys; + private final HashMap rollers; + private final HashMap gameScoreboards; + private final HashMap gameGates; + private final HashMap gameTimers; + private final HashMap banzaiTeleporters; + private final HashMap freezeExitTile; + public RoomItemManager() { + this.currentItems = new ConcurrentHashMap<>(); + + this.floorItems = new HashMap<>(); + this.wallItems = new HashMap<>(); + + 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); + this.petToys = new HashMap<>(0); + + this.rollers = new HashMap<>(0); + + this.gameScoreboards = new HashMap<>(0); + this.gameGates = new HashMap<>(0); + this.gameTimers = new HashMap<>(0); + + this.banzaiTeleporters = new HashMap<>(0); + this.freezeExitTile = new HashMap<>(0); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 379fa44b..935073f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -1,14 +1,14 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; import java.awt.*; import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; import java.util.List; +import java.util.*; @Slf4j public class RoomLayout { @@ -304,7 +304,7 @@ public class RoomLayout { continue; } - if (currentAdj.hasUnits() && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + if (currentAdj.hasUnits() && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -322,7 +322,7 @@ public class RoomLayout { } } - if (this.room.isAllowWalkthrough() && !isWalktroughRetry) { + if (this.room.getRoomInfo().isAllowWalkthrough() && !isWalktroughRetry) { return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); } @@ -590,8 +590,8 @@ public class RoomLayout { public RoomTile getRandomWalkableTilesAround(RoomUnit roomUnit, RoomTile tile, Room room, int radius) { if(!this.tileExists(tile.getX(), tile.getY())) { - tile = this.getTile(roomUnit.getX(), roomUnit.getY()); - room.getBot(roomUnit).needsUpdate(true); + tile = this.getTile(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()).needsUpdate(true); } List newTiles = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 17bbb7e8..e442474f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -22,7 +22,14 @@ import com.eu.habbo.habbohotel.pets.PetData; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.habbohotel.polls.PollManager; -import com.eu.habbo.habbohotel.users.*; +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.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.incoming.users.NewUserExperienceScriptProceedEvent; @@ -108,7 +115,7 @@ public class RoomManager { public CustomRoomLayout loadCustomLayout(Room room) { CustomRoomLayout layout = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models_custom WHERE id = ? LIMIT 1")) { - statement.setInt(1, room.getId()); + statement.setInt(1, room.getRoomInfo().getId()); try (ResultSet set = statement.executeQuery()) { if (set.next()) { layout = new CustomRoomLayout(set, room); @@ -212,10 +219,10 @@ public class RoomManager { return rooms; } - public List getActiveRooms(int categoryId) { + public List getActiveRoomsByCategoryId(int categoryId) { List rooms = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - if (categoryId == room.getCategory() || categoryId == -1) + if (categoryId == room.getRoomInfo().getCategory().getId() || categoryId == -1) rooms.add(room); } Collections.sort(rooms); @@ -226,10 +233,13 @@ public class RoomManager { public ArrayList getRoomsForHabbo(Habbo habbo) { ArrayList rooms = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - if (room.getOwnerId() == habbo.getHabboInfo().getId()) + if (room.getRoomInfo().isRoomOwner(habbo)) { rooms.add(room); + } } + rooms.sort(Room.SORT_ID); + return rooms; } @@ -245,7 +255,7 @@ public class RoomManager { statement.setString(1, username); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - rooms.add(this.loadRoom(set.getInt("id"))); + rooms.add(this.getRoom(set.getInt("id"))); } } } catch (SQLException e) { @@ -255,15 +265,15 @@ public class RoomManager { return rooms; } - public Room loadRoom(int id) { - return loadRoom(id, false); + public Room getRoom(int roomId) { + return getRoom(roomId, false); } - public Room loadRoom(int id, boolean loadData) { + public Room getRoom(int id, boolean loadData) { Room room = null; if (this.activeRooms.containsKey(id)) { - room = this.activeRooms.get(id); + room = this.getActiveRoomById(id); if (loadData && (room.isPreLoaded() && !room.isLoaded())) { room.loadData(); @@ -285,7 +295,7 @@ public class RoomManager { } if (room != null) { - this.activeRooms.put(room.getId(), room); + this.activeRooms.put(room.getRoomInfo().getId(), room); } } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -295,7 +305,7 @@ public class RoomManager { } - public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId, int tradeType) { + public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int maxUsers, int categoryId, int tradeType) { Room room = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( @@ -305,13 +315,13 @@ public class RoomManager { statement.setString(3, name); statement.setString(4, description); statement.setString(5, modelName); - statement.setInt(6, usersMax); + statement.setInt(6, maxUsers); statement.setInt(7, categoryId); statement.setInt(8, tradeType); statement.execute(); try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) - room = this.loadRoom(set.getInt(1)); + room = this.getRoom(set.getInt(1)); } } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -320,12 +330,9 @@ public class RoomManager { return room; } - public Room createRoomForHabbo(Habbo habbo, String name, String description, String modelName, int usersMax, int categoryId, int tradeType) { Room room = this.createRoom(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), name, description, modelName, usersMax, categoryId, tradeType); - Emulator.getPluginManager().fireEvent(new NavigatorRoomCreatedEvent(habbo, room)); - return room; } @@ -346,8 +353,12 @@ public class RoomManager { public void unloadRoomsForHabbo(Habbo habbo) { List roomsToDispose = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - if (!room.isPublicRoom() && !room.isStaffPromotedRoom() && room.getOwnerId() == habbo.getHabboInfo().getId() && room.getUserCount() == 0 && (this.roomCategories.get(room.getCategory()) == null || !this.roomCategories.get(room.getCategory()).isPublic())) { - roomsToDispose.add(room); + if (!room.getRoomInfo().isPublicRoom()) { + if (!room.getRoomInfo().isStaffPicked() && room.getRoomInfo().getOwnerInfo().getId() == habbo.getHabboInfo().getId()) { + if (room.getRoomUnitManager().getRoomHabbosCount() == 0 && (this.roomCategories.get(room.getRoomInfo().getCategory().getId()) == null || !this.roomCategories.get(room.getRoomInfo().getCategory().getId()).isPublic())) { + roomsToDispose.add(room); + } + } } } @@ -356,22 +367,24 @@ public class RoomManager { continue; room.dispose(); - this.activeRooms.remove(room.getId()); + this.activeRooms.remove(room.getRoomInfo().getId()); } } public void clearInactiveRooms() { THashSet roomsToDispose = new THashSet<>(); for (Room room : this.activeRooms.values()) { - if (!room.isPublicRoom() && !room.isStaffPromotedRoom() && !Emulator.getGameServer().getGameClientManager().containsHabbo(room.getOwnerId()) && room.isPreLoaded()) { - roomsToDispose.add(room); + if (!room.getRoomInfo().isPublicRoom()) { + if (!room.getRoomInfo().isStaffPicked() && !Emulator.getGameServer().getGameClientManager().containsHabbo(room.getRoomInfo().getOwnerInfo().getId()) && room.isPreLoaded()) { + roomsToDispose.add(room); + } } } for (Room room : roomsToDispose) { room.dispose(); - if (room.getUserCount() == 0) - this.activeRooms.remove(room.getId()); + if (room.getRoomUnitManager().getRoomHabbosCount() == 0) + this.activeRooms.remove(room.getRoomInfo().getId()); } } @@ -400,27 +413,27 @@ public class RoomManager { } public void uncacheRoom(Room room) { - this.activeRooms.remove(room.getId()); + this.activeRooms.remove(room.getRoomInfo().getId()); } public void voteForRoom(Habbo habbo, Room room) { - if (habbo.getHabboInfo().getCurrentRoom() != null && room != null && habbo.getHabboInfo().getCurrentRoom() == room) { + if (habbo.getRoomUnit().getRoom() != null && room != null && habbo.getRoomUnit().getRoom() == room) { if (this.hasVotedForRoom(habbo, room)) return; UserVoteRoomEvent event = new UserVoteRoomEvent(room, habbo); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; - room.setScore(room.getScore() + 1); + room.getRoomInfo().setScore(room.getRoomInfo().getScore() + 1); room.setNeedsUpdate(true); - habbo.getHabboStats().getVotedRooms().push(room.getId()); - for (Habbo h : room.getHabbos()) { - h.getClient().sendResponse(new RoomRatingComposer(room.getScore(), !this.hasVotedForRoom(h, room))); + habbo.getHabboStats().getVotedRooms().push(room.getRoomInfo().getId()); + for (Habbo h : room.getRoomUnitManager().getRoomHabbos()) { + h.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(h, room))); } try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_votes VALUES (?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); - statement.setInt(2, room.getId()); + statement.setInt(2, room.getRoomInfo().getId()); statement.execute(); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -429,18 +442,18 @@ public class RoomManager { } boolean hasVotedForRoom(Habbo habbo, Room room) { - if (room.getOwnerId() == habbo.getHabboInfo().getId()) + if (room.getRoomInfo().getOwnerInfo().getId() == habbo.getHabboInfo().getId()) return true; for (int i : habbo.getHabboStats().getVotedRooms().toArray()) { - if (i == room.getId()) + if (i == room.getRoomInfo().getId()) return true; } return false; } - public Room getRoom(int roomId) { + public Room getActiveRoomById(int roomId) { return this.activeRooms.get(roomId); } @@ -452,188 +465,169 @@ public class RoomManager { return this.activeRooms.size(); } - public void enterRoom(Habbo habbo, int roomId, String password) { - this.enterRoom(habbo, roomId, password, false, null); + public void enterRoom(Habbo habbo, int roomId, String password, boolean forceEnter) { + this.enterRoom(habbo, roomId, password, forceEnter, null); } - public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks) { - this.enterRoom(habbo, roomId, password, overrideChecks, null); - } + public void enterRoom(Habbo habbo, int roomId, String password, boolean forceEnter, RoomTile spawnLocation) { + Room room = this.getRoom(roomId, true); - public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks, RoomTile doorLocation) { - Room room = this.loadRoom(roomId, true); - - if (room == null) - return; - - if (habbo.getHabboInfo().getLoadingRoom() != 0 && room.getId() != habbo.getHabboInfo().getLoadingRoom()) { - habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - habbo.getHabboInfo().setLoadingRoom(0); + if (room == null) { + log.error("User (ID: {}) is trying to enter a corrupted room (ID: {})", habbo.getHabboInfo().getId(), roomId); return; } - if (Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled() - && habbo.getHabboInfo().getCurrentRoom() == null) { + if (habbo.getRoomUnit().isLoadingRoom() && room.getRoomInfo().getId() != habbo.getRoomUnit().getLoadingRoom().getRoomInfo().getId()) { habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - habbo.getHabboInfo().setLoadingRoom(0); + habbo.getRoomUnit().setLoadingRoom(null); return; } - if (room.isBanned(habbo) && !habbo.hasRight(Permission.ACC_ANYROOMOWNER) && !habbo.hasRight(Permission.ACC_ENTERANYROOM)) { + //Fire Plugin Event + if (Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled() && habbo.getRoomUnit().getRoom() == null) { + habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); + habbo.getRoomUnit().setLoadingRoom(null); + return; + } + + //If Habbo is banned AND doesn't have Permissions can't enter to room + if (room.isBanned(habbo) && !room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasRight(Permission.ACC_ENTERANYROOM)) { habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED)); return; } + //If room is full AND user doesn't have Permissions can't enter to room + if (room.getRoomUnitManager().getRoomHabbosCount() >= room.getRoomInfo().getMaxUsers() && !room.hasRights(habbo) && !habbo.hasRight(Permission.ACC_FULLROOMS)) { + habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_GUESTROOM_FULL)); + return; + } + if (habbo.getHabboInfo().getRoomQueueId() != roomId) { - Room queRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room queRoom = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (queRoom != null) { queRoom.removeFromQueue(habbo); } } - if (overrideChecks || - room.isOwner(habbo) || - room.getState() == RoomState.OPEN || - habbo.hasRight(Permission.ACC_ANYROOMOWNER) || - habbo.hasRight(Permission.ACC_ENTERANYROOM) || - room.hasRights(habbo) || - (room.getState().equals(RoomState.INVISIBLE) && room.hasRights(habbo)) || - (room.hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { - this.openRoom(habbo, room, doorLocation); - } else if (room.getState() == RoomState.LOCKED) { - boolean rightsFound = false; + /** + * If override checks open room + * If habbo is owner open room + * If room state is 'OPEN' open room + * If habbo has permissions open room + * If habbo has guild rights open room + */ + if (forceEnter || room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().getState() == RoomState.OPEN || habbo.hasRight(Permission.ACC_ENTERANYROOM) || room.hasRights(habbo) || (room.getRoomInfo().getState().equals(RoomState.INVISIBLE) && room.hasRights(habbo)) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + this.openRoom(habbo, room, spawnLocation); + } else if (room.getRoomInfo().getState() == RoomState.LOCKED) { + boolean habbosWithRights = false; - synchronized (room.roomUnitLock) { - for (Habbo current : room.getHabbos()) { - if (room.hasRights(current) || current.getHabboInfo().getId() == room.getOwnerId() || (room.hasGuild() && room.getGuildRightLevel(current).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + synchronized (room.getRoomUnitManager().roomUnitLock) { + for (Habbo current : room.getRoomUnitManager().getRoomHabbos()) { + if (room.hasRights(current) || current.getHabboInfo().getId() == room.getRoomInfo().getOwnerInfo().getId() || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(current).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { current.getClient().sendResponse(new DoorbellMessageComposer(habbo.getHabboInfo().getUsername())); - rightsFound = true; + habbosWithRights = true; } } } - if (!rightsFound) { + if (!habbosWithRights) { habbo.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - habbo.getHabboInfo().setLoadingRoom(0); + habbo.getRoomUnit().setLoadingRoom(null); return; } habbo.getHabboInfo().setRoomQueueId(roomId); habbo.getClient().sendResponse(new DoorbellMessageComposer("")); room.addToQueue(habbo); - } else if (room.getState() == RoomState.PASSWORD) { - if (room.getPassword().equalsIgnoreCase(password)) - this.openRoom(habbo, room, doorLocation); + } else if (room.getRoomInfo().getState() == RoomState.PASSWORD) { + if (room.getRoomInfo().getPassword().equalsIgnoreCase(password)) { + this.openRoom(habbo, room, spawnLocation); + } else { habbo.getClient().sendResponse(new GenericErrorComposer(GenericErrorComposer.WRONG_PASSWORD_USED)); habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - habbo.getHabboInfo().setLoadingRoom(0); + habbo.getRoomUnit().setLoadingRoom(null); } } else { habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - habbo.getHabboInfo().setLoadingRoom(0); + habbo.getRoomUnit().setLoadingRoom(null); } } - void openRoom(Habbo habbo, Room room, RoomTile doorLocation) { - if (room == null || room.getLayout() == null) + void openRoom(Habbo habbo, Room room, RoomTile spawnLocation) { + if (room.getLayout() == null) { return; + } if (Emulator.getConfig().getBoolean("hotel.room.enter.logs")) { this.logEnter(habbo, room); } if (habbo.getHabboInfo().getRoomQueueId() > 0) { - Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(habbo.getHabboInfo().getRoomQueueId()); + Room queuedRoom = this.getActiveRoomById(habbo.getHabboInfo().getRoomQueueId()); - if (r != null) { - r.removeFromQueue(habbo); + if (queuedRoom != null) { + queuedRoom.removeFromQueue(habbo); } } habbo.getHabboInfo().setRoomQueueId(0); habbo.getClient().sendResponse(new FlatAccessibleMessageComposer("")); - if (habbo.getRoomUnit() != null) { - RoomUnit existingRoom = habbo.getRoomUnit(); - if (existingRoom.getRoom() != null) { - if (existingRoom.getCurrentLocation() != null) - existingRoom.getCurrentLocation().removeUnit(existingRoom); - existingRoom.getRoom().sendComposer(new UserRemoveMessageComposer(existingRoom).compose()); - } - habbo.getRoomUnit().setRoom(null); - } + RoomHabbo roomHabbo = habbo.getRoomUnit(); - habbo.setRoomUnit(new RoomUnit()); + roomHabbo.clear(); + roomHabbo.clearWalking(); - habbo.getRoomUnit().clearStatus(); - if (habbo.getRoomUnit().getCurrentLocation() == null) { - habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile()); - if (habbo.getRoomUnit().getCurrentLocation() != null) - habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); + if (roomHabbo.getCurrentPosition() == null) { + RoomTile spawnTile = spawnLocation == null ? room.getLayout().getDoorTile() : spawnLocation; + RoomRotation spawnDirection = RoomRotation.values()[room.getLayout().getDoorDirection()]; - if (doorLocation == null) { - habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); - habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); - } else { - habbo.getRoomUnit().setCanLeaveRoomByDoor(false); - habbo.getRoomUnit().setTeleporting(true); - HabboItem topItem = room.getTopItemAt(doorLocation.getX(), doorLocation.getY()); - if (topItem != null) { - habbo.getRoomUnit().setRotation(RoomUserRotation.values()[topItem.getRotation()]); + if(spawnLocation != null) { + roomHabbo.setCanLeaveRoomByDoor(false); + roomHabbo.setTeleporting(true); + RoomItem topItem = room.getTopItemAt(spawnLocation); + + if(topItem != null) { + spawnDirection = RoomRotation.values()[topItem.getRotation()]; } } - } - habbo.getRoomUnit().setRoomUnitType(RoomUnitType.USER); - if (room.isBanned(habbo)) { - habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED)); - return; + this.handleSpawnLocation(roomHabbo, spawnTile, spawnDirection); } - if (room.getUserCount() >= room.getUsersMax() && !habbo.hasRight(Permission.ACC_FULLROOMS) && !room.hasRights(habbo)) { - habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_GUESTROOM_FULL)); - return; - } - - habbo.getRoomUnit().clearStatus(); - habbo.getRoomUnit().setCmdTeleport(false); - habbo.getClient().sendResponse(new OpenConnectionMessageComposer()); - habbo.getRoomUnit().setInRoom(true); - if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo, true); - } else if (!habbo.getHabboStats().isBlockFollowing() && habbo.getHabboInfo().getCurrentRoom() == null) { + roomHabbo.setInRoom(true); + + if (!habbo.getHabboStats().isBlockFollowing() && roomHabbo.getRoom() == null) { habbo.getMessenger().connectionChanged(habbo, true, true); } - if (habbo.getHabboInfo().getLoadingRoom() != 0) { - Room oldRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(habbo.getHabboInfo().getLoadingRoom()); - if (oldRoom != null) { - oldRoom.removeFromQueue(habbo); - } + if (roomHabbo.isLoadingRoom()) { + roomHabbo.getLoadingRoom().removeFromQueue(habbo); + roomHabbo.setLoadingRoom(null); } - habbo.getHabboInfo().setLoadingRoom(room.getId()); + roomHabbo.setLoadingRoom(room); habbo.getClient().sendResponse(new RoomReadyMessageComposer(room)); - if (!room.getWallPaint().equals("0.0")) - habbo.getClient().sendResponse(new RoomPropertyMessageComposer("wallpaper", room.getWallPaint())); + if (!room.getRoomInfo().getWallPaint().equals("0.0")) + habbo.getClient().sendResponse(new RoomPropertyMessageComposer("wallpaper", room.getRoomInfo().getWallPaint())); - if (!room.getFloorPaint().equals("0.0")) - habbo.getClient().sendResponse(new RoomPropertyMessageComposer("floor", room.getFloorPaint())); + if (!room.getRoomInfo().getFloorPaint().equals("0.0")) + habbo.getClient().sendResponse(new RoomPropertyMessageComposer("floor", room.getRoomInfo().getFloorPaint())); - habbo.getClient().sendResponse(new RoomPropertyMessageComposer("landscape", room.getBackgroundPaint())); + habbo.getClient().sendResponse(new RoomPropertyMessageComposer("landscape", room.getRoomInfo().getLandscapePaint())); room.refreshRightsForHabbo(habbo); - habbo.getClient().sendResponse(new RoomRatingComposer(room.getScore(), !this.hasVotedForRoom(habbo, room))); + habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room))); - habbo.getRoomUnit().setFastWalk(habbo.getRoomUnit().isFastWalk() && habbo.hasCommand("cmd_fastwalk", room.hasRights(habbo))); + roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.hasCommand("cmd_fastwalk", room.hasRights(habbo))); if (room.isPromoted()) { habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion())); @@ -641,62 +635,60 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomEventComposer(null, null)); } - if (room.getOwnerId() != habbo.getHabboInfo().getId() && !habbo.getHabboStats().visitedRoom(room.getId())) { - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); + if (!room.getRoomInfo().isRoomOwner(habbo)) { + if (!habbo.getHabboStats().visitedRoom(room.getRoomInfo().getId())) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); + } } } public void enterRoom(final Habbo habbo, final Room room) { - if (habbo.getHabboInfo().getLoadingRoom() != room.getId()) { - if (habbo.getHabboInfo().getLoadingRoom() != 0) { - habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); - } + if (habbo.getRoomUnit().isLoadingRoom() && room.getRoomInfo().getId() != habbo.getRoomUnit().getLoadingRoom().getRoomInfo().getId()) { + habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); + habbo.getRoomUnit().setLoadingRoom(null); return; } - habbo.getRoomUnit() - .removeStatus(RoomUnitStatus.FLAT_CONTROL) - .setPathFinderRoom(room) - .setHandItem(0) - .setRightsLevel(RoomRightLevels.NONE); + RoomHabbo roomHabbo = habbo.getRoomUnit(); - habbo.getHabboInfo().setLoadingRoom(0) - .setCurrentRoom(room); + roomHabbo.removeStatus(RoomUnitStatus.FLAT_CONTROL); + roomHabbo.setHandItem(0); + roomHabbo.setRightsLevel(RoomRightLevels.NONE); + roomHabbo.setRoom(room); + roomHabbo.setLoadingRoom(null); room.refreshRightsForHabbo(habbo); - if (habbo.getRoomUnit().isKicked() && !habbo.getRoomUnit().canWalk()) { + + if (habbo.getRoomUnit().isKicked() && !habbo.getRoomUnit().isCanWalk()) { habbo.getRoomUnit().setCanWalk(true); } - habbo.getRoomUnit().setKicked(false); - if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting()) { - RoomTile doorTile = room.getLayout().getTile(room.getLayout().getDoorX(), room.getLayout().getDoorY()); + roomHabbo.setKicked(false); + + if (roomHabbo.getCurrentPosition() == null && !habbo.getRoomUnit().isTeleporting()) { + RoomTile doorTile = room.getLayout().getDoorTile(); + RoomRotation doorDirection = RoomRotation.values()[room.getLayout().getDoorDirection()]; if (doorTile != null) { - habbo.getRoomUnit().setLocation(doorTile); - habbo.getRoomUnit().setZ(doorTile.getStackHeight()); + this.handleSpawnLocation(roomHabbo, doorTile, doorDirection); } - - habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); - habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); } - habbo.getRoomUnit().setPathFinderRoom(room); - habbo.getRoomUnit().resetIdleTimer(); + roomHabbo.resetIdleTimer(); + roomHabbo.setInvisible(false); - habbo.getRoomUnit().setInvisible(false); - room.addHabbo(habbo); + room.getRoomUnitManager().addRoomUnit(habbo); - List habbos = new ArrayList<>(); - if (!room.getCurrentHabbos().isEmpty()) { + List visibleHabbos = new ArrayList<>(); - Collection habbosToSendEnter = room.getCurrentHabbos().values(); - Collection visibleHabbos = room.getHabbos(); + if (!room.getRoomUnitManager().getCurrentRoomHabbos().isEmpty()) { + Collection habbosToSendEnter = room.getRoomUnitManager().getRoomHabbos(); + Collection allHabbos = room.getRoomUnitManager().getRoomHabbos(); if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { - HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, visibleHabbos)); + HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, allHabbos)); habbosToSendEnter = event.getHabbosToSendEnter(); - visibleHabbos = event.getVisibleHabbos(); + allHabbos = event.getVisibleHabbos(); } habbosToSendEnter.stream().map(Habbo::getClient).filter(Objects::nonNull).forEach(client -> { @@ -704,11 +696,11 @@ public class RoomManager { client.sendResponse(new UserUpdateComposer(habbo.getRoomUnit()).compose()); }); - habbos = visibleHabbos.stream().filter(h -> !h.getRoomUnit().isInvisible()).toList(); + visibleHabbos = allHabbos.stream().filter(h -> !h.getRoomUnit().isInvisible()).toList(); - synchronized (room.roomUnitLock) { - habbo.getClient().sendResponse(new RoomUsersComposer(habbos)); - habbo.getClient().sendResponse(new UserUpdateComposer(habbos)); + synchronized (room.getRoomUnitManager().roomUnitLock) { + habbo.getClient().sendResponse(new RoomUsersComposer(visibleHabbos)); + habbo.getClient().sendResponse(new UserUpdateComposer(visibleHabbos)); } if (habbo.getHabboStats().getGuild() != 0) { @@ -724,23 +716,26 @@ public class RoomManager { } - habbo.getClient().sendResponse(new RoomUsersComposer(room.getCurrentBots().valueCollection(), true)); - if (!room.getCurrentBots().isEmpty()) { - room.getCurrentBots().valueCollection().stream() + habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentRoomBots().values(), true)); + + if (!room.getRoomUnitManager().getCurrentRoomBots().isEmpty()) { + room.getRoomUnitManager().getCurrentRoomBots().values().stream() .filter(b -> !b.getRoomUnit().getDanceType().equals(DanceType.NONE)) .forEach(b -> habbo.getClient().sendResponse(new DanceMessageComposer(b.getRoomUnit()))); - room.getCurrentBots().valueCollection() - .forEach(b -> habbo.getClient().sendResponse(new UserUpdateComposer(b.getRoomUnit(), b.getRoomUnit().getZ()))); + room.getRoomUnitManager().getCurrentRoomBots().values() + .forEach(b -> habbo.getClient().sendResponse(new UserUpdateComposer(b.getRoomUnit(), b.getRoomUnit().getCurrentZ()))); } - habbo.getClient().sendResponse(new RoomEntryInfoMessageComposer(room, room.isOwner(habbo))); + habbo.getClient().sendResponse(new RoomEntryInfoMessageComposer(room, room.getRoomInfo().isRoomOwner(habbo))); habbo.getClient().sendResponse(new RoomVisualizationSettingsComposer(room)); habbo.getClient().sendResponse(new GetGuestRoomResultComposer(room, habbo.getClient().getHabbo(), false, true)); - habbo.getClient().sendResponse(new ItemsComposer(room)); - final THashSet floorItems = new THashSet<>(); - THashSet allFloorItems = new THashSet<>(room.getFloorItems()); + habbo.getClient().sendResponse(new ItemsComposer(room)); + + final THashSet floorItems = new THashSet<>(); + + THashSet allFloorItems = new THashSet<>(room.getFloorItems()); if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) { RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems)); @@ -750,7 +745,7 @@ public class RoomManager { } allFloorItems.forEach(object -> { - if (room.isHideWired() && object instanceof InteractionWired) + if (room.getRoomInfo().isHiddenWiredEnabled() && object instanceof InteractionWired) return true; floorItems.add(object); @@ -765,9 +760,9 @@ public class RoomManager { habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); floorItems.clear(); - if (!room.getCurrentPets().isEmpty()) { - habbo.getClient().sendResponse(new RoomPetComposer(room.getCurrentPets())); - room.getCurrentPets().valueCollection().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); + if (!room.getRoomUnitManager().getCurrentRoomPets().isEmpty()) { + habbo.getClient().sendResponse(new RoomPetComposer(room.getRoomUnitManager().getCurrentRoomPets())); + room.getRoomUnitManager().getCurrentRoomPets().values().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); } if (!habbo.getHabboStats().allowTalk()) { @@ -781,45 +776,45 @@ public class RoomManager { } THashMap guildBadges = new THashMap<>(); - for (Habbo roomHabbo : habbos) { - if (roomHabbo.getRoomUnit().getDanceType().getType() > 0) { - habbo.getClient().sendResponse(new DanceMessageComposer(roomHabbo.getRoomUnit())); + for (Habbo visibleHabbo : visibleHabbos) { + if (visibleHabbo.getRoomUnit().getDanceType().getType() > 0) { + habbo.getClient().sendResponse(new DanceMessageComposer(visibleHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().getHandItem() > 0) { - habbo.getClient().sendResponse(new CarryObjectMessageComposer(roomHabbo.getRoomUnit())); + if (visibleHabbo.getRoomUnit().getHandItem() > 0) { + habbo.getClient().sendResponse(new CarryObjectMessageComposer(visibleHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().getEffectId() > 0) { - habbo.getClient().sendResponse(new AvatarEffectMessageComposer(roomHabbo.getRoomUnit())); + if (visibleHabbo.getRoomUnit().getEffectId() > 0) { + habbo.getClient().sendResponse(new AvatarEffectMessageComposer(visibleHabbo.getRoomUnit())); } - if (roomHabbo.getRoomUnit().isIdle()) { - habbo.getClient().sendResponse(new SleepMessageComposer(roomHabbo.getRoomUnit())); + if (visibleHabbo.getRoomUnit().isIdle()) { + habbo.getClient().sendResponse(new SleepMessageComposer(visibleHabbo.getRoomUnit())); } - if (roomHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - roomHabbo.getClient().sendResponse(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.IGNORED)); + if (visibleHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + visibleHabbo.getClient().sendResponse(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.IGNORED)); } - if (!roomHabbo.getHabboStats().allowTalk()) { - habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.MUTED)); - } else if (habbo.getHabboStats().userIgnored(roomHabbo.getHabboInfo().getId())) { - habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.IGNORED)); + if (!visibleHabbo.getHabboStats().allowTalk()) { + habbo.getClient().sendResponse(new IgnoreResultMessageComposer(visibleHabbo, IgnoreResultMessageComposer.MUTED)); + } else if (habbo.getHabboStats().userIgnored(visibleHabbo.getHabboInfo().getId())) { + habbo.getClient().sendResponse(new IgnoreResultMessageComposer(visibleHabbo, IgnoreResultMessageComposer.IGNORED)); } - if (roomHabbo.getHabboStats().getGuild() != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().getGuild())) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().getGuild()); + if (visibleHabbo.getHabboStats().getGuild() != 0 && !guildBadges.containsKey(visibleHabbo.getHabboStats().getGuild())) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(visibleHabbo.getHabboStats().getGuild()); if (guild != null) { - guildBadges.put(roomHabbo.getHabboStats().getGuild(), guild.getBadge()); + guildBadges.put(visibleHabbo.getHabboStats().getGuild(), guild.getBadge()); } } - if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) { + if (visibleHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) { try { - habbo.getClient().sendResponse(new UserRemoveMessageComposer(roomHabbo.getRoomUnit())); - habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) roomHabbo.getHabboStats().getCache().get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().getCache().get("pet_race"), (String) roomHabbo.getHabboStats().getCache().get("pet_color"), roomHabbo)); + habbo.getClient().sendResponse(new UserRemoveMessageComposer(visibleHabbo.getRoomUnit())); + habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) visibleHabbo.getHabboStats().getCache().get("pet_type")).getType(), (Integer) visibleHabbo.getHabboStats().getCache().get("pet_race"), (String) visibleHabbo.getHabboStats().getCache().get("pet_color"), visibleHabbo)); } catch (Exception ignored) { } @@ -829,7 +824,7 @@ public class RoomManager { habbo.getClient().sendResponse(new HabboGroupBadgesMessageComposer(guildBadges)); if ((room.hasRights(habbo) - || (room.hasGuild() + || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) && !room.getHabboQueue().isEmpty()) { for (Habbo waiting : room.getHabboQueue().valueCollection()) { @@ -837,11 +832,13 @@ public class RoomManager { } } - if (room.getPollId() > 0 && !PollManager.donePoll(habbo.getClient().getHabbo(), room.getPollId())) { - Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(room.getPollId()); + if (room.getRoomInfo().getPollId() > 0) { + if (!PollManager.donePoll(habbo.getClient().getHabbo(), room.getRoomInfo().getPollId())) { + Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(room.getRoomInfo().getPollId()); - if (poll != null) { - habbo.getClient().sendResponse(new PollOfferComposer(poll)); + if (poll != null) { + habbo.getClient().sendResponse(new PollOfferComposer(poll)); + } } } @@ -856,21 +853,23 @@ public class RoomManager { WiredHandler.handle(WiredTriggerType.ENTER_ROOM, habbo.getRoomUnit(), room, null); room.habboEntered(habbo); - if (!habbo.getHabboStats().isNux() && (room.isOwner(habbo) || room.isPublicRoom())) { - NewUserExperienceScriptProceedEvent.handle(habbo); + if (!habbo.getHabboStats().isNux()) { + if (room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().isPublicRoom()) { + NewUserExperienceScriptProceedEvent.handle(habbo); + } } } void logEnter(Habbo habbo, Room room) { habbo.getHabboStats().roomEnterTimestamp = Emulator.getIntUnixTimestamp(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_enter_log (room_id, user_id, timestamp) VALUES(?, ?, ?)")) { - statement.setInt(1, room.getId()); + statement.setInt(1, room.getRoomInfo().getId()); statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, (int) (habbo.getHabboStats().getRoomEnterTimestamp())); statement.execute(); - if (!habbo.getHabboStats().visitedRoom(room.getId())) - habbo.getHabboStats().addVisitRoom(room.getId()); + if (!habbo.getHabboStats().visitedRoom(room.getRoomInfo().getId())) + habbo.getHabboStats().addVisitRoom(room.getRoomInfo().getId()); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); } @@ -881,20 +880,20 @@ public class RoomManager { } public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) { - if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) { - habbo.getRoomUnit().setPathFinderRoom(null); - + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) { this.logExit(habbo); - room.removeHabbo(habbo, true); + + room.getRoomUnitManager().removeHabbo(habbo, true); if (redirectToHotelView) { habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); } - habbo.getHabboInfo().setCurrentRoom(null); - habbo.getRoomUnit().setKicked(false); - if (room.getOwnerId() != habbo.getHabboInfo().getId()) { - AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0)); + habbo.getRoomUnit().setPreviousRoom(room); + habbo.getRoomUnit().setRoom(null); + + if (room.getRoomInfo().getOwnerInfo().getId() != habbo.getHabboInfo().getId()) { + AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0)); } habbo.getMessenger().connectionChanged(habbo, habbo.isOnline(), false); @@ -910,19 +909,19 @@ public class RoomManager { if (habbo.getHabboInfo().getRiding() != null) { if (habbo.getHabboInfo().getRiding().getRoomUnit() != null) { - habbo.getHabboInfo().getRiding().getRoomUnit().setGoalLocation(habbo.getHabboInfo().getRiding().getRoomUnit().getCurrentLocation()); + habbo.getHabboInfo().getRiding().getRoomUnit().setGoalLocation(habbo.getHabboInfo().getRiding().getRoomUnit().getCurrentPosition()); } habbo.getHabboInfo().getRiding().setTask(PetTasks.FREE); habbo.getHabboInfo().getRiding().setRider(null); habbo.getHabboInfo().setRiding(null); } - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room != null) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_enter_log SET exit_timestamp = ? WHERE user_id = ? AND room_id = ? ORDER BY timestamp DESC LIMIT 1")) { statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.setInt(2, habbo.getHabboInfo().getId()); - statement.setInt(3, room.getId()); + statement.setInt(3, room.getRoomInfo().getId()); statement.execute(); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); @@ -934,7 +933,7 @@ public class RoomManager { Map tagCount = new HashMap<>(); for (Room room : this.activeRooms.values()) { - for (String s : room.getTags().split(";")) { + for (String s : room.getRoomInfo().getTags().split(";")) { int i = 0; if (tagCount.get(s) != null) i++; @@ -946,12 +945,12 @@ public class RoomManager { } public ArrayList getPublicRooms() { - return this.activeRooms.values().stream().filter(Room::isPublicRoom).sorted(Room.SORT_ID) .collect(Collectors.toCollection(ArrayList::new)); + return this.activeRooms.values().stream().filter(room -> room.getRoomInfo().isPublicRoom()).sorted(Room.SORT_ID) .collect(Collectors.toCollection(ArrayList::new)); } public ArrayList getPopularRooms(int count) { return this.activeRooms.values().stream() - .filter(room -> room.getUserCount() > 0 && (!room.isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB)) + .filter(room -> room.getRoomUnitManager().getRoomHabbosCount() > 0 && (!room.getRoomInfo().isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB)) .sorted() .limit(count) .collect(Collectors.toCollection(ArrayList::new)); @@ -959,7 +958,7 @@ public class RoomManager { public List getPopularRooms(int count, int category) { return this.activeRooms.values().stream() - .filter(room -> !room.isPublicRoom() && room.getCategory() == category) + .filter(room -> !room.getRoomInfo().isPublicRoom() && room.getRoomInfo().getCategory().getId() == category) .sorted() .limit(count) .toList(); @@ -969,12 +968,12 @@ public class RoomManager { Map> rooms = new HashMap<>(); for (Room room : this.activeRooms.values()) { - if (!room.isPublicRoom()) { - if (!rooms.containsKey(room.getCategory())) { - rooms.put(room.getCategory(), new ArrayList<>()); + if (!room.getRoomInfo().isPublicRoom()) { + if (!rooms.containsKey(room.getRoomInfo().getCategory().getId())) { + rooms.put(room.getRoomInfo().getCategory().getId(), new ArrayList<>()); } - rooms.get(room.getCategory()).add(room); + rooms.get(room.getRoomInfo().getCategory().getId()).add(room); } } @@ -993,7 +992,7 @@ public class RoomManager { } public List getRoomsWithName(String name) { - List rooms = new ArrayList<>(activeRooms.values().stream().filter(room -> room.getName().equalsIgnoreCase(name)).toList()); + List rooms = new ArrayList<>(activeRooms.values().stream().filter(room -> room.getRoomInfo().getName().equalsIgnoreCase(name)).toList()); if (rooms.size() < 25) { rooms.addAll(this.getOfflineRoomsWithName(name)); @@ -1016,7 +1015,7 @@ public class RoomManager { Room r = new Room(set); rooms.add(r); - this.activeRooms.put(r.getId(), r); + this.activeRooms.put(r.getRoomInfo().getId(), r); } } } catch (SQLException e) { @@ -1030,7 +1029,7 @@ public class RoomManager { ArrayList rooms = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - for (String s : room.getTags().split(";")) { + for (String s : room.getRoomInfo().getTags().split(";")) { if (s.equalsIgnoreCase(tag)) { rooms.add(room); break; @@ -1047,10 +1046,10 @@ public class RoomManager { ArrayList rooms = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - if (room.getGuildId() == 0) + if (room.getRoomInfo().getGuild().getId() == 0) continue; - if (room.getName().toLowerCase().contains(name.toLowerCase())) + if (room.getRoomInfo().getName().toLowerCase().contains(name.toLowerCase())) rooms.add(room); } @@ -1076,7 +1075,7 @@ public class RoomManager { Room r = new Room(set); rooms.add(r); - this.activeRooms.put(r.getId(), r); + this.activeRooms.put(r.getRoomInfo().getId(), r); } } } catch (SQLException e) { @@ -1094,10 +1093,10 @@ public class RoomManager { continue; Habbo friend = Emulator.getGameEnvironment().getHabboManager().getHabbo(buddy.getId()); - if (friend == null || friend.getHabboInfo().getCurrentRoom() == null) + if (friend == null || friend.getRoomUnit().getRoom() == null) continue; - rooms.add(friend.getHabboInfo().getCurrentRoom()); + rooms.add(friend.getRoomUnit().getRoom()); } Collections.sort(rooms); @@ -1139,7 +1138,7 @@ public class RoomManager { if (room == null) { room = new Room(set); - this.activeRooms.put(room.getId(), room); + this.activeRooms.put(room.getRoomInfo().getId(), room); } rooms.add(room); @@ -1158,10 +1157,10 @@ public class RoomManager { final ArrayList rooms = new ArrayList<>(); habbo.getHabboStats().getFavoriteRooms().forEach(value -> { - Room room = RoomManager.this.getRoom(value); + Room room = RoomManager.this.getActiveRoomById(value); if (room != null) { - if (room.getState() == RoomState.INVISIBLE) { + if (room.getRoomInfo().getState() == RoomState.INVISIBLE) { room.loadData(); if (!room.hasRights(habbo)) return true; } @@ -1226,7 +1225,7 @@ public class RoomManager { if (friend == null || friend.getHabboInfo() == null) continue; - Room room = friend.getHabboInfo().getCurrentRoom(); + Room room = friend.getRoomUnit().getRoom(); if (room != null && !rooms.contains(room) && room.hasRights(habbo)) rooms.add(room); if (rooms.size() >= limit) break; @@ -1290,29 +1289,29 @@ public class RoomManager { return activeRooms.values().stream().filter(Room::isPromoted).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList getRoomsStaffPromoted() { - return activeRooms.values().stream().filter(Room::isStaffPromotedRoom).collect(Collectors.toCollection(ArrayList::new)); + return activeRooms.values().stream().filter(room -> room.getRoomInfo().isStaffPicked()).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList filterRoomsByOwner(List rooms, String filter) { - return rooms.stream().filter(r -> r.getOwnerName().equalsIgnoreCase(filter)).collect(Collectors.toCollection(ArrayList::new)); + return rooms.stream().filter(r -> r.getRoomInfo().getOwnerInfo().getUsername().equalsIgnoreCase(filter)).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList filterRoomsByName(List rooms, String filter) { - return rooms.stream().filter(room -> room.getName().toLowerCase().contains(filter.toLowerCase())).collect(Collectors.toCollection(ArrayList::new)); + return rooms.stream().filter(room -> room.getRoomInfo().getName().toLowerCase().contains(filter.toLowerCase())).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList filterRoomsByNameAndDescription(List rooms, String filter) { - return rooms.stream().filter(room -> room.getName().toLowerCase().contains(filter.toLowerCase()) || room.getDescription().toLowerCase().contains(filter.toLowerCase())).collect(Collectors.toCollection(ArrayList::new)); + return rooms.stream().filter(room -> room.getRoomInfo().getName().toLowerCase().contains(filter.toLowerCase()) || room.getRoomInfo().getDescription().toLowerCase().contains(filter.toLowerCase())).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList filterRoomsByTag(List rooms, String filter) { ArrayList r = new ArrayList<>(); for (Room room : rooms) { - if (room.getTags().split(";").length == 0) + if (room.getRoomInfo().getTags().split(";").length == 0) continue; - for (String s : room.getTags().split(";")) { + for (String s : room.getRoomInfo().getTags().split(";")) { if (s.equalsIgnoreCase(filter)) r.add(room); } @@ -1322,8 +1321,8 @@ public class RoomManager { } public ArrayList filterRoomsByGroup(List rooms, String filter) { - return rooms.stream().filter(room -> room.getGuildId() != 0) - .filter(room -> Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()).getName().toLowerCase().contains(filter.toLowerCase())) + return rooms.stream().filter(room -> room.getRoomInfo().getGuild().getId() != 0) + .filter(room -> Emulator.getGameEnvironment().getGuildManager().getGuild(room.getRoomInfo().getGuild().getId()).getName().toLowerCase().contains(filter.toLowerCase())) .collect(Collectors.toCollection(ArrayList::new)); } @@ -1339,8 +1338,8 @@ public class RoomManager { public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE door_x = ?, door_y = ?, door_dir = ?, heightmap = ?")) { - statement.setInt(1, room.getId()); - statement.setString(2, "custom_" + room.getId()); + statement.setInt(1, room.getRoomInfo().getId()); + statement.setString(2, "custom_" + room.getRoomInfo().getId()); statement.setInt(3, doorX); statement.setInt(4, doorY); statement.setInt(5, doorDirection); @@ -1358,7 +1357,7 @@ public class RoomManager { } public void banUserFromRoom(Habbo rights, int userId, int roomId, RoomBanTypes length) { - Room room = this.getRoom(roomId); + Room room = this.getActiveRoomById(roomId); if (room == null) return; @@ -1395,12 +1394,18 @@ public class RoomManager { room.addRoomBan(roomBan); - if (habbo != null && habbo.getHabboInfo().getCurrentRoom() == room) { - room.removeHabbo(habbo, true); + if (habbo != null && habbo.getRoomUnit().getRoom() == room) { + room.getRoomUnitManager().removeHabbo(habbo, true); habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED)); } } + public void handleSpawnLocation(RoomHabbo roomHabbo, RoomTile location, RoomRotation direction) { + roomHabbo.setLocation(location); + roomHabbo.setCurrentZ(location.getStackHeight()); + roomHabbo.setRotation(direction); + } + public void registerGameType(Class gameClass) { gameTypes.add(gameClass); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index e8bc4f23..02933c3e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -50,7 +50,7 @@ public class RoomPromotion { statement.setString(1, this.title); statement.setString(2, this.description); statement.setInt(3, this.category); - statement.setInt(4, this.room.getId()); + statement.setInt(4, this.room.getRoomInfo().getId()); statement.executeUpdate(); } catch (SQLException e) { log.error("Caught SQL exception", e); 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 c6bd6345..2697254d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -19,7 +19,7 @@ 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.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -48,7 +48,7 @@ public class RoomSpecialTypes { private final THashMap gameTimers; private final THashMap freezeExitTile; - private final THashMap undefined; + private final THashMap undefined; private final THashSet cycleTasks; public RoomSpecialTypes() { @@ -652,22 +652,22 @@ public class RoomSpecialTypes { return !this.freezeExitTile.isEmpty(); } - public void addUndefined(HabboItem item) { + public void addUndefined(RoomItem item) { synchronized (this.undefined) { this.undefined.put(item.getId(), item); } } - public void removeUndefined(HabboItem item) { + public void removeUndefined(RoomItem item) { synchronized (this.undefined) { this.undefined.remove(item.getId()); } } - public THashSet getItemsOfType(Class type) { - THashSet items = new THashSet<>(); + public THashSet getItemsOfType(Class type) { + THashSet items = new THashSet<>(); synchronized (this.undefined) { - for (HabboItem item : this.undefined.values()) { + for (RoomItem item : this.undefined.values()) { if (item.getClass() == type) items.add(item); } @@ -676,10 +676,10 @@ public class RoomSpecialTypes { return items; } - public HabboItem getLowestItemsOfType(Class type) { - HabboItem i = null; + public RoomItem getLowestItemsOfType(Class type) { + RoomItem i = null; synchronized (this.undefined) { - for (HabboItem item : this.undefined.values()) { + for (RoomItem item : this.undefined.values()) { if (i == null || item.getZ() < i.getZ()) { if (item.getClass().isAssignableFrom(type)) { i = item; @@ -724,7 +724,7 @@ public class RoomSpecialTypes { } public Rectangle tentAt(RoomTile location) { - for (HabboItem item : this.getItemsOfType(InteractionTent.class)) { + for (RoomItem item : this.getItemsOfType(InteractionTent.class)) { Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); if (RoomLayout.tileInSquare(rectangle, location)) { return rectangle; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index cea73922..f333c89c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -1,11 +1,13 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.items.Item; -import gnu.trove.set.hash.THashSet; +import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; public class RoomTile { @@ -15,7 +17,7 @@ public class RoomTile { private final short y; @Getter private final short z; - private final THashSet units; + private final HashSet units; @Setter @Getter private RoomTileState state; @@ -37,7 +39,7 @@ public class RoomTile { this.stackHeight = z; this.state = state; this.setAllowStack(allowStack); - this.units = new THashSet<>(); + this.units = new HashSet<>(); } public RoomTile(RoomTile tile) { @@ -173,23 +175,23 @@ public class RoomTile { return this.x == x && this.y == y; } - public List getUnits() { + public List getEntities() { synchronized (this.units) { return new ArrayList<>(this.units); } } - public void addUnit(RoomUnit unit) { + public void addUnit(RoomEntity entity) { synchronized (this.units) { - if (!this.units.contains(unit)) { - this.units.add(unit); + if (!this.units.contains(entity)) { + this.units.add(entity); } } } - public void removeUnit(RoomUnit unit) { + public void removeUnit(RoomEntity entity) { synchronized (this.units) { - this.units.remove(unit); + this.units.remove(entity); } } @@ -200,6 +202,9 @@ public class RoomTile { } public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) { - return (unit.getX() >= this.x && unit.getX() < this.x + item.getLength()) && (unit.getY() >= this.y && unit.getY() < this.y + item.getWidth()); + if ((unit.getCurrentPosition().getX() < this.x || unit.getCurrentPosition().getX() >= this.x + item.getLength())) + return false; + if (unit.getCurrentPosition().getY() < this.y) return false; + return unit.getCurrentPosition().getY() < this.y + item.getWidth(); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index a6231fa3..5ee43e00 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -54,7 +54,7 @@ public class RoomTrade { this.sendMessageToUsers(new TradingOpenComposer(this)); } - public void offerItem(Habbo habbo, HabboItem item) { + public void offerItem(Habbo habbo, RoomItem item) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); if (user.getItems().contains(item)) @@ -67,10 +67,10 @@ public class RoomTrade { this.updateWindow(); } - public void offerMultipleItems(Habbo habbo, THashSet items) { + public void offerMultipleItems(Habbo habbo, THashSet items) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); - for (HabboItem item : items) { + for (RoomItem item : items) { if (!user.getItems().contains(item)) { habbo.getInventory().getItemsComponent().removeHabboItem(item); user.getItems().add(item); @@ -81,7 +81,7 @@ public class RoomTrade { this.updateWindow(); } - public void removeItem(Habbo habbo, HabboItem item) { + public void removeItem(Habbo habbo, RoomItem item) { RoomTradeUser user = this.getRoomTradeUserForHabbo(habbo); if (!user.getItems().contains(item)) @@ -137,9 +137,9 @@ public class RoomTrade { boolean tradeItems() { for (RoomTradeUser roomTradeUser : this.users) { - for (HabboItem item : roomTradeUser.getItems()) { + for (RoomItem item : roomTradeUser.getItems()) { if (roomTradeUser.getHabbo().getInventory().getItemsComponent().getHabboItem(item.getId()) != null) { - this.sendMessageToUsers(new TradingCloseComposer(roomTradeUser.getHabbo().getRoomUnit().getId(), TradingCloseComposer.ITEMS_NOT_FOUND)); + this.sendMessageToUsers(new TradingCloseComposer(roomTradeUser.getHabbo().getRoomUnit().getVirtualId(), TradingCloseComposer.ITEMS_NOT_FOUND)); return false; } } @@ -182,7 +182,7 @@ public class RoomTrade { try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) { try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO room_trade_log_items (id, item_id, user_id) VALUES (?, ?, ?)")) { - for (HabboItem item : userOne.getItems()) { + for (RoomItem item : userOne.getItems()) { item.setUserId(userTwoId); statement.setInt(1, userTwoId); statement.setInt(2, item.getId()); @@ -196,7 +196,7 @@ public class RoomTrade { } } - for (HabboItem item : userTwo.getItems()) { + for (RoomItem item : userTwo.getItems()) { item.setUserId(userOneId); statement.setInt(1, userOneId); statement.setInt(2, item.getId()); @@ -221,15 +221,15 @@ public class RoomTrade { log.error("Caught SQL exception", e); } - THashSet itemsUserOne = new THashSet<>(userOne.getItems()); - THashSet itemsUserTwo = new THashSet<>(userTwo.getItems()); + THashSet itemsUserOne = new THashSet<>(userOne.getItems()); + THashSet itemsUserTwo = new THashSet<>(userTwo.getItems()); userOne.clearItems(); userTwo.clearItems(); int creditsForUserTwo = 0; - THashSet creditFurniUserOne = new THashSet<>(); - for (HabboItem item : itemsUserOne) { + THashSet creditFurniUserOne = new THashSet<>(); + for (RoomItem item : itemsUserOne) { int worth = RoomTrade.getCreditsByItem(item); if (worth > 0) { creditsForUserTwo += worth; @@ -240,8 +240,8 @@ public class RoomTrade { itemsUserOne.removeAll(creditFurniUserOne); int creditsForUserOne = 0; - THashSet creditFurniUserTwo = new THashSet<>(); - for (HabboItem item : itemsUserTwo) { + THashSet creditFurniUserTwo = new THashSet<>(); + for (RoomItem item : itemsUserTwo) { int worth = RoomTrade.getCreditsByItem(item); if (worth > 0) { creditsForUserOne += worth; @@ -328,7 +328,7 @@ public class RoomTrade { return this.users; } - public static int getCreditsByItem(HabboItem item) { + public static int getCreditsByItem(RoomItem item) { if (!Emulator.getConfig().getBoolean("redeem.currency.trade")) return 0; if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java index 5fb7f103..309b3087 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java @@ -1,7 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; @@ -9,7 +9,7 @@ import lombok.Setter; public class RoomTradeUser { @Getter private final Habbo habbo; - private final THashSet items; + private final THashSet items; @Setter @Getter private int userId; @@ -35,12 +35,12 @@ public class RoomTradeUser { this.confirmed = true; } - public void addItem(HabboItem item) { + public void addItem(RoomItem item) { this.items.add(item); } - public HabboItem getItem(int itemId) { - for (HabboItem item : this.items) { + public RoomItem getItem(int itemId) { + for (RoomItem item : this.items) { if (item.getId() == itemId) { return item; } @@ -49,7 +49,7 @@ public class RoomTradeUser { return null; } - public THashSet getItems() { + public THashSet getItems() { return this.items; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java deleted file mode 100644 index 91d778cf..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ /dev/null @@ -1,752 +0,0 @@ -package com.eu.habbo.habbohotel.rooms; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionWater; -import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; -import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; -import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.RideablePet; -import com.eu.habbo.habbohotel.users.DanceType; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; -import com.eu.habbo.plugin.Event; -import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; -import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent; -import com.eu.habbo.plugin.events.users.UserIdleEvent; -import com.eu.habbo.plugin.events.users.UserTakeStepEvent; -import com.eu.habbo.threading.runnables.RoomUnitKick; -import com.eu.habbo.util.pathfinding.Rotation; -import gnu.trove.map.TMap; -import gnu.trove.map.hash.THashMap; -import gnu.trove.set.hash.THashSet; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; -import lombok.extern.slf4j.Slf4j; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -@Slf4j -public class RoomUnit { - - @Getter - @Setter - private boolean isWiredTeleporting = false; - @Getter - @Setter - private boolean isLeavingTeleporter = false; - @Getter - @Setter - private boolean isSwimming = false; - @Getter - private final ConcurrentHashMap status; - private final THashMap cacheable; - @Getter - @Setter - private boolean canRotate = true; - @Getter - @Setter - private boolean animateWalk = false; - @Getter - @Setter - private boolean cmdTeleport = false; - @Getter - @Setter - private boolean cmdSit = false; - @Setter - @Getter - private boolean cmdStand = false; - @Getter - @Setter - private boolean cmdLay = false; - @Setter - @Getter - private boolean sitUpdate = false; - @Getter - @Setter - private boolean isTeleporting = false; - @Getter - @Setter - private boolean isKicked; - @Getter - @Setter - private int kickCount = 0; - private int id; - @Getter - private RoomTile startLocation; - @Getter - @Setter - private RoomTile botStartLocation; - @Getter - private RoomTile previousLocation; - @Getter - @Setter - @Accessors(chain = true) - private double previousLocationZ; - private RoomTile currentLocation; - @Getter - private RoomTile goalLocation; - @Getter - private double z; - private int tilesWalked; - @Getter - @Setter - private boolean inRoom; - @Setter - @Accessors(chain = true) - private boolean canWalk; - @Setter - @Getter - private boolean fastWalk = false; - private boolean statusUpdate = false; - @Getter - @Setter - @Accessors(chain = true) - private boolean invisible = false; - @Setter - private boolean canLeaveRoomByDoor = true; - @Setter - private RoomUserRotation bodyRotation = RoomUserRotation.NORTH; - @Getter - @Setter - private RoomUserRotation headRotation = RoomUserRotation.NORTH; - @Getter - @Setter - private DanceType danceType; - @Getter - @Setter - @Accessors(chain = true) - private RoomUnitType roomUnitType; - @Getter - @Setter - private Deque path = new LinkedList<>(); - private int handItem; - private long handItemTimestamp; - private int walkTimeOut; - private int effectId; - private int effectEndTimestamp; - private int previousEffectId; - private int previousEffectEndTimestamp; - private int timeInRoom; - - private int idleTimer; - @Setter - @Getter - private Room room; - @Getter - @Setter - private RoomRightLevels rightsLevel = RoomRightLevels.NONE; - private final THashSet overridableTiles; - - public RoomUnit() { - this.id = 0; - this.inRoom = false; - this.canWalk = true; - this.status = new ConcurrentHashMap<>(); - this.cacheable = new THashMap<>(); - this.roomUnitType = RoomUnitType.UNKNOWN; - this.danceType = DanceType.NONE; - this.handItem = 0; - this.handItemTimestamp = 0; - this.walkTimeOut = Emulator.getIntUnixTimestamp(); - this.effectId = 0; - this.previousEffectId = 0; - this.previousEffectEndTimestamp = -1; - this.setKicked(false); - this.overridableTiles = new THashSet<>(); - this.timeInRoom = 0; - } - - public void clearWalking() { - this.goalLocation = null; - this.startLocation = this.currentLocation; - this.inRoom = false; - - this.status.clear(); - - this.cacheable.clear(); - } - - public void stopWalking() { - synchronized (this.status) { - this.status.remove(RoomUnitStatus.MOVE); - this.setGoalLocation(this.currentLocation); - } - } - - public boolean cycle(Room room) { - try { - if (handleRider(room)) - return this.statusUpdate; - - Habbo habboT = room.getHabbo(this); - if (!this.isWalking() && !this.isKicked() && this.status.remove(RoomUnitStatus.MOVE) == null && habboT != null) { - habboT.getHabboInfo().getRiding().getRoomUnit().status.remove(RoomUnitStatus.MOVE); - return true; - } - - if (this.status.remove(RoomUnitStatus.SIT) != null || this.status.remove(RoomUnitStatus.MOVE) != null || this.status.remove(RoomUnitStatus.LAY) != null) - this.statusUpdate = true; - - for (Map.Entry set : this.status.entrySet()) { - if (set.getKey().isRemoveWhenWalking()) { - this.status.remove(set.getKey()); - } - } - - if (this.path == null || this.path.isEmpty()) - return true; - - boolean canfastwalk = habboT == null || habboT.getHabboInfo().getRiding() == null; - - RoomTile next = this.path.poll(); - boolean overrideChecks = next != null && this.canOverrideTile(next); - - if (this.path.isEmpty()) { - this.setSitUpdate(true); - - if (next != null && next.hasUnits() && !overrideChecks) { - return false; - } - } - - Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); - - if (peekPath == null) peekPath = new LinkedList<>(); - - if (peekPath.size() >= 3) { - if (path.isEmpty()) return true; - - path.pop(); - //peekPath.pop(); //Start - peekPath.removeLast(); //End - - if (peekPath.peek() != next) { - next = peekPath.poll(); - for (int i = 0; i < peekPath.size(); i++) { - this.path.addFirst(peekPath.removeLast()); - } - } - } - - if (canfastwalk && this.fastWalk && this.path.size() > 1) { - next = this.path.poll(); - } - - if (next == null) - return true; - - Habbo habbo = room.getHabbo(this); - - this.status.remove(RoomUnitStatus.DEAD); - - if (habbo != null) { - if (this.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled() && !event.isIdle()) { - room.unIdle(habbo); - this.idleTimer = 0; - } - } - - if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) { - Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getX(), this.getY()), next); - Emulator.getPluginManager().fireEvent(e); - - if (e.isCancelled()) - return true; - } - } - - HabboItem item = room.getTopItemAt(next.getX(), next.getY()); - - double height = next.getStackHeight() - this.currentLocation.getStackHeight(); - if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.room = room; - this.path.clear(); - this.findPath(); - - if (this.path.isEmpty()) { - this.status.remove(RoomUnitStatus.MOVE); - return false; - } - next = this.path.pop(); - - } - - boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); - - if (canSitNextTile) { - HabboItem tallestChair = room.getTallestChair(next); - - if (tallestChair != null) - item = tallestChair; - } - - if (next.equals(this.goalLocation) && next.getState() == RoomTileState.SIT && !overrideChecks - && (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.status.remove(RoomUnitStatus.MOVE); - return false; - } - - double zHeight = 0.0D; - if (habbo != null && habbo.getHabboInfo().getRiding() != null) { - zHeight += 1.0D; - } - - HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY()); - if (habboItem != null && (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) - habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next}); - - - this.tilesWalked++; - - RoomUserRotation oldRotation = this.getBodyRotation(); - this.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]); - if (item != null) { - if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { - if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next}); - } else if (item instanceof ConditionalGate conditionalGate) { - this.setRotation(oldRotation); - this.tilesWalked--; - this.setGoalLocation(this.currentLocation); - this.status.remove(RoomUnitStatus.MOVE); - room.sendComposer(new UserUpdateComposer(this).compose()); - - if (habbo != null) { - conditionalGate.onRejected(this, this.getRoom(), new Object[]{}); - } - return false; - } - } else { - item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next}); - } - - zHeight += item.getZ(); - - if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { - zHeight += Item.getCurrentHeight(item); - } - } else { - zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); - } - - - this.setPreviousLocation(this.getCurrentLocation()); - - this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); - if (habbo != null && habbo.getHabboInfo().getRiding() != null) { - RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit(); - - if (ridingUnit != null) { - ridingUnit.setPreviousLocationZ(this.getZ()); - this.setZ(zHeight - 1.0); - ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]); - ridingUnit.setPreviousLocation(this.getCurrentLocation()); - ridingUnit.setGoalLocation(this.getGoalLocation()); - ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); - room.sendComposer(new UserUpdateComposer(ridingUnit).compose()); - } - } - - this.setZ(zHeight); - this.setCurrentLocation(room.getLayout().getTile(next.getX(), next.getY())); - this.resetIdleTimer(); - - if (habbo != null) { - HabboItem topItem = room.getTopItemAt(next.getX(), next.getY()); - - boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); - boolean publicRoomKicks = !room.isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); - boolean invalidated = topItem != null && topItem.invalidatesToRoomKick(); - - if (this.canLeaveRoomByDoor && isAtDoor && publicRoomKicks && !invalidated) { - Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500); - } - } - - return false; - - } catch (Exception e) { - log.error("Caught exception", e); - return false; - } - } - - private boolean handleRider(Room room) { - Habbo rider = null; - if (this.getRoomUnitType() == RoomUnitType.PET) { - Pet pet = room.getPet(this); - if (pet instanceof RideablePet rideablePet) { - rider = rideablePet.getRider(); - } - } - - if (rider != null) { - // copy things from rider - if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatus().containsKey(RoomUnitStatus.MOVE)) { - this.status.remove(RoomUnitStatus.MOVE); - } - - if (rider.getRoomUnit().getCurrentLocation().getX() != this.getX() || rider.getRoomUnit().getCurrentLocation().getY() != this.getY()) { - this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().getX() + "," + rider.getRoomUnit().getCurrentLocation().getY() + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight())); - this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation()); - this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight()); - this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation()); - this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight()); - } - - return true; - } - return false; - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public RoomTile getCurrentLocation() { - return this.currentLocation; - } - - public void setCurrentLocation(RoomTile location) { - if (location != null) { - if (this.currentLocation != null) { - this.currentLocation.removeUnit(this); - } - this.currentLocation = location; - location.addUnit(this); - } - } - - public short getX() { - return this.currentLocation.getX(); - } - - public short getY() { - return this.currentLocation.getY(); - } - - public void setZ(double z) { - this.z = z; - - if (this.room != null) { - Bot bot = this.room.getBot(this); - if (bot != null) { - bot.needsUpdate(true); - } - } - } - - public void setRotation(RoomUserRotation rotation) { - this.bodyRotation = rotation; - this.headRotation = rotation; - } - - public RoomUserRotation getBodyRotation() { - return this.bodyRotation; - } - - public boolean canWalk() { - return this.canWalk; - } - - public int tilesWalked() { - return this.tilesWalked; - } - - public RoomUnit setGoalLocation(RoomTile goalLocation) { - if (goalLocation != null) { - this.setGoalLocation(goalLocation, false); - } - return this; - } - - public void setGoalLocation(RoomTile goalLocation, boolean noReset) { - if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) { - Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation); - Emulator.getPluginManager().fireEvent(event); - - if (event.isCancelled()) - return; - } - - /// Set start location - this.startLocation = this.currentLocation; - - if (goalLocation != null && !noReset) { - boolean isWalking = this.hasStatus(RoomUnitStatus.MOVE); - this.goalLocation = goalLocation; - this.findPath(); ///< Quadral: this is where we start formulating a path - if (!this.path.isEmpty()) { - this.tilesWalked = isWalking ? this.tilesWalked : 0; - this.setCmdSit(false); - } else { - this.goalLocation = this.currentLocation; - } - } - } - - public RoomUnit setLocation(RoomTile location) { - if (location != null) { - this.startLocation = location; - setPreviousLocation(location); - setCurrentLocation(location); - this.goalLocation = location; - this.botStartLocation = location; - } - return this; - } - - public void setPreviousLocation(RoomTile previousLocation) { - this.previousLocation = previousLocation; - this.previousLocationZ = this.z; - } - - public RoomUnit setPathFinderRoom(Room room) { - this.room = room; - return this; - } - - public void findPath() { - if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.getX(), this.goalLocation.getY()) || this.canOverrideTile(this.goalLocation))) { - Deque newPath = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); - if (newPath != null) this.path = newPath; - } - } - - public boolean isAtGoal() { - return this.currentLocation.equals(this.goalLocation); - } - - public boolean isWalking() { - return !this.isAtGoal() && this.canWalk; - } - - public String getStatus(RoomUnitStatus key) { - return this.status.get(key); - } - - public RoomUnit removeStatus(RoomUnitStatus key) { - this.status.remove(key); - return this; - } - - public void setStatus(RoomUnitStatus key, String value) { - if (key != null && value != null) { - this.status.put(key, value); - } - } - - public boolean hasStatus(RoomUnitStatus key) { - return this.status.containsKey(key); - } - - public void clearStatus() { - this.status.clear(); - } - - public void statusUpdate(boolean update) { - this.statusUpdate = update; - } - - public boolean needsStatusUpdate() { - return this.statusUpdate; - } - - public TMap getCacheable() { - return this.cacheable; - } - - public int getHandItem() { - return this.handItem; - } - - public RoomUnit setHandItem(int handItem) { - this.handItem = handItem; - this.handItemTimestamp = System.currentTimeMillis(); - return this; - } - - public long getHandItemTimestamp() { - return this.handItemTimestamp; - } - - public int getEffectId() { - return this.effectId; - } - - - public void setEffectId(int effectId, int endTimestamp) { - this.effectId = effectId; - this.effectEndTimestamp = endTimestamp; - } - - public int getEffectEndTimestamp() { - return this.effectEndTimestamp; - } - - public int getPreviousEffectId() { - return this.previousEffectId; - } - - public void setPreviousEffectId(int effectId, int endTimestamp) { - this.previousEffectId = effectId; - this.previousEffectEndTimestamp = endTimestamp; - } - - public int getPreviousEffectEndTimestamp() { - return this.previousEffectEndTimestamp; - } - - public int getWalkTimeOut() { - return this.walkTimeOut; - } - - public void setWalkTimeOut(int walkTimeOut) { - this.walkTimeOut = walkTimeOut; - } - - public void increaseTimeInRoom() { - this.timeInRoom++; - } - - public int getTimeInRoom() { - return this.timeInRoom; - } - - public void resetTimeInRoom() { - this.timeInRoom = 0; - } - - public void increaseIdleTimer() { - this.idleTimer++; - } - - public boolean isIdle() { - return this.idleTimer > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds. - } - - public int getIdleTimer() { - return this.idleTimer; - } - - public void resetIdleTimer() { - this.idleTimer = 0; - } - - public void setIdle() { - this.idleTimer = Room.IDLE_CYCLES + 1; - } - - public void lookAtPoint(RoomTile location) { - if (!this.isCanRotate()) return; - - if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) { - Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location); - Emulator.getPluginManager().fireEvent(lookAtPointEvent); - - if (lookAtPointEvent.isCancelled()) - return; - } - - if (this.status.containsKey(RoomUnitStatus.LAY)) { - return; - } - - if (!this.status.containsKey(RoomUnitStatus.SIT)) { - this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.getX(), location.getY())]); - } - - RoomUserRotation rotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.getX(), location.getY())]); - - if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) { - this.headRotation = rotation; - } - } - - public boolean canOverrideTile(RoomTile tile) { - if (tile == null || room == null || room.getLayout() == null) return false; - - if (room.getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, room, tile))) - return true; - - int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); - return this.overridableTiles.contains(tileIndex); - } - - public void addOverrideTile(RoomTile tile) { - int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); - if (!this.overridableTiles.contains(tileIndex)) { - this.overridableTiles.add(tileIndex); - } - } - - public void removeOverrideTile(RoomTile tile) { - if (room == null || room.getLayout() == null) return; - - int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); - this.overridableTiles.remove(tileIndex); - } - - public void clearOverrideTiles() { - this.overridableTiles.clear(); - } - - public boolean canLeaveRoomByDoor() { - return canLeaveRoomByDoor; - } - - public boolean canForcePosture() { - if (this.room == null) return false; - - HabboItem topItem = this.room.getTopItemAt(this.getX(), this.getY()); - - return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); - } - - public RoomTile getClosestTile(List tiles) { - return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null); - } - - public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { - if (room == null) return null; - - RoomTile baseTile = room.getLayout().getTile(x, y); - - if (baseTile == null) return null; - - List rotations = new ArrayList<>(); - rotations.add(RoomUserRotation.SOUTH.getValue()); - rotations.add(RoomUserRotation.NORTH.getValue()); - rotations.add(RoomUserRotation.EAST.getValue()); - rotations.add(RoomUserRotation.WEST.getValue()); - - if (diagonal) { - rotations.add(RoomUserRotation.NORTH_EAST.getValue()); - rotations.add(RoomUserRotation.NORTH_WEST.getValue()); - rotations.add(RoomUserRotation.SOUTH_EAST.getValue()); - rotations.add(RoomUserRotation.SOUTH_WEST.getValue()); - } - - return this.getClosestTile( - rotations.stream() - .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) - .filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) - || !room.hasHabbosAt(t.getX(), t.getY()))) - .toList() - ); - } - -} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java new file mode 100644 index 00000000..a08b97c7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -0,0 +1,439 @@ +package com.eu.habbo.habbohotel.rooms; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetManager; +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.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; +import com.eu.habbo.habbohotel.units.Unit; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; +import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; +import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +@Getter +public class RoomUnitManager { + private final int roomId; + private final ConcurrentHashMap currentRoomUnits; + private final ConcurrentHashMap currentRoomHabbos; + private final ConcurrentHashMap currentRoomBots; + private final ConcurrentHashMap currentRoomPets; + private volatile int roomUnitCounter; + public final Object roomUnitLock; + + public RoomUnitManager(int roomId) { + this.roomId = roomId; + this.currentRoomUnits = new ConcurrentHashMap<>(); + + this.currentRoomHabbos = new ConcurrentHashMap<>(); + this.currentRoomBots = new ConcurrentHashMap<>(); + this.currentRoomPets = new ConcurrentHashMap<>(); + this.roomUnitCounter = 0; + + this.roomUnitLock = new Object(); + } + + public synchronized void load(Connection connection) { + this.loadBots(connection); + this.loadPets(connection); + } + + private synchronized void loadBots(Connection connection) { + 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); + 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); + bot.setRoomUnit(new RoomBot()); + bot.getRoomUnit().setRoom(room); + bot.getRoomUnit().setLocation(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())); + } else { + bot.getRoomUnit().setCurrentZ(set.getDouble("z")); + bot.getRoomUnit().setPreviousLocationZ(set.getDouble("z")); + bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); + } + 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.addRoomUnit(bot); + } + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + private synchronized void loadPets(Connection connection) { + 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); + 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.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setRoom(room); + pet.getRoomUnit().setLocation(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())); + } else { + pet.getRoomUnit().setCurrentZ(set.getDouble("z")); + pet.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); + } + pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); + pet.getRoomUnit().setCanWalk(true); + this.addRoomUnit(pet); + room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + public void addRoomUnit(Unit unit) { + synchronized (this.roomUnitLock) { + unit.getRoomUnit().setVirtualId(this.roomUnitCounter); + this.currentRoomUnits.put(unit.getRoomUnit().getVirtualId(), unit.getRoomUnit()); + this.roomUnitCounter++; + + 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: + 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; + } + } + } + + public Collection getRoomUnitsAt(RoomTile tile) { + return this.currentRoomUnits.values().stream().filter(roomUnit -> roomUnit.getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + } + + public Collection getAvatarsAt(RoomTile tile) { + return Stream.concat(this.getHabbosAt(tile).stream(), this.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList()); + } + public Collection getRoomHabbos() { + return this.currentRoomHabbos.values(); + } + + public int getRoomHabbosCount() { + return this.currentRoomHabbos.size(); + } + + public boolean hasHabbosAt(RoomTile tile) { + return this.currentRoomHabbos.values().stream().anyMatch(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)); + } + + public Collection getHabbosAt(RoomTile tile) { + return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + } + + 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 getHabboByRoomUnit(RoomUnit roomUnit) { + return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit() == roomUnit).findFirst().orElse(null); + } + + public Bot getRoomBotById(int botId) { + return this.currentRoomBots.get(botId); + } + + public List getBotsByName(String name) { + synchronized (this.currentRoomBots) { + return currentRoomBots.values().stream().filter(bot -> bot.getName().equalsIgnoreCase(name)).toList(); + } + } + + public Bot getBotByRoomUnit(RoomUnit roomUnit) { + return this.currentRoomBots.values().stream().filter(bot -> bot.getRoomUnit() == roomUnit).findFirst().orElse(null); + } + + public boolean hasBotsAt(RoomTile tile) { + return this.currentRoomBots.values().stream().anyMatch(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)); + } + + public Collection getBotsAt(RoomTile tile) { + return this.currentRoomBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + } + + public void placePet(Pet pet, Room room, short x, short y, double z) { + synchronized (this.currentRoomPets) { + RoomTile tile = room.getLayout().getTile(x, y); + + if (tile == null) { + tile = room.getLayout().getDoorTile(); + } + + pet.setRoomUnit(new RoomPet()); + pet.setRoom(room); + pet.getRoomUnit() + .setGoalLocation(tile) + .setLocation(tile) + .setRoomUnitType(RoomUnitType.PET) + .setCanWalk(true) + .setPreviousLocationZ(z) + .setCurrentZ(z) + .setRoom(room); + + if (pet.getRoomUnit().getCurrentPosition() == null) { + pet.getRoomUnit() + .setLocation(room.getLayout().getDoorTile()) + .setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); + } + + pet.setNeedsUpdate(true); + room.getFurniOwnerNames().put(pet.getUserId(), this.getRoomHabboById(pet.getUserId()).getHabboInfo().getUsername()); + this.addRoomUnit(pet); + room.sendComposer(new RoomPetComposer(pet).compose()); + } + } + + public boolean hasPetsAt(RoomTile tile) { + return this.currentRoomPets.values().stream().anyMatch(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)); + } + + public Collection getPetsAt(RoomTile tile) { + return this.currentRoomPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + } + + public Pet getRoomPetById(int petId) { + return this.currentRoomPets.get(petId); + } + + public Pet getPetByRoomUnit(RoomUnit roomUnit) { + return this.currentRoomPets.values().stream().filter(pet -> pet.getRoomUnit() == roomUnit).findFirst().orElse(null); + } + + public void pickUpMyPets(Habbo owner) { + THashSet pets = new THashSet<>(); + + synchronized (this.currentRoomPets) { + for (Pet pet : this.currentRoomPets.values()) { + if (pet.getUserId() == owner.getHabboInfo().getId()) { + pets.add(pet); + } + } + } + + for (Pet pet : pets) { + pet.removeFromRoom(); + Emulator.getThreading().run(pet); + owner.getInventory().getPetsComponent().addPet(pet); + owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); + this.currentRoomPets.remove(pet.getId()); + } + } + + public void removeHabbo(Habbo habbo, boolean sendRemovePacket) { + if(!this.currentRoomHabbos.containsKey(habbo.getHabboInfo().getId())) { + return; + } + + RoomUnit roomUnit = habbo.getRoomUnit(); + + if(roomUnit == null || !(roomUnit instanceof RoomHabbo roomHabbo)) { + return; + } + + if(roomHabbo.getCurrentPosition() != null) { + roomHabbo.getCurrentPosition().removeUnit(habbo.getRoomUnit()); + } + + synchronized (this.roomUnitLock) { + this.currentRoomHabbos.remove(habbo.getHabboInfo().getId()); + this.currentRoomUnits.remove(roomHabbo.getVirtualId()); + } + + roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); + + RoomItem item = roomHabbo.getRoom().getTopItemAt(roomHabbo.getCurrentPosition()); + + if (item != null) { + try { + item.onWalkOff(habbo.getRoomUnit(), roomHabbo.getRoom(), new Object[]{}); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + if (habbo.getHabboInfo().getCurrentGame() != null && roomHabbo.getRoom().getGame(habbo.getHabboInfo().getCurrentGame()) != null) { + roomHabbo.getRoom().getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); + } + + RoomTrade trade = roomHabbo.getRoom().getActiveTradeForHabbo(habbo); + + if (trade != null) { + trade.stopTrade(habbo); + } + + if (!roomHabbo.getRoom().getRoomInfo().isRoomOwner(habbo)) { + this.pickUpMyPets(habbo); + } + + roomHabbo.getRoom().updateDatabaseUserCount(); + + roomHabbo.clear(); + } + + public boolean removeBot(Bot bot) { + synchronized (this.currentRoomBots) { + if (this.currentRoomBots.containsKey(bot.getId())) { + if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentPosition() != null) { + bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit()); + } + + this.currentRoomBots.remove(bot.getId()); + this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId()); + + bot.getRoomUnit().setInRoom(false); + bot.setRoom(null); + bot.getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); + bot.setRoomUnit(null); + return true; + } + } + + return false; + } + + public Pet removePet(int petId) { + Pet pet = this.currentRoomPets.get(petId); + this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId()); + return this.currentRoomPets.remove(petId); + } + + public void removeAllPetsExceptRoomOwner() { + ArrayList toRemovePets = new ArrayList<>(); + ArrayList removedPets = new ArrayList<>(); + synchronized (this.currentRoomPets) { + for (Pet pet : this.currentRoomPets.values()) { + try { + if (pet.getUserId() != pet.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId()) { + toRemovePets.add(pet); + } + + } catch (NoSuchElementException e) { + log.error("Caught exception", e); + break; + } + } + } + + for (Pet pet : toRemovePets) { + removedPets.add(pet); + + pet.removeFromRoom(); + + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); + if (habbo != null) { + habbo.getInventory().getPetsComponent().addPet(pet); + habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); + } + + pet.setNeedsUpdate(true); + pet.run(); + } + + for (Pet pet : removedPets) { + this.currentRoomPets.remove(pet.getId()); + this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId()); + } + } + + public void clear() { + synchronized (this.roomUnitLock) { + this.currentRoomUnits.clear(); + this.currentRoomHabbos.clear(); + this.currentRoomBots.clear(); + this.currentRoomPets.clear(); + this.roomUnitCounter = 0; + } + } + + public void dispose(Room room) { + for(Habbo habbo : this.currentRoomHabbos.values()) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room); + } + + room.sendComposer(new CloseConnectionMessageComposer().compose()); + + this.currentRoomHabbos.clear(); + + Iterator botIterator = this.currentRoomBots.values().iterator(); + + while(botIterator.hasNext()) { + try { + Bot bot = botIterator.next(); + bot.needsUpdate(true); + Emulator.getThreading().run(bot); + } catch (NoSuchElementException e) { + log.error("Caught Exception", e); + break; + } + } + + this.currentRoomBots.clear(); + this.currentRoomPets.clear(); + + this.currentRoomUnits.clear(); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java deleted file mode 100644 index 624afe34..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUserRotation.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.eu.habbo.habbohotel.rooms; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum RoomUserRotation { - NORTH(0), - NORTH_EAST(1), - EAST(2), - SOUTH_EAST(3), - SOUTH(4), - SOUTH_WEST(5), - WEST(6), - NORTH_WEST(7); - - private final int direction; - - - public static RoomUserRotation fromValue(int rotation) { - rotation %= 8; - for (RoomUserRotation rot : values()) { - if (rot.getValue() == rotation) { - return rot; - } - } - - return NORTH; - } - - public static RoomUserRotation counterClockwise(RoomUserRotation rotation) { - return fromValue(rotation.getValue() + 7); - } - - public static RoomUserRotation clockwise(RoomUserRotation rotation) { - return fromValue(rotation.getValue() + 9); - } - - public int getValue() { - return this.direction; - } - - public RoomUserRotation getOpposite() { - return switch (this) { - case NORTH -> RoomUserRotation.SOUTH; - case NORTH_EAST -> RoomUserRotation.SOUTH_WEST; - case EAST -> RoomUserRotation.WEST; - case SOUTH_EAST -> RoomUserRotation.NORTH_WEST; - case SOUTH -> RoomUserRotation.NORTH; - case SOUTH_WEST -> RoomUserRotation.NORTH_EAST; - case WEST -> RoomUserRotation.EAST; - case NORTH_WEST -> RoomUserRotation.SOUTH_EAST; - }; - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 1982f52e..60caf827 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; @@ -55,7 +55,7 @@ public class TraxManager implements Disposable { if (this.jukeBox == null) { //Check again if there's a jukebox on room but has not been saved on DB before - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) { + for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) { this.jukeBox = (InteractionJukeBox) item; } @@ -71,10 +71,10 @@ public class TraxManager implements Disposable { public InteractionJukeBox loadRoomJukebox() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_trax WHERE room_id = ?")) { - statement.setInt(1, this.room.getId()); + statement.setInt(1, this.room.getRoomInfo().getId()); try (ResultSet set = statement.executeQuery()) { if (set.next()) { - HabboItem jukebox = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("trax_item_id")); + RoomItem jukebox = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("trax_item_id")); if (jukebox != null) { if (!(jukebox instanceof InteractionJukeBox)) { return null; @@ -100,7 +100,7 @@ public class TraxManager implements Disposable { statement.setInt(1, this.jukeBox.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); + RoomItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); if (musicDisc != null) { if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) { deleteSongFromPlaylist(this.jukeBox.getId(), musicDisc.getId()); @@ -135,7 +135,7 @@ public class TraxManager implements Disposable { if (this.jukeBox != null) return; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement_1 = connection.prepareStatement("INSERT INTO room_trax (room_id, trax_item_id) VALUES (?, ?)")) { - statement_1.setInt(1, this.room.getId()); + statement_1.setInt(1, this.room.getRoomInfo().getId()); statement_1.setInt(2, jukeBox.getId()); statement_1.execute(); } @@ -153,7 +153,7 @@ public class TraxManager implements Disposable { if (this.jukeBox.getId() != jukeBox.getId()) return; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement_1 = connection.prepareStatement("DELETE FROM room_trax WHERE room_id = ?")) { - statement_1.setInt(1, this.room.getId()); + statement_1.setInt(1, this.room.getRoomInfo().getId()); statement_1.execute(); } catch (SQLException e) { @@ -195,7 +195,8 @@ public class TraxManager implements Disposable { this.currentlyPlaying = this.songs.get(index); if (this.currentlyPlaying != null) { - this.room.setJukeBoxActive(true); + this.room.getRoomInfo().setJukeboxEnabled(true); + this.room.setNeedsUpdate(true); this.startedTimestamp = Emulator.getIntUnixTimestamp(); this.playingIndex = index; @@ -217,7 +218,8 @@ public class TraxManager implements Disposable { AchievementManager.progressAchievement(this.starter, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicPlayer"), (Emulator.getIntUnixTimestamp() - cycleStartedTimestamp) / 60); } - this.room.setJukeBoxActive(false); + this.room.getRoomInfo().setJukeboxEnabled(false); + this.room.setNeedsUpdate(true); this.currentlyPlaying = null; this.startedTimestamp = 0; this.cycleStartedTimestamp = 0; @@ -317,7 +319,7 @@ public class TraxManager implements Disposable { statement.setInt(1, jukebox.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); + RoomItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); deleteSongFromPlaylist(jukebox.getId(), set.getInt("item_id")); if (musicDisc != null) { @@ -393,7 +395,7 @@ public class TraxManager implements Disposable { } public void sendUpdatedSongList() { - this.room.getHabbos().forEach(h -> { + this.room.getRoomUnitManager().getRoomHabbos().forEach(h -> { GameClient client = h.getClient(); if (client != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java new file mode 100644 index 00000000..5902ba08 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java @@ -0,0 +1,31 @@ +package com.eu.habbo.habbohotel.rooms.entities; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; + +public interface IRoomEntity { + Room getRoom(); + RoomEntity setRoom(Room room); + + RoomTile getPreviousPosition(); + RoomEntity setPreviousPosition(RoomTile previousPosition); + + double getPreviousZ(); + RoomEntity setPreviousZ(double previousZ); + + RoomTile getCurrentPosition(); + RoomEntity setCurrentPosition(RoomTile currentPosition); + + double getCurrentZ(); + RoomEntity setCurrentZ(double currentZ); + + RoomTile getTargetPosition(); + RoomEntity setTargetPosition(RoomTile targetPosition); + + double getTargetZ(); + RoomEntity setTargetZ(double targetZ); + + void setTargetTile(short x, short y); + + void incrementTilesMoved(); +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java new file mode 100644 index 00000000..c7f35994 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java @@ -0,0 +1,58 @@ +package com.eu.habbo.habbohotel.rooms.entities; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.Deque; +import java.util.LinkedList; + +@Getter +@Setter +@Accessors(chain = true) +public class RoomEntity implements IRoomEntity { + private Room room; + private RoomTile previousPosition; + private double previousZ; + private RoomTile currentPosition; + private double currentZ; + private RoomTile targetPosition; + private double targetZ; + private Deque path = new LinkedList<>(); + private int tilesMoved; + + public RoomEntity setCurrentPosition(RoomTile tile) { + if (this.currentPosition != null) { + this.currentPosition.removeUnit(this); + } + + this.currentPosition = tile; + + if(this.currentPosition != null) { + tile.addUnit(this); + } + + return this; + } + + public void setTargetTile(short x, short y) { + RoomTile targetTile = this.getRoom().getLayout().getTile(x, y); + + if(this.getCurrentPosition().equals(targetTile)) { + return; + } + + if (targetTile.isWalkable()) { + this.setTargetPosition(targetTile); + } + } + + public synchronized void incrementTilesMoved() { + this.tilesMoved++; + } + public synchronized void decrementTilesMoved() { + this.tilesMoved--; + } +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomRotation.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomRotation.java new file mode 100644 index 00000000..c32cfd6b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomRotation.java @@ -0,0 +1,56 @@ +package com.eu.habbo.habbohotel.rooms.entities; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum RoomRotation { + NORTH(0), + NORTH_EAST(1), + EAST(2), + SOUTH_EAST(3), + SOUTH(4), + SOUTH_WEST(5), + WEST(6), + NORTH_WEST(7); + + private final int direction; + + + public static RoomRotation fromValue(int rotation) { + rotation %= 8; + for (RoomRotation rot : values()) { + if (rot.getValue() == rotation) { + return rot; + } + } + + return NORTH; + } + + public static RoomRotation counterClockwise(RoomRotation rotation) { + return fromValue(rotation.getValue() + 7); + } + + public static RoomRotation clockwise(RoomRotation rotation) { + return fromValue(rotation.getValue() + 9); + } + + public int getValue() { + return this.direction; + } + + public RoomRotation getOpposite() { + return switch (this) { + case NORTH -> RoomRotation.SOUTH; + case NORTH_EAST -> RoomRotation.SOUTH_WEST; + case EAST -> RoomRotation.WEST; + case SOUTH_EAST -> RoomRotation.NORTH_WEST; + case SOUTH -> RoomRotation.NORTH; + case SOUTH_WEST -> RoomRotation.NORTH_EAST; + case WEST -> RoomRotation.EAST; + case NORTH_WEST -> RoomRotation.SOUTH_EAST; + }; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/ItemLimitedData.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/ItemLimitedData.java new file mode 100644 index 00000000..76df13cd --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/ItemLimitedData.java @@ -0,0 +1,13 @@ +package com.eu.habbo.habbohotel.rooms.entities.items; + +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter +@Setter +@Accessors(chain = true) +public class ItemLimitedData { + private int stack; + private int sells; +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java similarity index 91% rename from src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java index 9f1cfd7f..02dd89f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/RoomItem.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.users; +package com.eu.habbo.habbohotel.rooms.entities.items; import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; @@ -11,7 +11,14 @@ import com.eu.habbo.habbohotel.items.IEventTriggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -37,7 +44,7 @@ import java.util.Arrays; import java.util.List; @Slf4j -public abstract class HabboItem implements Runnable, IEventTriggers { +public abstract class RoomItem implements Runnable, IEventTriggers { @SuppressWarnings("rawtypes") private static final Class[] TOGGLING_INTERACTIONS = new Class[]{ @@ -82,7 +89,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { private boolean needsDelete = false; private boolean isFromGift = false; - public HabboItem(ResultSet set, Item baseItem) throws SQLException { + public RoomItem(ResultSet set, Item baseItem) throws SQLException { this.id = set.getInt("id"); this.userId = set.getInt(DatabaseConstants.USER_ID); this.roomId = set.getInt("room_id"); @@ -101,7 +108,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } } - public HabboItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public RoomItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { this.id = id; this.userId = userId; this.roomId = 0; @@ -116,7 +123,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { this.limitedStack = limitedStack; } - public static RoomTile getSquareInFront(RoomLayout roomLayout, HabboItem item) { + public static RoomTile getSquareInFront(RoomLayout roomLayout, RoomItem item) { return roomLayout.getTileInFront(roomLayout.getTile(item.getX(), item.getY()), item.getRotation()); } @@ -243,7 +250,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { return; } - if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice) || !(this instanceof InteractionSpinningBottle)) || Arrays.asList(HabboItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) { + if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice) || !(this instanceof InteractionSpinningBottle)) || Arrays.asList(RoomItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) { WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this}); } } @@ -269,8 +276,8 @@ public abstract class HabboItem implements Runnable, IEventTriggers { habbo.getHabboInfo().setLook(String.join(".", Arrays.stream(habbo.getHabboInfo().getLook().split("\\.")).filter(k -> !ArrayUtils.contains(clothingKeys, k.split("-")[0])).toArray(String[]::new)) + "." + this.getBaseItem().getClothingOnWalk()); habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } } } @@ -289,7 +296,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { public void onPlace(Room room) { //TODO: IMPORTANT: MAKE THIS GENERIC. (HOLES, ICE SKATE PATCHES, BLACK HOLE, BUNNY RUN FIELD, FOOTBALL FIELD) Achievement roomDecoAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFurniCount"); - Habbo owner = room.getHabbo(this.getUserId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getUserId()); int furniCollecterProgress; if (owner == null) { @@ -328,7 +335,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { public void onPickUp(Room room) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - HabboItem topItem2 = room.getTopItemAt(this.getX(), this.getY(), this); + RoomItem topItem2 = room.getTopItemAt(this.getX(), this.getY(), this); int nextEffectM = 0; int nextEffectF = 0; @@ -347,7 +354,8 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } } - for (Bot bot : room.getBotsAt(room.getLayout().getTile(this.getX(), this.getY()))) { + RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + for (Bot bot : room.getRoomUnitManager().getBotsAt(tile)) { if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { room.giveEffect(bot.getRoomUnit(), nextEffectM, -1); } @@ -361,7 +369,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - HabboItem topItem2 = room.getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); + RoomItem topItem2 = room.getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); int nextEffectM = 0; int nextEffectF = 0; @@ -376,13 +384,13 @@ public abstract class HabboItem implements Runnable, IEventTriggers { List newBots = new ArrayList<>(); for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) { - oldHabbos.addAll(room.getHabbosAt(tile)); - oldBots.addAll(room.getBotsAt(tile)); + oldHabbos.addAll(room.getRoomUnitManager().getHabbosAt(tile)); + oldBots.addAll(room.getRoomUnitManager().getBotsAt(tile)); } for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) { - newHabbos.addAll(room.getHabbosAt(tile)); - newBots.addAll(room.getBotsAt(tile)); + newHabbos.addAll(room.getRoomUnitManager().getHabbosAt(tile)); + newBots.addAll(room.getRoomUnitManager().getBotsAt(tile)); } oldHabbos.removeAll(newHabbos); @@ -448,7 +456,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { return this.baseItem.getStateCount() > 1; } - public boolean canStackAt(Room room, List>> itemsAtLocation) { + public boolean canStackAt(Room room, 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 new file mode 100644 index 00000000..cef8ef9d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomFloorItem.java @@ -0,0 +1,30 @@ +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 new file mode 100644 index 00000000..ea71dbb8 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/items/types/RoomWallItem.java @@ -0,0 +1,30 @@ +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/IRoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/IRoomUnit.java new file mode 100644 index 00000000..a85eb9a6 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/IRoomUnit.java @@ -0,0 +1,4 @@ +package com.eu.habbo.habbohotel.rooms.entities.units; + +public interface IRoomUnit { +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java new file mode 100644 index 00000000..6556c9ff --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -0,0 +1,433 @@ +package com.eu.habbo.habbohotel.rooms.entities.units; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.items.interactions.InteractionWater; +import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomRightLevels; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; +import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent; +import com.eu.habbo.util.pathfinding.Rotation; +import gnu.trove.map.TMap; +import gnu.trove.map.hash.THashMap; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Deque; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +@Slf4j +@Getter +@Accessors(chain = true) +public abstract class RoomUnit extends RoomEntity { + @Setter + private int virtualId; + @Setter + private RoomUnitType roomUnitType; + @Setter + private RoomRotation bodyRotation; + @Setter + private RoomRotation headRotation; + @Setter + private boolean canWalk; + @Setter + private boolean canRotate; + @Setter + private boolean isTeleporting; + @Setter + private boolean cmdTeleportEnabled = false; + @Setter + private boolean cmdSitEnabled = false; + @Setter + private boolean cmdStandEnabled = false; + @Setter + private boolean cmdLayEnabled = false; + @Setter + private boolean isSwimming = false; + @Setter + private boolean fastWalkEnabled; + private final ConcurrentHashMap statuses; + @Setter + private boolean statusUpdateNeeded; + @Getter + @Setter + private boolean isWiredTeleporting = false; + @Getter + @Setter + private boolean isLeavingTeleporter = false; + private final THashMap cacheable; + @Getter + @Setter + private boolean animateWalk = false; + @Setter + @Getter + private boolean sitUpdate = false; + @Setter + private boolean isKicked; + @Getter + @Setter + private int kickCount = 0; + @Getter + private RoomTile startLocation; + @Getter + @Setter + private RoomTile botStartLocation; + @Getter + private RoomTile previousLocation; + @Getter + @Setter + @Accessors(chain = true) + private double previousLocationZ; + @Getter + private RoomTile goalLocation; + @Getter + @Setter + private boolean inRoom; + @Getter + @Setter + @Accessors(chain = true) + private boolean invisible = false; + @Setter + private boolean canLeaveRoomByDoor = true; + @Getter + @Setter + private DanceType danceType; + private int walkTimeOut; + private int previousEffectId; + private int previousEffectEndTimestamp; + private int timeInRoom; + //RoomHabbo + private int idleTicks; + @Getter + @Setter + private RoomRightLevels rightsLevel = RoomRightLevels.NONE; + private final THashSet overridableTiles; + + public RoomUnit() { + this.virtualId = 0; + this.bodyRotation = RoomRotation.NORTH; + this.headRotation = RoomRotation.NORTH; + this.canWalk = true; + this.canRotate = true; + this.isTeleporting = false; + this.fastWalkEnabled = false; + this.statuses = new ConcurrentHashMap<>(); + this.statusUpdateNeeded = false; + + this.inRoom = false; + this.cacheable = new THashMap<>(); + this.roomUnitType = RoomUnitType.UNKNOWN; + this.walkTimeOut = Emulator.getIntUnixTimestamp(); + this.timeInRoom = 0; + + //RoomAvatar + this.danceType = DanceType.NONE; + this.previousEffectId = 0; + this.previousEffectEndTimestamp = -1; + + //RoomHabbo + this.isKicked = false; + this.overridableTiles = new THashSet<>(); + } + + public abstract boolean cycle(Room room); + + public void setRotation(RoomRotation rotation) { + this.bodyRotation = rotation; + this.headRotation = rotation; + } + + public void clearWalking() { + this.goalLocation = null; + this.setCurrentPosition(null); + this.startLocation = this.getCurrentPosition(); + this.statuses.clear(); + this.cacheable.clear(); + } + + public void stopWalking() { + synchronized (this.statuses) { + this.statuses.remove(RoomUnitStatus.MOVE); + this.setStatusUpdateNeeded(true); + this.setGoalLocation(this.getCurrentPosition()); + } + } + + @Override + public RoomUnit setCurrentZ(double currentZ) { + super.setCurrentZ(currentZ); + + if (this.getRoom() != null) { + Bot bot = this.getRoom().getRoomUnitManager().getRoomBotById(getVirtualId()); + if (bot != null) { + bot.needsUpdate(true); + } + } + + return this; + } + + public RoomUnit setGoalLocation(RoomTile goalLocation) { + if (goalLocation != null) { + this.setGoalLocation(goalLocation, false); + } + return this; + } + + public void setGoalLocation(RoomTile goalLocation, boolean noReset) { + if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) { + Event event = new RoomUnitSetGoalEvent(this.getRoom(), this, goalLocation); + Emulator.getPluginManager().fireEvent(event); + + if (event.isCancelled()) + return; + } + + /// Set start location + this.startLocation = this.getCurrentPosition(); + + if (goalLocation != null && !noReset) { + boolean isWalking = this.hasStatus(RoomUnitStatus.MOVE); + this.goalLocation = goalLocation; + this.findPath(); ///< Quadral: this is where we start formulating a path + if (!this.getPath().isEmpty()) { + this.setTilesMoved(isWalking ? this.getTilesMoved() : 0); + this.setCmdSitEnabled(false); + } else { + this.goalLocation = this.getCurrentPosition(); + } + } + } + + public RoomUnit setLocation(RoomTile location) { + if (location != null) { + this.startLocation = location; + this.setPreviousLocation(location); + this.setCurrentPosition(location); + this.goalLocation = location; + this.botStartLocation = location; + } + return this; + } + + public void setPreviousLocation(RoomTile previousLocation) { + this.previousLocation = previousLocation; + this.previousLocationZ = this.getCurrentZ(); + } + + public void findPath() { + if (this.getRoom() != null && this.getRoom().getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.getRoom().canSitOrLayAt(this.goalLocation.getX(), this.goalLocation.getY()) || this.canOverrideTile(this.goalLocation))) { + Deque newPath = this.getRoom().getLayout().findPath(this.getCurrentPosition(), this.goalLocation, this.goalLocation, this); + if (newPath != null) this.setPath(newPath); + } + } + + public boolean isAtGoal() { + if(this.getCurrentPosition() == null) { + return false; + } + + return this.getCurrentPosition().equals(this.goalLocation); + } + + public boolean isWalking() { + return !this.isAtGoal() && this.canWalk; + } + + public String getStatus(RoomUnitStatus key) { + return this.statuses.get(key); + } + + public RoomUnit removeStatus(RoomUnitStatus key) { + this.statuses.remove(key); + return this; + } + + public void setStatus(RoomUnitStatus key, String value) { + if (key != null && value != null) { + this.statuses.put(key, value); + } + } + + public boolean hasStatus(RoomUnitStatus key) { + return this.statuses.containsKey(key); + } + + public void clearStatuses() { + this.statuses.clear(); + } + + public TMap getCacheable() { + return this.cacheable; + } + + public int getPreviousEffectId() { + return this.previousEffectId; + } + + public void setPreviousEffectId(int effectId, int endTimestamp) { + this.previousEffectId = effectId; + this.previousEffectEndTimestamp = endTimestamp; + } + + public int getPreviousEffectEndTimestamp() { + return this.previousEffectEndTimestamp; + } + + public int getWalkTimeOut() { + return this.walkTimeOut; + } + + public void setWalkTimeOut(int walkTimeOut) { + this.walkTimeOut = walkTimeOut; + } + + public void increaseTimeInRoom() { + this.timeInRoom++; + } + + public int getTimeInRoom() { + return this.timeInRoom; + } + + public void resetTimeInRoom() { + this.timeInRoom = 0; + } + + public void increaseIdleTimer() { + this.idleTicks++; + } + + public boolean isIdle() { + return this.idleTicks > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds. + } + + public int getIdleTicks() { + return this.idleTicks; + } + + public void resetIdleTimer() { + this.idleTicks = 0; + } + + public void setIdle() { + this.idleTicks = Room.IDLE_CYCLES + 1; + } + + public void lookAtPoint(RoomTile location) { + if (!this.isCanRotate()) return; + + if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) { + Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.getRoom(), this, location); + Emulator.getPluginManager().fireEvent(lookAtPointEvent); + + if (lookAtPointEvent.isCancelled()) + return; + } + + if (this.statuses.containsKey(RoomUnitStatus.LAY)) { + return; + } + + if (!this.statuses.containsKey(RoomUnitStatus.SIT)) { + this.bodyRotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]); + } + + RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]); + + if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) { + this.headRotation = rotation; + } + } + + public boolean canOverrideTile(RoomTile tile) { + if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false; + + if (this.getRoom().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile))) + return true; + + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); + return this.overridableTiles.contains(tileIndex); + } + + public void addOverrideTile(RoomTile tile) { + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); + if (!this.overridableTiles.contains(tileIndex)) { + this.overridableTiles.add(tileIndex); + } + } + + public void removeOverrideTile(RoomTile tile) { + if (this.getRoom() == null || this.getRoom().getLayout() == null) return; + + int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); + this.overridableTiles.remove(tileIndex); + } + + public boolean canForcePosture() { + if (this.getRoom() == null) return false; + + RoomItem topItem = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + + return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); + } + + public RoomTile getClosestTile(List tiles) { + return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentPosition()))).orElse(null); + } + + public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { + if (this.getRoom() == null) return null; + + RoomTile baseTile = this.getRoom().getLayout().getTile(x, y); + + if (baseTile == null) return null; + + List rotations = new ArrayList<>(); + rotations.add(RoomRotation.SOUTH.getValue()); + rotations.add(RoomRotation.NORTH.getValue()); + rotations.add(RoomRotation.EAST.getValue()); + rotations.add(RoomRotation.WEST.getValue()); + + if (diagonal) { + rotations.add(RoomRotation.NORTH_EAST.getValue()); + rotations.add(RoomRotation.NORTH_WEST.getValue()); + rotations.add(RoomRotation.SOUTH_EAST.getValue()); + rotations.add(RoomRotation.SOUTH_WEST.getValue()); + } + + return this.getClosestTile( + rotations.stream() + .map(rotation -> this.getRoom().getLayout().getTileInFront(baseTile, rotation)) + .filter(t -> t != null && t.isWalkable() && (this.getCurrentPosition().equals(t) || !this.getRoom().getRoomUnitManager().hasHabbosAt(t))) + .toList() + ); + } + + public void clear() { + this.setRoom(null); + this.canWalk = true; + this.canRotate = true; + this.fastWalkEnabled = false; + this.cmdTeleportEnabled = false; + this.clearStatuses(); + this.danceType = DanceType.NONE; + this.previousEffectId = 0; + this.previousEffectEndTimestamp = -1; + this.isKicked = false; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnitType.java similarity index 73% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnitType.java index c12f7a61..024e81ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitType.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnitType.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.entities.units; import lombok.AllArgsConstructor; import lombok.Getter; @@ -6,11 +6,10 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum RoomUnitType { - USER(1), + HABBO(1), BOT(4), PET(2), UNKNOWN(3); private final int typeId; - } 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 new file mode 100644 index 00000000..b4eeb770 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomAvatar.java @@ -0,0 +1,322 @@ +package com.eu.habbo.habbohotel.rooms.entities.units.types; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; +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; +import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.users.UserIdleEvent; +import com.eu.habbo.plugin.events.users.UserTakeStepEvent; +import com.eu.habbo.threading.runnables.RoomUnitKick; +import com.eu.habbo.util.pathfinding.Rotation; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; + +import java.util.Deque; +import java.util.LinkedList; +import java.util.Map; + +@Slf4j +@Getter +@Setter +@Accessors(chain = true) +public class RoomAvatar extends RoomUnit { + private RideablePet rideablePet; + private DanceType danceType; + private int handItem; + private long handItemTimestamp; + private int effectId; + private int effectEndTimestamp; + private int previousEffectId; + private int previousEffectEndTimestamp; + + public RoomAvatar() { + super(); + + this.rideablePet = null; + this.danceType = DanceType.NONE; + this.handItem = 0; + this.handItemTimestamp = 0; + this.effectId = 0; + this.effectEndTimestamp = -1; + this.previousEffectId = 0; + this.previousEffectEndTimestamp = -1; + } + + @Override + public boolean cycle(Room room) { + try { + Habbo habboT = room.getRoomUnitManager().getHabboByRoomUnit(this); + + if (!this.isWalking() && !this.isKicked() && this.removeStatus(RoomUnitStatus.MOVE) == null && habboT != null) { + habboT.getHabboInfo().getRiding().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); + return true; + } + + if (this.removeStatus(RoomUnitStatus.SIT) != null || this.removeStatus(RoomUnitStatus.MOVE) != null || this.removeStatus(RoomUnitStatus.LAY) != null) + this.setStatusUpdateNeeded(true); + + for (Map.Entry set : this.getStatuses().entrySet()) { + if (set.getKey().isRemoveWhenWalking()) { + this.removeStatus(set.getKey()); + } + } + + if (this.getPath() == null || this.getPath().isEmpty()) { + this.setStatusUpdateNeeded(true); + return true; + } + + boolean canFastWalk = habboT == null || habboT.getHabboInfo().getRiding() == null; + + RoomTile next = this.getPath().poll(); + boolean overrideChecks = next != null && this.canOverrideTile(next); + + if (this.getPath().isEmpty()) { + this.setSitUpdate(true); + + if (next != null && next.hasUnits() && !overrideChecks) { + this.setStatusUpdateNeeded(false); + return false; + } + } + + Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); + + if (peekPath == null) peekPath = new LinkedList<>(); + + if (peekPath.size() >= 3) { + if (this.getPath().isEmpty()) { + this.setStatusUpdateNeeded(true); + return true; + } + + this.getPath().pop(); + //peekPath.pop(); //Start + peekPath.removeLast(); //End + + if (peekPath.peek() != next) { + next = peekPath.poll(); + for (int i = 0; i < peekPath.size(); i++) { + this.getPath().addFirst(peekPath.removeLast()); + } + } + } + + if (canFastWalk && this.isFastWalkEnabled() && this.getPath().size() > 1) { + next = this.getPath().poll(); + } + + if (next == null) { + this.setStatusUpdateNeeded(true); + return true; + } + + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(this); + + this.removeStatus(RoomUnitStatus.DEAD); + + if (habbo != null) { + if (this.isIdle()) { + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); + + if (!event.isCancelled() && !event.isIdle()) { + room.unIdle(habbo); + this.resetIdleTimer();; + } + } + + if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) { + Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), next); + Emulator.getPluginManager().fireEvent(e); + + if (e.isCancelled()) { + this.setStatusUpdateNeeded(true); + return true; + } + + } + } + + RoomItem item = room.getTopItemAt(next.getX(), next.getY()); + + double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); + if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + this.setRoom(room); + this.getPath().clear(); + this.findPath(); + + if (this.getPath().isEmpty()) { + this.removeStatus(RoomUnitStatus.MOVE); + this.setStatusUpdateNeeded(false); + return false; + } + next = this.getPath().pop(); + + } + + boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); + + if (canSitNextTile) { + RoomItem tallestChair = room.getTallestChair(next); + + if (tallestChair != null) + item = tallestChair; + } + + if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + this.removeStatus(RoomUnitStatus.MOVE); + this.setStatusUpdateNeeded(false); + return false; + } + + double zHeight = 0.0D; + + if(habbo != null && habbo.getHabboInfo().getRiding() != null) { + zHeight += 1.0D; + } + + RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) + roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); + + + this.incrementTilesMoved(); + + RoomRotation oldRotation = this.getBodyRotation(); + this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); + if (item != null) { + if (item != roomItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { + if (item.canWalkOn(this, room, null)) { + item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); + } else if (item instanceof ConditionalGate conditionalGate) { + this.setRotation(oldRotation); + this.decrementTilesMoved(); + this.setGoalLocation(this.getCurrentPosition()); + this.removeStatus(RoomUnitStatus.MOVE); + room.sendComposer(new UserUpdateComposer(this).compose()); + + if(this instanceof RoomHabbo) { + conditionalGate.onRejected(this, this.getRoom(), new Object[]{}); + } + + this.setStatusUpdateNeeded(false); + return false; + } + } else { + item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); + } + + zHeight += item.getZ(); + + if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { + zHeight += Item.getCurrentHeight(item); + } + } else { + zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); + } + + + this.setPreviousLocation(this.getCurrentPosition()); + + this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); + + if(habbo != null) { + RideablePet rideablePet = habbo.getHabboInfo().getRiding(); + + if(rideablePet != null) { + RoomUnit ridingUnit = rideablePet.getRoomUnit(); + + if (ridingUnit != null) { + ridingUnit.setPreviousLocationZ(this.getCurrentZ()); + this.setCurrentZ(zHeight - 1.0); + ridingUnit.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); + ridingUnit.setPreviousLocation(this.getCurrentPosition()); + ridingUnit.setGoalLocation(this.getGoalLocation()); + ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); + room.sendComposer(new UserUpdateComposer(ridingUnit).compose()); + } + } + } + + this.setCurrentZ(zHeight); + this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); + this.resetIdleTimer(); + + if(habbo != null) { + RoomItem topItem = room.getTopItemAt(next.getX(), next.getY()); + + boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); + boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); + boolean invalidated = topItem != null && topItem.invalidatesToRoomKick(); + + if (this.isCanLeaveRoomByDoor() && isAtDoor && publicRoomKicks && !invalidated) { + Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500); + } + } + + this.setStatusUpdateNeeded(false); + return false; + + } catch (Exception e) { + log.error("Caught exception", e); + this.setStatusUpdateNeeded(false); + return false; + } + } + + public RoomAvatar setHandItem(int handItem) { + this.handItem = handItem; + this.handItemTimestamp = System.currentTimeMillis(); + return this; + } + + private void handleSitStatus(RoomFloorItem topItem) { + if(!this.isCmdSitEnabled()) { + if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) { + this.removeStatus(RoomUnitStatus.SIT); + this.setStatusUpdateNeeded(true); + } else if(this.getCurrentPosition().getState() == RoomTileState.SIT && (!this.hasStatus(RoomUnitStatus.SIT))) { + this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); + this.setStatusUpdateNeeded(true); + } + } + } + + private void handleLayStatus(RoomFloorItem topItem) { + if(!this.isCmdLayEnabled()) { + if((topItem == null || !topItem.getBaseItem().allowLay()) && this.hasStatus(RoomUnitStatus.LAY)) { + this.removeStatus(RoomUnitStatus.LAY); + this.setStatusUpdateNeeded(true); + } else if(!this.hasStatus(RoomUnitStatus.LAY)) { + this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); + this.setStatusUpdateNeeded(true); + } + } + } + + @Override + public void clear() { + super.clear(); + + this.rideablePet = null; + this.danceType = DanceType.NONE; + this.handItem = 0; + this.handItemTimestamp = 0; + this.effectId = 0; + this.effectEndTimestamp = -1; + this.previousEffectId = 0; + this.previousEffectEndTimestamp = -1; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java new file mode 100644 index 00000000..ee62ecf2 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java @@ -0,0 +1,15 @@ +package com.eu.habbo.habbohotel.rooms.entities.units.types; + +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import lombok.Getter; + +@Getter +public class RoomBot extends RoomAvatar { + public RoomBot() { + super(); + } + + public RoomUnitType getRoomUnitType() { + return RoomUnitType.BOT; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java new file mode 100644 index 00000000..d5c71c0e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java @@ -0,0 +1,64 @@ +package com.eu.habbo.habbohotel.rooms.entities.units.types; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Getter +@Setter +@Accessors(chain = true) +public class RoomHabbo extends RoomAvatar { + private Room loadingRoom; + private Room previousRoom; + +// @Setter +// private boolean isKicked; + private int kickCount; + private int idleTicks; + private boolean isSleeping; +// private final HashSet overridableTiles; + + public RoomHabbo() { + super(); + +// this.isKicked = false; +// this.overridableTiles = new HashSet<>(); + } + + public boolean cycle(Room room) { + return super.cycle(room); + } + + public boolean isLoadingRoom() { + return this.loadingRoom != null; + } + + public boolean hasPreviousRoom() { + return this.previousRoom != null; + } + + public void incrementKickCount() { + this.kickCount++; + } + + public void incrementIdleTick() { + this.idleTicks++; + } + + public boolean isIdle() { + return this.idleTicks > Room.IDLE_CYCLES; + } + + public RoomUnitType getRoomUnitType() { + return RoomUnitType.HABBO; + } + + @Override + public void clear() { + super.clear(); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java new file mode 100644 index 00000000..25d079b1 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -0,0 +1,208 @@ +package com.eu.habbo.habbohotel.rooms.entities.units.types; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; +import com.eu.habbo.habbohotel.pets.Pet; +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.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; +import com.eu.habbo.util.pathfinding.Rotation; +import lombok.extern.slf4j.Slf4j; + +import java.util.Deque; +import java.util.LinkedList; +import java.util.Map; + +@Slf4j +public class RoomPet extends RoomUnit { + public RoomPet() { + super(); + } + + @Override + public boolean cycle(Room room) { + try { + Pet pet = this.getRoom().getRoomUnitManager().getPetByRoomUnit(this); + + if (this.handleRider(pet, room)) { + return this.isStatusUpdateNeeded(); + } + + if (this.removeStatus(RoomUnitStatus.SIT) != null || this.removeStatus(RoomUnitStatus.MOVE) != null || this.removeStatus(RoomUnitStatus.LAY) != null) { + this.setStatusUpdateNeeded(true); + } + + for (Map.Entry set : this.getStatuses().entrySet()) { + if (set.getKey().isRemoveWhenWalking()) { + this.removeStatus(set.getKey()); + } + } + + if (this.getPath() == null || this.getPath().isEmpty()) { + this.setStatusUpdateNeeded(true); + return true; + } + + RoomTile next = this.getPath().poll(); + boolean overrideChecks = next != null && this.canOverrideTile(next); + + if (this.getPath().isEmpty()) { + this.setSitUpdate(true); + + if (next != null && next.hasUnits() && !overrideChecks) { + this.setStatusUpdateNeeded(false); + return false; + } + } + + Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); + + if (peekPath == null) peekPath = new LinkedList<>(); + + if (peekPath.size() >= 3) { + if (this.getPath().isEmpty()) { + this.setStatusUpdateNeeded(true); + return true; + } + + this.getPath().pop(); + //peekPath.pop(); //Start + peekPath.removeLast(); //End + + if (peekPath.peek() != next) { + next = peekPath.poll(); + for (int i = 0; i < peekPath.size(); i++) { + this.getPath().addFirst(peekPath.removeLast()); + } + } + } + + if (next == null) { + this.setStatusUpdateNeeded(true); + return true; + } + + this.removeStatus(RoomUnitStatus.DEAD); + + RoomItem item = room.getTopItemAt(next.getX(), next.getY()); + + double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); + if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + this.setRoom(room); + this.getPath().clear(); + this.findPath(); + + if (this.getPath().isEmpty()) { + this.removeStatus(RoomUnitStatus.MOVE); + this.setStatusUpdateNeeded(false); + return false; + } + next = this.getPath().pop(); + + } + + boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); + + if (canSitNextTile) { + RoomItem tallestChair = room.getTallestChair(next); + + if (tallestChair != null) + item = tallestChair; + } + + if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + this.removeStatus(RoomUnitStatus.MOVE); + this.setStatusUpdateNeeded(false); + return false; + } + + double zHeight = 0.0D; + + RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) + roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); + + + this.incrementTilesMoved(); + + RoomRotation oldRotation = this.getBodyRotation(); + this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); + if (item != null) { + if (item != roomItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { + if (item.canWalkOn(this, room, null)) { + item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); + } else if (item instanceof ConditionalGate conditionalGate) { + this.setRotation(oldRotation); + this.decrementTilesMoved(); + this.setGoalLocation(this.getCurrentPosition()); + this.removeStatus(RoomUnitStatus.MOVE); + room.sendComposer(new UserUpdateComposer(this).compose()); + + this.setStatusUpdateNeeded(false); + return false; + } + } else { + item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); + } + + zHeight += item.getZ(); + + if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { + zHeight += Item.getCurrentHeight(item); + } + } else { + zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); + } + + + this.setPreviousLocation(this.getCurrentPosition()); + + this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); + + this.setCurrentZ(zHeight); + this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); + + this.setStatusUpdateNeeded(false); + return false; + } catch (Exception e) { + log.error("Caught exception", e); + return false; + } + } + + public boolean handleRider(Pet pet, Room room) { + Habbo rider = null; + + if (pet instanceof RideablePet rideablePet) { + rider = rideablePet.getRider(); + } + + if(rider == null) { + return false; + } + + // copy things from rider + if (this.hasStatus(RoomUnitStatus.MOVE) && !rider.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) { + this.removeStatus(RoomUnitStatus.MOVE); + } + + if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) { + this.setStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); + this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation()); + this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight()); + this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition()); + this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight()); + } + + return true; + } + + public RoomUnitType getRoomUnitType() { + return RoomUnitType.PET; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/units/Unit.java b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java new file mode 100644 index 00000000..04b99d71 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java @@ -0,0 +1,11 @@ +package com.eu.habbo.habbohotel.units; + +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class Unit { + private RoomUnit roomUnit; +} 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 9990c8ba..3eac30f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -8,7 +8,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.RoomUserAction; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.outgoing.generic.alerts.*; import com.eu.habbo.messages.outgoing.inventory.*; @@ -34,7 +40,9 @@ import java.util.*; import java.util.stream.Collectors; @Slf4j -public class Habbo implements Runnable { +public class Habbo extends Unit implements Runnable { + @Getter + private RoomHabbo roomUnit; @Getter private final HabboInfo habboInfo; @Getter @@ -46,9 +54,6 @@ public class Habbo implements Runnable { @Setter @Getter private GameClient client; - @Setter - @Getter - private RoomUnit roomUnit; private volatile boolean update; private volatile boolean disconnected = false; @@ -64,8 +69,7 @@ public class Habbo implements Runnable { this.messenger.loadFriends(this); this.messenger.loadFriendRequests(this); - this.roomUnit = new RoomUnit(); - this.roomUnit.setRoomUnitType(RoomUnitType.USER); + this.roomUnit = new RoomHabbo(); this.update = false; } @@ -143,11 +147,11 @@ public class Habbo implements Runnable { this.disconnecting = true; try { - if (this.getHabboInfo().getCurrentRoom() != null) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(this, this.getHabboInfo().getCurrentRoom()); + if (this.getRoomUnit().getRoom() != null) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(this, this.getRoomUnit().getRoom()); } if (this.getHabboInfo().getRoomQueueId() > 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getHabboInfo().getRoomQueueId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getHabboInfo().getRoomQueueId()); if (room != null) { room.removeFromQueue(this); @@ -280,7 +284,7 @@ public class Habbo implements Runnable { public void talk(String message, RoomChatMessageBubbles bubble) { if (this.getRoomUnit().isInRoom()) { - this.getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); + this.getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); } } @@ -292,7 +296,7 @@ public class Habbo implements Runnable { public void shout(String message, RoomChatMessageBubbles bubble) { if (this.getRoomUnit().isInRoom()) { - this.getHabboInfo().getCurrentRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); + this.getRoomUnit().getRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose()); } } @@ -321,21 +325,21 @@ public class Habbo implements Runnable { } - public void addFurniture(HabboItem item) { + public void addFurniture(RoomItem item) { this.inventory.getItemsComponent().addItem(item); this.client.sendResponse(new UnseenItemsComposer(item)); this.client.sendResponse(new FurniListInvalidateComposer()); } - public void addFurniture(THashSet items) { + public void addFurniture(THashSet items) { this.inventory.getItemsComponent().addItems(items); this.client.sendResponse(new UnseenItemsComposer(items)); this.client.sendResponse(new FurniListInvalidateComposer()); } - public void removeFurniture(HabboItem item) { + public void removeFurniture(RoomItem item) { this.inventory.getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getId())); } @@ -355,7 +359,7 @@ public class Habbo implements Runnable { public void deleteBot(Bot bot) { this.removeBot(bot); - bot.getRoom().removeBot(bot); + bot.getRoom().getRoomUnitManager().removeBot(bot); Emulator.getGameEnvironment().getBotManager().deleteBot(bot); } @@ -411,7 +415,7 @@ public class Habbo implements Runnable { this.client.sendResponse(new FloodControlMessageComposer(remaining)); this.client.sendResponse(new RemainingMutePeriodComposer(remaining)); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null && !isFlood) { room.sendComposer(new IgnoreResultMessageComposer(this, IgnoreResultMessageComposer.MUTED).compose()); } @@ -421,7 +425,7 @@ public class Habbo implements Runnable { public void unMute() { this.habboStats.unMute(); this.client.sendResponse(new FloodControlMessageComposer(3)); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { room.sendComposer(new IgnoreResultMessageComposer(this, IgnoreResultMessageComposer.UNIGNORED).compose()); } @@ -457,14 +461,14 @@ public class Habbo implements Runnable { target.getHabboStats().setRespectPointsReceived(target.getHabboStats().getRespectPointsReceived()+1); this.client.getHabbo().getHabboStats().setRespectPointsGiven(this.client.getHabbo().getHabboStats().getRespectPointsGiven()+1); this.client.getHabbo().getHabboStats().setRespectPointsToGive(this.client.getHabbo().getHabboStats().getRespectPointsToGive()-1); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRespectComposer(target).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ExpressionMessageComposer(this.client.getHabbo().getRoomUnit(), RoomUserAction.THUMB_UP).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RoomUserRespectComposer(target).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new ExpressionMessageComposer(this.client.getHabbo().getRoomUnit(), RoomUserAction.THUMB_UP).compose()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven")); AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned")); - this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().dance(this.client.getHabbo().getRoomUnit(), DanceType.NONE); + this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().getRoom().dance(this.client.getHabbo().getRoomUnit(), DanceType.NONE); } } 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 43aa908d..a27e1e0f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -12,7 +12,7 @@ import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import gnu.trove.map.hash.TIntIntHashMap; import lombok.Getter; @@ -59,11 +59,6 @@ public class HabboInfo implements Runnable { @Setter private boolean online; @Setter - @Accessors(chain = true) - private int loadingRoom; - @Setter - private Room currentRoom; - @Setter private int roomQueueId; @Setter private RideablePet riding; @@ -112,7 +107,6 @@ public class HabboInfo implements Runnable { this.lastOnline = set.getInt("last_online"); this.machineID = set.getString("machine_id"); this.online = false; - this.currentRoom = null; } catch (SQLException e) { log.error("Caught SQL exception", e); } @@ -304,15 +298,16 @@ public class HabboInfo implements Runnable { this.run(); } - public void dismountPet() { - this.dismountPet(false); + public void dismountPet(Room room) { + this.dismountPet(false, room); } - public void dismountPet(boolean isRemoving) { + public void dismountPet(boolean isRemoving, Room room) { if (this.getRiding() == null) return; - Habbo habbo = this.getCurrentRoom().getHabbo(this.getId()); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(this.getId()); + if (habbo == null) return; @@ -322,7 +317,6 @@ public class HabboInfo implements Runnable { riding.setTask(PetTasks.FREE); this.setRiding(null); - Room room = this.getCurrentRoom(); if (room != null) room.giveEffect(habbo, 0, -1); @@ -330,17 +324,17 @@ public class HabboInfo implements Runnable { if (roomUnit == null) return; - roomUnit.setZ(riding.getRoomUnit().getZ()); - roomUnit.setPreviousLocationZ(riding.getRoomUnit().getZ()); + roomUnit.setCurrentZ(riding.getRoomUnit().getCurrentZ()); + roomUnit.setPreviousLocationZ(riding.getRoomUnit().getCurrentZ()); roomUnit.stopWalking(); if (room != null) room.sendComposer(new UserUpdateComposer(roomUnit).compose()); - List availableTiles = isRemoving ? new ArrayList<>() : this.getCurrentRoom().getLayout().getWalkableTilesAround(roomUnit.getCurrentLocation()); + List availableTiles = isRemoving ? new ArrayList<>() : room.getLayout().getWalkableTilesAround(roomUnit.getCurrentPosition()); - RoomTile tile = availableTiles.isEmpty() ? roomUnit.getCurrentLocation() : availableTiles.get(0); + RoomTile tile = availableTiles.isEmpty() ? roomUnit.getCurrentPosition() : availableTiles.get(0); roomUnit.setGoalLocation(tile); - roomUnit.statusUpdate(true); + roomUnit.setStatusUpdateNeeded(true); } public boolean isInGame() { diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 3ac89048..6f4f4d91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -139,8 +139,8 @@ public class EffectsComponent { this.activatedEffect = effectId; - if (this.habbo.getHabboInfo().getCurrentRoom() != null) { - this.habbo.getHabboInfo().getCurrentRoom().giveEffect(this.habbo, effectId, effect.remainingTime()); + if (this.habbo.getRoomUnit().getRoom() != null) { + this.habbo.getRoomUnit().getRoom().giveEffect(this.habbo, effectId, effect.remainingTime()); } this.habbo.getClient().sendResponse(new AvatarEffectActivatedMessageComposer(effect)); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index f9597b16..5b82df81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.plugin.events.inventory.InventoryItemAddedEvent; import com.eu.habbo.plugin.events.inventory.InventoryItemRemovedEvent; import com.eu.habbo.plugin.events.inventory.InventoryItemsAddedEvent; @@ -27,7 +27,7 @@ import java.util.NoSuchElementException; public class ItemsComponent { @Getter - private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final HabboInventory inventory; @@ -36,8 +36,8 @@ public class ItemsComponent { this.items.putAll(loadItems(habbo)); } - public static THashMap loadItems(Habbo habbo) { - THashMap itemsList = new THashMap<>(); + public static THashMap loadItems(Habbo habbo) { + THashMap itemsList = new THashMap<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, 0); @@ -45,7 +45,7 @@ public class ItemsComponent { try (ResultSet set = statement.executeQuery()) { while (set.next()) { try { - HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); + RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); if (item != null) { itemsList.put(set.getInt("id"), item); @@ -64,7 +64,7 @@ public class ItemsComponent { return itemsList; } - public void addItem(HabboItem item) { + public void addItem(RoomItem item) { if (item == null) { return; } @@ -79,14 +79,14 @@ public class ItemsComponent { } } - public void addItems(THashSet items) { + public void addItems(THashSet items) { InventoryItemsAddedEvent event = new InventoryItemsAddedEvent(this.inventory, items); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; } synchronized (this.items) { - for (HabboItem item : event.items) { + for (RoomItem item : event.items) { if (item == null) { continue; } @@ -96,31 +96,31 @@ public class ItemsComponent { } } - public HabboItem getHabboItem(int itemId) { + public RoomItem getHabboItem(int itemId) { return this.items.get(Math.abs(itemId)); } - public HabboItem getAndRemoveHabboItem(final Item item) { - final HabboItem[] habboItem = {null}; + public RoomItem getAndRemoveHabboItem(final Item item) { + final RoomItem[] roomItem = {null}; synchronized (this.items) { this.items.forEachValue(object -> { if (object.getBaseItem() == item) { - habboItem[0] = object; + roomItem[0] = object; return false; } return true; }); } - this.removeHabboItem(habboItem[0]); - return habboItem[0]; + this.removeHabboItem(roomItem[0]); + return roomItem[0]; } public void removeHabboItem(int itemId) { this.items.remove(itemId); } - public void removeHabboItem(HabboItem item) { + public void removeHabboItem(RoomItem item) { InventoryItemRemovedEvent event = new InventoryItemRemovedEvent(this.inventory, item); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; @@ -131,8 +131,8 @@ public class ItemsComponent { } } - public THashSet getItemsAsValueCollection() { - THashSet items = new THashSet<>(); + public THashSet getItemsAsValueCollection() { + THashSet items = new THashSet<>(); items.addAll(this.items.valueCollection()); return items; @@ -144,7 +144,7 @@ public class ItemsComponent { public void dispose() { synchronized (this.items) { - TIntObjectIterator items = this.items.iterator(); + TIntObjectIterator items = this.items.iterator(); if (items == null) { log.error("Items is NULL!"); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java index f4a93859..89e48402 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java @@ -164,8 +164,8 @@ public class SubscriptionHabboClub extends Subscription { habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); } - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java index c4844c49..d03fd1f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredChangeDirectionSetting.java @@ -1,6 +1,6 @@ package com.eu.habbo.habbohotel.wired; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -10,6 +10,6 @@ import lombok.Setter; public class WiredChangeDirectionSetting { private final int itemId; private int rotation; - @Setter private RoomUserRotation direction; + @Setter private RoomRotation direction; } 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 7fcdcb29..87aa305e 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.RoomUnit; +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.users.HabboItem; +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; @@ -153,7 +153,7 @@ public class WiredHandler { } long millis = System.currentTimeMillis(); - int roomUnitId = roomUnit != null ? roomUnit.getId() : -1; + int roomUnitId = roomUnit != null ? roomUnit.getVirtualId() : -1; if (((Emulator.getConfig().getBoolean("wired.custom.enabled", false) && (trigger.canExecute(millis) || roomUnitId > -1) && trigger.userCanExecute(roomUnitId, millis)) || (!Emulator.getConfig().getBoolean("wired.custom.enabled", false) && trigger.canExecute(millis))) && trigger.execute(roomUnit, room, stuff)) { //DUNNO IF YOU HAVE TO SET EXTRADATA TO 1 IN HERE (In case of Repeaters) trigger.activateBox(room, roomUnit, millis); @@ -224,7 +224,7 @@ public class WiredHandler { private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis) { boolean executed = false; - if (effect != null && (effect.canExecute(millis) || (roomUnit != null && effect.requiresTriggeringUser() && Emulator.getConfig().getBoolean("wired.custom.enabled", false) && effect.userCanExecute(roomUnit.getId(), millis)))) { + if (effect != null && (effect.canExecute(millis) || (roomUnit != null && effect.requiresTriggeringUser() && Emulator.getConfig().getBoolean("wired.custom.enabled", false) && effect.userCanExecute(roomUnit.getVirtualId(), millis)))) { executed = true; if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { Emulator.getThreading().run(() -> { @@ -256,10 +256,10 @@ public class WiredHandler { public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { for (RoomTile tile : tiles) { if (room != null) { - THashSet items = room.getItemsAt(tile); + THashSet items = room.getItemsAt(tile); long millis = room.getCycleTimestamp(); - for (final HabboItem item : items) { + for (final RoomItem item : items) { if (item instanceof InteractionWiredEffect && !(item instanceof WiredEffectTriggerStacks)) { triggerEffect((InteractionWiredEffect) item, roomUnit, room, stuff, millis); ((InteractionWiredEffect) item).setCooldown(millis); @@ -340,7 +340,7 @@ public class WiredHandler { } else if (rewardReceived.getType().equalsIgnoreCase("furni")) { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(Integer.parseInt(rewardReceived.getValue())); if (baseItem != null) { - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), baseItem, 0, 0, ""); + RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), baseItem, 0, 0, ""); if (item != null) { habbo.getClient().sendResponse(new UnseenItemsComposer(item)); diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java index 7b60b22c..00a70218 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.wired.highscores; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import java.time.LocalDateTime; @@ -19,8 +19,8 @@ public class WiredHighscoreMidnightUpdater implements Runnable { for (Room room : rooms) { if (room == null || room.getRoomSpecialTypes() == null) continue; - THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class); - for (HabboItem item : items) { + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class); + for (RoomItem item : items) { ((InteractionWiredHighscore) item).reloadData(); room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java index 45dfd6b6..35bc2470 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java @@ -19,7 +19,7 @@ public class AmbassadorAlertEvent extends MessageHandler { int userId = this.packet.readInt(); - Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); + Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboById(userId); if (habbo == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java index 4f3f7304..7fbd9fc6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java @@ -15,8 +15,8 @@ public class FollowFriendEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); if (habbo != null) { - if (habbo.getHabboInfo().getCurrentRoom() != null) { - this.client.sendResponse(new RoomForwardMessageComposer(habbo.getHabboInfo().getCurrentRoom().getId())); + if (habbo.getRoomUnit().getRoom() != null) { + this.client.sendResponse(new RoomForwardMessageComposer(habbo.getRoomUnit().getRoom().getRoomInfo().getId())); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java index a0de9495..91336f57 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.camera; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPurchaseOKMessageComposer; import com.eu.habbo.messages.outgoing.catalog.NotEnoughBalanceMessageComposer; @@ -32,11 +32,11 @@ public class PurchasePhotoEvent extends MessageHandler { if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) return; - if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) { + if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) { return; } - HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); + RoomItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); if (photoItem != null) { photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + "")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java index 1207db74..87b4b354 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java @@ -21,12 +21,12 @@ public class RenderRoomEvent extends MessageHandler { byte[] data = this.packet.getBuffer().readBytes(this.packet.getBuffer().readableBytes()).array(); String content = new String(ZIP.inflate(data)); - CameraRenderImageComposer composer = new CameraRenderImageComposer(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getBackgroundTonerColor().getRGB(), 320, 320, content); + CameraRenderImageComposer composer = new CameraRenderImageComposer(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getRoomUnit().getRoom().getBackgroundTonerColor().getRGB(), 320, 320, content); this.client.getHabbo().getHabboInfo().setPhotoJSON(Emulator.getConfig().getValue("camera.extradata").replace("%timestamp%", composer.timestamp + "")); this.client.getHabbo().getHabboInfo().setPhotoTimestamp(composer.timestamp); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().setPhotoRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getHabboInfo().setPhotoRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); } Emulator.getCameraClient().sendMessage(composer); diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java index 56931182..f95d53bd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java @@ -16,7 +16,7 @@ public class RenderRoomThumbnailEvent extends MessageHandler { return; } - if (!this.client.getHabbo().getHabboInfo().getCurrentRoom().isOwner(this.client.getHabbo())) + if (!this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().isRoomOwner(this.client.getHabbo())) return; if (CameraClient.isLoggedIn) { @@ -24,7 +24,7 @@ public class RenderRoomThumbnailEvent extends MessageHandler { byte[] data = this.packet.getBuffer().readBytes(this.packet.getBuffer().readableBytes()).array(); String content = new String(ZIP.inflate(data)); - CameraRenderImageComposer composer = new CameraRenderImageComposer(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getBackgroundTonerColor().getRGB(), 110, 110, content); + CameraRenderImageComposer composer = new CameraRenderImageComposer(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getRoomUnit().getRoom().getBackgroundTonerColor().getRGB(), 110, 110, content); this.client.getHabbo().getHabboInfo().setPhotoJSON(Emulator.getConfig().getValue("camera.extradata").replace("%timestamp%", composer.timestamp + "")); this.client.getHabbo().getHabboInfo().setPhotoTimestamp(composer.timestamp); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java index 8d9a156a..830d410b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java @@ -13,7 +13,7 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; @@ -192,7 +192,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { limitedStack = limitedConfiguration.getTotalSet(); } - THashSet itemsList = new THashSet<>(); + THashSet itemsList = new THashSet<>(); boolean badgeFound = false; for (Item baseItem : item.getBaseItems()) { @@ -271,13 +271,13 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { } if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) { - HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + RoomItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + RoomItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId()); itemsList.add(teleportOne); itemsList.add(teleportTwo); } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) { - HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData); + RoomItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData); Emulator.getGameEnvironment().getItemManager().insertHopper(hopper); @@ -298,8 +298,8 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId); itemsList.add(habboItem); } else { - HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - itemsList.add(habboItem); + RoomItem roomItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + itemsList.add(roomItem); } } } else { @@ -312,13 +312,13 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { StringBuilder giftData = new StringBuilder(itemsList.size() + "\t"); - for (HabboItem i : itemsList) { + for (RoomItem i : itemsList) { giftData.append(i.getId()).append("\t"); } giftData.append(color).append("\t").append(ribbonId).append("\t").append(showName ? "1" : "0").append("\t").append(message.replace("\t", "")).append("\t").append(this.client.getHabbo().getHabboInfo().getUsername()).append("\t").append(this.client.getHabbo().getHabboInfo().getLook()); - HabboItem gift = Emulator.getGameEnvironment().getItemManager().createGift(username, giftItem, giftData.toString(), 0, 0); + RoomItem gift = Emulator.getGameEnvironment().getItemManager().createGift(username, giftItem, giftData.toString(), 0, 0); if (gift == null) { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java index 56495b1a..53a3d739 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/MakeOfferEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.catalog.marketplace; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.habbohotel.modtool.ScripterManager; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceMakeOfferResult; @@ -24,7 +24,7 @@ public class MakeOfferEvent extends MessageHandler { int unknown = this.packet.readInt(); int itemId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item != null) { if (!item.getBaseItem().allowMarketplace()) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index 262e8530..932d65fe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -17,13 +17,13 @@ import com.eu.habbo.threading.runnables.OpenGift; public class PresentOpenEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - HabboItem item = room.getHabboItem(this.packet.readInt()); + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + RoomItem item = room.getHabboItem(this.packet.readInt()); if (item == null) return; @@ -39,7 +39,7 @@ public class PresentOpenEvent extends MessageHandler { if (item.getExtradata().length() == 0) { this.client.sendResponse(new WhisperMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("error.recycler.box.empty"), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.BOT))); } else { - HabboItem reward = Emulator.getGameEnvironment().getItemManager().handleOpenRecycleBox(this.client.getHabbo(), item); + RoomItem reward = Emulator.getGameEnvironment().getItemManager().handleOpenRecycleBox(this.client.getHabbo(), item); if (reward != null) { this.client.getHabbo().getInventory().getItemsComponent().addItem(reward); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java index 99796945..c08a44e2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/RecycleItemsEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.catalog.recycler; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.ItemManager; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.catalog.RecyclerFinishedComposer; @@ -24,13 +24,13 @@ public class RecycleItemsEvent extends MessageHandler { } if (Emulator.getGameEnvironment().getCatalogManager().ecotronItem != null && ItemManager.RECYCLER_ENABLED) { - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); int count = this.packet.readInt(); if (count < Emulator.getConfig().getInt("recycler.value", 8)) return; for (int i = 0; i < count; i++) { - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); if (item == null) return; @@ -41,7 +41,7 @@ public class RecycleItemsEvent extends MessageHandler { } if (items.size() == count) { - for (HabboItem item : items) { + for (RoomItem item : items) { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getGiftAdjustedId())); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -51,7 +51,7 @@ public class RecycleItemsEvent extends MessageHandler { return; } - HabboItem reward = Emulator.getGameEnvironment().getItemManager().handleRecycle(this.client.getHabbo(), Emulator.getGameEnvironment().getCatalogManager().getRandomRecyclerPrize().getId() + ""); + RoomItem reward = Emulator.getGameEnvironment().getItemManager().handleRecycle(this.client.getHabbo(), Emulator.getGameEnvironment().getCatalogManager().getRandomRecyclerPrize().getId() + ""); if (reward == null) { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java index 152f88ca..f56aaa20 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.crafting.CraftingAltar; import com.eu.habbo.habbohotel.crafting.CraftingRecipe; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.LimitedEditionSoldOutComposer; import com.eu.habbo.messages.outgoing.crafting.CraftingResultComposer; @@ -21,7 +21,7 @@ public class CraftEvent extends MessageHandler { @Override public void handle() { int craftingTable = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(craftingTable); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(craftingTable); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); CraftingRecipe recipe = altar.getRecipe(this.packet.readString()); @@ -31,20 +31,20 @@ public class CraftEvent extends MessageHandler { return; } - TIntObjectHashMap toRemove = new TIntObjectHashMap<>(); + TIntObjectHashMap toRemove = new TIntObjectHashMap<>(); for (Map.Entry set : recipe.getIngredients().entrySet()) { for (int i = 0; i < set.getValue(); i++) { - HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getAndRemoveHabboItem(set.getKey()); + RoomItem roomItem = this.client.getHabbo().getInventory().getItemsComponent().getAndRemoveHabboItem(set.getKey()); - if (habboItem == null) { + if (roomItem == null) { return; } - toRemove.put(habboItem.getId(), habboItem); + toRemove.put(roomItem.getId(), roomItem); } } - HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); + RoomItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); if (rewardItem != null) { if (recipe.isLimited()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java index 68ac6b93..d20db53d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.crafting.CraftingAltar; import com.eu.habbo.habbohotel.crafting.CraftingRecipe; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.LimitedEditionSoldOutComposer; import com.eu.habbo.messages.outgoing.crafting.CraftingResultComposer; @@ -25,30 +25,30 @@ public class CraftSecretEvent extends MessageHandler { int altarId = this.packet.readInt(); int count = this.packet.readInt(); - HabboItem craftingAltar = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(altarId); + RoomItem craftingAltar = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(altarId); if (craftingAltar != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(craftingAltar.getBaseItem()); if (altar != null) { - Set habboItems = new THashSet<>(); + Set roomItems = new THashSet<>(); Map items = new THashMap<>(); for (int i = 0; i < count; i++) { - HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); + RoomItem roomItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if (habboItem == null) { + if (roomItem == null) { this.client.sendResponse(new CraftingResultComposer(null)); return; } - habboItems.add(habboItem); + roomItems.add(roomItem); - if (!items.containsKey(habboItem.getBaseItem())) { - items.put(habboItem.getBaseItem(), 0); + if (!items.containsKey(roomItem.getBaseItem())) { + items.put(roomItem.getBaseItem(), 0); } - items.put(habboItem.getBaseItem(), items.get(habboItem.getBaseItem()) + 1); + items.put(roomItem.getBaseItem(), items.get(roomItem.getBaseItem()) + 1); } CraftingRecipe recipe = altar.getRecipe(items); @@ -59,7 +59,7 @@ public class CraftSecretEvent extends MessageHandler { return; } - HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); + RoomItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), recipe.getReward(), 0, 0, ""); if (rewardItem != null) { if (recipe.isLimited()) { @@ -77,7 +77,7 @@ public class CraftSecretEvent extends MessageHandler { } this.client.getHabbo().getInventory().getItemsComponent().addItem(rewardItem); this.client.sendResponse(new UnseenItemsComposer(rewardItem)); - for (HabboItem item : habboItems) { + for (RoomItem item : roomItems) { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getGiftAdjustedId())); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java index 8f7e5f0a..a87b6e17 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.crafting; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.crafting.CraftingAltar; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.crafting.CraftableProductsComposer; @@ -10,7 +10,7 @@ public class GetCraftingRecipeEvent extends MessageHandler { @Override public void handle() { int itemId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java index d2ce560b..ecd3605f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.crafting.CraftingAltar; import com.eu.habbo.habbohotel.crafting.CraftingRecipe; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.crafting.CraftingRecipesAvailableComposer; import gnu.trove.map.hash.THashMap; @@ -16,7 +16,7 @@ public class GetCraftingRecipesAvailableEvent extends MessageHandler { public void handle() { int altarId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(altarId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(altarId); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); @@ -25,14 +25,14 @@ public class GetCraftingRecipesAvailableEvent extends MessageHandler { int count = this.packet.readInt(); for (int i = 0; i < count; i++) { - HabboItem habboItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); + RoomItem roomItem = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); - if (habboItem != null) { - if (!items.containsKey(habboItem.getBaseItem())) { - items.put(habboItem.getBaseItem(), 0); + if (roomItem != null) { + if (!items.containsKey(roomItem.getBaseItem())) { + items.put(roomItem.getBaseItem(), 0); } - items.put(habboItem.getBaseItem(), items.get(habboItem.getBaseItem()) + 1); + items.put(roomItem.getBaseItem(), items.get(roomItem.getBaseItem()) + 1); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetOccupiedTilesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetOccupiedTilesEvent.java index 4bc3e64a..9330f50a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetOccupiedTilesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetOccupiedTilesEvent.java @@ -6,9 +6,9 @@ import com.eu.habbo.messages.outgoing.floorplaneditor.RoomOccupiedTilesMessageCo public class GetOccupiedTilesEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - this.client.sendResponse(new RoomOccupiedTilesMessageComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom())); + this.client.sendResponse(new RoomOccupiedTilesMessageComposer(this.client.getHabbo().getRoomUnit().getRoom())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetRoomEntryTileEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetRoomEntryTileEvent.java index 4d5c3f53..96144dbf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetRoomEntryTileEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/GetRoomEntryTileEvent.java @@ -7,10 +7,10 @@ import com.eu.habbo.messages.outgoing.rooms.RoomFloorThicknessUpdatedComposer; public class GetRoomEntryTileEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - this.client.sendResponse(new RoomEntryTileMessageComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom())); - this.client.sendResponse(new RoomFloorThicknessUpdatedComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom())); + this.client.sendResponse(new RoomEntryTileMessageComposer(this.client.getHabbo().getRoomUnit().getRoom())); + this.client.sendResponse(new RoomFloorThicknessUpdatedComposer(this.client.getHabbo().getRoomUnit().getRoom())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index a6727ac1..bf1ead0a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -28,12 +28,12 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { return; } - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { StringJoiner errors = new StringJoiner("
"); String map = this.packet.readString(); map = map.replace("X", "x"); @@ -165,18 +165,18 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { } if (layout != null) { - room.setHasCustomLayout(true); + room.getRoomInfo().setModelOverridden(true); room.setNeedsUpdate(true); room.setLayout(layout); - room.setWallSize(wallSize); - room.setFloorSize(floorSize); - room.setWallHeight(wallHeight); + room.getRoomInfo().setWallThickness(wallSize); + room.getRoomInfo().setFloorThickness(floorSize); + room.getRoomInfo().setWallHeight(wallHeight); room.save(); - Collection habbos = new ArrayList<>(room.getUserCount()); - habbos.addAll(room.getHabbos()); + Collection habbos = new ArrayList<>(room.getRoomUnitManager().getRoomHabbosCount()); + habbos.addAll(room.getRoomUnitManager().getRoomHabbos()); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); - room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); - ServerMessage message = new RoomForwardMessageComposer(room.getId()).compose(); + room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); + ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); for (Habbo habbo : habbos) { habbo.getClient().sendResponse(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java index 82d9cab3..9bef5cd0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java @@ -17,13 +17,13 @@ public class FindNewFriendsEvent extends MessageHandler { Collections.shuffle(roomCategories); for (RoomCategory category : roomCategories) { - List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(category.getId()); + List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRoomsByCategoryId(category.getId()); if (!rooms.isEmpty()) { Room room = rooms.get(0); - if (room.getUserCount() > 0) { - this.client.sendResponse(new RoomForwardMessageComposer(room.getId())); + if (room.getRoomUnitManager().getRoomHabbosCount() > 0) { + this.client.sendResponse(new RoomForwardMessageComposer(room.getRoomInfo().getId())); return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java index fc7737b1..ab51be7f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java @@ -35,13 +35,13 @@ public class VisitUserEvent extends MessageHandler { return; } - if (habbo.getHabboInfo().getCurrentRoom() == null) { + if (habbo.getRoomUnit().getRoom() == null) { this.client.sendResponse(new FollowFriendFailedComposer(FollowFriendFailedComposer.FRIEND_NOT_IN_ROOM)); return; } - if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { - this.client.sendResponse(new RoomForwardMessageComposer(habbo.getHabboInfo().getCurrentRoom().getId())); + if (habbo.getRoomUnit().getRoom() != this.client.getHabbo().getRoomUnit().getRoom()) { + this.client.sendResponse(new RoomForwardMessageComposer(habbo.getRoomUnit().getRoom().getRoomInfo().getId())); } else { this.client.sendResponse(new WhisperMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("stalk.failed.same.room").replace("%user%", habbo.getHabboInfo().getUsername()), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionGetRequesterRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionGetRequesterRoomEvent.java index 4302617f..9443eda8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionGetRequesterRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionGetRequesterRoomEvent.java @@ -11,7 +11,7 @@ public class GuideSessionGetRequesterRoomEvent extends MessageHandler { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHelper(this.client.getHabbo()); if (tour != null) { - this.client.sendResponse(new GuideSessionRequesterRoomMessageComposer(tour.getNoob().getHabboInfo().getCurrentRoom())); + this.client.sendResponse(new GuideSessionRequesterRoomMessageComposer(tour.getNoob().getRoomUnit().getRoom())); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionInviteRequesterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionInviteRequesterEvent.java index 350577a9..d3427215 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionInviteRequesterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionInviteRequesterEvent.java @@ -12,7 +12,7 @@ public class GuideSessionInviteRequesterEvent extends MessageHandler { GuideTour tour = Emulator.getGameEnvironment().getGuideManager().getGuideTourByHelper(this.client.getHabbo()); if (tour != null) { - ServerMessage message = new GuideSessionInvitedToGuideRoomMessageComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom()).compose(); + ServerMessage message = new GuideSessionInvitedToGuideRoomMessageComposer(this.client.getHabbo().getRoomUnit().getRoom()).compose(); tour.getNoob().getClient().sendResponse(message); tour.getHelper().getClient().sendResponse(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java index a8c6faa6..73804bdd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java @@ -29,9 +29,11 @@ public class AddAdminRightsToMemberEvent extends MessageHandler { return; if (habbo != null) { - Room room = habbo.getHabboInfo().getCurrentRoom(); - if (room != null && room.getGuildId() == guildId) { - room.refreshRightsForHabbo(habbo); + Room room = habbo.getRoomUnit().getRoom(); + if (room != null) { + if (room.getRoomInfo().getGuild().getId() == guildId) { + room.refreshRightsForHabbo(habbo); + } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java index ff32b0d2..cf4b6fd2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java @@ -56,9 +56,11 @@ public class ApproveMembershipRequestEvent extends MessageHandler { guild.increaseMemberCount(); this.client.sendResponse(new GuildMembershipRejectedMessageComposer(guild, userId)); - if (habbo != null && userInfo.isOnline() && userInfo.getCurrentRoom() != null && userInfo.getCurrentRoom().getGuildId() == guildId) { - habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); - userInfo.getCurrentRoom().refreshRightsForHabbo(habbo); + if (habbo != null && userInfo.isOnline() && habbo.getRoomUnit().getRoom() != null) { + if (habbo.getRoomUnit().getRoom().getRoomInfo().getGuild().getId() == guildId) { + habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); + habbo.getRoomUnit().getRoom().refreshRightsForHabbo(habbo); + } } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java index 26945507..ea3f508f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java @@ -43,16 +43,16 @@ public class CreateGuildEvent extends GuildBadgeEvent { int roomId = this.packet.readInt(); - Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room r = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (r != null) { - if (r.hasGuild()) { + if (r.getRoomInfo().hasGuild()) { this.client.sendResponse(new GuildEditFailedMessageComposer(GuildEditFailedMessageComposer.ROOM_ALREADY_IN_USE)); return; } - if (r.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { - if (r.getGuildId() == 0) { + if (r.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { + if (r.getRoomInfo().getGuild().getId() == 0) { int colorOne = this.packet.readInt(); int colorTwo = this.packet.readInt(); @@ -60,9 +60,9 @@ public class CreateGuildEvent extends GuildBadgeEvent { StringBuilder badge = createBadge(count); - Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge.toString(), colorOne, colorTwo); + Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getRoomInfo().getName(), name, description, badge.toString(), colorOne, colorTwo); - r.setGuildId(guild.getId()); + r.getRoomInfo().setGuild(guild); r.removeAllRights(); r.setNeedsUpdate(true); @@ -72,7 +72,7 @@ public class CreateGuildEvent extends GuildBadgeEvent { this.client.sendResponse(new PurchaseOKMessageComposer()); this.client.sendResponse(new GuildCreatedMessageComposer(guild)); - for (Habbo habbo : r.getHabbos()) { + for (Habbo habbo : r.getRoomUnitManager().getRoomHabbos()) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, null)); } r.refreshGuild(guild); @@ -82,7 +82,7 @@ public class CreateGuildEvent extends GuildBadgeEvent { Emulator.getGameEnvironment().getGuildManager().addGuild(guild); } } else { - String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName())); + String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getRoomInfo().getName().replace("%owner%", r.getRoomInfo().getOwnerInfo().getUsername())); ScripterManager.scripterDetected(this.client, message); log.info(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java index 8e36cedf..d2637bfb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java @@ -27,17 +27,17 @@ public class DeactivateGuildEvent extends MessageHandler { for (GuildMember member : members) { Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(member.getUserId()); if (habbo != null) - if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) - habbo.getHabboInfo().getCurrentRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(habbo.getRoomUnit(), null).compose()); + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit() != null) + habbo.getRoomUnit().getRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(habbo.getRoomUnit(), null).compose()); } Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo())); - Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new HabboGroupDeactivatedMessageComposer(guildId).compose()); + Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()).sendComposer(new HabboGroupDeactivatedMessageComposer(guildId).compose()); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - if (guild.getRoomId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) { - this.client.sendResponse(new GetGuestRoomResultComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom(), this.client.getHabbo(), false, false)); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + if (guild.getRoomId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()) { + this.client.sendResponse(new GetGuestRoomResultComposer(this.client.getHabbo().getRoomUnit().getRoom(), this.client.getHabbo(), false, false)); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java index de87760d..81d23d15 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeselectFavouriteHabboGroupEvent.java @@ -21,8 +21,8 @@ public class DeselectFavouriteHabboGroupEvent extends MessageHandler { this.client.getHabbo().getHabboStats().setGuild(0); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(this.client.getHabbo().getRoomUnit(), null).compose()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null && guild != null) { + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(this.client.getHabbo().getRoomUnit(), null).compose()); } this.client.sendResponse(new ExtendedProfileMessageComposer(this.client.getHabbo(), this.client)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java index 94ca7636..0c605d43 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildCreationInfoEvent.java @@ -16,7 +16,7 @@ public class GetGuildCreationInfoEvent extends MessageHandler { THashSet roomList = new THashSet<>(); for (Room room : rooms) { - if (room.getGuildId() == 0) + if (room.getRoomInfo().getGuild().getId() == 0) roomList.add(room); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java index 7eeb9b4f..6917a1f8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildFurniContextMenuInfoMessageComposer; @@ -12,8 +12,8 @@ public class GetGuildFurniContextMenuInfoEvent extends MessageHandler { int itemId = this.packet.readInt(); int guildId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (item != null && guild != null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java index 472001bb..9fb09b0a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java @@ -20,7 +20,7 @@ public class GetMemberGuildItemCountEvent extends MessageHandler { if (guild == null) return; GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN))) || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); int count = 0; if (room != null) { count = room.getUserFurniCount(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java index a01526fe..1563de2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java @@ -29,9 +29,9 @@ public class JoinHabboGroupEvent extends MessageHandler { Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, 0, false); this.client.sendResponse(new HabboGroupDetailsMessageComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()))); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null || room.getGuildId() != guildId) + if (room == null || room.getRoomInfo().getGuild().getId() != guildId) return; room.refreshRightsForHabbo(this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java index ff80c26d..584ae61f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java @@ -38,7 +38,7 @@ public class KickMemberEvent extends MessageHandler { this.client.sendResponse(new GuildMembershipRejectedMessageComposer(guild, userId)); } - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); if (habbo != null) { habbo.getHabboStats().removeGuild(guild.getId()); @@ -46,9 +46,9 @@ public class KickMemberEvent extends MessageHandler { habbo.getHabboStats().setGuild(0); if (room != null) { - if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) - habbo.getHabboInfo().getCurrentRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(habbo.getRoomUnit(), null).compose()); - if (habbo.getHabboInfo().getCurrentRoom() == room) + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit() != null) + habbo.getRoomUnit().getRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(habbo.getRoomUnit(), null).compose()); + if (habbo.getRoomUnit().getRoom() == room) room.refreshRightsForHabbo(habbo); } @@ -56,7 +56,7 @@ public class KickMemberEvent extends MessageHandler { } if (room != null) { - if (room.getGuildId() == guildId) { + if (room.getRoomInfo().getGuild().getId() == guildId) { room.ejectUserFurni(userId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java index b2eb9cb4..62b74fdf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java @@ -33,9 +33,9 @@ public class RejectMembershipRequestEvent extends MessageHandler { Emulator.getPluginManager().fireEvent(new GuildDeclinedMembershipEvent(guild, userId, habbo, this.client.getHabbo())); if (habbo != null) { - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room != null) { - if (room.getGuildId() == guildId) { + if (room.getRoomInfo().getGuild().getId() == guildId) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, null)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java index 81a38874..ecfb8c29 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java @@ -22,7 +22,7 @@ public class RemoveAdminRightsFromMemberEvent extends MessageHandler { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { int userId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); GuildRemovedAdminEvent removedAdminEvent = new GuildRemovedAdminEvent(guild, userId, habbo); @@ -36,7 +36,7 @@ public class RemoveAdminRightsFromMemberEvent extends MessageHandler { if (habbo != null) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId))); - if (room != null && habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) room.refreshRightsForHabbo(habbo); + if (room != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) room.refreshRightsForHabbo(habbo); } GuildMember guildMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java index 6834ebef..2e927171 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/SelectFavouriteHabboGroupEvent.java @@ -24,10 +24,10 @@ public class SelectFavouriteHabboGroupEvent extends MessageHandler { this.client.getHabbo().getHabboStats().setGuild(guildId); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { if (guild != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HabboAddGroupBadgesMessageComposer(guild).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HabboAddGroupBadgesMessageComposer(guild).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java index 434857b9..4148080c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java @@ -14,9 +14,9 @@ public class UpdateGuildBadgeEvent extends GuildBadgeEvent { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); - if (room == null || room.getId() != guild.getRoomId()) + if (room == null || room.getRoomInfo().getId() != guild.getRoomId()) return; int count = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java index 37bc64e6..faa95180 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java @@ -26,12 +26,14 @@ public class UpdateGuildColorsEvent extends MessageHandler { guild.setColorOne(colorsEvent.getColorOne()); guild.setColorTwo(colorsEvent.getColorTwo()); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); - if (room != null && room.getUserCount() > 0) { - room.refreshGuild(guild); + if (room != null) { + if (room.getRoomUnitManager().getRoomHabbosCount() > 0) { + room.refreshGuild(guild); - room.refreshGuildColors(guild); + room.refreshGuildColors(guild); + } } guild.needsUpdate = true; Emulator.getThreading().run(guild); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java index 3e89e0e1..4047240f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java @@ -33,10 +33,12 @@ public class UpdateGuildIdentityEvent extends MessageHandler { guild.needsUpdate = true; guild.run(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); - if (room != null && !room.getCurrentHabbos().isEmpty()) { - room.refreshGuild(guild); + if (room != null) { + if (!room.getRoomUnitManager().getCurrentRoomHabbos().isEmpty()) { + room.refreshGuild(guild); + } } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java index 5edff097..895fec66 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java @@ -26,7 +26,7 @@ public class UpdateGuildSettingsEvent extends MessageHandler { guild.setState(GuildState.valueOf(settingsEvent.getState())); guild.setRights(settingsEvent.isRights()); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); if(room != null) { room.refreshGuild(guild); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java index 7c59c7b2..7a8b5c0b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java @@ -2,20 +2,23 @@ package com.eu.habbo.messages.incoming.hotelview; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; public class QuitEvent extends MessageHandler { @Override public void handle() { - this.client.getHabbo().getHabboInfo().setLoadingRoom(0); + RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); + roomHabbo.setLoadingRoom(null); + + if (roomHabbo.getRoom() != null) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), roomHabbo.getRoom()); } if (this.client.getHabbo().getHabboInfo().getRoomQueueId() != 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.client.getHabbo().getHabboInfo().getRoomQueueId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.client.getHabbo().getHabboInfo().getRoomQueueId()); if (room != null) { room.removeFromQueue(this.client.getHabbo()); @@ -25,9 +28,9 @@ public class QuitEvent extends MessageHandler { this.client.sendResponse(new CloseConnectionMessageComposer()); } - if (this.client.getHabbo().getRoomUnit() != null) { - this.client.getHabbo().getRoomUnit().clearWalking(); - this.client.getHabbo().getRoomUnit().setInRoom(false); + if (roomHabbo != null) { + roomHabbo.clearWalking(); + roomHabbo.setInRoom(false); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java index e4db03f4..977c1c80 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestFurniInventoryWhenNotInRoomEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.incoming.inventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.FurniListComposer; import gnu.trove.iterator.TIntObjectIterator; @@ -29,9 +29,9 @@ public class RequestFurniInventoryWhenNotInRoomEvent extends MessageHandler { } synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) { - TIntObjectMap items = new TIntObjectHashMap<>(); + TIntObjectMap items = new TIntObjectHashMap<>(); - TIntObjectIterator iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator(); + TIntObjectIterator iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator(); int count = 0; int fragmentNumber = 0; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java index 35393c6f..4cd0f8f2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpEvent.java @@ -27,7 +27,7 @@ public class CallForHelpEvent extends MessageHandler { int roomId = this.packet.readInt(); int messageCount = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); List issues = Emulator.getGameEnvironment().getModToolManager().openTicketsForHabbo(this.client.getHabbo()); if (!issues.isEmpty()) { //this.client.sendResponse(new GenericAlertComposer("You've got still a pending ticket. Wait till the moderators are done reviewing your ticket.")); @@ -87,7 +87,7 @@ public class CallForHelpEvent extends MessageHandler { } } } else { - ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), room != null ? room.getOwnerId() : 0, room != null ? room.getOwnerName() : "", roomId, message, ModToolTicketType.ROOM); + ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), room != null ? room.getRoomInfo().getOwnerInfo().getId() : 0, room != null ? room.getRoomInfo().getOwnerInfo().getUsername() : "", roomId, message, ModToolTicketType.ROOM); issue.category = topic; new InsertModToolIssue(issue).run(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java index f6bef706..05eb4e67 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java @@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.modtool.CfhTopic; import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.habbohotel.modtool.ModToolTicketType; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.CallForHelpResultMessageComposer; import com.eu.habbo.threading.runnables.InsertModToolIssue; @@ -32,11 +32,11 @@ public class CallForHelpFromPhotoEvent extends MessageHandler { if (topic == null) return; - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (!(item instanceof InteractionExternalImage)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java index a4aaf565..66e9d0fb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ChatReviewSessionCreateEvent.java @@ -26,10 +26,10 @@ public class ChatReviewSessionCreateEvent extends MessageHandler { return; } - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - Habbo habbo = room.getHabbo(userId); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { GuardianTicket ticket = Emulator.getGameEnvironment().getGuideManager().getOpenReportedHabboTicket(habbo); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java index d8bfa94f..de8dd024 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java @@ -61,11 +61,11 @@ public class GetCfhChatlogEvent extends MessageHandler { } } - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(issue.roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(issue.roomId); String roomName = ""; if (room != null) { - roomName = room.getName(); + roomName = room.getRoomInfo().getName(); } this.client.sendResponse(new CfhChatlogComposer(issue, chatlog, roomName, chatlogType)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java index 06b9e539..e9058210 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java @@ -13,7 +13,7 @@ public class GetModeratorRoomInfoEvent extends MessageHandler { if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { this.client.sendResponse(new ModeratorRoomInfoComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java index 827fcd57..01f8f452 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java @@ -12,10 +12,10 @@ public class GetRoomChatlogEvent extends MessageHandler { public void handle() { if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); if (room != null) - this.client.sendResponse(new RoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getId()))); + this.client.sendResponse(new RoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getRoomInfo().getId()))); } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java index 6bfdaa56..0dcf9b93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java @@ -17,10 +17,10 @@ public class ModToolRequestRoomUserChatlogEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - this.client.sendResponse(new RoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getId()))); + this.client.sendResponse(new RoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getRoomInfo().getId()))); } } } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java index 7d08216d..882b918c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java @@ -10,7 +10,7 @@ public class ModerateRoomEvent extends MessageHandler { @Override public void handle() { if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); if (room != null) { final boolean lockDoor = this.packet.readInt() == 1; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java index a9c7171e..f58da46c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java @@ -12,7 +12,7 @@ public class ModeratorActionEvent extends MessageHandler { if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { int type = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { room.alert(this.packet.readString()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java index b8eb6de7..94596eda 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/CreateFlatEvent.java @@ -45,11 +45,11 @@ public class CreateFlatEvent extends MessageHandler { if (description.length() > 128 || !Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description)) return; - int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); - int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_HC : RoomManager.MAXIMUM_ROOMS_USER; + int totalRoomsCount = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); + int maxRoomsCount = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_HC : RoomManager.MAXIMUM_ROOMS_USER; - if (count >= max) { - this.client.sendResponse(new CanCreateRoomComposer(count, max)); + if (totalRoomsCount >= maxRoomsCount) { + this.client.sendResponse(new CanCreateRoomComposer(totalRoomsCount, maxRoomsCount)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index 7ec78be7..c3a8854b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -27,11 +27,11 @@ public class DeleteRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - if (room.isOwner(this.client.getHabbo())) { - if (room.getId() == this.client.getHabbo().getHabboInfo().getHomeRoom()) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { + if (room.getRoomInfo().getId() == this.client.getHabbo().getHabboInfo().getHomeRoom()) { return; } @@ -40,18 +40,18 @@ public class DeleteRoomEvent extends MessageHandler { } room.ejectAll(); - room.ejectUserFurni(room.getOwnerId()); + room.ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); - List bots = new ArrayList<>(room.getCurrentBots().valueCollection()); + List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomBots().values()); for (Bot bot : bots) { - Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null); + Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room); } - List pets = new ArrayList<>(room.getCurrentPets().valueCollection()); + List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomPets().values()); for (Pet pet : pets) { if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { - rideablePet.getRider().getHabboInfo().dismountPet(true); + rideablePet.getRider().getHabboInfo().dismountPet(true, room); } } @@ -66,8 +66,8 @@ public class DeleteRoomEvent extends MessageHandler { } } - if (room.getGuildId() > 0) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()); + if (room.getRoomInfo().getGuild().getId() > 0) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(room.getRoomInfo().getGuild().getId()); if (guild != null) { Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); @@ -84,7 +84,7 @@ public class DeleteRoomEvent extends MessageHandler { statement.execute(); } - if (room.hasCustomLayout()) { + if (room.getRoomInfo().isModelOverridden()) { try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_models_custom WHERE id = ? LIMIT 1")) { stmt.setInt(1, roomId); stmt.execute(); @@ -111,7 +111,7 @@ public class DeleteRoomEvent extends MessageHandler { log.error("Caught SQL exception", e); } } else { - String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getName()).replace("%roomowner%", room.getOwnerName()); + String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getRoomInfo().getName()).replace("%roomowner%", room.getRoomInfo().getOwnerInfo().getUsername()); ScripterManager.scripterDetected(this.client, message); log.info(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/ForwardToSomeRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/ForwardToSomeRoomEvent.java index abb96fdb..e7411786 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/ForwardToSomeRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/ForwardToSomeRoomEvent.java @@ -6,7 +6,6 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.RoomForwardMessageComposer; import com.eu.habbo.messages.outgoing.users.NavigatorSettingsComposer; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -19,7 +18,7 @@ public class ForwardToSomeRoomEvent extends MessageHandler { List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(); if (!rooms.isEmpty()) { Collections.shuffle(rooms); - this.client.sendResponse(new RoomForwardMessageComposer(rooms.get(0).getId())); + this.client.sendResponse(new RoomForwardMessageComposer(rooms.get(0).getRoomInfo().getId())); } } else if (data.equalsIgnoreCase("predefined_noob_lobby")) { this.client.sendResponse(new RoomForwardMessageComposer(Emulator.getConfig().getInt("hotel.room.nooblobby"))); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java index e58b2b30..484bae60 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java @@ -124,7 +124,7 @@ public class NewNavigatorSearchEvent extends MessageHandler { for (SearchResultList li : resultLists) { for (Room room : li.getRooms()) { - searchRooms.put(room.getId(), room); + searchRooms.put(room.getRoomInfo().getId(), room); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/PopularRoomsSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/PopularRoomsSearchEvent.java index f6734d32..1330cd06 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/PopularRoomsSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/PopularRoomsSearchEvent.java @@ -7,6 +7,6 @@ import com.eu.habbo.messages.outgoing.navigator.GuestRoomSearchResultComposer; public class PopularRoomsSearchEvent extends MessageHandler { @Override public void handle() { - this.client.sendResponse(new GuestRoomSearchResultComposer(Emulator.getGameEnvironment().getRoomManager().getActiveRooms(-1))); + this.client.sendResponse(new GuestRoomSearchResultComposer(Emulator.getGameEnvironment().getRoomManager().getActiveRoomsByCategoryId(-1))); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index 33ef0cff..b2e2770c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -29,7 +29,7 @@ public class AnswerPollEvent extends MessageHandler { if(answer.length() <= 0) return; if (pollId == 0 && questionId <= 0) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().handleWordQuiz(this.client.getHabbo(), answer.toString()); + this.client.getHabbo().getRoomUnit().getRoom().handleWordQuiz(this.client.getHabbo(), answer.toString()); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/AddFavouriteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/AddFavouriteRoomEvent.java index 726cb9cd..d0513d23 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/AddFavouriteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/AddFavouriteRoomEvent.java @@ -10,7 +10,7 @@ public class AddFavouriteRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); boolean added = true; if (room != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/DeleteFavouriteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/DeleteFavouriteRoomEvent.java index ae943e23..47a2e66f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/DeleteFavouriteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/DeleteFavouriteRoomEvent.java @@ -10,7 +10,7 @@ public class DeleteFavouriteRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetBannedUsersFromRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetBannedUsersFromRoomEvent.java index 4918cf88..80852fbc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetBannedUsersFromRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetBannedUsersFromRoomEvent.java @@ -11,7 +11,7 @@ public class GetBannedUsersFromRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { this.client.sendResponse(new BannedUsersFromRoomComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java index b1339c5e..7d966d46 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.outgoing.rooms.RoomFilterSettingsMessageComposer; public class GetCustomRoomFilterEvent extends MessageHandler { @Override public void handle() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); if (room != null && room.hasRights(this.client.getHabbo())) { this.client.sendResponse(new RoomFilterSettingsMessageComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java index 6054e8f9..32874859 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java @@ -8,12 +8,12 @@ import com.eu.habbo.messages.outgoing.rooms.FlatControllersComposer; public class GetFlatControllersEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { this.client.sendResponse(new FlatControllersComposer(room)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java index ffaddec2..69f26dbb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetGuestRoomEvent.java @@ -8,14 +8,15 @@ import com.eu.habbo.messages.outgoing.rooms.GetGuestRoomResultComposer; public class GetGuestRoomEvent extends MessageHandler { @Override public void handle() { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.packet.readInt()); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt()); int something = this.packet.readInt(); int something2 = this.packet.readInt(); + if (room != null) { boolean unknown = something != 0 || something2 != 1; - //this.client.getHabbo().getHabboInfo().getCurrentRoom() != room + //this.client.getHabbo().getRoomUnit().getRoom() != room this.client.sendResponse(new GetGuestRoomResultComposer(room, this.client.getHabbo(), true, unknown)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomEntryDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomEntryDataEvent.java index bab4015c..4a4cfd2a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomEntryDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomEntryDataEvent.java @@ -9,8 +9,8 @@ import com.eu.habbo.messages.outgoing.rooms.HeightMapComposer; public class GetRoomEntryDataEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.client.getHabbo().getHabboInfo().getLoadingRoom()); + if (this.client.getHabbo().getRoomUnit().isLoadingRoom()) { + Room room = this.client.getHabbo().getRoomUnit().getLoadingRoom(); if (room != null && room.getLayout() != null) { this.client.sendResponse(new HeightMapComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomSettingsEvent.java index b9c450f4..418ded5e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetRoomSettingsEvent.java @@ -10,7 +10,7 @@ public class GetRoomSettingsEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) this.client.sendResponse(new RoomSettingsDataComposer(room)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java index 74a5f0e7..f6952e6f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java @@ -10,23 +10,25 @@ import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; public class LetUserInEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { String username = this.packet.readString(); boolean accepted = this.packet.readBoolean(); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); - if (habbo != null && habbo.getHabboInfo().getRoomQueueId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().removeFromQueue(habbo); + if (habbo != null) { + if (habbo.getHabboInfo().getRoomQueueId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()) { + this.client.getHabbo().getRoomUnit().getRoom().removeFromQueue(habbo); - if (accepted) { - habbo.getClient().sendResponse(new FlatAccessibleMessageComposer("")); - Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); - } else { - habbo.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); - habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); + if (accepted) { + habbo.getClient().sendResponse(new FlatAccessibleMessageComposer("")); + Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), "", true); + } else { + habbo.getClient().sendResponse(new FlatAccessDeniedMessageComposer("")); + habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); + } + habbo.getHabboInfo().setRoomQueueId(0); } - habbo.getHabboInfo().setRoomQueueId(0); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java index 8711ef77..35576d89 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java @@ -7,10 +7,10 @@ import com.eu.habbo.messages.outgoing.rooms.MuteAllInRoomComposer; public class MuteAllInRoomEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.isOwner(this.client.getHabbo())) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { room.setMuted(!room.isMuted()); this.client.sendResponse(new MuteAllInRoomComposer(room)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/OpenFlatConnectionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/OpenFlatConnectionEvent.java index 5787a41d..c669084b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/OpenFlatConnectionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/OpenFlatConnectionEvent.java @@ -3,30 +3,33 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class OpenFlatConnectionEvent extends MessageHandler { + /** + * When user clicks to enter a room + */ @Override public void handle() { int roomId = this.packet.readInt(); String password = this.packet.readString(); - if (this.client.getHabbo().getHabboInfo().getLoadingRoom() == 0 && this.client.getHabbo().getHabboStats().roomEnterTimestamp + 1000 < System.currentTimeMillis()) { + if (!this.client.getHabbo().getRoomUnit().isLoadingRoom() && this.client.getHabbo().getHabboStats().roomEnterTimestamp + 1000 < System.currentTimeMillis()) { + Room previousRoom = this.client.getHabbo().getRoomUnit().getRoom(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) { + if (previousRoom != null) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); - - room.removeHabbo(this.client.getHabbo(), true); - - this.client.getHabbo().getHabboInfo().setCurrentRoom(null); + previousRoom.getRoomUnitManager().removeHabbo(this.client.getHabbo(), true); + this.client.getHabbo().getRoomUnit().setPreviousRoom(previousRoom); } - if (this.client.getHabbo().getRoomUnit() != null && this.client.getHabbo().getRoomUnit().isTeleporting()) { + if (this.client.getHabbo().getRoomUnit().isTeleporting()) { this.client.getHabbo().getRoomUnit().setTeleporting(false); } - Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), roomId, password); + Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), roomId, password, false); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RateFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RateFlatEvent.java index 683e5a18..45ce93a0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RateFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RateFlatEvent.java @@ -6,6 +6,6 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class RateFlatEvent extends MessageHandler { @Override public void handle() { - Emulator.getGameEnvironment().getRoomManager().voteForRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); + Emulator.getGameEnvironment().getRoomManager().voteForRoom(this.client.getHabbo(), this.client.getHabbo().getRoomUnit().getRoom()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java index 1a96ec8b..254da30a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java @@ -12,14 +12,14 @@ import com.eu.habbo.messages.outgoing.rooms.users.NoSuchFlatComposer; public class RemoveAllRightsEvent extends MessageHandler { @Override public void handle() { - final Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + final Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null || room.getId() != this.packet.readInt()) + if (room == null || room.getRoomInfo().getId() != this.packet.readInt()) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { room.getRights().forEach(value -> { - Habbo habbo = room.getHabbo(value); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(value); if (habbo != null) { room.sendComposer(new NoSuchFlatComposer(room, value).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java index b5bace40..67b0df6d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java @@ -8,6 +8,6 @@ public class RemoveOwnRoomRightsRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Emulator.getGameEnvironment().getRoomManager().getRoom(roomId).removeRights(this.client.getHabbo().getHabboInfo().getId()); + Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId).removeRights(this.client.getHabbo().getHabboInfo().getId()); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java index e40258eb..6b11663b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestHeightmapEvent.java @@ -7,12 +7,11 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class RequestHeightmapEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getLoadingRoom() > 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.client.getHabbo().getHabboInfo().getLoadingRoom()); + if (this.client.getHabbo().getRoomUnit().isLoadingRoom()) { + Room room = this.client.getHabbo().getRoomUnit().getLoadingRoom(); if (room != null) { Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), room); - } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 5809d1fd..202e7c75 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.RoomPropertyMessageComposer; @@ -12,14 +12,14 @@ import com.eu.habbo.messages.outgoing.rooms.RoomPropertyMessageComposer; public class RequestRoomPropertySet extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { int itemId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item == null) { this.client.sendResponse(new FurniListRemoveComposer(itemId)); @@ -28,17 +28,17 @@ public class RequestRoomPropertySet extends MessageHandler { switch (item.getBaseItem().getName()) { case "floor": - room.setFloorPaint(item.getExtradata()); + room.getRoomInfo().setFloorPaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFloor")); break; case "wallpaper": - room.setWallPaint(item.getExtradata()); + room.getRoomInfo().setWallPaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoWallpaper")); break; case "landscape": - room.setBackgroundPaint(item.getExtradata()); + room.getRoomInfo().setLandscapePaint(item.getExtradata()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoLandscape")); break; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java index c0b93562..2dd9e688 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java @@ -20,19 +20,19 @@ public class SaveRoomSettingsEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - if (room.isOwner(this.client.getHabbo())) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { String name = this.packet.readString(); if (name.trim().isEmpty() || name.length() > 60) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.ROOM_NAME_MISSING, "")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.ROOM_NAME_MISSING, "")); return; } if (!Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equals(name)) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.ROOM_NAME_BADWORDS, "")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.ROOM_NAME_BADWORDS, "")); return; } @@ -43,15 +43,15 @@ public class SaveRoomSettingsEvent extends MessageHandler { } if (!Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description)) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.ROOM_DESCRIPTION_BADWORDS, "")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.ROOM_DESCRIPTION_BADWORDS, "")); return; } RoomState state = RoomState.values()[this.packet.readInt() % RoomState.values().length]; String password = this.packet.readString(); - if (state == RoomState.PASSWORD && password.isEmpty() && (room.getPassword() == null || room.getPassword().isEmpty())) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.PASSWORD_REQUIRED, "")); + if (state == RoomState.PASSWORD && password.isEmpty() && (room.getRoomInfo().getPassword() == null || room.getRoomInfo().getPassword().isEmpty())) { + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.PASSWORD_REQUIRED, "")); return; } @@ -64,7 +64,7 @@ public class SaveRoomSettingsEvent extends MessageHandler { String tag = this.packet.readString(); if (tag.length() > 15) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.TAGS_TOO_LONG, "")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.TAGS_TOO_LONG, "")); return; } if(!uniqueTags.contains(tag)) { @@ -74,7 +74,7 @@ public class SaveRoomSettingsEvent extends MessageHandler { } if (!Emulator.getGameEnvironment().getWordFilter().filter(tags.toString(), this.client.getHabbo()).equals(tags.toString())) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.ROOM_TAGS_BADWWORDS, "")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.ROOM_TAGS_BADWWORDS, "")); return; } @@ -82,21 +82,21 @@ public class SaveRoomSettingsEvent extends MessageHandler { if (tags.length() > 0) { for (String s : Emulator.getConfig().getValue("hotel.room.tags.staff").split(";")) { if (tags.toString().contains(s)) { - this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getId(), RoomSettingsSaveErrorComposer.RESTRICTED_TAGS, "1")); + this.client.sendResponse(new RoomSettingsSaveErrorComposer(room.getRoomInfo().getId(), RoomSettingsSaveErrorComposer.RESTRICTED_TAGS, "1")); return; } } } - room.setName(name); - room.setDescription(description); - room.setState(state); - if (!password.isEmpty()) room.setPassword(password); - room.setUsersMax(usersMax); + room.getRoomInfo().setName(name); + room.getRoomInfo().setDescription(description); + room.getRoomInfo().setState(state); + if (!password.isEmpty()) room.getRoomInfo().setPassword(password); + room.getRoomInfo().setMaxUsers(usersMax); if (Emulator.getGameEnvironment().getRoomManager().hasCategory(categoryId, this.client.getHabbo())) - room.setCategory(categoryId); + room.getRoomInfo().setCategory(Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId)); else { RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId); @@ -113,22 +113,39 @@ public class SaveRoomSettingsEvent extends MessageHandler { } - room.setTags(tags.toString()); - room.setTradeMode(this.packet.readInt()); - room.setAllowPets(this.packet.readBoolean()); - room.setAllowPetsEat(this.packet.readBoolean()); - room.setAllowWalkthrough(this.packet.readBoolean()); - room.setHideWall(this.packet.readBoolean()); - room.setWallSize(this.packet.readInt()); - room.setFloorSize(this.packet.readInt()); - room.setMuteOption(this.packet.readInt()); - room.setKickOption(this.packet.readInt()); - room.setBanOption(this.packet.readInt()); - room.setChatMode(this.packet.readInt()); - room.setChatWeight(this.packet.readInt()); - room.setChatSpeed(this.packet.readInt()); - room.setChatDistance(Math.abs(this.packet.readInt())); - room.setChatProtection(this.packet.readInt()); + room.getRoomInfo().setTags(tags.toString()); + int tradeMode = this.packet.readInt(); + room.getRoomInfo().setTradeMode(tradeMode); + room.getRoomInfo().setAllowPets(this.packet.readBoolean()); + + if(!room.getRoomInfo().isAllowPets()) { + room.getRoomUnitManager().removeAllPetsExceptRoomOwner(); + } + + boolean allowPetsEat = this.packet.readBoolean(); + room.getRoomInfo().setAllowPetsEat(allowPetsEat); + boolean allowWalkthrough = this.packet.readBoolean(); + room.getRoomInfo().setAllowWalkthrough(allowWalkthrough); + boolean hideWall = this.packet.readBoolean(); + room.getRoomInfo().setHideWalls(hideWall); + room.getRoomInfo().setWallThickness(this.packet.readInt()); + room.getRoomInfo().setFloorThickness(this.packet.readInt()); + int muteOption = this.packet.readInt(); + room.getRoomInfo().setWhoCanMuteOption(muteOption); + int kickOption = this.packet.readInt(); + room.getRoomInfo().setWhoCanKickOption(kickOption); + int banOption = this.packet.readInt(); + room.getRoomInfo().setWhoCanBanOption(banOption); + int chatMode = this.packet.readInt(); + room.getRoomInfo().setChatMode(chatMode); + int chatWeight = this.packet.readInt(); + room.getRoomInfo().setChatWeight(chatWeight); + int chatSpeed = this.packet.readInt(); + room.getRoomInfo().setChatSpeed(chatSpeed); + int chatDistance = Math.abs(this.packet.readInt()); + room.getRoomInfo().setChatDistance(chatDistance); + int chatProtection = this.packet.readInt(); + room.getRoomInfo().setChatProtection(chatProtection); room.setNeedsUpdate(true); room.sendComposer(new RoomVisualizationSettingsComposer(room).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index 25f7df27..e784eb25 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.furniture.FurnitureRoomTonerEvent; @@ -12,12 +12,12 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java index d2e40610..25c9d8fe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java @@ -15,15 +15,16 @@ public class SubmitRoomToCompetitionEvent extends MessageHandler { if (this.client.getHabbo().hasRight(Permission.ACC_STAFF_PICK)) { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - room.setStaffPromotedRoom(!room.isStaffPromotedRoom()); + boolean staffPromotedRoom = !room.getRoomInfo().isStaffPicked(); + room.getRoomInfo().setStaffPicked(staffPromotedRoom); room.setNeedsUpdate(true); NavigatorPublicCategory publicCategory = Emulator.getGameEnvironment().getNavigatorManager().publicCategories.get(Emulator.getConfig().getInt("hotel.navigator.staffpicks.categoryid")); - if (room.isStaffPromotedRoom()) { - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getOwnerId()); + if (room.getRoomInfo().isStaffPicked()) { + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getRoomInfo().getOwnerInfo().getId()); if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("Spr")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java index af162d35..9c4ca8d4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java @@ -15,15 +15,16 @@ public class ToggleStaffPickEvent extends MessageHandler { if (this.client.getHabbo().hasRight(Permission.ACC_STAFF_PICK)) { int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - room.setStaffPromotedRoom(!room.isStaffPromotedRoom()); + boolean staffPromotedRoom = !room.getRoomInfo().isStaffPicked(); + room.getRoomInfo().setStaffPicked(staffPromotedRoom); room.setNeedsUpdate(true); NavigatorPublicCategory publicCategory = Emulator.getGameEnvironment().getNavigatorManager().publicCategories.get(Emulator.getConfig().getInt("hotel.navigator.staffpicks.categoryid")); - if (room.isStaffPromotedRoom()) { - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getOwnerId()); + if (room.getRoomInfo().isStaffPicked()) { + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getRoomInfo().getOwnerInfo().getId()); if (habbo != null) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("Spr")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java index b8df73ab..e3b6aaf5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java @@ -16,13 +16,13 @@ public class UpdateRoomFilterEvent extends MessageHandler { } // Get current room of user. - final Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room == null || room.getId() != roomId) { + final Room room = this.client.getHabbo().getRoomUnit().getRoom(); + if (room == null || room.getRoomInfo().getId() != roomId) { return; } // Check if owner. - if (!room.isOwner(this.client.getHabbo())) { + if (!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { ScripterManager.scripterDetected(this.client, String.format("User (%s) tried to change wordfilter for a not owned room.", this.client.getHabbo().getHabboInfo().getUsername())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java index 91d18c51..1290c6de 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java @@ -21,15 +21,15 @@ import java.util.ArrayList; public class CommandBotEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); - Bot bot = room.getBot(Math.abs(botId)); + Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); if (bot == null) return; @@ -129,7 +129,7 @@ public class CommandBotEvent extends MessageHandler { bot.setName(nameEvent.getName()); bot.needsUpdate(true); - room.sendComposer(new UserNameChangedMessageComposer(bot.getRoomUnit().getId(), bot.getRoomUnit().getId(), nameEvent.getName()).compose()); + room.sendComposer(new UserNameChangedMessageComposer(bot.getRoomUnit().getVirtualId(), bot.getRoomUnit().getVirtualId(), nameEvent.getName()).compose()); } } if (invalidName) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java index 1945016b..f88fc392 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java @@ -9,15 +9,15 @@ import com.eu.habbo.messages.outgoing.rooms.BotCommandConfigurationComposer; public class GetBotCommandConfigurationDataEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); - Bot bot = room.getBot(Math.abs(botId)); + Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); if (bot == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java index ed6cea2d..1325ee9e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java @@ -8,19 +8,21 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class PlaceBotEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } Bot bot = this.client.getHabbo().getInventory().getBotsComponent().getBot(this.packet.readInt()); - if (bot == null) + if (bot == null) { return; + } int x = this.packet.readInt(); int y = this.packet.readInt(); - Emulator.getGameEnvironment().getBotManager().placeBot(bot, this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom(), room.getLayout().getTile((short) x, (short) y)); + Emulator.getGameEnvironment().getBotManager().placeBot(bot, this.client.getHabbo(), room, room.getLayout().getTile((short) x, (short) y)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java index 87189997..9a351609 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java @@ -9,11 +9,11 @@ public class RemoveBotFromFlatEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - Emulator.getGameEnvironment().getBotManager().pickUpBot(this.packet.readInt(), this.client.getHabbo()); + Emulator.getGameEnvironment().getBotManager().pickUpBot(this.packet.readInt(), this.client.getHabbo(), room); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index 0e4fea1d..e3fa9574 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.PostItColor; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import lombok.extern.slf4j.Slf4j; @@ -34,11 +34,11 @@ public class AddSpamWallPostItEvent extends MessageHandler { } else { String text = this.packet.readString(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - HabboItem sticky = room.getHabboItem(itemId); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); + RoomItem sticky = room.getHabboItem(itemId); if (sticky != null && sticky.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { - sticky.setUserId(room.getOwnerId()); + sticky.setUserId(room.getRoomInfo().getOwnerInfo().getId()); if (color.equalsIgnoreCase(PostItColor.YELLOW.hexColor)) { color = PostItColor.randomColorNotYellow().hexColor; @@ -47,7 +47,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { text = InteractionPostIt.STICKYPOLE_PREFIX_TEXT.replace("\\r", "\r").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%timestamp%", LocalDate.now().toString()) + text; } - sticky.setUserId(room.getOwnerId()); + sticky.setUserId(room.getRoomInfo().getOwnerInfo().getId()); sticky.setExtradata(color + " " + text); sticky.needsUpdate(true); room.updateItem(sticky); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java index bb577502..53dad411 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; @@ -20,10 +20,10 @@ public class CreditFurniRedeemEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getUserId()) { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index 937aae78..290987c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.ClothItem; import com.eu.habbo.habbohotel.items.interactions.InteractionClothing; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -26,9 +26,9 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && - this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + if (this.client.getHabbo().getRoomUnit().getRoom() != null && + this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { if (item instanceof InteractionClothing) { @@ -37,11 +37,11 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { if (clothing != null) { if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) { item.setRoomId(0); - RoomTile tile = this.client.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(item.getX(), item.getY()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose()); + RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getX(), item.getY()); + this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_clothing (user_id, clothing_id) VALUES (?, ?)")) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java index 6fda922f..b24375ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDice; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class DiceOffEvent extends MessageHandler { @@ -13,16 +13,16 @@ public class DiceOffEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item != null) { if (item instanceof InteractionDice) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { if (!item.getExtradata().equals("-1")) { item.setExtradata("0"); item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java index 9c3dc5e5..c55d66a7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java @@ -1,17 +1,17 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionOneWayGate; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class EnterOneWayDoorEvent extends MessageHandler { @Override public void handle() throws Exception { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; int itemId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item == null) return; @@ -20,7 +20,7 @@ public class EnterOneWayDoorEvent extends MessageHandler { if (!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting()) return; - item.onClick(this.client, this.client.getHabbo().getHabboInfo().getCurrentRoom(), null); + item.onClick(this.client, this.client.getHabbo().getRoomUnit().getRoom(), null); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java index d78c2b42..85d8c969 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.ItemDataUpdateMessageComposer; @@ -11,10 +11,10 @@ public class GetItemDataEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item instanceof InteractionPostIt) { this.client.sendResponse(new ItemDataUpdateMessageComposer((InteractionPostIt) item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java index a2dd1bf2..fc967f9c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -12,13 +12,13 @@ import com.eu.habbo.messages.outgoing.rooms.items.ObjectUpdateMessageComposer; public class MoveObjectEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; int furniId = this.packet.readInt(); - HabboItem item = room.getHabboItem(furniId); + RoomItem item = room.getHabboItem(furniId); if (item == null) return; int x = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index 62609bfc..5dfd49bc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomRightLevels; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -12,14 +12,16 @@ import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageCo public class MoveWallItemEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI) && !(room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); - return; + if (!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (!(room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); + return; + } } int itemId = this.packet.readInt(); @@ -28,7 +30,7 @@ public class MoveWallItemEvent extends MessageHandler { if (itemId <= 0 || wallPosition.length() <= 13) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index 162fd074..7260604d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class PickupObjectEvent extends MessageHandler { @@ -12,12 +12,12 @@ public class PickupObjectEvent extends MessageHandler { int category = this.packet.readInt(); //10 = floorItem and 20 = wallItem int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item == null) return; @@ -31,8 +31,12 @@ public class PickupObjectEvent extends MessageHandler { if (room.hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { item.setUserId(this.client.getHabbo().getHabboInfo().getId()); - } else if (this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId() && item.getUserId() == room.getOwnerId()) { - return; + } else { + if (this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) { + if (item.getUserId() == room.getRoomInfo().getOwnerInfo().getId()) { + return; + } + } } room.ejectUserItem(item); 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 5ba6485e..2c888ead 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 @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -27,22 +27,22 @@ public class PlaceObjectEvent extends MessageHandler { return; } - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) { return; } - HabboItem rentSpace = null; + RoomItem rentSpace = null; if (this.client.getHabbo().getHabboStats().isRentingSpace()) { rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); } - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) return; - if (room.getId() != item.getRoomId() && item.getRoomId() != 0) + 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 @@ -65,13 +65,13 @@ public class PlaceObjectEvent extends MessageHandler { if(tile == null) { String userName = this.client.getHabbo().getHabboInfo().getUsername(); - int roomId = room.getId(); + int roomId = room.getRoomInfo().getId(); ScripterManager.scripterDetected(this.client, "User [" + userName + "] tried to place a furni with itemId [" + itemId + "] at a tile which is not existing in room [" + roomId + "], tile: [" + x + "," + y + "]"); return; } - HabboItem buildArea = null; - for (HabboItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { + RoomItem buildArea = null; + for (RoomItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { if (((InteractionBuildArea) area).inSquare(tile)) { buildArea = area; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index 1f6eee07..2b97acc9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.items.interactions.InteractionStickyPole; import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -19,17 +19,17 @@ public class PlacePostItEvent extends MessageHandler { int itemId = this.packet.readInt(); String location = this.packet.readString(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { if (room.hasRights(this.client.getHabbo()) || !room.getRoomSpecialTypes().getItemsOfType(InteractionStickyPole.class).isEmpty()) { - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item instanceof InteractionPostIt) { if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) { room.addHabboItem(item); item.setExtradata("FFFF33"); - item.setRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId()); + item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); item.setWallPosition(location); item.setUserId(this.client.getHabbo().getHabboInfo().getId()); item.needsUpdate(true); @@ -39,8 +39,8 @@ public class PlacePostItEvent extends MessageHandler { item.setFromGift(false); Emulator.getThreading().run(item); - if (room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { - AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesReceived")); + if (room.getRoomInfo().getOwnerInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { + AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesReceived")); AchievementManager.progressAchievement(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("NotesLeft")); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index 44b57ac3..67548297 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionExternalImage; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.ItemRemoveMessageComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -15,12 +15,12 @@ public class RemoveItemEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java index 2ba8cb82..301d36c2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java @@ -5,22 +5,23 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionMoodLight; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.habbohotel.rooms.RoomRightLevels; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; +import gnu.trove.map.TIntObjectMap; public class RoomDimmerChangeStateEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if ((room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) return; - for (HabboItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { + for (RoomItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { // enabled ? 2 : 1, preset id, background only ? 2 : 1, color, intensity String extradata = "2,1,2,#FF00FF,255"; - for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) { if (data.isEnabled()) { extradata = data.toString(); break; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerGetPresetsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerGetPresetsEvent.java index fbfb8fb5..0a2016d7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerGetPresetsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerGetPresetsEvent.java @@ -1,12 +1,14 @@ package com.eu.habbo.messages.incoming.rooms.items; +import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RoomDimmerPresetsComposer; +import gnu.trove.map.TIntObjectMap; public class RoomDimmerGetPresetsEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - this.client.sendResponse(new RoomDimmerPresetsComposer(this.client.getHabbo().getHabboInfo().getCurrentRoom().getMoodlightData())); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) + this.client.sendResponse(new RoomDimmerPresetsComposer((TIntObjectMap) this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getMoodLightData())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java index 122f0902..51a72b1c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java @@ -6,9 +6,10 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.habbohotel.rooms.RoomRightLevels; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RoomDimmerPresetsComposer; +import gnu.trove.map.TIntObjectMap; import java.util.Arrays; import java.util.List; @@ -19,9 +20,9 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if ((room.getGuildId() <= 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getRoomInfo().getGuild().getId() <= 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) return; int id = this.packet.readInt(); @@ -40,14 +41,14 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { return; } - for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { + for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) { if (data.getId() == id) { data.setBackgroundOnly(backgroundOnly == 2); data.setColor(color); data.setIntensity(brightness); if (apply) data.enable(); - for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { + for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { item.setExtradata(data.toString()); item.needsUpdate(true); room.updateItem(item); @@ -59,6 +60,6 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { } room.setNeedsUpdate(true); - this.client.sendResponse(new RoomDimmerPresetsComposer(room.getMoodlightData())); + this.client.sendResponse(new RoomDimmerPresetsComposer((TIntObjectMap) room.getRoomInfo().getMoodLightData())); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java index 5820a0f2..6fbb679e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java @@ -2,18 +2,18 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.games.football.InteractionFootballGate; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class SetClothingChangeDataEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId()) + if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) return; - HabboItem item = room.getHabboItem(this.packet.readInt()); + RoomItem item = room.getHabboItem(this.packet.readInt()); if (!(item instanceof InteractionFootballGate)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 0dfc6682..06294c71 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionStackHelper; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.UpdateStackHeightTileHeightComposer; @@ -14,14 +14,14 @@ public class SetCustomStackingHeightEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() || this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item instanceof InteractionStackHelper) { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY()); double stackerHeight = this.packet.readInt(); @@ -49,10 +49,10 @@ public class SetCustomStackingHeightEvent extends MessageHandler { item.setZ(height); item.setExtradata((int) (height * 100) + ""); item.needsUpdate(true); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new HeightMapUpdateMessageComposer (room, tiles).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); + this.client.getHabbo().getRoomUnit().getRoom().updateItem(item); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(tiles); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HeightMapUpdateMessageComposer (room, tiles).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index f7d649ff..2626b663 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.PostItColor; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import java.util.Arrays; @@ -29,12 +29,12 @@ public class SetItemDataEvent extends MessageHandler { return; } - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (!(item instanceof InteractionPostIt)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java index 0e924d12..19e632ab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java @@ -2,20 +2,20 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; public class SetMannequinFigureEvent extends MessageHandler { @Override public void handle() { Habbo habbo = this.client.getHabbo(); - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); - if (room == null || !room.isOwner(habbo)) + if (room == null || !room.getRoomInfo().isRoomOwner(habbo)) return; - HabboItem item = room.getHabboItem(this.packet.readInt()); + RoomItem item = room.getHabboItem(this.packet.readInt()); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java index 825d2649..c43b5f3d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java @@ -2,17 +2,17 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class SetMannequinNameEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room == null || !room.isOwner(this.client.getHabbo())) + Room room = this.client.getHabbo().getRoomUnit().getRoom(); + if (room == null || !room.getRoomInfo().isRoomOwner(this.client.getHabbo())) return; - HabboItem item = room.getHabboItem(this.packet.readInt()); + RoomItem item = room.getHabboItem(this.packet.readInt()); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index cca723e6..28a65bea 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -5,21 +5,21 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionCustomValues; import com.eu.habbo.habbohotel.items.interactions.InteractionRoomAds; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import gnu.trove.map.hash.THashMap; public class SetObjectDataEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; if (!room.hasRights(this.client.getHabbo())) return; - HabboItem item = room.getHabboItem(this.packet.readInt()); + RoomItem item = room.getHabboItem(this.packet.readInt()); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java index 9ffa42ef..89044cc3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionRandomState; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import lombok.extern.slf4j.Slf4j; @@ -15,9 +15,9 @@ public class SetRandomStateEvent extends MessageHandler { int itemId = this.packet.readInt(); int state = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (!(item instanceof InteractionRandomState randomStateItem)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java index 77142088..93558204 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionColorWheel; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class SpinWheelOfFortuneEvent extends MessageHandler { @@ -10,12 +10,12 @@ public class SpinWheelOfFortuneEvent extends MessageHandler { public void handle() throws Exception { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item instanceof InteractionColorWheel) { item.onClick(this.client, room, null); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java index f04ddc35..7cd7a3aa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDice; import com.eu.habbo.habbohotel.items.interactions.InteractionSpinningBottle; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class ThrowDiceEvent extends MessageHandler { @@ -12,17 +12,17 @@ public class ThrowDiceEvent extends MessageHandler { public void handle() throws Exception { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) { return; } - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item != null) { if (item instanceof InteractionDice || item instanceof InteractionSpinningBottle) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentLocation())) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { item.onClick(this.client, room, new Object[]{}); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index e6fd0d84..b2acd4df 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -3,11 +3,10 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionDice; import com.eu.habbo.habbohotel.items.interactions.InteractionSpinningBottle; -import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.OpenPetPackageRequestedMessageComposer; @@ -27,7 +26,7 @@ public class UseFurnitureEvent extends MessageHandler { @Override public void handle() { try { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; @@ -35,7 +34,7 @@ public class UseFurnitureEvent extends MessageHandler { int itemId = this.packet.readInt(); int state = this.packet.readInt(); - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item == null || item instanceof InteractionDice || item instanceof InteractionSpinningBottle) return; @@ -50,9 +49,11 @@ public class UseFurnitureEvent extends MessageHandler { if (handleMonsterPlantSeed(room, item)) return; - if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase()) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) { - this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item)); - return; + if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase())) { + if (room.getRoomUnitManager().getCurrentRoomPets().size() < Room.MAXIMUM_PETS) { + this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item)); + return; + } } item.onClick(this.client, room, new Object[]{state}); @@ -61,7 +62,7 @@ public class UseFurnitureEvent extends MessageHandler { } } - private boolean handleMonsterPlantSeed(Room room, HabboItem item) { + private boolean handleMonsterPlantSeed(Room room, RoomItem item) { if (item instanceof InteractionMonsterPlantSeed) { Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -72,7 +73,7 @@ public class UseFurnitureEvent extends MessageHandler { room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); room.removeHabboItem(item); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); - room.placePet(pet, item.getX(), item.getY(), item.getZ()); + room.getRoomUnitManager().placePet(pet, room, item.getX(), item.getY(), item.getZ()); pet.cycle(); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); return true; @@ -80,7 +81,7 @@ public class UseFurnitureEvent extends MessageHandler { return false; } - private int getRarity(HabboItem item, boolean isRare) { + private int getRarity(RoomItem item, boolean isRare) { if (item.getExtradata().isEmpty() || Integer.parseInt(item.getExtradata()) - 1 < 0) { return isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel(); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java index a59b3232..2ae4f89e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; @@ -10,7 +10,7 @@ import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; public class UseWallItemEvent extends MessageHandler { @Override public void handle() throws Exception { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; @@ -18,7 +18,7 @@ public class UseWallItemEvent extends MessageHandler { int itemId = this.packet.readInt(); int state = this.packet.readInt(); - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java index 402281f6..d24eb1b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; public class AddJukeboxDiskEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) return; + if (!this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) return; int itemId = this.packet.readInt(); int slotId = this.packet.readInt(); @@ -16,10 +16,10 @@ public class AddJukeboxDiskEvent extends MessageHandler { Habbo habbo = this.client.getHabbo(); if (habbo != null) { - HabboItem item = habbo.getInventory().getItemsComponent().getHabboItem(itemId); + RoomItem item = habbo.getInventory().getItemsComponent().getHabboItem(itemId); if (item instanceof InteractionMusicDisc interactionMusicDisc && item.getRoomId() == 0) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong(interactionMusicDisc, habbo); + this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().addSong(interactionMusicDisc, habbo); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java index bef71287..31640475 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java @@ -7,9 +7,9 @@ import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventory public abstract class JukeboxEvent extends MessageHandler { protected void updateHabboWithCurrentPlaying() { - TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); + TraxManager traxManager = this.client.getHabbo().getRoomUnit().getRoom().getTraxManager(); this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength())); this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo()))); - this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java index 7902048d..454880bb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java @@ -8,10 +8,10 @@ public class RemoveJukeboxDiskEvent extends MessageHandler { public void handle() { int index = this.packet.readInt(); - InteractionMusicDisc musicDisc = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().getSongs().get(index); + InteractionMusicDisc musicDisc = this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().getSongs().get(index); if (musicDisc != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().removeSong(musicDisc.getId()); + this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().removeSong(musicDisc.getId()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java index 98313948..62fd5e46 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java @@ -1,8 +1,8 @@ package com.eu.habbo.messages.incoming.rooms.items.lovelock; import com.eu.habbo.habbohotel.items.interactions.InteractionLoveLock; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.FriendFurniCancelLockMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.FriendFurniOtherLockConfirmedMessageComposer; @@ -13,10 +13,10 @@ public class FriendFurniConfirmLockEvent extends MessageHandler { int itemId = this.packet.readInt(); if (this.packet.readBoolean()) { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item == null) return; @@ -31,7 +31,7 @@ public class FriendFurniConfirmLockEvent extends MessageHandler { } if (userId > 0) { - Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); + Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { habbo.getClient().sendResponse(new FriendFurniOtherLockConfirmedMessageComposer((InteractionLoveLock) item)); @@ -39,7 +39,7 @@ public class FriendFurniConfirmLockEvent extends MessageHandler { habbo.getClient().sendResponse(new FriendFurniCancelLockMessageComposer((InteractionLoveLock) item)); this.client.sendResponse(new FriendFurniCancelLockMessageComposer((InteractionLoveLock) item)); - ((InteractionLoveLock) item).lock(habbo, this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom()); + ((InteractionLoveLock) item).lock(habbo, this.client.getHabbo(), this.client.getHabbo().getRoomUnit().getRoom()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java index b4e97674..b7df07a5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items.rentablespace; import com.eu.habbo.habbohotel.items.interactions.InteractionRentableSpace; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class RentableSpaceCancelRentEvent extends MessageHandler { @@ -11,14 +11,14 @@ public class RentableSpaceCancelRentEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { if (item instanceof InteractionRentableSpace) { ((InteractionRentableSpace) item).endRent(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java index 5dc6abb7..5c1b2cd3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items.rentablespace; import com.eu.habbo.habbohotel.items.interactions.InteractionRentableSpace; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class RentableSpaceRentEvent extends MessageHandler { @@ -10,12 +10,12 @@ public class RentableSpaceRentEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (!(item instanceof InteractionRentableSpace)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java index b6b5805a..457f1714 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java @@ -2,11 +2,9 @@ package com.eu.habbo.messages.incoming.rooms.items.youtube; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; -import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeControlVideoMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; @@ -47,8 +45,8 @@ public class ControlYoutubeDisplayPlaybackEvent extends YoutubeEvent { if(!validate(habbo)) return; - Room room = habbo.getHabboInfo().getCurrentRoom(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + Room room = habbo.getRoomUnit().getRoom(); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (!(item instanceof InteractionYoutubeTV tv)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java index 4dfc7fd1..0da80f51 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items.youtube; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayPlaylistsComposer; @@ -19,8 +19,8 @@ public class GetYoutubeDisplayStatusEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item instanceof InteractionYoutubeTV tv) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java index 7f9fbeca..d14a1e33 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java @@ -3,11 +3,9 @@ package com.eu.habbo.messages.incoming.rooms.items.youtube; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; -import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo; @@ -23,10 +21,10 @@ public class SetYoutubeDisplayPlaylistEvent extends YoutubeEvent { if (!validate(habbo)) return; - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (!(item instanceof InteractionYoutubeTV)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java index c7e43781..ec893441 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java @@ -12,12 +12,12 @@ public abstract class YoutubeEvent extends MessageHandler { return false; } - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room == null) { return false; } - if (!room.isOwner(habbo) && !habbo.hasRight(Permission.ACC_ANYROOMOWNER)) { + if (!room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasRight(Permission.ACC_ANYROOMOWNER)) { return false; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java index 016aafba..2d022131 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java @@ -10,8 +10,10 @@ public class BreedPetsEvent extends MessageHandler { int unknownInt = this.packet.readInt(); //Something state. 2 = accept if (unknownInt == 0) { - Pet petOne = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); - Pet petTwo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); + int petId1 = this.packet.readInt(); + Pet petOne = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId1); + int petId = this.packet.readInt(); + Pet petTwo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (petOne == null || petTwo == null || petOne == petTwo) { //TODO Add error diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java index 58b0dc53..a31733ad 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class CancelPetBreedingEvent extends MessageHandler { @@ -9,7 +9,7 @@ public class CancelPetBreedingEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item instanceof InteractionPetBreedingNest) { ((InteractionPetBreedingNest) item).stopBreeding(this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java index f024f092..816225f6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer; import lombok.extern.slf4j.Slf4j; @@ -22,8 +22,8 @@ public class CompostPlantEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - Pet pet = room.getPet(petId); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); + Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (pet != null) { if (pet instanceof MonsterplantPet) { @@ -32,10 +32,10 @@ public class CompostPlantEvent extends MessageHandler { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem("mnstr_compost"); if (baseItem != null) { - HabboItem compost = Emulator.getGameEnvironment().getItemManager().createItem(pet.getUserId(), baseItem, 0, 0, ""); - compost.setX(pet.getRoomUnit().getX()); - compost.setY(pet.getRoomUnit().getY()); - compost.setZ(pet.getRoomUnit().getZ()); + RoomItem compost = Emulator.getGameEnvironment().getItemManager().createItem(pet.getUserId(), baseItem, 0, 0, ""); + compost.setX(pet.getRoomUnit().getCurrentPosition().getX()); + compost.setY(pet.getRoomUnit().getCurrentPosition().getY()); + compost.setZ(pet.getRoomUnit().getCurrentZ()); compost.setRotation(pet.getRoomUnit().getBodyRotation().getValue()); room.addHabboItem(compost); room.sendComposer(new ObjectAddMessageComposer(compost, this.client.getHabbo().getHabboInfo().getUsername()).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java index bc0c0fbf..fa412627 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class ConfirmPetBreedingEvent extends MessageHandler { @@ -13,7 +13,7 @@ public class ConfirmPetBreedingEvent extends MessageHandler { int petOneId = this.packet.readInt(); int petTwoId = this.packet.readInt(); - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item instanceof InteractionPetBreedingNest) { ((InteractionPetBreedingNest) item).breed(this.client.getHabbo(), name); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 87d1d190..692bdfa3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetFigureUpdateComposer; @@ -20,17 +20,17 @@ public class CustomizePetWithFurniEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item == null) return; int petId = this.packet.readInt(); - Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (pet instanceof HorsePet) { if (item.getBaseItem().getName().toLowerCase().startsWith("horse_dye")) { @@ -81,7 +81,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { if (pet.isNeedsUpdate()) { Emulator.getThreading().run(pet); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose()); room.removeHabboItem(item); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); @@ -92,15 +92,15 @@ public class CustomizePetWithFurniEvent extends MessageHandler { if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_revival")) { if (((MonsterplantPet) pet).isDead()) { ((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.TIME_TO_LIVE); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev"); pet.setPacketUpdate(true); - this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantHealer")); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -108,15 +108,15 @@ public class CustomizePetWithFurniEvent extends MessageHandler { } else if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_fert")) { if (!((MonsterplantPet) pet).isFullyGrown()) { pet.setCreated(pet.getCreated() - MonsterplantPet.GROW_TIME); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.cycle(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "spd"); pet.getRoomUnit().setStatus(RoomUnitStatus.fromString("grw" + ((MonsterplantPet) pet).getGrowthStage()), ""); - this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); pet.cycle(); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -131,14 +131,14 @@ public class CustomizePetWithFurniEvent extends MessageHandler { { ((MonsterplantPet) pet).setCanBreed(true); - pet.getRoomUnit().clearStatus(); + pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "reb"); - this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java index e3dbf722..dcc9ea99 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java @@ -9,10 +9,10 @@ public class GetPetCommandsEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (pet != null) this.client.sendResponse(new PetTrainingPanelComposer(pet)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java index f357f711..bf5b49a9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java @@ -10,12 +10,12 @@ public class GetPetInfoEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - Pet pet = room.getPet(petId); + Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (pet != null) { this.client.sendResponse(new PetInfoMessageComposer(pet, room, this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index eeab20d1..906e9dd0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -16,20 +16,21 @@ public class MountPetEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); Habbo habbo = this.client.getHabbo(); - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } - Pet pet = room.getPet(petId); + Pet pet = room.getRoomUnitManager().getRoomPetById(petId); - if (!(pet instanceof RideablePet rideablePet)) + if (!(pet instanceof RideablePet rideablePet)) { return; + } //dismount if (habbo.getHabboInfo().getRiding() != null) { - habbo.getHabboInfo().dismountPet(); - return; + habbo.getHabboInfo().dismountPet(room); } // someone is already on it @@ -40,7 +41,7 @@ public class MountPetEvent extends MessageHandler { if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) return; - List availableTiles = room.getLayout().getWalkableTilesAround(pet.getRoomUnit().getCurrentLocation()); + List availableTiles = room.getLayout().getWalkableTilesAround(pet.getRoomUnit().getCurrentPosition()); // if cant reach it then cancel if (availableTiles.isEmpty()) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index 3a1337e8..a29be34b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -3,17 +3,18 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; public class MovePetEvent extends MessageHandler { @Override public void handle() { - Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(this.packet.readInt()); + int petId = this.packet.readInt(); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (pet != null) { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null && room.hasRights(this.client.getHabbo())) { if (pet.getRoomUnit() != null) { int x = this.packet.readInt(); @@ -24,9 +25,9 @@ public class MovePetEvent extends MessageHandler { if (tile != null) { pet.getRoomUnit().setLocation(tile); pet.getRoomUnit().setPreviousLocation(tile); - pet.getRoomUnit().setZ(tile.getZ()); - pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.packet.readInt())); - pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getZ()); + pet.getRoomUnit().setCurrentZ(tile.getZ()); + pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt())); + pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getCurrentZ()); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); pet.setNeedsUpdate(true); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index 0e001ca5..cee8c416 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; @@ -18,10 +18,10 @@ public class OpenPetPackageEvent extends MessageHandler { int itemId = this.packet.readInt(); String name = this.packet.readString(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - HabboItem item = room.getHabboItem(itemId); + RoomItem item = room.getHabboItem(itemId); if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { if (!name.matches("^[a-zA-Z0-9]*$")) { this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", ""))); @@ -55,11 +55,11 @@ public class OpenPetPackageEvent extends MessageHandler { } if (pet != null) { - room.placePet(pet, item.getX(), item.getY(), item.getZ()); + room.getRoomUnitManager().placePet(pet, room, item.getX(), item.getY(), item.getZ()); pet.setUserId(this.client.getHabbo().getHabboInfo().getId()); pet.setNeedsUpdate(true); pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getX(), item.getY())); - pet.getRoomUnit().setZ(item.getZ()); + pet.getRoomUnit().setCurrentZ(item.getZ()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); room.removeHabboItem(item); room.sendComposer(new RemoveFloorItemComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index e99af933..ab3185ea 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -3,7 +3,12 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; -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.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.PetPlacingErrorComposer; import com.eu.habbo.messages.outgoing.inventory.PetRemovedFromInventoryComposer; @@ -12,14 +17,16 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; public class PlacePetEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId() && !room.isAllowPets() && !(this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI))) { - this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT)); - return; + if (this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) { + if (!room.getRoomInfo().isAllowPets() && !(this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI))) { + this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT)); + return; + } } int petId = this.packet.readInt(); @@ -29,7 +36,7 @@ public class PlacePetEvent extends MessageHandler { if (pet == null) { return; } - if (room.getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS)) { + if (room.getRoomUnitManager().getCurrentRoomPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS)) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_MAX_PETS)); return; } @@ -38,11 +45,11 @@ public class PlacePetEvent extends MessageHandler { int y = this.packet.readInt(); RoomTile tile; - RoomTile playerTile = this.client.getHabbo().getRoomUnit().getCurrentLocation(); + RoomTile playerTile = this.client.getHabbo().getRoomUnit().getCurrentPosition(); - if ((x == 0 && y == 0) || !room.isOwner(this.client.getHabbo())) { + if ((x == 0 && y == 0) || !room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { //Place the pet in front of the player. - tile = room.getLayout().getTileInFront(this.client.getHabbo().getRoomUnit().getCurrentLocation(), this.client.getHabbo().getRoomUnit().getBodyRotation().getValue()); + tile = room.getLayout().getTileInFront(this.client.getHabbo().getRoomUnit().getCurrentPosition(), this.client.getHabbo().getRoomUnit().getBodyRotation().getValue()); if (tile == null || !tile.isWalkable()) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_PETS_NO_FREE_TILES)); @@ -70,20 +77,20 @@ public class PlacePetEvent extends MessageHandler { RoomUnit roomUnit = pet.getRoomUnit(); if (roomUnit == null) { - roomUnit = new RoomUnit(); + roomUnit = new RoomPet(); } - roomUnit.setPathFinderRoom(room); + roomUnit.setRoom(room); roomUnit.setLocation(tile); - roomUnit.setZ(tile.getStackHeight()); + roomUnit.setCurrentZ(tile.getStackHeight()); roomUnit.setStatus(RoomUnitStatus.SIT, "0"); roomUnit.setRoomUnitType(RoomUnitType.PET); if (playerTile != null) { roomUnit.lookAtPoint(playerTile); } pet.setRoomUnit(roomUnit); - room.addPet(pet); + room.getRoomUnitManager().addRoomUnit(pet); pet.setNeedsUpdate(true); Emulator.getThreading().run(pet); room.sendComposer(new RoomPetComposer(pet).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java index 3ed3c6a4..d7744512 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java @@ -15,15 +15,15 @@ public class RemovePetFromFlatEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - Pet pet = room.getPet(petId); + Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (pet != null) { - if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { if (!this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); return; @@ -31,7 +31,7 @@ public class RemovePetFromFlatEvent extends MessageHandler { if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { - rideablePet.getRider().getHabboInfo().dismountPet(true); + rideablePet.getRider().getHabboInfo().dismountPet(true, room); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java index 51fe2603..2f80abbc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -23,8 +23,9 @@ public class RemoveSaddleFromPetEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - Pet pet = room.getPet(this.packet.readInt()); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); + int petId = this.packet.readInt(); + Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (!(pet instanceof HorsePet horse) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; @@ -54,9 +55,9 @@ public class RemoveSaddleFromPetEvent extends MessageHandler { horse.hasSaddle(false); horse.setNeedsUpdate(true); Emulator.getThreading().run(pet); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetFigureUpdateComposer(horse).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer(horse).compose()); - HabboItem saddle = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), saddleItem, 0, 0, ""); + RoomItem saddle = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), saddleItem, 0, 0, ""); this.client.getHabbo().getInventory().getItemsComponent().addItem(saddle); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java index 23ea7f00..e61b8109 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java @@ -3,11 +3,11 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import java.util.ArrayList; import java.util.List; @@ -21,10 +21,10 @@ public class RespectPetEvent extends MessageHandler { final Habbo habbo = this.client.getHabbo(); if (habbo == null) { return; } - final Room room = habbo.getHabboInfo().getCurrentRoom(); + final Room room = habbo.getRoomUnit().getRoom(); if (room == null) { return; } - final Pet pet = room.getPet(petId); + final Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (pet == null) { return; } if (habbo.getHabboStats().getPetRespectPointsToGive() > 0 || pet instanceof MonsterplantPet) { @@ -35,7 +35,7 @@ public class RespectPetEvent extends MessageHandler { Emulator.getThreading().run(pet); }); - RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), true); + RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getCurrentPosition().getX(), pet.getRoomUnit().getCurrentPosition().getY(), true); if(tile != null) { habbo.getRoomUnit().setGoalLocation(tile); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java index 45633ef4..be729dab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java @@ -9,7 +9,7 @@ public class TogglePetBreedingPermissionEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (pet != null) { if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java index ac7087ef..4eabeea3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java @@ -11,10 +11,10 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); if (pet == null || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId() || !(pet instanceof RideablePet rideablePet)) return; @@ -23,7 +23,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { rideablePet.setNeedsUpdate(true); if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { - rideablePet.getRider().getHabboInfo().dismountPet(); + rideablePet.getRider().getHabboInfo().dismountPet(this.client.getHabbo().getRoomUnit().getRoom()); } if (pet instanceof HorsePet) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java index f6a10972..600dc8b0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java @@ -17,9 +17,9 @@ public class EditEventEvent extends MessageHandler { String promotionName = this.packet.readString(); String promotionDescription = this.packet.readString(); - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(id); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(id); - if (room == null || room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room == null || room.getRoomInfo().getOwnerInfo().getId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java index e622e071..65a2e257 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java @@ -36,9 +36,9 @@ public class PurchaseRoomAdEvent extends MessageHandler { CatalogItem item = page.getCatalogItem(itemId); if (item != null) { if (this.client.getHabbo().getHabboInfo().canBuy(item)) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); - if (!(room.isOwner(this.client.getHabbo()) || room.hasRights(this.client.getHabbo()) || room.getGuildRightLevel(this.client.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { + if (!(room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || room.hasRights(this.client.getHabbo()) || room.getGuildRightLevel(this.client.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java index c905c207..f1f9f177 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java @@ -13,13 +13,13 @@ public class AssignRightsEvent extends MessageHandler { public void handle() { int userId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - Habbo target = room.getHabbo(userId); + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + Habbo target = room.getRoomUnitManager().getRoomHabboById(userId); if (target != null) { if (!Emulator.getPluginManager().fireEvent(new UserRightsGivenEvent(this.client.getHabbo(), target)).isCancelled()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java index c3dffc03..aa1fcca1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java @@ -11,7 +11,7 @@ import com.eu.habbo.plugin.events.users.UserIdleEvent; public class AvatarExpressionEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) { return; } @@ -21,7 +21,7 @@ public class AvatarExpressionEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) { habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if (habbo.getHabboInfo().getCurrentRoom() != room) { + if (habbo.getRoomUnit().getRoom() != room) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/CancelTypingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/CancelTypingEvent.java index dc309636..c98ddddc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/CancelTypingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/CancelTypingEvent.java @@ -6,7 +6,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserTypingMessageComposer; public class CancelTypingEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) { + if (this.client.getHabbo().getRoomUnit().getRoom() == null) { return; } @@ -14,6 +14,6 @@ public class CancelTypingEvent extends MessageHandler { return; } - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserTypingMessageComposer(this.client.getHabbo().getRoomUnit(), false).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserTypingMessageComposer(this.client.getHabbo().getRoomUnit(), false).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java index f71580fa..d4392ecd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java @@ -7,18 +7,18 @@ import com.eu.habbo.plugin.events.users.UserIdleEvent; public class ChangePostureEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { if (this.client.getHabbo().getRoomUnit().isWalking()) { this.client.getHabbo().getRoomUnit().stopWalking(); } - this.client.getHabbo().getHabboInfo().getCurrentRoom().makeSit(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().getRoom().makeSit(this.client.getHabbo()); UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); if (!event.isCancelled()) { if (!event.isIdle()) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java index 8a095856..8d2b7028 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java @@ -16,7 +16,7 @@ public class ChatEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java index 58dec5ae..d92262fc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.plugin.events.users.UserIdleEvent; public class DanceEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; int danceId = this.packet.readInt(); @@ -22,7 +22,7 @@ public class DanceEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getCacheable().get("control") != null) { habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { + if (habbo.getRoomUnit().getRoom() != this.client.getHabbo().getRoomUnit().getRoom()) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -36,11 +36,11 @@ public class DanceEvent extends MessageHandler { if (!event.isCancelled()) { if (!event.isIdle()) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(habbo); + this.client.getHabbo().getRoomUnit().getRoom().unIdle(habbo); } } - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java index 5f87c859..24f382da 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; public class DropCarryItemEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); this.client.getHabbo().getRoomUnit().setHandItem(0); if (room != null) { room.unIdle(this.client.getHabbo()); 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 0e485506..37696e30 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 @@ -9,8 +9,8 @@ public class GetUserTagsEvent extends MessageHandler { public void handle() { int roomUnitId = this.packet.readInt(); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboByRoomUnitId(roomUnitId); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getHabboByRoomUnitId(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 9dab2387..dcbfa00f 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 @@ -10,7 +10,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.IgnoreResultMessageComposer; public class IgnoreUserEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { String username = this.packet.readString(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java index 819463d3..263131fb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java @@ -2,15 +2,15 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; public class LookToEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; @@ -19,7 +19,7 @@ public class LookToEvent extends MessageHandler { if (habbo.getRoomUnit().getCacheable().get("control") != null) { habbo = (Habbo) this.client.getHabbo().getRoomUnit().getCacheable().get("control"); - if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { + if (habbo.getRoomUnit().getRoom() != this.client.getHabbo().getRoomUnit().getRoom()) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); @@ -28,13 +28,13 @@ public class LookToEvent extends MessageHandler { RoomUnit roomUnit = habbo.getRoomUnit(); - if (!roomUnit.canWalk()) + if (!roomUnit.isCanWalk()) return; if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) return; - if (roomUnit.isCmdLay() || roomUnit.hasStatus(RoomUnitStatus.LAY)) + if (roomUnit.isCmdLayEnabled() || roomUnit.hasStatus(RoomUnitStatus.LAY)) return; if (roomUnit.isIdle()) @@ -43,14 +43,15 @@ public class LookToEvent extends MessageHandler { int x = this.packet.readInt(); int y = this.packet.readInt(); - if (x == roomUnit.getX() && y == roomUnit.getY()) - return; + if (x == roomUnit.getCurrentPosition().getX()) { + if (y == roomUnit.getCurrentPosition().getY()) return; + } - RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); + RoomTile tile = habbo.getRoomUnit().getRoom().getLayout().getTile((short) x, (short) y); if (tile != null) { roomUnit.lookAtPoint(tile); - roomUnit.statusUpdate(true); + roomUnit.setStatusUpdateNeeded(true); //room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 88c83947..d1e2ce4b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -4,10 +4,10 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +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.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; @@ -25,128 +25,146 @@ public class MoveAvatarEvent extends MessageHandler { @Override public void handle() throws Exception { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { int x = this.packet.readInt(); // Position X int y = this.packet.readInt(); // Position Y // Get Habbo object Habbo habbo = this.client.getHabbo(); + if(habbo == null) { + return; + } + // Get Room Habbo object (Unique GUID?) RoomUnit roomUnit = this.client.getHabbo().getRoomUnit(); - // If habbo is teleporting, dont calculate a new path - if (roomUnit.isTeleporting()) + if(roomUnit == null) { return; + } - // If habbo is being kicked dont calculate a new path - if (roomUnit.isKicked()) + // If habbo is teleporting, don't calculate a new path + if (roomUnit.isTeleporting()) { return; + } + + // If habbo is being kicked don't calculate a new path + if (roomUnit.isKicked()) { + return; + } + + // Get the room the habbo is in + Room room = habbo.getRoomUnit().getRoom(); + + if (room == null || room.getLayout() == null) { + return; + } + + // Don't calulcate a new path if are already at the end position + if (x == roomUnit.getCurrentPosition().getX() && y == roomUnit.getCurrentPosition().getY()) { + return; + } // If habbo has control (im assuming admin, do something else, but we dont care about this part here) if (roomUnit.getCacheable().get("control") != null) { habbo = (Habbo) roomUnit.getCacheable().get("control"); - if (habbo.getHabboInfo().getCurrentRoom() != this.client.getHabbo().getHabboInfo().getCurrentRoom()) { + if (habbo.getRoomUnit().getRoom() != room) { habbo.getRoomUnit().getCacheable().remove("controller"); this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); habbo = this.client.getHabbo(); } } - // Get room unit? + // Recover roomUnit if necessary roomUnit = habbo.getRoomUnit(); - // Get the room the habbo is in - Room room = habbo.getHabboInfo().getCurrentRoom(); - // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path - if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) { - // If we are not teleporting calcualte a new path - if (!roomUnit.isCmdTeleport()) { - // Don't calculate a new path if we are on a horse - if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) - return; + if (roomUnit != null && roomUnit.isInRoom() && roomUnit.isCanWalk()) { - // Don't calulcate a new path if are already at the end position - if (x == roomUnit.getX() && y == roomUnit.getY()) - return; - - if (room == null || room.getLayout() == null) - return; - - // Reset idle status - if (roomUnit.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled()) { - if (!event.isIdle()) { - if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo); - roomUnit.resetIdleTimer(); - } - } - } - - // Get room height map - RoomTile tile = room.getLayout().getTile((short) x, (short) y); - - // this should never happen, if it does it would be a design flaw - if (tile == null) { - return; - } - - // Don't care - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { - if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) - return; - } - if (room.canLayAt(tile.getX(), tile.getY())) { - HabboItem bed = room.getTopItemAt(tile.getX(), tile.getY()); - - if (bed != null && bed.getBaseItem().allowLay()) { - room.getLayout().getTile(bed.getX(), bed.getY()); - RoomTile pillow = switch (bed.getRotation()) { - case 0, 4 -> room.getLayout().getTile((short) x, bed.getY()); - case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y); - default -> room.getLayout().getTile(bed.getX(), bed.getY()); - }; - - if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) { - roomUnit.setGoalLocation(pillow); - return; - } - } - } - - THashSet items = room.getItemsAt(tile); - - if (items.size() > 0) { - for (HabboItem item : items) { - RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile); - - if (overriddenTile == null) { - return; // null cancels the entire event - } - - if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) { - tile = overriddenTile; - break; - } - } - } - - // This is where we set the end location and begin finding a path - if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { - roomUnit.setGoalLocation(tile); - } - } else { + //If teleport command is enabled + if(roomUnit.isCmdTeleportEnabled()) { RoomTile t = room.getLayout().getTile((short) x, (short) y); - room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose()); if (habbo.getHabboInfo().getRiding() != null) { + room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, null, roomUnit.getCurrentPosition(), roomUnit.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose()); room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose()); + } else { + room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose()); } + + return; + } + + // Don't calculate a new path if we are on a horse + if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) + return; + + // Reset idle status + if (roomUnit.isIdle()) { + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); + + if (!event.isCancelled()) { + if (!event.isIdle()) { + if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo); + roomUnit.resetIdleTimer(); + } + } + } + + // Get room height map + RoomTile tile = room.getLayout().getTile((short) x, (short) y); + + // this should never happen, if it does it would be a design flaw + if (tile == null) { + return; + } + + // Don't care + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { + if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) + return; + } + + if (room.canLayAt(tile.getX(), tile.getY())) { + RoomItem bed = room.getTopItemAt(tile.getX(), tile.getY()); + + if (bed != null && bed.getBaseItem().allowLay()) { + room.getLayout().getTile(bed.getX(), bed.getY()); + RoomTile pillow = switch (bed.getRotation()) { + case 0, 4 -> room.getLayout().getTile((short) x, bed.getY()); + case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y); + default -> room.getLayout().getTile(bed.getX(), bed.getY()); + }; + + if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) { + roomUnit.setGoalLocation(pillow); + return; + } + } + } + + THashSet items = room.getItemsAt(tile); + + if (items.size() > 0) { + for (RoomItem item : items) { + RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile); + + if (overriddenTile == null) { + return; // null cancels the entire event + } + + if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) { + tile = overriddenTile; + break; + } + } + } + + // This is where we set the end location and begin finding a path + if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { + roomUnit.setGoalLocation(tile); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/PassCarryItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/PassCarryItemEvent.java index ef606c0b..a817be2d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/PassCarryItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/PassCarryItemEvent.java @@ -15,15 +15,15 @@ public class PassCarryItemEvent extends MessageHandler { public void handle() { int userId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - Habbo target = room.getHabbo(userId); + Habbo target = room.getRoomUnitManager().getRoomHabboById(userId); if (target != null) { List executable = new ArrayList<>(); executable.add(new HabboGiveHandItemToHabbo(this.client.getHabbo(), target)); - Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.client.getHabbo().getRoomUnit(), target.getRoomUnit(), this.client.getHabbo().getHabboInfo().getCurrentRoom(), executable, executable)); + Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.client.getHabbo().getRoomUnit(), target.getRoomUnit(), this.client.getHabbo().getRoomUnit().getRoom(), executable, executable)); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java index 3399e52e..867779e6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java @@ -9,12 +9,12 @@ public class RemoveRightsEvent extends MessageHandler { public void handle() { int amount = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; - if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { for (int i = 0; i < amount; i++) { int userId = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java index e0211d32..178465a9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RespectUserEvent.java @@ -14,7 +14,7 @@ public class RespectUserEvent extends MessageHandler { return; } if (this.client.getHabbo().getHabboStats().getRespectPointsToGive() > 0) { - Habbo target = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); + Habbo target = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboById(userId); if (Emulator.getPluginManager().isRegistered(UserRespectedEvent.class, false)) { if (Emulator.getPluginManager().fireEvent(new UserRespectedEvent(target, this.client.getHabbo())).isCancelled()) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java index 4dac9cb0..33f27912 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java @@ -14,14 +14,14 @@ import com.eu.habbo.plugin.events.users.UserKickEvent; public class RoomUserKickEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; int userId = this.packet.readInt(); - Habbo target = room.getHabbo(userId); + Habbo target = room.getRoomUnitManager().getRoomHabboById(userId); if (target == null) return; @@ -31,7 +31,7 @@ public class RoomUserKickEvent extends MessageHandler { return; } - if (room.isOwner(target)) { + if (room.getRoomInfo().isRoomOwner(target)) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java index 3b737e69..8aac4969 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java @@ -15,11 +15,11 @@ public class RoomUserMuteEvent extends MessageHandler { int roomId = this.packet.readInt(); int minutes = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasCommand("cmd_mute") || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { - Habbo habbo = room.getHabbo(userId); + Habbo habbo = room.getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { room.muteHabbo(habbo, minutes); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java index 40c2b46f..569495b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java @@ -13,7 +13,7 @@ public class ShoutEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; if (!this.client.getHabbo().getHabboStats().allowTalk()) @@ -27,7 +27,7 @@ public class ShoutEvent extends MessageHandler { return; } - this.client.getHabbo().getHabboInfo().getCurrentRoom().talk(this.client.getHabbo(), message, RoomChatType.SHOUT); + this.client.getHabbo().getRoomUnit().getRoom().talk(this.client.getHabbo(), message, RoomChatType.SHOUT); if (!message.isCommand) { if (RoomChatMessage.SAVE_ROOM_CHATS) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java index 9e38ba84..428089c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSignEvent; @@ -13,7 +13,7 @@ public class SignEvent extends MessageHandler { public void handle() { int signId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) return; @@ -21,12 +21,12 @@ public class SignEvent extends MessageHandler { UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.getSign() + ""); - this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); if(signId <= 10) { int userId = this.client.getHabbo().getHabboInfo().getId(); - for (HabboItem item : room.getFloorItems()) { + for (RoomItem item : room.getFloorItems()) { if (item instanceof InteractionVoteCounter) { ((InteractionVoteCounter)item).vote(room, userId, signId); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/StartTypingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/StartTypingEvent.java index deda8e53..f352f238 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/StartTypingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/StartTypingEvent.java @@ -6,7 +6,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserTypingMessageComposer; public class StartTypingEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) { + if (this.client.getHabbo().getRoomUnit().getRoom() == null) { return; } @@ -14,6 +14,6 @@ public class StartTypingEvent extends MessageHandler { return; } - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserTypingMessageComposer(this.client.getHabbo().getRoomUnit(), true).compose()); + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserTypingMessageComposer(this.client.getHabbo().getRoomUnit(), true).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java index 3c1560f9..0741b6d0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java @@ -10,10 +10,10 @@ public class UnbanUserFromRoomEvent extends MessageHandler { int userId = this.packet.readInt(); int roomId = this.packet.readInt(); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - if (room.isOwner(this.client.getHabbo())) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { room.unbanHabbo(userId); } } 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 81c3773b..91ca8a76 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 @@ -8,7 +8,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.IgnoreResultMessageComposer; public class UnignoreUserEvent extends MessageHandler { @Override public void handle() { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { String username = this.packet.readString(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java index 910faaee..6a6fcd1c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java @@ -13,7 +13,7 @@ public class WhisperEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; RoomChatMessage chatMessage = new RoomChatMessage(this); @@ -26,7 +26,7 @@ public class WhisperEvent extends MessageHandler { return; } - this.client.getHabbo().getHabboInfo().getCurrentRoom().talk(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER, true); + this.client.getHabbo().getRoomUnit().getRoom().talk(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER, true); if (RoomChatMessage.SAVE_ROOM_CHATS) { Emulator.getThreading().run(chatMessage); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java index 85870b34..708facba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java @@ -9,10 +9,10 @@ public class AcceptTradingEvent extends MessageHandler { public void handle() { Habbo habbo = this.client.getHabbo(); - if (habbo == null || habbo.getHabboInfo() == null || habbo.getHabboInfo().getCurrentRoom() == null) + if (habbo == null || habbo.getHabboInfo() == null || habbo.getRoomUnit().getRoom() == null) return; - RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java index 233fdec7..f3c16d65 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java @@ -1,21 +1,21 @@ package com.eu.habbo.messages.incoming.trading; import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class AddItemToTradeEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); if (trade == null) return; - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); if (item == null || !item.getBaseItem().allowTrade()) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java index 716eff81..4adcc2d7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java @@ -1,26 +1,26 @@ package com.eu.habbo.messages.incoming.trading; import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import gnu.trove.set.hash.THashSet; public class AddItemsToTradeEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) + if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); if (trade == null) return; - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); int count = this.packet.readInt(); for (int i = 0; i < count; i++) { - HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); + RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt()); if (item != null && item.getBaseItem().allowTrade()) { items.add(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java index c75d62bd..1a17b345 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java @@ -8,7 +8,7 @@ public class ConfirmAcceptTradingEvent extends MessageHandler { @Override public void handle() { Habbo habbo = this.client.getHabbo(); - RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); if (trade == null || !trade.getRoomTradeUserForHabbo(habbo).isAccepted()) return; 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 b0661bdc..2a88aefc 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 @@ -16,9 +16,9 @@ public class OpenTradingEvent extends MessageHandler { this.client.getHabbo().getHabboStats().setLastTradeTimestamp(Emulator.getIntUnixTimestamp()); int userId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getId()) { + if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getVirtualId()) { Habbo targetUser = room.getHabboByRoomUnitId(userId); boolean tradeAnywhere = this.client.getHabbo().hasRight(Permission.ACC_TRADE_ANYWHERE); @@ -28,7 +28,7 @@ public class OpenTradingEvent extends MessageHandler { return; } - if ((room.getTradeMode() == 0 || (room.getTradeMode() == 1 && this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId())) && !tradeAnywhere) { + if ((room.getRoomInfo().getTradeMode() == 0 || (room.getRoomInfo().getTradeMode() == 1 && this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId())) && !tradeAnywhere) { this.client.sendResponse(new TradingOpenFailedComposer(TradingOpenFailedComposer.ROOM_TRADING_NOT_ALLOWED)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java index ee8245f1..e3213a64 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.incoming.trading; import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; public class RemoveItemFromTradeEvent extends MessageHandler { @@ -9,9 +9,9 @@ public class RemoveItemFromTradeEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - RoomTrade trade = this.client.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); if (trade != null) { - HabboItem item = trade.getRoomTradeUserForHabbo(this.client.getHabbo()).getItem(itemId); + RoomItem item = trade.getRoomTradeUserForHabbo(this.client.getHabbo()).getItem(itemId); if (!trade.getRoomTradeUserForHabbo(this.client.getHabbo()).isAccepted() && item != null) { trade.removeItem(this.client.getHabbo(), item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java index a2fb005a..188da4d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java @@ -7,7 +7,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public abstract class TradingEvent extends MessageHandler { protected void stopTrade(Habbo habbo) { - Room room = habbo.getHabboInfo().getCurrentRoom(); + Room room = habbo.getRoomUnit().getRoom(); if (room == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java index ac788b39..d5d3db0c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java @@ -8,7 +8,7 @@ public class UnacceptTradingEvent extends MessageHandler { @Override public void handle() { Habbo habbo = this.client.getHabbo(); - RoomTrade trade = habbo.getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java index 7146433a..91e190fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java @@ -14,8 +14,8 @@ public class AvatarEffectSelectedEvent extends MessageHandler { } else { this.client.getHabbo().getInventory().getEffectsComponent().setActivatedEffect(0); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(this.client.getHabbo().getRoomUnit(), 0, -1); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getRoomUnit().getRoom().giveEffect(this.client.getHabbo().getRoomUnit(), 0, -1); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeMottoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeMottoEvent.java index 6d2405e5..aceeab5f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeMottoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeMottoEvent.java @@ -21,8 +21,8 @@ public class ChangeMottoEvent extends MessageHandler { this.client.getHabbo().getHabboInfo().run(); } - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(this.client.getHabbo()).compose()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(this.client.getHabbo()).compose()); } else { this.client.sendResponse(new UserChangeMessageComposer(this.client.getHabbo())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java index 241ac1c9..af63c7c2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java @@ -1,12 +1,12 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.ChangeUserNameResultMessageEvent; -import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer; import com.eu.habbo.messages.outgoing.users.CheckUserNameResultMessageComposer; import com.eu.habbo.messages.outgoing.users.UserObjectComposer; @@ -58,7 +58,6 @@ public class ChangeUserNameEvent extends MessageHandler { Emulator.getPluginManager().fireEvent(new UserNameChangedEvent(this.client.getHabbo(), oldName)); for (Room room : Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo())) { - room.setOwnerName(name); room.setNeedsUpdate(true); room.save(); } @@ -69,13 +68,13 @@ public class ChangeUserNameEvent extends MessageHandler { this.client.sendResponse(new ChangeUserNameResultMessageEvent(this.client.getHabbo())); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserNameChangedMessageComposer(this.client.getHabbo()).compose()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserNameChangedMessageComposer(this.client.getHabbo()).compose()); } else { this.client.sendResponse(new UserNameChangedMessageComposer(this.client.getHabbo()).compose()); } - this.client.getHabbo().getMessenger().connectionChanged(this.client.getHabbo(), true, this.client.getHabbo().getHabboInfo().getCurrentRoom() != null); + this.client.getHabbo().getMessenger().connectionChanged(this.client.getHabbo(), true, this.client.getHabbo().getRoomUnit().getRoom() != null); this.client.getHabbo().getClient().sendResponse(new UserObjectComposer(this.client.getHabbo())); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO namechange_log (user_id, old_name, new_name, timestamp) VALUES (?, ?, ?, ?) ")) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetActivatedBadgesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetActivatedBadgesEvent.java index c7509697..e798c4b7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetActivatedBadgesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetActivatedBadgesEvent.java @@ -35,8 +35,8 @@ public class SetActivatedBadgesEvent extends MessageHandler { } } - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(updatedBadges, this.client.getHabbo().getHabboInfo().getId()).compose()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserBadgesComposer(updatedBadges, this.client.getHabbo().getHabboInfo().getId()).compose()); } else { this.client.sendResponse(new UserBadgesComposer(updatedBadges, this.client.getHabbo().getHabboInfo().getId())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java index d2e1b78d..2e1dbbd7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UpdateFigureDataEvent.java @@ -39,8 +39,8 @@ public class UpdateFigureDataEvent extends MessageHandler { this.client.getHabbo().getHabboInfo().setGender(lookEvent.getGender()); Emulator.getThreading().run(this.client.getHabbo().getHabboInfo()); this.client.sendResponse(new FigureUpdateComposer(this.client.getHabbo())); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(this.client.getHabbo()).compose()); + if (this.client.getHabbo().getRoomUnit().getRoom() != null) { + this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(this.client.getHabbo()).compose()); } AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("AvatarLooks")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 6971d6ca..20b952e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; 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.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -35,19 +35,19 @@ public class ApplySnapshotEvent extends MessageHandler { return; } - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); // Executing Habbo should be able to edit wireds - if (room == null || (!room.hasRights(this.client.getHabbo()) && !room.isOwner(this.client.getHabbo()))) { + if (room == null || (!room.hasRights(this.client.getHabbo()) && !room.getRoomInfo().isRoomOwner(this.client.getHabbo()))) { return; } - List wireds = new ArrayList<>(); + List wireds = new ArrayList<>(); wireds.addAll(room.getRoomSpecialTypes().getConditions()); wireds.addAll(room.getRoomSpecialTypes().getEffects()); // Find the item with the given ID in the room - Optional item = wireds.stream() + Optional item = wireds.stream() .filter(wired -> wired.getId() == itemId) .findFirst(); @@ -56,13 +56,13 @@ public class ApplySnapshotEvent extends MessageHandler { return; } - HabboItem wiredItem = item.get(); + RoomItem wiredItem = item.get(); // The item should have settings to match furni state, position and rotation if (wiredItem instanceof InteractionWiredMatchFurniSettings wired) { // Try to apply the set settings to each item wired.getMatchSettings().forEach(setting -> { - HabboItem matchItem = room.getHabboItem(setting.getItem_id()); + RoomItem matchItem = room.getHabboItem(setting.getItem_id()); // Match state if (wired.shouldMatchState() && matchItem.allowWiredResetState() && !setting.getState().equals(" ") && !matchItem.getExtradata().equals(setting.getState())) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index 80c3d987..32fd699b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -13,10 +13,10 @@ public class UpdateActionEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { //TODO Check SUPER WIRED PERMISSIONS TOO InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index 24ce1cb6..96d3be2a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -13,10 +13,10 @@ public class UpdateConditionEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index 7f3d0ff7..b277efb1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -13,10 +13,10 @@ public class UpdateTriggerEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java index 0db1cc67..f044aea3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionInvitedToGuideRoomMessageComposer.java @@ -15,8 +15,8 @@ public class GuideSessionInvitedToGuideRoomMessageComposer extends MessageCompos @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionInvitedToGuideRoomMessageComposer); - this.response.appendInt(this.room != null ? this.room.getId() : 0); - this.response.appendString(this.room != null ? this.room.getName() : ""); + this.response.appendInt(this.room != null ? this.room.getRoomInfo().getId() : 0); + this.response.appendString(this.room != null ? this.room.getRoomInfo().getName() : ""); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java index bcce411b..61d95616 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guides/GuideSessionRequesterRoomMessageComposer.java @@ -12,7 +12,7 @@ public class GuideSessionRequesterRoomMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.guideSessionRequesterRoomMessageComposer); - this.response.appendInt(this.room != null ? this.room.getId() : 0); + this.response.appendInt(this.room != null ? this.room.getRoomInfo().getId() : 0); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java index 28b34815..72aad389 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/FavoriteMembershipUpdateMessageComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.habbohotel.guilds.Guild; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -16,7 +16,7 @@ public class FavoriteMembershipUpdateMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.favoriteMembershipUpdateMessageComposer); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendInt(this.guild != null ? this.guild.getId() : 0); this.response.appendInt(this.guild != null ? this.guild.getState().getState() : 3); this.response.appendString(this.guild != null ? this.guild.getName() : ""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java index 670715c3..2edf2412 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildCreationInfoMessageComposer.java @@ -18,8 +18,8 @@ public class GuildCreationInfoMessageComposer extends MessageComposer { this.response.appendInt(this.rooms.size()); for (Room room : this.rooms) { - this.response.appendInt(room.getId()); - this.response.appendString(room.getName()); + this.response.appendInt(room.getRoomInfo().getId()); + this.response.appendString(room.getRoomInfo().getName()); this.response.appendBoolean(false); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java index 3fc033e8..ff968a33 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFurniContextMenuInfoMessageComposer.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -13,7 +13,7 @@ import lombok.AllArgsConstructor; public class GuildFurniContextMenuInfoMessageComposer extends MessageComposer { private final Habbo habbo; private final Guild guild; - private final HabboItem item; + private final RoomItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java index 34809b06..fc797a33 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.inventory; import com.eu.habbo.habbohotel.items.FurnitureType; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -9,43 +9,43 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class FurniListAddOrUpdateComposer extends MessageComposer { - private final HabboItem habboItem; + private final RoomItem roomItem; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.furniListAddOrUpdateComposer); - this.response.appendInt(this.habboItem.getGiftAdjustedId()); - this.response.appendString(this.habboItem.getBaseItem().getType().code); - this.response.appendInt(this.habboItem.getId()); - this.response.appendInt(this.habboItem.getBaseItem().getSpriteId()); + this.response.appendInt(this.roomItem.getGiftAdjustedId()); + this.response.appendString(this.roomItem.getBaseItem().getType().code); + this.response.appendInt(this.roomItem.getId()); + this.response.appendInt(this.roomItem.getBaseItem().getSpriteId()); - switch (this.habboItem.getBaseItem().getName()) { + switch (this.roomItem.getBaseItem().getName()) { case "landscape" -> this.response.appendInt(4); case "floor" -> this.response.appendInt(3); case "wallpaper" -> this.response.appendInt(2); case "poster" -> this.response.appendInt(6); } - if (this.habboItem.isLimited()) { + if (this.roomItem.isLimited()) { this.response.appendInt(1); this.response.appendInt(256); - this.response.appendString(this.habboItem.getExtradata()); - this.response.appendInt(this.habboItem.getLimitedSells()); - this.response.appendInt(this.habboItem.getLimitedStack()); + this.response.appendString(this.roomItem.getExtradata()); + this.response.appendInt(this.roomItem.getLimitedSells()); + this.response.appendInt(this.roomItem.getLimitedStack()); } else { this.response.appendInt(1); this.response.appendInt(0); - this.response.appendString(this.habboItem.getExtradata()); + this.response.appendString(this.roomItem.getExtradata()); } - this.response.appendBoolean(this.habboItem.getBaseItem().allowRecyle()); - this.response.appendBoolean(this.habboItem.getBaseItem().allowTrade()); - this.response.appendBoolean(!this.habboItem.isLimited() && this.habboItem.getBaseItem().allowInventoryStack()); - this.response.appendBoolean(this.habboItem.getBaseItem().allowMarketplace()); + this.response.appendBoolean(this.roomItem.getBaseItem().allowRecyle()); + this.response.appendBoolean(this.roomItem.getBaseItem().allowTrade()); + this.response.appendBoolean(!this.roomItem.isLimited() && this.roomItem.getBaseItem().allowInventoryStack()); + this.response.appendBoolean(this.roomItem.getBaseItem().allowMarketplace()); this.response.appendInt(-1); this.response.appendBoolean(false); this.response.appendInt(-1); - if (this.habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { + if (this.roomItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.response.appendString(""); //slotId this.response.appendInt(0); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java index 9def2fb0..71f01bec 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.outgoing.inventory; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -16,11 +16,11 @@ import java.util.List; @Slf4j @AllArgsConstructor -public class FurniListComposer extends MessageComposer implements TIntObjectProcedure { +public class FurniListComposer extends MessageComposer implements TIntObjectProcedure { private final int fragmentNumber; private final int totalFragments; - private final TIntObjectMap items; + private final TIntObjectMap items; @Override @@ -41,14 +41,14 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc } @Override - public boolean execute(int a, HabboItem habboItem) { - this.response.appendInt(habboItem.getGiftAdjustedId()); - this.response.appendString(habboItem.getBaseItem().getType().code); - this.response.appendInt(habboItem.getId()); - this.response.appendInt(habboItem.getBaseItem().getSpriteId()); + public boolean execute(int a, RoomItem roomItem) { + this.response.appendInt(roomItem.getGiftAdjustedId()); + this.response.appendString(roomItem.getBaseItem().getType().code); + this.response.appendInt(roomItem.getId()); + this.response.appendInt(roomItem.getBaseItem().getSpriteId()); - if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("song_disk") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { - switch (habboItem.getBaseItem().getName()) { + if (roomItem.getBaseItem().getName().equals("floor") || roomItem.getBaseItem().getName().equals("song_disk") || roomItem.getBaseItem().getName().equals("landscape") || roomItem.getBaseItem().getName().equals("wallpaper") || roomItem.getBaseItem().getName().equals("poster")) { + switch (roomItem.getBaseItem().getName()) { case "landscape" -> this.response.appendInt(4); case "floor" -> this.response.appendInt(3); case "wallpaper" -> this.response.appendInt(2); @@ -57,39 +57,39 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc } this.response.appendInt(0); - this.response.appendString(habboItem.getExtradata()); + this.response.appendString(roomItem.getExtradata()); } else { - if (habboItem.getBaseItem().getName().equals("gnome_box")) + if (roomItem.getBaseItem().getName().equals("gnome_box")) this.response.appendInt(13); else - this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); + this.response.appendInt(roomItem instanceof InteractionGift ? ((((InteractionGift) roomItem).getColorId() * 1000) + ((InteractionGift) roomItem).getRibbonId()) : 1); - habboItem.serializeExtradata(this.response); + roomItem.serializeExtradata(this.response); } - this.response.appendBoolean(habboItem.getBaseItem().allowRecyle()); - this.response.appendBoolean(habboItem.getBaseItem().allowTrade()); - this.response.appendBoolean(!habboItem.isLimited() && habboItem.getBaseItem().allowInventoryStack()); - this.response.appendBoolean(habboItem.getBaseItem().allowMarketplace()); + this.response.appendBoolean(roomItem.getBaseItem().allowRecyle()); + this.response.appendBoolean(roomItem.getBaseItem().allowTrade()); + this.response.appendBoolean(!roomItem.isLimited() && roomItem.getBaseItem().allowInventoryStack()); + this.response.appendBoolean(roomItem.getBaseItem().allowMarketplace()); this.response.appendInt(-1); this.response.appendBoolean(true); this.response.appendInt(-1); - if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { + if (roomItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.response.appendString(""); - if(habboItem.getBaseItem().getName().equals("song_disk")) { - List extraDataAsList = Arrays.asList(habboItem.getExtradata().split("\n")); + if(roomItem.getBaseItem().getName().equals("song_disk")) { + List extraDataAsList = Arrays.asList(roomItem.getExtradata().split("\n")); this.response.appendInt(Integer.valueOf(extraDataAsList.get(extraDataAsList.size() - 1))); return true; } - this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); + this.response.appendInt(roomItem instanceof InteractionGift ? ((((InteractionGift) roomItem).getColorId() * 1000) + ((InteractionGift) roomItem).getRibbonId()) : 1); } return true; } - public void addExtraDataToResponse(HabboItem habboItem) { + public void addExtraDataToResponse(RoomItem roomItem) { this.response.appendInt(0); - this.response.appendString(habboItem.getExtradata()); + this.response.appendString(roomItem.getExtradata()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java index 670f204e..2f7313ef 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.inventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -10,18 +10,18 @@ import java.util.List; import java.util.Map; public class UnseenItemsComposer extends MessageComposer { - private THashSet itemsList; - private HabboItem item; + private THashSet itemsList; + private RoomItem item; private int[] ids; private AddHabboItemCategory category; private Map> entries; - public UnseenItemsComposer(THashSet itemsList) { + public UnseenItemsComposer(THashSet itemsList) { this.itemsList = itemsList; this.category = AddHabboItemCategory.OWNED_FURNI; } - public UnseenItemsComposer(HabboItem item) { + public UnseenItemsComposer(RoomItem item) { this.item = item; this.category = AddHabboItemCategory.OWNED_FURNI; } @@ -67,8 +67,8 @@ public class UnseenItemsComposer extends MessageComposer { this.response.appendInt(1); this.response.appendInt(1); this.response.appendInt(this.itemsList.size()); - for (HabboItem habboItem : this.itemsList) { - this.response.appendInt(habboItem.getId()); + for (RoomItem roomItem : this.itemsList) { + this.response.appendInt(roomItem.getId()); } } else { this.response.appendInt(1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java index ff356e02..d4e763d2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/CfhChatlogComposer.java @@ -73,8 +73,8 @@ public class CfhChatlogComposer extends MessageComposer { this.response.appendInt(this.issue.roomId); ModToolChatRecordDataContext.GROUP_ID.append(this.response); - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.issue.roomId); - this.response.appendInt(room == null ? 0 : room.getGuildId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.issue.roomId); + this.response.appendInt(room == null ? 0 : room.getRoomInfo().getGuild().getId()); } this.response.appendShort(this.chatlog.size()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java index 4e05d6f0..44d93cdd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java @@ -13,17 +13,17 @@ public class ModeratorRoomInfoComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorRoomInfoComposer); - this.response.appendInt(this.room.getId()); - this.response.appendInt(this.room.getCurrentHabbos().size()); - this.response.appendBoolean(this.room.getHabbo(this.room.getOwnerId()) != null); - this.response.appendInt(this.room.getOwnerId()); - this.response.appendString(this.room.getOwnerName()); + this.response.appendInt(this.room.getRoomInfo().getId()); + this.response.appendInt(this.room.getRoomUnitManager().getCurrentRoomHabbos().size()); + this.response.appendBoolean(this.room.getRoomUnitManager().getRoomHabboById(this.room.getRoomInfo().getOwnerInfo().getId()) != null); + this.response.appendInt(this.room.getRoomInfo().getOwnerInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getOwnerInfo().getUsername()); this.response.appendBoolean(true); - this.response.appendString(this.room.getName()); - this.response.appendString(this.room.getDescription()); - this.response.appendInt(this.room.getTags().split(";").length); - for (int i = 0; i < this.room.getTags().split(";").length; i++) { - this.response.appendString(this.room.getTags().split(";")[i]); + this.response.appendString(this.room.getRoomInfo().getName()); + this.response.appendString(this.room.getRoomInfo().getDescription()); + this.response.appendInt(this.room.getRoomInfo().getTags().split(";").length); + for (int i = 0; i < this.room.getRoomInfo().getTags().split(";").length; i++) { + this.response.appendString(this.room.getRoomInfo().getTags().split(";")[i]); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java index e7118bda..1d16b565 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/RoomChatlogComposer.java @@ -23,10 +23,10 @@ public class RoomChatlogComposer extends MessageComposer { this.response.appendShort(2); this.response.appendString("roomName"); this.response.appendByte(2); - this.response.appendString(this.room.getName()); + this.response.appendString(this.room.getRoomInfo().getName()); this.response.appendString("roomId"); this.response.appendByte(1); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); SimpleDateFormat formatDate = new SimpleDateFormat("HH:mm"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java index 5b7ebaf1..04e32e6c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/FlatCreatedComposer.java @@ -13,8 +13,8 @@ public class FlatCreatedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatCreatedComposer); - this.response.appendInt(this.room.getId()); - this.response.appendString(this.room.getName()); + this.response.appendInt(this.room.getRoomInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getName()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java index c09508f2..7e7eaded 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java @@ -39,7 +39,7 @@ public class BannedUsersFromRoomComposer extends MessageComposer { return null; this.response.init(Outgoing.bannedUsersFromRoomComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendInt(roomBans.size()); for (RoomBan ban : roomBans) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java index 8534955a..99fd4b5d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerAddedComposer.java @@ -15,7 +15,7 @@ public class FlatControllerAddedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatControllerAddedComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendInt(this.userId); this.response.appendString(this.userName); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java index 4300380c..3c2d73c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllerRemovedComposer.java @@ -15,7 +15,7 @@ public class FlatControllerRemovedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatControllerRemovedComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendInt(this.userId); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java index 079357f7..77a70991 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java @@ -16,7 +16,7 @@ public class FlatControllersComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.flatControllersComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); THashMap rightsMap = this.room.getUsersWithRights(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java index 253b4ee0..321a481f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FloorHeightMapComposer.java @@ -14,7 +14,7 @@ public class FloorHeightMapComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.floorHeightMapComposer); this.response.appendBoolean(true); - this.response.appendInt(this.room.getWallHeight()); //FixedWallsHeight + this.response.appendInt(this.room.getRoomInfo().getWallThickness()); //FixedWallsHeight this.response.appendString(this.room.getLayout().getRelativeMap()); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java index 14017806..96ecebbe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GamePlayerValueMessageComposer.java @@ -13,7 +13,7 @@ public class GamePlayerValueMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.gamePlayerValueMessageComposer); - this.response.appendInt(this.gamePlayer.getHabbo().getRoomUnit().getId()); + this.response.appendInt(this.gamePlayer.getHabbo().getRoomUnit().getVirtualId()); this.response.appendInt(this.gamePlayer.getLives()); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java index 0f37d218..e2a73ccf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java @@ -1,7 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; @@ -20,89 +19,31 @@ public class GetGuestRoomResultComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.getGuestRoomResultComposer); this.response.appendBoolean(this.enterRoom); - this.response.appendInt(this.room.getId()); - this.response.appendString(this.room.getName()); - if (this.room.isPublicRoom()) { - this.response.appendInt(0); - this.response.appendString(""); - } else { - this.response.appendInt(this.room.getOwnerId()); - this.response.appendString(this.room.getOwnerName()); - } - this.response.appendInt(this.room.getState().ordinal()); - this.response.appendInt(this.room.getUserCount()); - this.response.appendInt(this.room.getUsersMax()); - this.response.appendString(this.room.getDescription()); - this.response.appendInt(this.room.getTradeMode()); - this.response.appendInt(this.room.getScore()); - this.response.appendInt(2);//Top rated room rank - this.response.appendInt(this.room.getCategory()); - if (!this.room.getTags().isEmpty()) { - String[] tags = this.room.getTags().split(";"); - this.response.appendInt(tags.length); - for (String s : tags) { - this.response.appendString(s); - } - } else { - this.response.appendInt(0); - } - - int base = 0; - - if (this.room.getGuildId() > 0) { - base = base | 2; - } - - if (!this.room.isPublicRoom()) { - base = base | 8; - } - - if (this.room.isPromoted()) { - base = base | 4; - } - - if (this.room.isAllowPets()) { - base = base | 16; - } - - this.response.appendInt(base); - - if (this.room.getGuildId() > 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.room.getGuildId()); - if (g != null) { - this.response.appendInt(g.getId()); - this.response.appendString(g.getName()); - this.response.appendString(g.getBadge()); - } else { - this.response.appendInt(0); - this.response.appendString(""); - this.response.appendString(""); - } - } - - if (this.room.isPromoted()) { - this.response.appendString(this.room.getPromotion().getTitle()); - this.response.appendString(this.room.getPromotion().getDescription()); - this.response.appendInt((this.room.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); - } + this.response.append(this.room); this.response.appendBoolean(this.roomForward); - this.response.appendBoolean(this.room.isStaffPromotedRoom()); // staffpicked - this.response.appendBoolean(this.room.hasGuild() && Emulator.getGameEnvironment().getGuildManager().getGuildMember(this.room.getGuildId(), this.habbo.getHabboInfo().getId()) != null); // is group member + this.response.appendBoolean(this.room.getRoomInfo().isStaffPicked()); // staffpicked + + if(this.room.getRoomInfo().hasGuild()) { + this.response.appendBoolean(Emulator.getGameEnvironment().getGuildManager().getGuildMember(this.room.getRoomInfo().getGuild().getId(), this.habbo.getHabboInfo().getId()) != null); + } else { + this.response.appendBoolean(false); + } + this.response.appendBoolean(this.room.isMuted()); // isroommuted - this.response.appendInt(this.room.getMuteOption()); - this.response.appendInt(this.room.getKickOption()); - this.response.appendInt(this.room.getBanOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanMuteOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanKickOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanBanOption()); this.response.appendBoolean(this.room.hasRights(this.habbo)); //mute all button - this.response.appendInt(this.room.getChatMode()); - this.response.appendInt(this.room.getChatWeight()); - this.response.appendInt(this.room.getChatSpeed()); - this.response.appendInt(this.room.getChatDistance()); - this.response.appendInt(this.room.getChatProtection()); + this.response.appendInt(this.room.getRoomInfo().getChatMode()); + this.response.appendInt(this.room.getRoomInfo().getChatWeight()); + this.response.appendInt(this.room.getRoomInfo().getChatSpeed()); + this.response.appendInt(this.room.getRoomInfo().getChatDistance()); + this.response.appendInt(this.room.getRoomInfo().getChatProtection()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java index 0f51fb6a..d73702f8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomChatSettingsMessageComposer.java @@ -13,11 +13,11 @@ public class RoomChatSettingsMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomChatSettingsMessageComposer); - this.response.appendInt(this.room.getChatMode()); - this.response.appendInt(this.room.getChatWeight()); - this.response.appendInt(this.room.getChatSpeed()); - this.response.appendInt(this.room.getChatDistance()); - this.response.appendInt(this.room.getChatProtection()); + this.response.appendInt(this.room.getRoomInfo().getChatMode()); + this.response.appendInt(this.room.getRoomInfo().getChatWeight()); + this.response.appendInt(this.room.getRoomInfo().getChatSpeed()); + this.response.appendInt(this.room.getRoomInfo().getChatDistance()); + this.response.appendInt(this.room.getRoomInfo().getChatProtection()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java index b236b606..74e1ee07 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoComposer.java @@ -13,8 +13,8 @@ public class RoomEntryInfoComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomEntryInfoComposer); - this.response.appendInt(this.room.getId()); - this.response.appendString(this.room.getOwnerName()); + this.response.appendInt(this.room.getRoomInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getOwnerInfo().getUsername()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java index cad2f54f..254611a9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomEntryInfoMessageComposer.java @@ -14,7 +14,7 @@ public class RoomEntryInfoMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomEntryInfoMessageComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendBoolean(this.roomOwner); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java index f123933c..a5475d47 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFloorThicknessUpdatedComposer.java @@ -13,9 +13,9 @@ public class RoomFloorThicknessUpdatedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomFloorThicknessUpdatedComposer); - this.response.appendBoolean(this.room.isHideWall()); //Hide walls? - this.response.appendInt(this.room.getFloorSize()); //Floor Thickness - this.response.appendInt(this.room.getWallSize()); //Wall Thickness + this.response.appendBoolean(this.room.getRoomInfo().isHideWalls()); + this.response.appendInt(this.room.getRoomInfo().getFloorThickness()); + this.response.appendInt(this.room.getRoomInfo().getWallThickness()); return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java index 77ed4d97..a0e2e673 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomInfoUpdatedComposer.java @@ -13,7 +13,7 @@ public class RoomInfoUpdatedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomInfoUpdatedComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java index d57b2c22..641e07c8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomReadyMessageComposer.java @@ -14,7 +14,7 @@ public class RoomReadyMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.roomReadyMessageComposer); this.response.appendString(this.room.getLayout().getName()); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java index 6e461e65..84ff0674 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsDataComposer.java @@ -12,17 +12,17 @@ public class RoomSettingsDataComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomSettingsDataComposer); - this.response.appendInt(this.room.getId()); - this.response.appendString(this.room.getName()); - this.response.appendString(this.room.getDescription()); - this.response.appendInt(this.room.getState().ordinal()); - this.response.appendInt(this.room.getCategory()); - this.response.appendInt(this.room.getUsersMax()); - this.response.appendInt(this.room.getUsersMax()); + this.response.appendInt(this.room.getRoomInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getName()); + this.response.appendString(this.room.getRoomInfo().getDescription()); + this.response.appendInt(this.room.getRoomInfo().getState().ordinal()); + this.response.appendInt(this.room.getRoomInfo().getCategory().getId()); + this.response.appendInt(this.room.getRoomInfo().getMaxUsers()); + this.response.appendInt(this.room.getRoomInfo().getMaxUsers()); - if (!this.room.getTags().isEmpty()) { - this.response.appendInt(this.room.getTags().split(";").length); - for (String tag : this.room.getTags().split(";")) { + if (!this.room.getRoomInfo().getTags().isEmpty()) { + this.response.appendInt(this.room.getRoomInfo().getTags().split(";").length); + for (String tag : this.room.getRoomInfo().getTags().split(";")) { this.response.appendString(tag); } } else { @@ -30,25 +30,25 @@ public class RoomSettingsDataComposer extends MessageComposer { } //this.response.appendInt(this.room.getRights().size()); - this.response.appendInt(this.room.getTradeMode()); //Trade Mode - this.response.appendInt(this.room.isAllowPets() ? 1 : 0); - this.response.appendInt(this.room.isAllowPetsEat() ? 1 : 0); - this.response.appendInt(this.room.isAllowWalkthrough() ? 1 : 0); - this.response.appendInt(this.room.isHideWall() ? 1 : 0); - this.response.appendInt(this.room.getWallSize()); - this.response.appendInt(this.room.getFloorSize()); + this.response.appendInt(this.room.getRoomInfo().getTradeMode()); //Trade Mode + this.response.appendInt(this.room.getRoomInfo().isAllowPets() ? 1 : 0); + this.response.appendInt(this.room.getRoomInfo().isAllowPetsEat() ? 1 : 0); + this.response.appendInt(this.room.getRoomInfo().isAllowWalkthrough() ? 1 : 0); + this.response.appendInt(this.room.getRoomInfo().isHideWalls() ? 1 : 0); + this.response.appendInt(this.room.getRoomInfo().getWallThickness()); + this.response.appendInt(this.room.getRoomInfo().getFloorThickness()); - this.response.appendInt(this.room.getChatMode()); - this.response.appendInt(this.room.getChatWeight()); - this.response.appendInt(this.room.getChatSpeed()); - this.response.appendInt(this.room.getChatDistance()); - this.response.appendInt(this.room.getChatProtection()); + this.response.appendInt(this.room.getRoomInfo().getChatMode()); + this.response.appendInt(this.room.getRoomInfo().getChatWeight()); + this.response.appendInt(this.room.getRoomInfo().getChatSpeed()); + this.response.appendInt(this.room.getRoomInfo().getChatDistance()); + this.response.appendInt(this.room.getRoomInfo().getChatProtection()); this.response.appendBoolean(false); //IDK? - this.response.appendInt(this.room.getMuteOption()); - this.response.appendInt(this.room.getKickOption()); - this.response.appendInt(this.room.getBanOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanMuteOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanKickOption()); + this.response.appendInt(this.room.getRoomInfo().getWhoCanBanOption()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java index 5ebf1aa1..6240dde0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomSettingsSavedComposer.java @@ -13,7 +13,7 @@ public class RoomSettingsSavedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomSettingsSavedComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java index 4982e0db..a434684c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomVisualizationSettingsComposer.java @@ -13,9 +13,9 @@ public class RoomVisualizationSettingsComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomVisualizationSettingsComposer); - this.response.appendBoolean(this.room.isHideWall()); - this.response.appendInt(this.room.getWallSize()); - this.response.appendInt(this.room.getFloorSize()); + this.response.appendBoolean(this.room.getRoomInfo().isHideWalls()); + this.response.appendInt(this.room.getRoomInfo().getWallThickness()); + this.response.appendInt(this.room.getRoomInfo().getFloorThickness()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java index 40629d13..092a2e9c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -12,8 +12,8 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class FloorItemOnRollerComposer extends MessageComposer { // THIS IS WRONG SlideObjectBundleMessageComposer - private final HabboItem item; - private final HabboItem roller; + private final RoomItem item; + private final RoomItem roller; private final RoomTile oldLocation; private final double oldZ; private final RoomTile newLocation; @@ -21,7 +21,7 @@ public class FloorItemOnRollerComposer extends MessageComposer { private final double heightOffset; private final Room room; - public FloorItemOnRollerComposer(HabboItem item, HabboItem roller, RoomTile newLocation, double heightOffset, Room room) { + public FloorItemOnRollerComposer(RoomItem item, RoomItem roller, RoomTile newLocation, double heightOffset, Room room) { this.item = item; this.roller = roller; this.newLocation = newLocation; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java index 88325771..84d63be3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemAddMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ItemAddMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final String itemOwnerName; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java index 50fa9538..79954732 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ItemRemoveMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java index d2b3ecf0..52a974e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ItemUpdateMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java index 13ff6004..64ab747a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -42,10 +42,10 @@ public class ItemsComposer extends MessageComposer { this.response.appendString(set.getValue()); } - List items = this.room.getWallItems(); + List items = this.room.getWallItems(); this.response.appendInt(items.size()); - for (HabboItem item : items) { + for (RoomItem item : items) { item.serializeWallData(this.response); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java index 76359e60..0777a895 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -10,14 +10,14 @@ import java.util.Set; @AllArgsConstructor public class ItemsDataUpdateComposer extends MessageComposer { - private final Set items; + private final Set items; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.objectsDataUpdateMessageComposer); this.response.appendInt(this.items.size()); - for (HabboItem item : this.items) { + for (RoomItem item : this.items) { this.response.appendInt(item.getId()); item.serializeExtradata(this.response); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java index 6f89621e..e6776dbc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.habbohotel.items.interactions.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -9,7 +9,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ObjectAddMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final String itemOwnerName; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java index 76b98b6f..08e461bb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectDataUpdateMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ObjectDataUpdateMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java index 9f48b749..1dcf506d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -10,7 +10,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class ObjectUpdateMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java index 797533a0..30062513 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.rooms.items; import com.eu.habbo.habbohotel.items.interactions.*; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -15,7 +15,7 @@ import java.util.NoSuchElementException; @AllArgsConstructor public class ObjectsMessageComposer extends MessageComposer { private final TIntObjectMap furniOwnerNames; - private final THashSet items; + private final THashSet items; @Override @@ -37,7 +37,7 @@ public class ObjectsMessageComposer extends MessageComposer { this.response.appendInt(this.items.size()); - for (HabboItem item : this.items) { + for (RoomItem item : this.items) { item.serializeFloorData(this.response); this.response.appendInt(item instanceof InteractionGift ? ((((InteractionGift) item).getColorId() * 1000) + ((InteractionGift) item).getRibbonId()) : (item instanceof InteractionMusicDisc ? ((InteractionMusicDisc) item).getSongId() : 1)); item.serializeExtradata(this.response); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java index dfaa9c36..9ee6f7af 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class OneWayDoorStatusMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java index 21e5773a..11ade4fa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/PresentOpenedMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class PresentOpenedMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final String text; private final boolean unknown; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java index 724b51a6..36e7daf8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,10 +8,10 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class RemoveFloorItemComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final boolean noUser; - public RemoveFloorItemComposer(HabboItem item) { + public RemoveFloorItemComposer(RoomItem item) { this.item = item; this.noUser = false; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java index f3016dd0..fb230aee 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RequestSpamWallPostItMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class RequestSpamWallPostItMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override protected ServerMessage composeInternal() { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java index c9c07747..749d9580 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/UpdateStackHeightTileHeightComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.items; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class UpdateStackHeightTileHeightComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final int height; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java index 0061c9a6..4a130394 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/rentablespaces/RentableSpaceStatusMessageComposer.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.outgoing.rooms.items.rentablespaces; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionRentableSpace; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -27,7 +27,7 @@ public class RentableSpaceStatusMessageComposer extends MessageComposer { //:test 194 b:1 i:101 i:1 s:Admin i:10 i:10 private final Habbo habbo; - private final HabboItem item; + private final RoomItem item; private int errorCode = 0; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java index d360906a..f72de30a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/OpenPetPackageRequestedMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.pets; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class OpenPetPackageRequestedMessageComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java index 63a0d18b..9822184e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetExperienceComposer.java @@ -16,7 +16,7 @@ public class PetExperienceComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.petExperienceComposer); this.response.appendInt(this.pet.getId()); - this.response.appendInt(this.pet.getRoomUnit().getId()); + this.response.appendInt(this.pet.getRoomUnit().getVirtualId()); this.response.appendInt(this.amount); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java index f393d9e2..392d5203 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetFigureUpdateComposer.java @@ -14,7 +14,7 @@ public class PetFigureUpdateComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petFigureUpdateComposer); - this.response.appendInt(this.pet.getRoomUnit().getId()); + this.response.appendInt(this.pet.getRoomUnit().getVirtualId()); this.response.appendInt(this.pet.getId()); this.response.appendInt(this.pet.getPetData().getType()); this.response.appendInt(this.pet.getRace()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java index 01583576..dbcc7382 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetLevelUpdatedComposer.java @@ -14,7 +14,7 @@ public class PetLevelUpdatedComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petLevelUpdateComposer); - this.response.appendInt(this.pet.getRoomUnit().getId()); + this.response.appendInt(this.pet.getRoomUnit().getVirtualId()); this.response.appendInt(this.pet.getId()); this.response.appendInt(this.pet.getLevel()); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java index 0b4c7408..5f5b065a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/PetStatusUpdateComposer.java @@ -15,7 +15,7 @@ public class PetStatusUpdateComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.petStatusUpdateComposer); - this.response.appendInt(this.pet.getRoomUnit().getId()); + this.response.appendInt(this.pet.getRoomUnit().getVirtualId()); this.response.appendInt(this.pet instanceof RideablePet && ((RideablePet) this.pet).anyoneCanRide() ? 1 : 0); this.response.appendBoolean((this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).canBreed())); //unknown 1 this.response.appendBoolean((this.pet instanceof MonsterplantPet && !((MonsterplantPet) this.pet).isFullyGrown())); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java index 2d942965..b5285772 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/pets/RoomPetComposer.java @@ -4,17 +4,16 @@ import com.eu.habbo.habbohotel.pets.*; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.map.TIntObjectMap; -import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TIntObjectProcedure; import lombok.AllArgsConstructor; +import java.util.concurrent.ConcurrentHashMap; + @AllArgsConstructor -public class RoomPetComposer extends MessageComposer implements TIntObjectProcedure { - private final TIntObjectMap pets; +public class RoomPetComposer extends MessageComposer { + private final ConcurrentHashMap pets; public RoomPetComposer(Pet pet) { - this.pets = new TIntObjectHashMap<>(); + this.pets = new ConcurrentHashMap<>(); this.pets.put(pet.getId(), pet); } @@ -23,11 +22,10 @@ public class RoomPetComposer extends MessageComposer implements TIntObjectProced protected ServerMessage composeInternal() { this.response.init(Outgoing.usersComposer); this.response.appendInt(this.pets.size()); - this.pets.forEachEntry(this); + this.pets.forEach((a, p) -> this.execute(a, p)); return this.response; } - @Override public boolean execute(int a, Pet pet) { this.response.appendInt(pet.getId()); this.response.appendString(pet.getName()); @@ -38,10 +36,10 @@ public class RoomPetComposer extends MessageComposer implements TIntObjectProced // TODO: It will never be a type of MonsterplantPet in this scenario? this.response.appendString(pet.getPetData().getType() + " " + pet.getRace() + " " + pet.getColor() + " " + ((pet instanceof HorsePet ? (((HorsePet) pet).hasSaddle() ? "3" : "2") + " 2 " + ((HorsePet) pet).getHairStyle() + " " + ((HorsePet) pet).getHairColor() + " 3 " + ((HorsePet) pet).getHairStyle() + " " + ((HorsePet) pet).getHairColor() + (((HorsePet) pet).hasSaddle() ? " 4 9 0" : "") : pet instanceof MonsterplantPet ? (((MonsterplantPet) pet).look.isEmpty() ? "2 1 8 6 0 -1 -1" : ((MonsterplantPet) pet).look) : "2 2 -1 0 3 -1 0"))); } - this.response.appendInt(pet.getRoomUnit().getId()); - this.response.appendInt(pet.getRoomUnit().getX()); - this.response.appendInt(pet.getRoomUnit().getY()); - this.response.appendString(pet.getRoomUnit().getZ() + ""); + this.response.appendInt(pet.getRoomUnit().getVirtualId()); + this.response.appendInt(pet.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(pet.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(pet.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(0); this.response.appendInt(2); this.response.appendInt(pet.getPetData().getType()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java index 437f05dd..7d75dc76 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java @@ -24,8 +24,8 @@ public class RoomAdPurchaseInfoComposer extends MessageComposer { this.response.appendBoolean(true); this.response.appendInt(this.rooms.size()); for (Room room : this.rooms) { - this.response.appendInt(room.getId()); - this.response.appendString(room.getName()); + this.response.appendInt(room.getRoomInfo().getId()); + this.response.appendString(room.getRoomInfo().getName()); this.response.appendBoolean(true); //IDK what the fuck this is. } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java index 0f5f1ebd..5d0a6cd1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java @@ -30,11 +30,11 @@ public class RoomEventComposer extends MessageComposer { this.response.appendInt(0); this.response.appendInt(0); } else { - this.response.appendInt(this.room.getId()); // promotion id - this.response.appendInt(this.room.getOwnerId()); - this.response.appendString(this.room.getOwnerName()); + this.response.appendInt(this.room.getRoomInfo().getId()); // promotion id + this.response.appendInt(this.room.getRoomInfo().getOwnerInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getOwnerInfo().getUsername()); - this.response.appendInt(this.room.getId()); // room id + this.response.appendInt(this.room.getRoomInfo().getId()); // room id this.response.appendInt(1); // "type" this.response.appendString(this.roomPromotion.getTitle()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java index 3004bd7b..41926d47 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/AvatarEffectMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,11 +8,11 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class AvatarEffectMessageComposer extends MessageComposer { - private final RoomUnit roomUnit; + private final RoomAvatar roomAvatar; private final int effectId; - public AvatarEffectMessageComposer(RoomUnit roomUnit) { - this.roomUnit = roomUnit; + public AvatarEffectMessageComposer(RoomAvatar roomAvatar) { + this.roomAvatar = roomAvatar; this.effectId = -1; } @@ -20,8 +20,8 @@ public class AvatarEffectMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.avatarEffectMessageComposer); - this.response.appendInt(this.roomUnit.getId()); - this.response.appendInt(this.effectId == -1 ? this.roomUnit.getEffectId() : this.effectId); + this.response.appendInt(this.roomAvatar.getVirtualId()); + this.response.appendInt(this.effectId == -1 ? this.roomAvatar.getEffectId() : this.effectId); this.response.appendInt(0); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java index 5d3e1947..31171227 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/CarryObjectMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,14 +8,14 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class CarryObjectMessageComposer extends MessageComposer { - private final RoomUnit roomUnit; + private final RoomAvatar roomAvatar; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.carryObjectMessageComposer); - this.response.appendInt(this.roomUnit.getId()); - this.response.appendInt(this.roomUnit.getHandItem()); + this.response.appendInt(this.roomAvatar.getVirtualId()); + this.response.appendInt(this.roomAvatar.getHandItem()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java index 5da8c5b0..fbac4cf0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -14,7 +14,7 @@ public class DanceMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.danceMessageComposer); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendInt(this.roomUnit.getDanceType().getType()); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java index e4a3aef5..370c450f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ExpressionMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -15,7 +15,7 @@ public class ExpressionMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.expressionMessageComposer); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendInt(this.action.getAction()); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java index aa9914e5..7774d2b3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/HandItemReceivedMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -14,7 +14,7 @@ public class HandItemReceivedMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.handItemReceivedMessageComposer); - this.response.appendInt(this.from.getId()); + this.response.appendInt(this.from.getVirtualId()); this.response.appendInt(this.handItem); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java index 559cbc76..cf6fad8f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/NoSuchFlatComposer.java @@ -15,7 +15,7 @@ public class NoSuchFlatComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.noSuchFlatComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendInt(this.habboId); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 36d8ee4e..34fef1f7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionRoller; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -18,7 +18,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { // THIS IS WRONG SlideObjectBundleMessageComposer private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitOnRollerComposer.class); private final RoomUnit roomUnit; - private final HabboItem roller; + private final RoomItem roller; private final RoomTile oldLocation; private final double oldZ; private final RoomTile newLocation; @@ -26,9 +26,9 @@ public class RoomUnitOnRollerComposer extends MessageComposer { private final Room room; private int x; private int y; - private final HabboItem oldTopItem; + private final RoomItem oldTopItem; - public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) { + public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) { this.roomUnit = roomUnit; this.roller = roller; this.oldLocation = oldLocation; @@ -42,8 +42,8 @@ public class RoomUnitOnRollerComposer extends MessageComposer { public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) { this.roomUnit = roomUnit; this.roller = null; - this.oldLocation = this.roomUnit.getCurrentLocation(); - this.oldZ = this.roomUnit.getZ(); + this.oldLocation = this.roomUnit.getCurrentPosition(); + this.oldZ = this.roomUnit.getCurrentZ(); this.newLocation = newLocation; this.newZ = this.newLocation.getStackHeight(); this.room = room; @@ -63,15 +63,15 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.response.appendInt(0); this.response.appendInt(this.roller == null ? 0 : this.roller.getId()); this.response.appendInt(2); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendString(this.oldZ + ""); this.response.appendString(this.newZ + ""); if (this.roller != null && room.getLayout() != null) { Emulator.getThreading().run(() -> { - if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentLocation() == this.oldLocation) { - HabboItem topItem = this.room.getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); - HabboItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); + if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentPosition() == this.oldLocation) { + RoomItem topItem = this.room.getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); + RoomItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) { try { @@ -82,7 +82,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { } this.roomUnit.setLocation(this.newLocation); - this.roomUnit.setZ(this.newLocation.getStackHeight()); + this.roomUnit.setCurrentZ(this.newLocation.getStackHeight()); this.roomUnit.setPreviousLocationZ(this.newLocation.getStackHeight()); if (topItemNewLocation != null && topItemNewLocation != roller && oldTopItem != topItemNewLocation) { @@ -93,7 +93,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { } } } - }, this.room.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); + }, this.room.getRoomInfo().getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); /* RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY()); Emulator.getThreading().run(() -> { @@ -117,7 +117,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { */ } else { this.roomUnit.setLocation(this.newLocation); - this.roomUnit.setZ(this.newZ); + this.roomUnit.setCurrentZ(this.newZ); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java index 10225e60..c491cb35 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java @@ -41,10 +41,10 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendString(this.habbo.getHabboInfo().getMotto()); this.response.appendString(this.habbo.getHabboInfo().getLook()); - this.response.appendInt(this.habbo.getRoomUnit().getId()); //Room Unit ID - this.response.appendInt(this.habbo.getRoomUnit().getX()); - this.response.appendInt(this.habbo.getRoomUnit().getY()); - this.response.appendString(this.habbo.getRoomUnit().getZ() + ""); + this.response.appendInt(this.habbo.getRoomUnit().getVirtualId()); //Room Unit ID + this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(this.habbo.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(1); this.response.appendString(this.habbo.getHabboInfo().getGender().name().toUpperCase()); @@ -71,10 +71,10 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendString(habbo.getHabboInfo().getUsername()); this.response.appendString(habbo.getHabboInfo().getMotto()); this.response.appendString(habbo.getHabboInfo().getLook()); - this.response.appendInt(habbo.getRoomUnit().getId()); //Room Unit ID - this.response.appendInt(habbo.getRoomUnit().getX()); - this.response.appendInt(habbo.getRoomUnit().getY()); - this.response.appendString(habbo.getRoomUnit().getZ() + ""); + this.response.appendInt(habbo.getRoomUnit().getVirtualId()); //Room Unit ID + this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(habbo.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(1); this.response.appendString(habbo.getHabboInfo().getGender().name().toUpperCase()); @@ -99,10 +99,10 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendString(this.bot.getName()); this.response.appendString(this.bot.getMotto()); this.response.appendString(this.bot.getFigure()); - this.response.appendInt(this.bot.getRoomUnit().getId()); - this.response.appendInt(this.bot.getRoomUnit().getX()); - this.response.appendInt(this.bot.getRoomUnit().getY()); - this.response.appendString(this.bot.getRoomUnit().getZ() + ""); + this.response.appendInt(this.bot.getRoomUnit().getVirtualId()); + this.response.appendInt(this.bot.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(this.bot.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(this.bot.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(this.bot.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(4); this.response.appendString(this.bot.getGender().name().toUpperCase()); @@ -126,10 +126,10 @@ public class RoomUsersComposer extends MessageComposer { this.response.appendString(bot.getName()); this.response.appendString(bot.getMotto()); this.response.appendString(bot.getFigure()); - this.response.appendInt(bot.getRoomUnit().getId()); - this.response.appendInt(bot.getRoomUnit().getX()); - this.response.appendInt(bot.getRoomUnit().getY()); - this.response.appendString(bot.getRoomUnit().getZ() + ""); + this.response.appendInt(bot.getRoomUnit().getVirtualId()); + this.response.appendInt(bot.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(bot.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(bot.getRoomUnit().getCurrentZ() + ""); this.response.appendInt(bot.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(4); this.response.appendString(bot.getGender().name().toUpperCase()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java index 778f4fc0..68e9148f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -14,7 +14,7 @@ public class SleepMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.sleepMessageComposer); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendBoolean(this.roomUnit.isIdle()); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java index d35c7dbb..1eee6ba2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserChangeMessageComposer.java @@ -13,7 +13,7 @@ public class UserChangeMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userChangeMessageComposer); - this.response.appendInt(this.habbo.getRoomUnit() == null ? -1 : this.habbo.getRoomUnit().getId()); + this.response.appendInt(this.habbo.getRoomUnit() == null ? -1 : this.habbo.getRoomUnit().getVirtualId()); this.response.appendString(this.habbo.getHabboInfo().getLook()); this.response.appendString(this.habbo.getHabboInfo().getGender().name() + ""); this.response.appendString(this.habbo.getHabboInfo().getMotto()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java index 80d4a998..83d43b65 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java @@ -20,7 +20,7 @@ public class UserNameChangedMessageComposer extends MessageComposer { public UserNameChangedMessageComposer(Habbo habbo, boolean includePrefix) { this.userId = habbo.getHabboInfo().getId(); - this.roomId = habbo.getRoomUnit().getId(); + this.roomId = habbo.getRoomUnit().getVirtualId(); this.name = (includePrefix ? Room.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getPermissionGroup().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getPermissionGroup().getPrefix()) : "") + habbo.getHabboInfo().getUsername(); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java index b1bb08b8..deab7c0f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -13,7 +13,7 @@ public class UserRemoveMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userRemoveMessageComposer); - this.response.appendString(this.roomUnit.getId() + ""); + this.response.appendString(this.roomUnit.getVirtualId() + ""); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java index 72a1482a..d23e22b2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTagsMessageComposer.java @@ -13,7 +13,7 @@ public class UserTagsMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userTagsMessageComposer); - this.response.appendInt(this.habbo.getRoomUnit().getId()); + this.response.appendInt(this.habbo.getRoomUnit().getVirtualId()); this.response.appendInt(this.habbo.getHabboStats().getTags().length); for (String tag : this.habbo.getHabboStats().getTags()) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java index f9e91566..b7da4c61 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserTypingMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -14,7 +14,7 @@ public class UserTypingMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userTypingMessageComposer); - this.response.appendInt(this.roomUnit.getId()); + this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendInt(this.typing ? 1 : 0); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java index 917b0ebc..5aa02593 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUnbannedFromRoomComposer.java @@ -14,7 +14,7 @@ public class UserUnbannedFromRoomComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userUnbannedFromRoomComposer); - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getRoomInfo().getId()); this.response.appendInt(this.userId); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java index e1f23e2b..6df02fa0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -40,7 +40,7 @@ public class UserUpdateComposer extends MessageComposer { if (this.roomUnits != null) { this.response.appendInt(this.roomUnits.size()); for (RoomUnit roomUnit : this.roomUnits) { - this.response.appendInt(roomUnit.getId()); + this.response.appendInt(roomUnit.getVirtualId()); this.response.appendInt(roomUnit.getPreviousLocation().getX()); this.response.appendInt(roomUnit.getPreviousLocation().getY()); this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); @@ -50,18 +50,18 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(roomUnit.getBodyRotation().getValue()); StringBuilder status = new StringBuilder("/"); - for (Map.Entry entry : roomUnit.getStatus().entrySet()) { + for (Map.Entry entry : roomUnit.getStatuses().entrySet()) { status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); } this.response.appendString(status.toString()); - roomUnit.setPreviousLocation(roomUnit.getCurrentLocation()); + roomUnit.setPreviousLocation(roomUnit.getCurrentPosition()); } } else { synchronized (this.habbos) { this.response.appendInt(this.habbos.size()); for (Habbo habbo : this.habbos) { - this.response.appendInt(habbo.getRoomUnit().getId()); + this.response.appendInt(habbo.getRoomUnit().getVirtualId()); this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getX()); this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getY()); this.response.appendString(habbo.getRoomUnit().getPreviousLocationZ() + ""); @@ -72,11 +72,11 @@ public class UserUpdateComposer extends MessageComposer { StringBuilder status = new StringBuilder("/"); - for (Map.Entry entry : habbo.getRoomUnit().getStatus().entrySet()) { + for (Map.Entry entry : habbo.getRoomUnit().getStatuses().entrySet()) { status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); } this.response.appendString(status.toString()); - habbo.getRoomUnit().setPreviousLocation(habbo.getRoomUnit().getCurrentLocation()); + habbo.getRoomUnit().setPreviousLocation(habbo.getRoomUnit().getCurrentPosition()); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java index f0ecff94..d21a0231 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.outgoing.trading; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.rooms.RoomTrade; import com.eu.habbo.habbohotel.rooms.RoomTradeUser; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -20,7 +20,7 @@ public class TradingItemListComposer extends MessageComposer { this.response.appendInt(roomTradeUser.getUserId()); this.response.appendInt(roomTradeUser.getItems().size()); - for (HabboItem item : roomTradeUser.getItems()) { + for (RoomItem item : roomTradeUser.getItems()) { this.response.appendInt(item.getId()); this.response.appendString(item.getBaseItem().getType().code); this.response.appendInt(item.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java index c4bf530a..718bb50d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/PostItPlacedComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.unknown; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class PostItPlacedComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; private final int unknownInt; @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java index 9b74bbd7..06f34882 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/unknown/RoomMessageNotificationMessageComposer.java @@ -15,8 +15,8 @@ public class RoomMessageNotificationMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.roomMessageNotificationMessageComposer); - this.response.appendInt(this.room.getId()); - this.response.appendString(this.room.getName()); + this.response.appendInt(this.room.getRoomInfo().getId()); + this.response.appendString(this.room.getRoomInfo().getName()); this.response.appendInt(this.count); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java index 1fb6f4ee..1885bf52 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/OpenComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.wired; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,7 +8,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class OpenComposer extends MessageComposer { - private final HabboItem item; + private final RoomItem item; @Override diff --git a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java index 262b60be..b5348e2f 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; public class ChangeRoomOwner extends RCONMessage { @@ -11,15 +12,22 @@ public class ChangeRoomOwner extends RCONMessage { @Override public void handle(Gson gson, JSON json) { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(json.room_id); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(json.room_id); - if (room != null) { - room.setOwnerId(json.user_id); - room.setOwnerName(json.username); - room.setNeedsUpdate(true); - room.save(); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + if(room == null) { + return; } + + Habbo newOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(json.user_id); + + if(newOwner == null) { + return; + } + + room.getRoomInfo().setOwnerInfo(newOwner.getHabboInfo()); + room.setNeedsUpdate(true); + room.save(); + Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); } static class JSON { diff --git a/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java b/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java index 62629656..af576538 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java @@ -17,11 +17,11 @@ public class ForwardUser extends RCONMessage { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id); if (habbo != null) { - Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(object.room_id); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(object.room_id); if (room != null) { - if (habbo.getHabboInfo().getCurrentRoom() != null) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, habbo.getHabboInfo().getCurrentRoom()); + if (habbo.getRoomUnit().getRoom() != null) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, habbo.getRoomUnit().getRoom()); } habbo.getClient().sendResponse(new RoomForwardMessageComposer(object.room_id)); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java index 450e0b38..051c706c 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; @@ -70,7 +70,7 @@ public class SendGift extends RCONMessage { return; } - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); + RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); String extraData = "1\t" + item.getId(); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java index ec83db61..ffd0bc14 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -23,7 +23,7 @@ public class SetMotto extends RCONMessage { if (habbo != null) { habbo.getHabboInfo().setMotto(json.motto); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { try (PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ? WHERE id = ? LIMIT 1")) { diff --git a/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java b/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java index 3e2a61fb..9a47fe13 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/StalkUser.java @@ -23,7 +23,7 @@ public class StalkUser extends RCONMessage { return; } - if (target.getHabboInfo().getCurrentRoom() == null) { + if (target.getRoomUnit().getRoom() == null) { this.message = Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; @@ -35,14 +35,14 @@ public class StalkUser extends RCONMessage { return; } - if (target.getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) { + if (target.getRoomUnit().getRoom() == habbo.getRoomUnit().getRoom()) { this.message = Emulator.getTexts().getValue("commands.generic.cmd_stalk.same_room").replace("%user%", json.user_id + ""); this.status = STATUS_ERROR; return; } if (this.status == 0) { - habbo.getClient().sendResponse(new RoomForwardMessageComposer(target.getHabboInfo().getCurrentRoom().getId())); + habbo.getClient().sendResponse(new RoomForwardMessageComposer(target.getRoomUnit().getRoom().getRoomInfo().getId())); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java index cfb39f08..c73cd92c 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -53,8 +53,8 @@ public class UpdateUser extends RCONMessage { habbo.getClient().sendResponse(new FigureUpdateComposer(habbo).compose()); } - if (habbo.getHabboInfo().getCurrentRoom() != null) { - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java index ada589e7..eac552ac 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurnitureBuildheightEvent extends FurnitureUserEvent { @@ -12,7 +12,7 @@ public class FurnitureBuildheightEvent extends FurnitureUserEvent { private boolean changedHeight = false; - public FurnitureBuildheightEvent(HabboItem furniture, Habbo habbo, double oldHeight, double newHeight) { + public FurnitureBuildheightEvent(RoomItem furniture, Habbo habbo, double oldHeight, double newHeight) { super(furniture, habbo); this.oldHeight = oldHeight; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java index 228a6568..b6c191d6 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureDiceRolledEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; @Getter @@ -10,7 +10,7 @@ public class FurnitureDiceRolledEvent extends FurnitureUserEvent { private final int result; - public FurnitureDiceRolledEvent(HabboItem furniture, Habbo habbo, int result) { + public FurnitureDiceRolledEvent(RoomItem furniture, Habbo habbo, int result) { super(furniture, habbo); this.result = result; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java index 00e5db80..c21048fe 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.plugin.events.furniture; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.plugin.Event; public abstract class FurnitureEvent extends Event { - public final HabboItem furniture; + public final RoomItem furniture; - public FurnitureEvent(HabboItem furniture) { + public FurnitureEvent(RoomItem furniture) { this.furniture = furniture; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java index cbf4e1e5..f0eddd0a 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureMovedEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurnitureMovedEvent extends FurnitureUserEvent { @@ -11,7 +11,7 @@ public class FurnitureMovedEvent extends FurnitureUserEvent { private boolean pluginHelper; - public FurnitureMovedEvent(HabboItem furniture, Habbo habbo, RoomTile oldPosition, RoomTile newPosition) { + public FurnitureMovedEvent(RoomItem furniture, Habbo habbo, RoomTile oldPosition, RoomTile newPosition) { super(furniture, habbo); this.oldPosition = oldPosition; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java index 37114d2f..d42eebaa 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePickedUpEvent.java @@ -1,11 +1,11 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurniturePickedUpEvent extends FurnitureUserEvent { - public FurniturePickedUpEvent(HabboItem furniture, Habbo habbo) { + public FurniturePickedUpEvent(RoomItem furniture, Habbo habbo) { super(furniture, habbo); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java index 6af5747e..ef6b028b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurniturePlacedEvent.java @@ -2,14 +2,14 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurniturePlacedEvent extends FurnitureUserEvent { public final RoomTile location; private boolean pluginHelper; - public FurniturePlacedEvent(HabboItem furniture, Habbo habbo, RoomTile location) { + public FurniturePlacedEvent(RoomItem furniture, Habbo habbo, RoomTile location) { super(furniture, habbo); this.location = location; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java index ce2dd0dc..11c4c519 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurnitureRedeemedEvent extends FurnitureUserEvent { public static final int CREDITS = -1; @@ -11,7 +11,7 @@ public class FurnitureRedeemedEvent extends FurnitureUserEvent { public final int amount; public final int currencyID; - public FurnitureRedeemedEvent(HabboItem furniture, Habbo habbo, int amount, int currencyID) { + public FurnitureRedeemedEvent(RoomItem furniture, Habbo habbo, int amount, int currencyID) { super(furniture, habbo); this.amount = amount; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java index 92da1e6b..ff446c80 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRolledEvent.java @@ -1,17 +1,17 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurnitureRolledEvent extends FurnitureEvent { - public final HabboItem roller; + public final RoomItem roller; public final RoomTile newLocation; - public FurnitureRolledEvent(HabboItem furniture, HabboItem roller, RoomTile newLocation) { + public FurnitureRolledEvent(RoomItem furniture, RoomItem roller, RoomTile newLocation) { super(furniture); this.roller = roller; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java index 402b16f8..ef6942c9 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRoomTonerEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; @Getter @@ -12,7 +12,7 @@ public class FurnitureRoomTonerEvent extends FurnitureUserEvent { private final int brightness; - public FurnitureRoomTonerEvent(HabboItem furniture, Habbo habbo, int hue, int saturation, int brightness) { + public FurnitureRoomTonerEvent(RoomItem furniture, Habbo habbo, int hue, int saturation, int brightness) { super(furniture, habbo); this.hue = hue; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java index da314b59..29d931de 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRotatedEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class FurnitureRotatedEvent extends FurnitureUserEvent { public final int oldRotation; - public FurnitureRotatedEvent(HabboItem furniture, Habbo habbo, int oldRotation) { + public FurnitureRotatedEvent(RoomItem furniture, Habbo habbo, int oldRotation) { super(furniture, habbo); this.oldRotation = oldRotation; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java index 89386461..e9c00479 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureToggleEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; @Getter public class FurnitureToggleEvent extends FurnitureUserEvent { private final int state; - public FurnitureToggleEvent(HabboItem furniture, Habbo habbo, int state) { + public FurnitureToggleEvent(RoomItem furniture, Habbo habbo, int state) { super(furniture, habbo); this.state = state; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java index 54017a4b..2d2f79cc 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureUserEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.plugin.events.furniture; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public abstract class FurnitureUserEvent extends FurnitureEvent { public final Habbo habbo; - public FurnitureUserEvent(HabboItem furniture, Habbo habbo) { + public FurnitureUserEvent(RoomItem furniture, Habbo habbo) { super(furniture); this.habbo = habbo; } diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java index c8e420f1..2d259087 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredConditionFailedEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.plugin.events.furniture.wired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; public class WiredConditionFailedEvent extends RoomUnitEvent { diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java index 9ed4385a..011af408 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackExecutedEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java index 59e3f8ac..3ca3e482 100644 --- a/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/wired/WiredStackTriggeredEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.plugin.events.roomunit.RoomUnitEvent; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java index af3ed727..3802e5ce 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemAddedEvent.java @@ -1,10 +1,10 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class InventoryItemAddedEvent extends InventoryItemEvent { - public InventoryItemAddedEvent(HabboInventory inventory, HabboItem item) { + public InventoryItemAddedEvent(HabboInventory inventory, RoomItem item) { super(inventory, item); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java index 11581a4f..c8e70499 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; @Getter public class InventoryItemEvent extends InventoryEvent { - private final HabboItem item; + private final RoomItem item; - public InventoryItemEvent(HabboInventory inventory, HabboItem item) { + public InventoryItemEvent(HabboInventory inventory, RoomItem item) { super(inventory); this.item = item; diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java index 26330b8a..e8259475 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemRemovedEvent.java @@ -1,10 +1,10 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class InventoryItemRemovedEvent extends InventoryItemEvent { - public InventoryItemRemovedEvent(HabboInventory inventory, HabboItem item) { + public InventoryItemRemovedEvent(HabboInventory inventory, RoomItem item) { super(inventory, item); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java index a0ead84f..4bf32cfd 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java @@ -1,13 +1,13 @@ package com.eu.habbo.plugin.events.inventory; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; public class InventoryItemsAddedEvent extends InventoryEvent { - public final THashSet items; + public final THashSet items; - public InventoryItemsAddedEvent(HabboInventory inventory, THashSet items) { + public InventoryItemsAddedEvent(HabboInventory inventory, THashSet items) { super(inventory); this.items = items; } diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java index 100228e4..4a3d39e8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemOfferedEvent.java @@ -1,16 +1,16 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.Getter; @Getter public class MarketPlaceItemOfferedEvent extends MarketPlaceEvent { private final Habbo habbo; - private final HabboItem item; + private final RoomItem item; private final int price; - public MarketPlaceItemOfferedEvent(Habbo habbo, HabboItem item, int price) { + public MarketPlaceItemOfferedEvent(Habbo habbo, RoomItem item, int price) { this.habbo = habbo; this.item = item; this.price = price; diff --git a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java index 2f6957b8..5dfc03ca 100644 --- a/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/marketplace/MarketPlaceItemSoldEvent.java @@ -1,15 +1,15 @@ package com.eu.habbo.plugin.events.marketplace; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class MarketPlaceItemSoldEvent extends MarketPlaceEvent { public final Habbo seller; public final Habbo purchaser; - public final HabboItem item; + public final RoomItem item; public int price; - public MarketPlaceItemSoldEvent(Habbo seller, Habbo purchaser, HabboItem item, int price) { + public MarketPlaceItemSoldEvent(Habbo seller, Habbo purchaser, RoomItem item, int price) { this.seller = seller; this.purchaser = purchaser; this.item = item; diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java index 01bea305..659ab411 100644 --- a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java @@ -1,21 +1,21 @@ package com.eu.habbo.plugin.events.rooms; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.plugin.events.users.UserEvent; import gnu.trove.set.hash.THashSet; public class RoomFloorItemsLoadEvent extends UserEvent { - private THashSet floorItems; + private THashSet floorItems; private boolean changedFloorItems; - public RoomFloorItemsLoadEvent(Habbo habbo, THashSet floorItems) { + public RoomFloorItemsLoadEvent(Habbo habbo, THashSet floorItems) { super(habbo); this.floorItems = floorItems; this.changedFloorItems = false; } - public void setFloorItems(THashSet floorItems) { + public void setFloorItems(THashSet floorItems) { this.changedFloorItems = true; this.floorItems = floorItems; } @@ -24,7 +24,7 @@ public class RoomFloorItemsLoadEvent extends UserEvent { return this.changedFloorItems; } - public THashSet getFloorItems() { + public THashSet getFloorItems() { return this.floorItems; } } diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java index 6979df52..dbb1cb13 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.roomunit; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.plugin.Event; public abstract class RoomUnitEvent extends Event { diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java index b1e5c280..a18290a8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitLookAtPointEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.plugin.events.roomunit; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; public class RoomUnitLookAtPointEvent extends RoomUnitEvent { diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java index c7583272..4e1e0902 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.plugin.events.roomunit; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; public class RoomUnitSetGoalEvent extends RoomUnitEvent { diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java index c38f36a3..0f1037ed 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRolledEvent.java @@ -2,17 +2,17 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class UserRolledEvent extends UserEvent { - public final HabboItem roller; + public final RoomItem roller; public final RoomTile location; - public UserRolledEvent(Habbo habbo, HabboItem roller, RoomTile location) { + public UserRolledEvent(Habbo habbo, RoomItem roller, RoomTile location) { super(habbo); this.roller = roller; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java index 2e38aa88..df686a54 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java @@ -2,15 +2,15 @@ package com.eu.habbo.plugin.events.users.catalog; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; public class UserCatalogFurnitureBoughtEvent extends UserCatalogEvent { - public final THashSet furniture; + public final THashSet furniture; - public UserCatalogFurnitureBoughtEvent(Habbo habbo, CatalogItem catalogItem, THashSet furniture) { + public UserCatalogFurnitureBoughtEvent(Habbo habbo, CatalogItem catalogItem, THashSet furniture) { super(habbo, catalogItem); this.furniture = furniture; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java index 6875591b..1895d858 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.plugin.events.users.catalog; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -11,13 +11,13 @@ import java.util.List; @Getter public class UserCatalogItemPurchasedEvent extends UserCatalogEvent { - public final THashSet itemsList; + public final THashSet itemsList; private final int totalCredits; private final int totalPoints; private final List badges; - public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, THashSet itemsList, int totalCredits, int totalPoints, List badges) { + public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, THashSet itemsList, int totalCredits, int totalPoints, List badges) { super(habbo, catalogItem); this.itemsList = itemsList; diff --git a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java index 2e275877..7ac9c258 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java @@ -2,12 +2,12 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public class BackgroundAnimation implements Runnable { - private final HabboItem toner; + private final RoomItem toner; private final Room room; private int length = 1000; private int state = 0; diff --git a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java index 7c034d46..96e781ef 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -3,24 +3,24 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +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 lombok.AllArgsConstructor; import org.slf4j.LoggerFactory; @AllArgsConstructor public class BanzaiRandomTeleport implements Runnable { - private final HabboItem item; - private final HabboItem toItem; + private final RoomItem item; + private final RoomItem toItem; private final RoomUnit habbo; private final Room room; @Override public void run() { - HabboItem topItemNow = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY()); - RoomTile lastLocation = this.habbo.getCurrentLocation(); + RoomItem topItemNow = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); + RoomTile lastLocation = this.habbo.getCurrentPosition(); RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY()); if(topItemNow != null) { @@ -45,7 +45,7 @@ public class BanzaiRandomTeleport implements Runnable { Emulator.getThreading().run(() -> { this.habbo.setCanWalk(true); - HabboItem topItemNext = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY()); + RoomItem topItemNext = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); if(topItemNext != null) { try { @@ -62,7 +62,7 @@ public class BanzaiRandomTeleport implements Runnable { }, 750); Emulator.getThreading().run(() -> { - this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8))); + this.habbo.setRotation(RoomRotation.fromValue(Emulator.getRandom().nextInt(8))); this.room.teleportRoomUnitToLocation(this.habbo, newLocation.getX(), newLocation.getY(), newLocation.getStackHeight()); }, 250); diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java index 8828e86d..0e4670f3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -4,14 +4,14 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.items.ItemsDataUpdateComposer; import gnu.trove.set.hash.THashSet; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public class BattleBanzaiTilesFlicker implements Runnable { - private final THashSet items; + private final THashSet items; private final GameTeamColors color; private final Room room; @@ -32,14 +32,14 @@ public class BattleBanzaiTilesFlicker implements Runnable { this.on = true; } - for (HabboItem item : this.items) { + for (RoomItem item : this.items) { item.setExtradata(state + ""); } this.room.sendComposer(new ItemsDataUpdateComposer(this.items).compose()); if (this.count == 9) { - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { + for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("0"); this.room.updateItemState(item); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java index 493497a6..478c4168 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java @@ -20,16 +20,16 @@ public class BotFollowHabbo implements Runnable { public void run() { if (this.bot != null) { if (this.habbo != null && this.bot.getFollowingHabboId() == this.habbo.getHabboInfo().getId()) { - if (this.habbo.getHabboInfo().getCurrentRoom() != null && this.habbo.getHabboInfo().getCurrentRoom() == this.room) { + if (this.habbo.getRoomUnit().getRoom() != null && this.habbo.getRoomUnit().getRoom() == this.room) { if (this.habbo.getRoomUnit() != null) { if (this.bot.getRoomUnit() != null) { - RoomTile target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + 4)) % 8); + RoomTile target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentPosition(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + 4)) % 8); if (target != null) { if (target.getX() < 0 || target.getY() < 0) - target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue()); + target = this.room.getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentPosition(), this.habbo.getRoomUnit().getBodyRotation().getValue()); - if(this.habbo.getRoomUnit().getCurrentLocation().distance(this.bot.getRoomUnit().getCurrentLocation()) < 2) { + if(this.habbo.getRoomUnit().getCurrentPosition().distance(this.bot.getRoomUnit().getCurrentPosition()) < 2) { if(!hasReached) { WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{}); hasReached = true; diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java index 68fa5b31..65970b1f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -37,10 +37,12 @@ public class CannonKickAction implements Runnable { ServerMessage message = new NotificationDialogMessageComposer("cannon.png", dater).compose(); for (RoomTile t : tiles) { - for (Habbo habbo : this.room.getHabbosAt(t.getX(), t.getY())) { - if (!habbo.hasRight(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); - habbo.getClient().sendResponse(message); //kicked composer + for (Habbo habbo : this.room.getRoomUnitManager().getHabbosAt(t)) { + if (!habbo.hasRight(Permission.ACC_UNKICKABLE)) { + if (!this.room.getRoomInfo().isRoomOwner(habbo)) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); + habbo.getClient().sendResponse(message); //kicked composer + } } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index 4d4ff335..233f312d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRentableSpace; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; @@ -17,10 +17,10 @@ public class ClearRentedSpace implements Runnable { @Override public void run() { - THashSet items = new THashSet<>(); + THashSet items = new THashSet<>(); for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { - for (HabboItem i : this.room.getItemsAt(t)) { + for (RoomItem i : this.room.getItemsAt(t)) { if (i.getUserId() == this.item.getRenterId()) { items.add(i); i.setRoomId(0); @@ -36,7 +36,7 @@ public class ClearRentedSpace implements Runnable { owner.getHabboStats().setRentedItemId(0); owner.getHabboStats().setRentedTimeEnd(0); } else { - for (HabboItem i : items) { + for (RoomItem i : items) { i.run(); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java index 2a092f01..22033b4a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java @@ -1,19 +1,26 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; @AllArgsConstructor public class CloseGate implements Runnable { - private final HabboItem gate; + private final RoomItem gate; private final Room room; @Override public void run() { - if (this.gate.getRoomId() == this.room.getId()) { + if (this.gate.getRoomId() == this.room.getRoomInfo().getId()) { if (this.room.isLoaded()) { - if (this.room.getHabbosAt(this.gate.getX(), this.gate.getY()).isEmpty()) { + RoomTile tile = this.room.getLayout().getTile(this.gate.getX(), this.gate.getY()); + + if(tile == null) { + return; + } + + if (!this.room.getRoomUnitManager().hasHabbosAt(tile)) { this.gate.setExtradata("0"); this.room.updateItem(this.gate); this.gate.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index 22d9aafa..bd9619a9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer; @@ -40,7 +40,7 @@ public class CrackableExplode implements Runnable { Item rewardItem = Emulator.getGameEnvironment().getItemManager().getCrackableReward(this.habboItem.getBaseItem().getId()); if (rewardItem != null) { - HabboItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getUserId(), rewardItem, 0, 0, ""); + RoomItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getUserId(), rewardItem, 0, 0, ""); if (newItem != null) { //Add to inventory in case if isn't possible place the item or in case is wall item @@ -52,7 +52,7 @@ public class CrackableExplode implements Runnable { newItem.setX(this.x); newItem.setY(this.y); newItem.setZ(this.room.getStackHeight(this.x, this.y, false)); - newItem.setRoomId(this.room.getId()); + newItem.setRoomId(this.room.getRoomInfo().getId()); newItem.needsUpdate(true); this.room.addHabboItem(newItem); this.room.updateItem(newItem); diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java index bdc2b307..4e114026 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java @@ -12,22 +12,22 @@ public class HabboGiveHandItemToHabbo implements Runnable { @Override public void run() { - if (this.from.getHabboInfo().getCurrentRoom() == null || this.target.getHabboInfo().getCurrentRoom() == null) + if (this.from.getRoomUnit().getRoom() == null || this.target.getRoomUnit().getRoom() == null) return; - if (this.from.getHabboInfo().getCurrentRoom() != this.target.getHabboInfo().getCurrentRoom()) + if (this.from.getRoomUnit().getRoom() != this.target.getRoomUnit().getRoom()) return; int itemId = this.from.getRoomUnit().getHandItem(); if (itemId > 0) { this.from.getRoomUnit().setHandItem(0); - this.from.getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(this.from.getRoomUnit()).compose()); - this.target.getRoomUnit().lookAtPoint(this.from.getRoomUnit().getCurrentLocation()); - this.target.getRoomUnit().statusUpdate(true); + this.from.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(this.from.getRoomUnit()).compose()); + this.target.getRoomUnit().lookAtPoint(this.from.getRoomUnit().getCurrentPosition()); + this.target.getRoomUnit().setStatusUpdateNeeded(true); this.target.getClient().sendResponse(new HandItemReceivedMessageComposer(this.from.getRoomUnit(), itemId)); this.target.getRoomUnit().setHandItem(itemId); - this.target.getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(this.target.getRoomUnit()).compose()); + this.target.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(this.target.getRoomUnit()).compose()); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java index 8a6492c5..a2e8ed07 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java @@ -1,12 +1,12 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; @AllArgsConstructor public class HabboItemNewState implements Runnable { - private final HabboItem item; + private final RoomItem item; private final Room room; private final String state; @@ -14,7 +14,7 @@ public class HabboItemNewState implements Runnable { public void run() { this.item.setExtradata(this.state); - if (this.item.getRoomId() == this.room.getId()) { + if (this.item.getRoomId() == this.room.getRoomInfo().getId()) { this.room.updateItemState(this.item); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java index d1305f7e..7afad767 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionPushable; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -16,11 +16,11 @@ public class KickBallAction implements Runnable { private final RoomUnit kicker; //The Habbo which initiated the move of the item private final int totalSteps; //The total number of steps in the move sequence public boolean dead = false; //When true the run() function will not execute. Used when another user kicks the ball whilst it is arleady moving. - private RoomUserRotation currentDirection; //The current direction the item is moving in + private RoomRotation currentDirection; //The current direction the item is moving in private int currentStep; //The current step of the move sequence public final boolean isDrag; - public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomUserRotation direction, int steps, boolean isDrag) { + public KickBallAction(InteractionPushable ball, Room room, RoomUnit kicker, RoomRotation direction, int steps, boolean isDrag) { this.ball = ball; this.room = room; this.kicker = kicker; @@ -40,7 +40,7 @@ public class KickBallAction implements Runnable { RoomTile next = this.room.getLayout().getTileInFront(currentTile, this.currentDirection.getValue()); if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) { - RoomUserRotation oldDirection = this.currentDirection; + RoomRotation oldDirection = this.currentDirection; if(!this.isDrag) { this.currentDirection = this.ball.getBounceDirection(this.room, this.currentDirection); diff --git a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java index 428d53e3..36a01410 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import lombok.AllArgsConstructor; @@ -12,7 +12,7 @@ import lombok.AllArgsConstructor; public class OneWayGateActionOne implements Runnable { private final GameClient client; private final Room room; - private final HabboItem oneWayGate; + private final RoomItem oneWayGate; @Override @@ -26,7 +26,7 @@ public class OneWayGateActionOne implements Runnable { } if (t.isWalkable()) { - if (this.room.tileWalkable(t) && this.client.getHabbo().getRoomUnit().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getY() == this.oneWayGate.getY()) { + if (this.room.tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getY()) { this.client.getHabbo().getRoomUnit().setGoalLocation(t); if (!this.oneWayGate.getExtradata().equals("0")) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index e711e000..5434592c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.inventory.FurniListAddOrUpdateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -23,17 +23,17 @@ import java.util.Map; @AllArgsConstructor public class OpenGift implements Runnable { - private final HabboItem item; + private final RoomItem item; private final Habbo habbo; private final Room room; @Override public void run() { try { - HabboItem inside = null; + RoomItem inside = null; - THashSet items = ((InteractionGift) this.item).loadItems(); - for (HabboItem i : items) { + THashSet items = ((InteractionGift) this.item).loadItems(); + for (RoomItem i : items) { if (inside == null) inside = i; @@ -58,7 +58,7 @@ public class OpenGift implements Runnable { Map> unseenItems = new HashMap<>(); - for (HabboItem item : items) { + for (RoomItem item : items) { switch (item.getBaseItem().getType()) { case WALL, FLOOR -> { if (!unseenItems.containsKey(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI)) diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java index 3cf9613e..ec9c04e3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -22,11 +22,11 @@ public class PetFollowHabbo implements Runnable { if (this.habbo != null) { if (this.habbo.getRoomUnit() != null) { if (this.pet.getRoomUnit() != null) { - RoomTile target = this.habbo.getHabboInfo().getCurrentRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + this.directionOffset + 4) % 8)); + RoomTile target = this.habbo.getRoomUnit().getRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentPosition(), Math.abs((this.habbo.getRoomUnit().getBodyRotation().getValue() + this.directionOffset + 4) % 8)); if (target != null) { if (target.getX() < 0 || target.getY() < 0) - target = this.habbo.getHabboInfo().getCurrentRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentLocation(), this.habbo.getRoomUnit().getBodyRotation().getValue()); + target = this.habbo.getRoomUnit().getRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentPosition(), this.habbo.getRoomUnit().getBodyRotation().getValue()); if (target.getX() >= 0 && target.getY() >= 0) { if (this.pet.getRoom().getLayout().tileWalkable(target.getX(), target.getY())) { @@ -35,7 +35,7 @@ public class PetFollowHabbo implements Runnable { this.pet.setTask(PetTasks.FOLLOW); } } - if(target.distance(this.pet.getRoomUnit().getCurrentLocation()) > 1) { + if(target.distance(this.pet.getRoomUnit().getCurrentPosition()) > 1) { Emulator.getThreading().run(this, 500); } else { this.pet.setTask(PetTasks.FREE); diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java index f0493e9f..796df747 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -1,7 +1,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -16,7 +16,7 @@ public class QueryDeleteHabboItem implements Runnable { private final int itemId; - public QueryDeleteHabboItem(HabboItem item) { + public QueryDeleteHabboItem(RoomItem item) { this.itemId = item.getId(); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java index 6ee3bc53..fa125375 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -1,7 +1,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.map.TIntObjectMap; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -14,13 +14,13 @@ import java.sql.SQLException; @AllArgsConstructor public class QueryDeleteHabboItems implements Runnable { - private TIntObjectMap items; + private TIntObjectMap items; @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { - for (HabboItem item : this.items.valueCollection()) { + for (RoomItem item : this.items.valueCollection()) { if (item.getRoomId() > 0) continue; diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java index e6c83600..0aa18560 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java @@ -3,22 +3,22 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionColorWheel; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class RandomDiceNumber implements Runnable { - private final HabboItem item; + private final RoomItem item; private final Room room; private final int maxNumber; private int result; - public RandomDiceNumber(HabboItem item, Room room, int maxNumber) { + public RandomDiceNumber(RoomItem item, Room room, int maxNumber) { this.item = item; this.room = room; this.maxNumber = maxNumber; this.result = -1; } - public RandomDiceNumber(Room room, HabboItem item, int result) { + public RandomDiceNumber(Room room, RoomItem item, int result) { this.item = item; this.room = room; this.maxNumber = -1; diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java index 53f17b63..b699cda0 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java @@ -2,22 +2,22 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; public class RandomSpinningBottleNumber implements Runnable { - private final HabboItem item; + private final RoomItem item; private final Room room; private final int maxNumber; private int result; - public RandomSpinningBottleNumber(HabboItem item, Room room, int maxNumber) { + public RandomSpinningBottleNumber(RoomItem item, Room room, int maxNumber) { this.item = item; this.room = room; this.maxNumber = maxNumber; this.result = -1; } - public RandomSpinningBottleNumber(Room room, HabboItem item, int result) { + public RandomSpinningBottleNumber(Room room, RoomItem item, int result) { this.item = item; this.room = room; this.maxNumber = -1; diff --git a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java index 27d26b3b..13ac670f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -2,7 +2,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import lombok.AllArgsConstructor; @@ -10,7 +10,7 @@ import lombok.AllArgsConstructor; @AllArgsConstructor class RemoveFloorItemTask implements Runnable { private final Room room; - private final HabboItem item; + private final RoomItem item; @Override diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java index ba50a1d9..2d1e5f22 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java @@ -3,8 +3,8 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; 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.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.plugin.EventHandler; @@ -36,11 +36,11 @@ public class RoomTrashing implements Runnable { INSTANCE.habbo = null; if (INSTANCE.habbo == event.habbo) { - if (event.habbo.getHabboInfo().getCurrentRoom() != null) { - if (event.habbo.getHabboInfo().getCurrentRoom().equals(INSTANCE.room)) { + if (event.habbo.getRoomUnit().getRoom() != null) { + if (event.habbo.getRoomUnit().getRoom().equals(INSTANCE.room)) { THashSet messages = new THashSet<>(); - THashSet items = INSTANCE.room.getItemsAt(event.toLocation); + THashSet items = INSTANCE.room.getItemsAt(event.toLocation); int offset = Emulator.getRandom().nextInt(4) + 2; @@ -55,7 +55,7 @@ public class RoomTrashing implements Runnable { } } - for (HabboItem item : items) { + for (RoomItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); @@ -75,13 +75,13 @@ public class RoomTrashing implements Runnable { } } - RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentLocation(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); + RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); if (s != null) { items = INSTANCE.room.getItemsAt(s); } - for (HabboItem item : items) { + for (RoomItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); @@ -100,10 +100,10 @@ public class RoomTrashing implements Runnable { } } - s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentLocation(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); + s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); items = INSTANCE.room.getItemsAt(s); - for (HabboItem item : items) { + for (RoomItem item : items) { double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java index 8fe54bec..bb05a419 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitGiveHanditem.java @@ -1,21 +1,21 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import lombok.AllArgsConstructor; @AllArgsConstructor public class RoomUnitGiveHanditem implements Runnable { - private final RoomUnit roomUnit; + private final RoomAvatar roomAvatar; private final Room room; private final int itemId; @Override public void run() { - if (this.room != null && this.roomUnit.isInRoom()) { - this.roomUnit.setHandItem(this.itemId); - this.room.sendComposer(new CarryObjectMessageComposer(this.roomUnit).compose()); + if (this.room != null && this.roomAvatar.isInRoom()) { + this.roomAvatar.setHandItem(this.itemId); + this.room.sendComposer(new CarryObjectMessageComposer(this.roomAvatar).compose()); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java index e290ab01..fd3fbe5a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitKick.java @@ -14,7 +14,8 @@ public class RoomUnitKick implements Runnable { @Override public void run() { if (this.removeEffect) { - this.habbo.getRoomUnit().setEffectId(0, 0); + this.habbo.getRoomUnit().setEffectId(0); + this.habbo.getRoomUnit().setEffectEndTimestamp(0); } Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.habbo, this.room); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 75f3ad42..7d30c4a8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -18,22 +18,22 @@ public class RoomUnitRidePet implements Runnable { @Override public void run() { - if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getHabboInfo().getCurrentRoom() || this.goalTile == null || this.habbo.getRoomUnit().getGoalLocation() != this.goalTile) + if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getRoomUnit().getRoom() || this.goalTile == null || this.habbo.getRoomUnit().getGoalLocation() != this.goalTile) return; - if (habbo.getRoomUnit().getCurrentLocation().distance(pet.getRoomUnit().getCurrentLocation()) <= 1) { + if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) { habbo.getRoomUnit().stopWalking(); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, 77, -1); + habbo.getRoomUnit().getRoom().giveEffect(habbo, 77, -1); habbo.getHabboInfo().setRiding(pet); - habbo.getRoomUnit().setCurrentLocation(this.pet.getRoomUnit().getCurrentLocation()); - habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentLocation()); - habbo.getRoomUnit().setZ(this.pet.getRoomUnit().getZ() + 1); - habbo.getRoomUnit().setPreviousLocationZ(this.pet.getRoomUnit().getZ() + 1); + habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition()); + habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentPosition()); + habbo.getRoomUnit().setCurrentZ(this.pet.getRoomUnit().getCurrentZ() + 1); + habbo.getRoomUnit().setPreviousLocationZ(this.pet.getRoomUnit().getCurrentZ() + 1); habbo.getRoomUnit().setRotation(this.pet.getRoomUnit().getBodyRotation()); - habbo.getRoomUnit().statusUpdate(true); + habbo.getRoomUnit().setStatusUpdateNeeded(true); pet.setRider(habbo); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); - habbo.getHabboInfo().getCurrentRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); + habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose()); pet.setTask(PetTasks.RIDE); } else { pet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 58fbcc87..2040c680 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -2,9 +2,9 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -33,10 +33,10 @@ public class RoomUnitTeleport implements Runnable { return; } - RoomTile lastLocation = this.roomUnit.getCurrentLocation(); + RoomTile lastLocation = this.roomUnit.getCurrentPosition(); RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y); - HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().getX(), this.roomUnit.getCurrentLocation().getY()); + RoomItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentPosition().getX(), this.roomUnit.getCurrentPosition().getY()); if (topItem != null) { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); @@ -45,22 +45,22 @@ public class RoomUnitTeleport implements Runnable { } } this.roomUnit.setPath(new LinkedList<>()); - this.roomUnit.setCurrentLocation(newLocation); + this.roomUnit.setCurrentPosition(newLocation); this.roomUnit.setPreviousLocation(newLocation); - this.roomUnit.setZ(this.z); + this.roomUnit.setCurrentZ(this.z); this.roomUnit.setPreviousLocationZ(this.z); this.roomUnit.removeStatus(RoomUnitStatus.MOVE); //ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose(); this.roomUnit.setLocation(newLocation); //this.room.sendComposer(teleportMessage); - this.roomUnit.statusUpdate(true); + this.roomUnit.setStatusUpdateNeeded(true); roomUnit.setWiredTeleporting(false); - this.room.updateHabbosAt(newLocation.getX(), newLocation.getY()); + this.room.updateHabbosAt(newLocation); this.room.updateBotsAt(newLocation.getX(), newLocation.getY()); topItem = room.getTopItemAt(x, y); - if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) { + if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) { try { topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this }); } catch (Exception ignored) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 8285f9cd..2422f360 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -3,8 +3,8 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; 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.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,24 +13,24 @@ import lombok.extern.slf4j.Slf4j; public class RoomUnitTeleportWalkToAction implements Runnable { private final Habbo habbo; - private final HabboItem habboItem; + private final RoomItem roomItem; private final Room room; @Override public void run() { - if (this.habbo.getHabboInfo().getCurrentRoom() != this.room || this.habboItem.getRoomId() != this.room.getId()) { + if (this.habbo.getRoomUnit().getRoom() != this.room || this.roomItem.getRoomId() != this.room.getRoomInfo().getId()) { return; } - RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem); + RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.roomItem); if (!this.habbo.getRoomUnit().getGoalLocation().equals(tile)) { return; } - if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) { + if (this.habbo.getRoomUnit().getCurrentPosition().equals(tile)) { try { - this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); + this.roomItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { log.error("Caught exception", e); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 786843d8..7a333ae9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -3,8 +3,8 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; 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.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,24 +13,24 @@ import lombok.extern.slf4j.Slf4j; public class RoomUnitVendingMachineAction implements Runnable { private final Habbo habbo; - private final HabboItem habboItem; + private final RoomItem roomItem; private final Room room; @Override public void run() { - if (this.habbo.getHabboInfo().getCurrentRoom() != this.room || this.habboItem.getRoomId() != this.room.getId()) { + if (this.habbo.getRoomUnit().getRoom() != this.room || this.roomItem.getRoomId() != this.room.getRoomInfo().getId()) { return; } - RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem); + RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.roomItem); if (tile == null) { return; } if (this.habbo.getRoomUnit().getGoalLocation().equals(tile)) { - if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) { + if (this.habbo.getRoomUnit().getCurrentPosition().equals(tile)) { try { - this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); + this.roomItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { log.error("Caught exception", e); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index 4ebf20fc..ed9f3467 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -3,8 +3,8 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.AllArgsConstructor; import java.util.ArrayList; @@ -33,12 +33,12 @@ public class RoomUnitWalkToLocation implements Runnable { @Override public void run() { - if (this.goalTile == null || this.walker == null || this.room == null || this.walker.getRoom() == null || this.walker.getRoom().getId() != this.room.getId()) { + if (this.goalTile == null || this.walker == null || this.room == null || this.walker.getRoom() == null || this.walker.getRoom().getRoomInfo().getId() != this.room.getRoomInfo().getId()) { onFail(); return; } - if (this.walker.getCurrentLocation().equals(this.goalTile)) { + if (this.walker.getCurrentPosition().equals(this.goalTile)) { onSuccess(); return; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index 7e84e3c9..193e6d1b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -3,7 +3,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.RequiredArgsConstructor; @@ -39,7 +39,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { } if (this.walker.getGoalLocation().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal - if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) { + if (this.walker.getCurrentPosition().distance(this.goalTile) <= this.minDistance) { for (Runnable r : this.targetReached) { Emulator.getThreading().run(r); @@ -52,7 +52,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { } private void findNewLocation() { - this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().getX(), this.target.getCurrentLocation().getY(), true); + this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentPosition().getX(), this.target.getCurrentPosition().getY(), true); if (this.goalTile == null) { if (this.failedReached != null) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java index 8871b071..7f3cbab6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeam; +import com.eu.habbo.habbohotel.rooms.Room; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -23,7 +24,8 @@ public class SaveScoreForTeam implements Runnable { public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_game_scores (room_id, game_start_timestamp, game_name, user_id, team_id, score, team_score) VALUES (?, ?, ?, ?, ?, ?, ?)")) { for (GamePlayer player : this.team.getMembers()) { - statement.setInt(1, this.game.getRoom().getId()); + Room room = this.game.getRoom(); + statement.setInt(1, room.getRoomInfo().getId()); statement.setInt(2, this.game.getStartTime()); statement.setString(3, this.game.getClass().getName()); statement.setInt(4, player.getHabbo().getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java b/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java index ec90782f..69312a1c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SendRoomUnitEffectComposer.java @@ -1,20 +1,20 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import lombok.AllArgsConstructor; @AllArgsConstructor public class SendRoomUnitEffectComposer implements Runnable { private final Room room; - private final RoomUnit roomUnit; + private final RoomAvatar roomAvatar; @Override public void run() { - if (this.room != null && this.roomUnit != null) { - this.room.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose()); + if (this.room != null && this.roomAvatar != null) { + this.room.sendComposer(new AvatarEffectMessageComposer(roomAvatar).compose()); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index 01366809..7f42f831 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; @@ -18,13 +18,13 @@ class TeleportInteraction extends Thread { private final Room room; private final GameClient client; - private final HabboItem teleportOne; + private final RoomItem teleportOne; private int state; private Room targetRoom; - private HabboItem teleportTwo; + private RoomItem teleportTwo; @Deprecated - public TeleportInteraction(Room room, GameClient client, HabboItem teleportOne) { + public TeleportInteraction(Room room, GameClient client, RoomItem teleportOne) { this.room = room; this.client = client; this.teleportOne = teleportOne; @@ -40,7 +40,7 @@ class TeleportInteraction extends Thread { this.teleportTwo.setExtradata("1"); this.targetRoom.updateItem(this.teleportTwo); this.room.updateItem(this.teleportOne); - RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.teleportTwo); + RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportTwo); if (tile != null) { this.client.getHabbo().getRoomUnit().setGoalLocation(tile); } @@ -49,7 +49,7 @@ class TeleportInteraction extends Thread { } else if (this.state == 4) { int[] data = Emulator.getGameEnvironment().getItemManager().getTargetTeleportRoomId(this.teleportOne); if (data.length == 2 && data[0] != 0) { - if (this.room.getId() == data[0]) { + if (this.room.getRoomInfo().getId() == data[0]) { this.targetRoom = this.room; this.teleportTwo = this.room.getHabboItem(data[1]); @@ -57,7 +57,7 @@ class TeleportInteraction extends Thread { this.teleportTwo = this.teleportOne; } } else { - this.targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(data[0]); + this.targetRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(data[0]); this.teleportTwo = this.targetRoom.getHabboItem(data[1]); } } else { @@ -70,13 +70,13 @@ class TeleportInteraction extends Thread { if (this.room != this.targetRoom) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); - this.room.removeHabbo(this.client.getHabbo(), true); + this.room.getRoomUnitManager().removeHabbo(this.client.getHabbo(), true); Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), this.targetRoom); } - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[this.teleportTwo.getRotation()]); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.teleportTwo.getRotation()]); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportTwo.getX(), this.teleportTwo.getY())); - this.client.getHabbo().getRoomUnit().setZ(this.teleportTwo.getZ()); + this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportTwo.getZ()); this.room.sendComposer(new UserRemoveMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); this.targetRoom.sendComposer(new UserRemoveMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); @@ -96,7 +96,7 @@ class TeleportInteraction extends Thread { Emulator.getThreading().run(this, 500); } else if (this.state == 2) { this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getX(), this.teleportOne.getY())); - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[this.newRotation(this.teleportOne.getRotation())]); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.newRotation(this.teleportOne.getRotation())]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); //room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit())); @@ -104,14 +104,16 @@ class TeleportInteraction extends Thread { Emulator.getThreading().run(this, 500); } else if (this.state == 1) { - RoomTile loc = HabboItem.getSquareInFront(this.room.getLayout(), this.teleportOne); + RoomTile loc = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportOne); - if (this.client.getHabbo().getRoomUnit().getX() == loc.getX() && this.client.getHabbo().getRoomUnit().getY() == loc.getY()) { - this.teleportOne.setExtradata("1"); - this.room.updateItem(this.teleportOne); - this.state = 2; + if (this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == loc.getX()) { + if (this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == loc.getY()) { + this.teleportOne.setExtradata("1"); + this.room.updateItem(this.teleportOne); + this.state = 2; - Emulator.getThreading().run(this, 250); + Emulator.getThreading().run(this, 250); + } } } } catch (Exception e) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java b/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java index 126371c6..4648472c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredCollissionRunnable.java @@ -1,7 +1,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java b/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java index a7479cfa..68be8a64 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredExecuteTask.java @@ -26,16 +26,18 @@ public class WiredExecuteTask implements Runnable { @Override public void run() { if (!Emulator.isShuttingDown && Emulator.isReady) { - if (this.room != null && this.room.getId() == this.task.getRoomId()) { - if (this.task instanceof WiredTriggerAtSetTime) { - if (((WiredTriggerAtSetTime) this.task).taskId != this.taskId) - return; + if (this.room != null) { + if (this.room.getRoomInfo().getId() == this.task.getRoomId()) { + if (this.task instanceof WiredTriggerAtSetTime) { + if (((WiredTriggerAtSetTime) this.task).taskId != this.taskId) + return; + } + if (this.task instanceof WiredTriggerAtTimeLong) { + if (((WiredTriggerAtTimeLong) this.task).taskId != this.taskId) + return; + } + WiredHandler.handle(this.task, null, this.room, null); } - if (this.task instanceof WiredTriggerAtTimeLong) { - if (((WiredTriggerAtTimeLong) this.task).taskId != this.taskId) - return; - } - WiredHandler.handle(this.task, null, this.room, null); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java b/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java index 36ee8c67..8bcb97da 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/WiredRepeatEffectTask.java @@ -15,10 +15,12 @@ class WiredRepeatEffectTask implements Runnable { @Override public void run() { if (!Emulator.isShuttingDown && Emulator.isReady) { - if (this.room != null && this.room.getId() == this.effect.getRoomId()) { - this.effect.execute(null, this.room, null); + if (this.room != null) { + if (this.room.getRoomInfo().getId() == this.effect.getRoomId()) { + this.effect.execute(null, this.room, null); - Emulator.getThreading().run(this, this.delay); + Emulator.getThreading().run(this, this.delay); + } } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java index c1787a10..e7847c9b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java @@ -86,7 +86,7 @@ public class YouAreAPirate implements Runnable { @Override public void run() { - if (this.room == this.habbo.getHabboInfo().getCurrentRoom()) { + if (this.room == this.habbo.getRoomUnit().getRoom()) { if (!iamapirate[this.index].isEmpty()) { this.room.talk(this.habbo, new RoomChatMessage(iamapirate[this.index], this.habbo, RoomChatMessageBubbles.PIRATE), RoomChatType.SHOUT); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java index 9f60fa0c..05e42c1f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java @@ -14,7 +14,7 @@ public class YoutubeAdvanceVideo implements Runnable { public void run() { if (this.tv.autoAdvance == null) return; - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.tv.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.tv.getRoomId()); if (room == null) return; diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java index b02f2d17..7fed4683 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeClearEffects.java @@ -11,10 +11,11 @@ public class FreezeClearEffects implements Runnable { @Override public void run() { - this.habbo.getRoomUnit().setEffectId(0, 0); + this.habbo.getRoomUnit().setEffectId(0); + this.habbo.getRoomUnit().setEffectEndTimestamp(0); this.habbo.getRoomUnit().setCanWalk(true); - if (this.habbo.getHabboInfo().getCurrentRoom() != null) { - this.habbo.getHabboInfo().getCurrentRoom().sendComposer(new AvatarEffectMessageComposer(this.habbo.getRoomUnit()).compose()); + if (this.habbo.getRoomUnit().getRoom() != null) { + this.habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(this.habbo.getRoomUnit()).compose()); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index dde9430e..abd1673f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -7,8 +7,8 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -52,9 +52,9 @@ class FreezeHandleSnowballExplosion implements Runnable { THashSet freezeTiles = new THashSet<>(); for (RoomTile roomTile : tiles) { - THashSet items = this.thrownData.room.getItemsAt(roomTile); + THashSet items = this.thrownData.room.getItemsAt(roomTile); - for (HabboItem freezeTile : items) { + for (RoomItem freezeTile : items) { if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) { int distance = 0; if (freezeTile.getX() != this.thrownData.targetTile.getX() && freezeTile.getY() != this.thrownData.targetTile.getY()) { @@ -70,7 +70,8 @@ class FreezeHandleSnowballExplosion implements Runnable { THashSet habbos = new THashSet<>(); - habbos.addAll(this.thrownData.room.getHabbosAt(freezeTile.getX(), freezeTile.getY())); + RoomTile tile = this.thrownData.room.getLayout().getTile(freezeTile.getX(), freezeTile.getY()); + habbos.addAll(this.thrownData.room.getRoomUnitManager().getHabbosAt(tile)); for (Habbo habbo : habbos) { if (habbo.getHabboInfo().getGamePlayer() != null && habbo.getHabboInfo().getGamePlayer() instanceof FreezeGamePlayer hPlayer) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java index b81932ac..329543d1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java @@ -2,7 +2,7 @@ package com.eu.habbo.threading.runnables.freeze; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; @@ -14,7 +14,7 @@ class FreezeResetExplosionTiles implements Runnable { @Override public void run() { - for (HabboItem item : this.tiles) { + for (RoomItem item : this.tiles) { item.setExtradata("0"); this.room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java index a6101523..2c86bff4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.threading.runnables.HabboItemNewState; public class FreezeThrowSnowball implements Runnable { @@ -14,7 +14,7 @@ public class FreezeThrowSnowball implements Runnable { public final Room room; public final int radius; - public FreezeThrowSnowball(Habbo habbo, HabboItem targetTile, Room room) { + public FreezeThrowSnowball(Habbo habbo, RoomItem targetTile, Room room) { this.habbo = habbo; this.targetTile = (InteractionFreezeTile) targetTile; this.room = room; diff --git a/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java b/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java index fe8124ab..05498a3d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java +++ b/src/main/java/com/eu/habbo/threading/runnables/games/GameTimer.java @@ -20,7 +20,7 @@ public class GameTimer implements Runnable { return; } - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(timer.getRoomId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(timer.getRoomId()); if (room == null || !timer.isRunning() || timer.isPaused()) { timer.setThreadActive(false); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java index 1097c8e3..8f1602fe 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java @@ -4,13 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.threading.runnables.HabboItemNewState; import lombok.AllArgsConstructor; @AllArgsConstructor class HopperActionFive implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java index d0584b75..9c9c7823 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java @@ -3,12 +3,12 @@ package com.eu.habbo.threading.runnables.hopper; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; @AllArgsConstructor class HopperActionFour implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java index 88df9fa3..ec1c8c4e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java @@ -4,25 +4,25 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import lombok.AllArgsConstructor; @AllArgsConstructor public class HopperActionOne implements Runnable { - private final HabboItem teleportOne; + private final RoomItem teleportOne; private final Room room; private final GameClient client; @Override public void run() { //this.client.getHabbo().getRoomUnit().setGoalLocation(this.teleportOne.getX(), this.teleportOne.getY()); - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[(this.teleportOne.getRotation() + 4) % 8]); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[(this.teleportOne.getRotation() + 4) % 8]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getX(), this.teleportOne.getY())); - this.client.getHabbo().getRoomUnit().setZ(this.teleportOne.getZ()); + this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getZ()); this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getZ()); Emulator.getThreading().run(() -> { diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java index 2af1f7f6..247d4c26 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java @@ -6,15 +6,15 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.interactions.InteractionCostumeHopper; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; import lombok.AllArgsConstructor; @AllArgsConstructor class HopperActionThree implements Runnable { - private final HabboItem teleportOne; + private final RoomItem teleportOne; private final Room room; private final GameClient client; private final int targetRoomId; @@ -23,13 +23,13 @@ class HopperActionThree implements Runnable { @Override public void run() { - HabboItem targetTeleport; + RoomItem targetTeleport; Room targetRoom = this.room; if (this.teleportOne.getRoomId() != this.targetRoomId) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.room, false); - targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.targetRoomId); - Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getId(), "", false); + targetRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(this.targetRoomId); + Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getRoomInfo().getId(), "", false); } targetTeleport = targetRoom.getHabboItem(this.targetItemId); @@ -44,8 +44,8 @@ class HopperActionThree implements Runnable { targetRoom.updateItem(targetTeleport); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getX(), targetTeleport.getY())); this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getZ()); - this.client.getHabbo().getRoomUnit().setZ(targetTeleport.getZ()); - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[targetTeleport.getRotation() % 8]); + this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getZ()); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); targetRoom.sendComposer(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index 0eb672c7..3a7c7831 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -3,7 +3,7 @@ package com.eu.habbo.threading.runnables.hopper; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -16,7 +16,7 @@ import java.sql.SQLException; @AllArgsConstructor class HopperActionTwo implements Runnable { - private final HabboItem teleportOne; + private final RoomItem teleportOne; private final Room room; private final GameClient client; diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index 6d4d0732..bed23943 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.threading.runnables.HabboItemNewState; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import lombok.AllArgsConstructor; @@ -16,7 +16,7 @@ import java.util.List; @AllArgsConstructor class TeleportActionFive implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; @@ -30,7 +30,7 @@ class TeleportActionFive implements Runnable { unit.setTeleporting(false); unit.setCanWalk(true); - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) + if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) return; //if (!(this.currentTeleport instanceof InteractionTeleportTile)) @@ -50,7 +50,7 @@ class TeleportActionFive implements Runnable { unit.setCanLeaveRoomByDoor(false); unit.setGoalLocation(tile); - unit.statusUpdate(true); + unit.setStatusUpdateNeeded(true); unit.setLeavingTeleporter(true); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess)); } @@ -60,7 +60,7 @@ class TeleportActionFive implements Runnable { Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); - HabboItem teleportTile = this.room.getTopItemAt(unit.getX(), unit.getY()); + RoomItem teleportTile = this.room.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); if (teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { try { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java index 817ec8aa..6ed4fef4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java @@ -3,19 +3,19 @@ package com.eu.habbo.threading.runnables.teleport; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; @AllArgsConstructor class TeleportActionFour implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; @Override public void run() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) { + if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) { this.client.getHabbo().getRoomUnit().setCanWalk(true); this.currentTeleport.setExtradata("0"); this.room.updateItem(this.currentTeleport); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java index 03128e18..652b2bb1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java @@ -5,20 +5,20 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import lombok.AllArgsConstructor; @AllArgsConstructor public class TeleportActionOne implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; @Override public void run() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) + if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) return; int delay = 500; @@ -27,9 +27,9 @@ public class TeleportActionOne implements Runnable { delay = 0; } - if (this.client.getHabbo().getRoomUnit().getCurrentLocation() != this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())) { + if (this.client.getHabbo().getRoomUnit().getCurrentPosition() != this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())) { this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())); - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[(this.currentTeleport.getRotation() + 4) % 8]); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[(this.currentTeleport.getRotation() + 4) % 8]); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.currentTeleport.getX() + "," + this.currentTeleport.getY() + "," + this.currentTeleport.getZ()); this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 1083f9af..38b3e68e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -7,26 +7,26 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import lombok.AllArgsConstructor; @AllArgsConstructor class TeleportActionThree implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; @Override public void run() { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) + if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) return; - HabboItem targetTeleport; + RoomItem targetTeleport; Room targetRoom = this.room; if (this.currentTeleport.getRoomId() != ((InteractionTeleport) this.currentTeleport).getTargetRoomId()) { - targetRoom = Emulator.getGameEnvironment().getRoomManager().loadRoom(((InteractionTeleport) this.currentTeleport).getTargetRoomId()); + targetRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(((InteractionTeleport) this.currentTeleport).getTargetRoomId()); } if (targetRoom == null) { @@ -54,22 +54,22 @@ class TeleportActionThree implements Runnable { this.client.getHabbo().getRoomUnit().setLocation(teleportLocation); this.client.getHabbo().getRoomUnit().getPath().clear(); this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - this.client.getHabbo().getRoomUnit().setZ(teleportLocation.getStackHeight()); + this.client.getHabbo().getRoomUnit().setCurrentZ(teleportLocation.getStackHeight()); this.client.getHabbo().getRoomUnit().setPreviousLocationZ(teleportLocation.getStackHeight()); if (targetRoom != this.room) { - this.room.removeHabbo(this.client.getHabbo(), false); - Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getId(), "", Emulator.getConfig().getBoolean("hotel.teleport.locked.allowed"), teleportLocation); + this.room.getRoomUnitManager().removeHabbo(this.client.getHabbo(), false); + Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getRoomInfo().getId(), "", Emulator.getConfig().getBoolean("hotel.teleport.locked.allowed"), teleportLocation); } - this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[targetTeleport.getRotation() % 8]); - this.client.getHabbo().getRoomUnit().statusUpdate(true); + this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); + this.client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true); targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); //targetRoom.updateHabbo(this.client.getHabbo()); //LOGGER.info((targetTeleport.getX() + " | " + targetTeleport.getY()); - this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); + this.client.getHabbo().getRoomUnit().setRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index 377a4812..b86acdd0 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; import com.eu.habbo.habbohotel.items.interactions.InteractionTeleportTile; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; import lombok.AllArgsConstructor; @@ -21,7 +21,7 @@ import java.sql.SQLException; @AllArgsConstructor class TeleportActionTwo implements Runnable { - private final HabboItem currentTeleport; + private final RoomItem currentTeleport; private final Room room; private final GameClient client; @@ -34,14 +34,14 @@ class TeleportActionTwo implements Runnable { delayOffset = 0; } - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) + if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) return; this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); this.room.sendComposer(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); if (((InteractionTeleport) this.currentTeleport).getTargetRoomId() > 0 && ((InteractionTeleport) this.currentTeleport).getTargetId() > 0) { - HabboItem item = this.room.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); + RoomItem item = this.room.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); if (item == null) { ((InteractionTeleport) this.currentTeleport).setTargetRoomId(0); ((InteractionTeleport) this.currentTeleport).setTargetId(0); From 1c5e1cde61e6bfc017d0604357f33622f72df6ec Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 17 Jul 2023 12:29:11 -0500 Subject: [PATCH 18/42] Dismounting Fix --- .../habbo/messages/incoming/rooms/pets/MountPetEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index 906e9dd0..fce34f12 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -30,7 +30,13 @@ public class MountPetEvent extends MessageHandler { //dismount if (habbo.getHabboInfo().getRiding() != null) { + boolean mountAgain = petId != habbo.getHabboInfo().getRiding().getId(); + habbo.getHabboInfo().dismountPet(room); + + if(!mountAgain) { + return; + } } // someone is already on it From ab529344ef3fd76a334b45919c3490221d3f3803 Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 18 Jul 2023 15:24:46 -0500 Subject: [PATCH 19/42] Separating DanceType from RoomUnit --- .../com/eu/habbo/habbohotel/rooms/Room.java | 26 ++++--------------- .../rooms/entities/items/RoomItem.java | 9 ++++--- .../rooms/entities/units/RoomUnit.java | 6 ----- .../entities/units/types/RoomAvatar.java | 17 ++++++++++++ .../com/eu/habbo/habbohotel/users/Habbo.java | 2 +- .../rooms/users/DanceMessageComposer.java | 8 +++--- 6 files changed, 33 insertions(+), 35 deletions(-) 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 de340115..009ceaa5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1265,7 +1265,9 @@ public class Room implements Comparable, ISerialize, Runnable { update = true; } } else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) { - this.dance(unit, DanceType.NONE); + if(unit instanceof RoomAvatar roomAvatar) { + roomAvatar.setDance(DanceType.NONE); + } unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + ""); unit.setCurrentZ(topItem.getZ()); unit.setRotation(RoomRotation.values()[topItem.getRotation()]); @@ -2852,7 +2854,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - this.dance(habbo, DanceType.NONE); + habbo.getRoomUnit().setDance(DanceType.NONE); habbo.getRoomUnit().setCmdSitEnabled(true); habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + ""); @@ -3082,7 +3084,7 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().setIdle(); if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) { - this.dance(habbo, DanceType.NONE); + habbo.getRoomUnit().setDance(DanceType.NONE); } this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose()); @@ -3096,24 +3098,6 @@ public class Room implements Comparable, ISerialize, Runnable { WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } - public void dance(Habbo habbo, DanceType danceType) { - this.dance(habbo.getRoomUnit(), danceType); - } - - public void dance(RoomUnit unit, DanceType danceType) { - if (unit.getDanceType() != danceType) { - boolean isDancing = !unit.getDanceType().equals(DanceType.NONE); - unit.setDanceType(danceType); - this.sendComposer(new DanceMessageComposer(unit).compose()); - - if (danceType.equals(DanceType.NONE) && isDancing) { - WiredHandler.handle(WiredTriggerType.STOPS_DANCING, unit, this, new Object[]{unit}); - } else if (!danceType.equals(DanceType.NONE) && !isDancing) { - WiredHandler.handle(WiredTriggerType.STARTS_DANCING, unit, this, new Object[]{unit}); - } - } - } - public void addToWordFilter(String word) { synchronized (this.wordFilterWords) { if (this.wordFilterWords.contains(word)) 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 02dd89f6..e2ad56ce 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 @@ -16,6 +16,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -263,9 +264,11 @@ public abstract class RoomItem implements Runnable, IEventTriggers { WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, roomUnit, room, new Object[]{this}); - if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && !roomUnit.getDanceType().equals(DanceType.NONE)) { - roomUnit.setDanceType(DanceType.NONE); - room.sendComposer(new DanceMessageComposer(roomUnit).compose()); + if(roomUnit instanceof RoomAvatar roomAvatar) { + if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && !roomAvatar.getDanceType().equals(DanceType.NONE)) { + roomAvatar.setDanceType(DanceType.NONE); + room.sendComposer(new DanceMessageComposer(roomAvatar).compose()); + } } if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoalLocation() && roomUnit.getGoalLocation() == room.getLayout().getTile(this.x, this.y)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 6556c9ff..bdc11e53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent; @@ -103,9 +102,6 @@ public abstract class RoomUnit extends RoomEntity { private boolean invisible = false; @Setter private boolean canLeaveRoomByDoor = true; - @Getter - @Setter - private DanceType danceType; private int walkTimeOut; private int previousEffectId; private int previousEffectEndTimestamp; @@ -135,7 +131,6 @@ public abstract class RoomUnit extends RoomEntity { this.timeInRoom = 0; //RoomAvatar - this.danceType = DanceType.NONE; this.previousEffectId = 0; this.previousEffectEndTimestamp = -1; @@ -425,7 +420,6 @@ public abstract class RoomUnit extends RoomEntity { this.fastWalkEnabled = false; this.cmdTeleportEnabled = false; this.clearStatuses(); - this.danceType = DanceType.NONE; this.previousEffectId = 0; this.previousEffectEndTimestamp = -1; this.isKicked = false; 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 b4eeb770..a0a8989c 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 @@ -11,6 +11,9 @@ 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; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.users.UserIdleEvent; @@ -275,6 +278,20 @@ public class RoomAvatar extends RoomUnit { return false; } } + + public void setDance(DanceType danceType) { + if (this.danceType != danceType) { + boolean isDancing = !this.danceType.equals(DanceType.NONE); + this.danceType = danceType; + this.getRoom().sendComposer(new DanceMessageComposer(this).compose()); + + if (danceType.equals(DanceType.NONE) && isDancing) { + WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.getRoom(), new Object[]{this}); + } else if (!danceType.equals(DanceType.NONE) && !isDancing) { + WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.getRoom(), new Object[]{this}); + } + } + } public RoomAvatar setHandItem(int handItem) { this.handItem = handItem; 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 3eac30f3..35889c5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -468,7 +468,7 @@ public class Habbo extends Unit implements Runnable { AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned")); this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); - this.client.getHabbo().getRoomUnit().getRoom().dance(this.client.getHabbo().getRoomUnit(), DanceType.NONE); + this.client.getHabbo().getRoomUnit().setDance(DanceType.NONE); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java index fbac4cf0..92a28ac1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/DanceMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,14 +8,14 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class DanceMessageComposer extends MessageComposer { - private final RoomUnit roomUnit; + private final RoomAvatar roomAvatar; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.danceMessageComposer); - this.response.appendInt(this.roomUnit.getVirtualId()); - this.response.appendInt(this.roomUnit.getDanceType().getType()); + this.response.appendInt(this.roomAvatar.getVirtualId()); + this.response.appendInt(this.roomAvatar.getDanceType().getType()); return this.response; } } From 659a9d375f3d28468080bde656dd7c48fdcdd076 Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 20 Jul 2023 16:17:29 -0500 Subject: [PATCH 20/42] 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); From c08c57db3c3df618e69e885acdebeb0867eaa4ec Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 20 Jul 2023 18:14:24 -0500 Subject: [PATCH 21/42] Cleaning up Room.java --- .../com/eu/habbo/habbohotel/bots/Bot.java | 93 +--- .../commands/list/EnableCommand.java | 2 +- .../commands/list/HabnamCommand.java | 2 +- .../commands/list/MoonwalkCommand.java | 2 +- .../commands/list/RoomEffectCommand.java | 2 +- .../battlebanzai/BattleBanzaiGameTeam.java | 6 +- .../games/freeze/FreezeGamePlayer.java | 2 +- .../games/freeze/FreezeGameTeam.java | 6 +- .../habbo/habbohotel/games/tag/TagGame.java | 20 +- .../habbohotel/games/wired/WiredGame.java | 9 +- .../interactions/InteractionBuildArea.java | 6 +- .../interactions/InteractionDefault.java | 58 ++- .../interactions/InteractionEffectGiver.java | 6 +- .../interactions/InteractionEffectTile.java | 11 +- .../InteractionEffectVendingMachine.java | 2 +- ...nteractionEffectVendingMachineNoSides.java | 2 +- .../interactions/InteractionGymEquipment.java | 11 +- .../interactions/InteractionMultiHeight.java | 8 +- .../InteractionRentableSpace.java | 2 +- .../InteractionSnowboardSlope.java | 10 +- .../InteractionTileEffectProvider.java | 2 +- .../items/interactions/InteractionTrap.java | 18 +- .../InteractionVendingMachine.java | 4 +- .../wired/effects/WiredEffectBotTalk.java | 2 +- .../effects/WiredEffectBotTalkToRoom.java | 2 +- .../WiredEffectChangeFurniDirection.java | 10 +- .../wired/effects/WiredEffectGiveEffect.java | 9 +- .../wired/effects/WiredEffectKickRoom.java | 2 +- .../wired/effects/WiredEffectMatchFurni.java | 18 +- .../effects/WiredEffectMoveFurniAway.java | 4 +- .../effects/WiredEffectMoveFurniTowards.java | 6 +- .../effects/WiredEffectMoveRotateFurni.java | 18 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 481 +----------------- .../habbohotel/rooms/RoomItemManager.java | 219 +++++++- .../habbo/habbohotel/rooms/RoomManager.java | 2 +- .../habbohotel/rooms/RoomUnitManager.java | 4 +- .../rooms/entities/items/RoomItem.java | 24 +- .../entities/units/types/RoomAvatar.java | 32 ++ .../eu/habbo/habbohotel/users/HabboInfo.java | 7 +- .../users/inventory/EffectsComponent.java | 2 +- .../incoming/rooms/items/MoveObjectEvent.java | 4 +- .../rooms/items/PickupObjectEvent.java | 2 +- .../rooms/items/PlaceObjectEvent.java | 4 +- .../users/AvatarEffectSelectedEvent.java | 2 +- .../incoming/wired/ApplySnapshotEvent.java | 13 +- .../threading/runnables/RoomUnitRidePet.java | 2 +- .../threading/runnables/YouAreAPirate.java | 4 +- 47 files changed, 460 insertions(+), 697 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 6eb9d81d..49cc2bb8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -31,26 +31,37 @@ import java.util.List; @Slf4j public class Bot extends Unit implements Runnable { - public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; - public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); - - private final ArrayList chatLines; + @Getter + @Setter private transient int id; + @Getter private String name; + @Getter private String motto; + @Getter private String figure; + @Getter private HabboGender gender; + @Getter private int ownerId; + @Getter private String ownerName; + @Getter + @Setter private Room room; + @Getter private boolean chatAuto; + @Getter private boolean chatRandom; + @Getter private short chatDelay; private int chatTimeOut; private int chatTimestamp; private short lastChatIndex; private final int bubble; + @Getter private final String type; + @Getter private int effect; private transient boolean canWalk = true; private boolean needsUpdate; @@ -59,6 +70,10 @@ public class Bot extends Unit implements Runnable { @Setter @Accessors(chain = true) private RoomBot roomUnit; + public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; + public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); + @Getter + private final ArrayList chatLines; public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) { this.id = id; @@ -193,7 +208,7 @@ public class Bot extends Unit implements Runnable { String message = this.chatLines.get(this.lastChatIndex) .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getRoomInfo().getOwnerInfo().getUsername()) - .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "") + .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.getRoomItemManager().getCurrentItems().size() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getRoomInfo().getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getRoomUnitManager().getRoomHabbosCount() + ""); @@ -251,7 +266,7 @@ public class Bot extends Unit implements Runnable { public void onPlace(Habbo habbo, Room room) { if (this.getRoomUnit() != null) { - room.giveEffect(this.getRoomUnit(), this.effect, -1); + this.getRoomUnit().giveEffect(this.effect, -1); } if(PLACEMENT_MESSAGES.length > 0) { @@ -270,18 +285,6 @@ public class Bot extends Unit implements Runnable { } - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return this.name; - } - public int getBubbleId() { return bubble; } @@ -294,19 +297,11 @@ public class Bot extends Unit implements Runnable { //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose()); } - public String getMotto() { - return this.motto; - } - public void setMotto(String motto) { this.motto = motto; this.needsUpdate = true; } - public String getFigure() { - return this.figure; - } - public void setFigure(String figure) { this.figure = figure; this.needsUpdate = true; @@ -315,10 +310,6 @@ public class Bot extends Unit implements Runnable { this.room.sendComposer(new RoomUsersComposer(this).compose()); } - public HabboGender getGender() { - return this.gender; - } - public void setGender(HabboGender gender) { this.gender = gender; this.needsUpdate = true; @@ -327,10 +318,6 @@ public class Bot extends Unit implements Runnable { this.room.sendComposer(new RoomUsersComposer(this).compose()); } - public int getOwnerId() { - return this.ownerId; - } - public void setOwnerId(int ownerId) { this.ownerId = ownerId; this.needsUpdate = true; @@ -339,10 +326,6 @@ public class Bot extends Unit implements Runnable { this.room.sendComposer(new RoomUsersComposer(this).compose()); } - public String getOwnerName() { - return this.ownerName; - } - public void setOwnerName(String ownerName) { this.ownerName = ownerName; this.needsUpdate = true; @@ -351,27 +334,11 @@ public class Bot extends Unit implements Runnable { this.room.sendComposer(new RoomUsersComposer(this).compose()); } - public Room getRoom() { - return this.room; - } - - public void setRoom(Room room) { - this.room = room; - } - - public boolean isChatAuto() { - return this.chatAuto; - } - public void setChatAuto(boolean chatAuto) { this.chatAuto = chatAuto; this.needsUpdate = true; } - public boolean isChatRandom() { - return this.chatRandom; - } - public void setChatRandom(boolean chatRandom) { this.chatRandom = chatRandom; this.needsUpdate = true; @@ -381,10 +348,6 @@ public class Bot extends Unit implements Runnable { return !this.chatLines.isEmpty(); } - public int getChatDelay() { - return this.chatDelay; - } - public void setChatDelay(short chatDelay) { this.chatDelay = (short) Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED); this.needsUpdate = true; @@ -402,21 +365,13 @@ public class Bot extends Unit implements Runnable { } } - public String getType() { - return this.type; - } - - public int getEffect() { - return this.effect; - } - public void setEffect(int effect, int duration) { this.effect = effect; this.needsUpdate = true; if (this.getRoomUnit() != null) { if (this.room != null) { - this.room.giveEffect(this.getRoomUnit(), this.effect, duration); + this.getRoomUnit().giveEffect(this.effect, duration); } } } @@ -435,10 +390,6 @@ public class Bot extends Unit implements Runnable { } } - public ArrayList getChatLines() { - return this.chatLines; - } - public int getFollowingHabboId() { return this.followingHabboId; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java index 87af068d..fad0c8d9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java @@ -39,7 +39,7 @@ public class EnableCommand extends Command { return true; } - target.getRoomUnit().getRoom().giveEffect(target, effectId, -1); + target.getRoomUnit().giveEffect(effectId, -1); } } catch (Exception e) { log.error("Caught exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java index e089d6ae..b8e18ced 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java @@ -11,7 +11,7 @@ public class HabnamCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getRoomUnit().getRoom() != null) { - gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), 140, 30); + gameClient.getHabbo().getRoomUnit().giveEffect(140, 30); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java index e21db613..191ffd98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java @@ -15,7 +15,7 @@ public class MoonwalkCommand extends Command { if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136) effect = 0; - gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), effect, -1); + gameClient.getHabbo().getRoomUnit().giveEffect(effect, -1); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java index ebecd5fc..946ebac7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java @@ -22,7 +22,7 @@ public class RoomEffectCommand extends Command { if (effectId >= 0) { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> room.giveEffect(habbo, effectId, -1)); + room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> habbo.getRoomUnit().giveEffect(effectId, -1)); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java index c061c627..eecc6df9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java @@ -27,7 +27,7 @@ public class BattleBanzaiGameTeam extends GameTeam { roomHabbo.setPreviousEffectEndTimestamp(roomHabbo.getPreviousEffectEndTimestamp()); } - gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true); + gamePlayer.getHabbo().getRoomUnit().giveEffect(BattleBanzaiGame.effectId + this.teamColor.type, -1, true); } @Override @@ -56,12 +56,12 @@ public class BattleBanzaiGameTeam extends GameTeam { } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } roomUnit.setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java index 67a21c88..80334649 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java @@ -208,6 +208,6 @@ public class FreezeGamePlayer extends GamePlayer { if (this.dead) return; - super.getHabbo().getRoomUnit().getRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true); + super.getHabbo().getRoomUnit().giveEffect(this.correctEffectId(), -1, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index 9a4e764d..8385c35d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -44,12 +44,12 @@ public class FreezeGameTeam extends GameTeam { } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } roomUnit.setCanWalk(true); @@ -68,6 +68,6 @@ public class FreezeGameTeam extends GameTeam { RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit(); if (roomHabbo.getEffectId() > 0) roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true); + gamePlayer.getHabbo().getRoomUnit().giveEffect(FreezeGame.effectId + this.teamColor.type, -1, true); } } 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 27241fbb..076b70b3 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 @@ -100,7 +100,7 @@ public abstract class TagGame extends Game { THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole()); InteractionTagPole pole = this.taggers.get(tagger); - room.giveEffect(tagged, this.getTaggedEffect(tagged), -1); + tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1); if (poles.size() > this.taggers.size()) { for (Map.Entry set : this.taggers.entrySet()) { @@ -108,12 +108,12 @@ public abstract class TagGame extends Game { } for (RoomItem item : poles) { - tagged.getRoomUnit().getRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1); + tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1); this.taggers.put(tagged, (InteractionTagPole) item); } } else { if (tagger != null) { - room.giveEffect(tagger, this.getEffect(tagger), -1); + tagger.getRoomUnit().giveEffect(this.getEffect(tagger), -1); this.taggers.remove(tagger); } @@ -145,8 +145,8 @@ public abstract class TagGame extends Game { RoomItem item = iterator.next(); if (roomHabbo.getEffectId() > 0) roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); - this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); + habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true); + this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true)); this.taggers.put(habbo, (InteractionTagPole) item); return true; } @@ -155,15 +155,15 @@ public abstract class TagGame extends Game { if (this.taggers.isEmpty()) { if (roomHabbo.getEffectId() > 0) roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); - this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true)); + habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true); + this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true)); this.taggers.put(habbo, null); return true; } } if (roomHabbo.getEffectId() > 0) roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true); + habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true); return true; } @@ -192,12 +192,12 @@ public abstract class TagGame extends Game { } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 78886dc2..29bc1940 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -4,7 +4,6 @@ import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; 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.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -35,14 +34,14 @@ public class WiredGame extends Game { RoomHabbo roomHabbo = habbo.getRoomUnit(); if (roomHabbo.getEffectId() > 0) roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true); + roomHabbo.giveEffect(FreezeGame.effectId + teamColor.type, -1, true); return super.addHabbo(habbo, teamColor); } @Override public void removeHabbo(Habbo habbo) { super.removeHabbo(habbo); - RoomUnit roomUnit = habbo.getRoomUnit(); + RoomHabbo roomUnit = habbo.getRoomUnit(); Room room = this.room; if (room == null) return; @@ -61,12 +60,12 @@ public class WiredGame extends Game { } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + roomUnit.giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + roomUnit.giveEffect(nextEffectF, nextEffectDuration, true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index 998193a9..b81bf641 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -81,7 +81,7 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet tileItems = room.getItemsAt(tile); for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { - room.pickUpItem(tileItem, null); + room.getRoomItemManager().pickUpItem(tileItem, null); } } } @@ -131,7 +131,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (newTiles.contains(tile)) continue; for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { - room.pickUpItem(tileItem, null); + room.getRoomItemManager().pickUpItem(tileItem, null); } } } @@ -205,7 +205,7 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet tileItems = room.getItemsAt(tile); for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { - room.pickUpItem(tileItem, null); + room.getRoomItemManager().pickUpItem(tileItem, null); } } } 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 bc6e535e..a01185e8 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 @@ -9,7 +9,8 @@ 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.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -108,39 +109,46 @@ public class InteractionDefault extends RoomItem { return; } - if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); + if (roomUnit instanceof RoomHabbo roomHabbo) { + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo); if (habbo == null) return; - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - if (((RoomAvatar) roomUnit).getEffectId() > 0) - roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) { + if (roomHabbo.getEffectId() > 0) { + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + } + + roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - if (((RoomAvatar) roomUnit).getEffectId() > 0) - roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) { + if (roomHabbo.getEffectId() > 0) { + roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); + } + roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1); } - } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); + } else if (roomUnit instanceof RoomBot roomBot) { + Bot bot = room.getRoomUnitManager().getBotByRoomUnit(roomBot); if (bot == null) return; - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectM()) { - if (((RoomAvatar) roomUnit).getEffectId() > 0) - roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectM()) { + if (roomBot.getEffectId() > 0) { + roomBot.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp()); + } + + roomBot.giveEffect(this.getBaseItem().getEffectM(), -1); return; } - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectF()) { - if (((RoomAvatar) roomUnit).getEffectId() > 0) - roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp()); - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectF()) { + if (roomBot.getEffectId() > 0) { + roomUnit.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp()); + } + + roomBot.giveEffect(this.getBaseItem().getEffectF(), -1); } } } @@ -180,12 +188,12 @@ public class InteractionDefault extends RoomItem { if (habbo != null) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration); + habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration); + habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration); } } } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { @@ -193,12 +201,12 @@ public class InteractionDefault extends RoomItem { if (bot != null) { if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - room.giveEffect(roomUnit, nextEffectM, nextEffectDuration); + bot.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration); return; } if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - room.giveEffect(roomUnit, nextEffectF, nextEffectDuration); + bot.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java index b662f8e8..9e321918 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import java.sql.ResultSet; import java.sql.SQLException; @@ -38,7 +39,10 @@ public class InteractionEffectGiver extends InteractionDefault { if (!this.getExtradata().equals("0")) return; RoomItem instance = this; - room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem(), -1); + + if(roomUnit instanceof RoomAvatar roomAvatar) { + roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), -1); + } if (this.getBaseItem().getStateCount() > 1) { this.setExtradata("1"); 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 a1c65f49..3504ef38 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -67,10 +68,12 @@ public class InteractionEffectTile extends InteractionPressurePlate { } private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender) { - if (gender.equals(HabboGender.M)) { - room.giveEffect(roomUnit, this.getBaseItem().getEffectM(), -1); - } else { - room.giveEffect(roomUnit, this.getBaseItem().getEffectF(), -1); + if(roomUnit instanceof RoomAvatar roomAvatar) { + if (gender.equals(HabboGender.M)) { + roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1); + } else { + roomAvatar.giveEffect(this.getBaseItem().getEffectF(), -1); + } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java index 3cb7e9de..91da5312 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java @@ -20,6 +20,6 @@ public class InteractionEffectVendingMachine extends InteractionVendingMachine { @Override public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) { - room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30); + roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java index 59d8e0f2..ffd43e91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java @@ -22,7 +22,7 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa @Override public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) { - room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30); + roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30); } @Override 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 72d89ab5..270c0e65 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 @@ -10,6 +10,7 @@ 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.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -86,12 +87,12 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - room.giveEffect(habbo, nextEffectM, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - room.giveEffect(habbo, nextEffectF, nextEffectDuration, true); + habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } } } @@ -164,7 +165,11 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC private void setEffect(Room room, int effectId) { if (this.roomUnitId == -1) return; - room.giveEffect(this.getCurrentRoomUnit(room), effectId, -1); + RoomUnit roomUnit = this.getCurrentRoomUnit(room); + + if(roomUnit instanceof RoomAvatar roomAvatar) { + roomAvatar.giveEffect(effectId, -1); + } } private void reset(Room room) { 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 4d851bee..312bc875 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 @@ -114,12 +114,12 @@ public class InteractionMultiHeight extends RoomItem { if (habbo != null) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1); } } } @@ -136,12 +136,12 @@ public class InteractionMultiHeight extends RoomItem { if (habbo != null) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - room.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - room.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1); } } } 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 703c528b..5103f749 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 @@ -167,7 +167,7 @@ public class InteractionRentableSpace extends RoomItem { for (RoomItem item : items) { if (item.getUserId() == this.renterId) { - room.pickUpItem(item, null); + room.getRoomItemManager().pickUpItem(item, null); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java index 724a4b00..731b1483 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java @@ -28,7 +28,9 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - room.giveEffect(roomUnit, 97, -1); + if(roomUnit instanceof RoomAvatar roomAvatar) { + roomAvatar.giveEffect(97, -1); + } } @Override @@ -36,7 +38,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { super.onWalkOff(roomUnit, room, objects); if (roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.getEffectId() == 97) { - room.giveEffect(roomAvatar, 0, -1); + roomAvatar.giveEffect(0, -1); } } @@ -70,7 +72,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { public void onPickUp(Room room) { for (Habbo habbo : room.getHabbosOnItem(this)) { if (habbo.getRoomUnit().getEffectId() == 97) { - room.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1); } } } @@ -81,7 +83,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { for (Habbo habbo : room.getHabbosOnItem(this)) { if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY())) { - room.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java index 3b642d99..22ee08b2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java @@ -57,6 +57,6 @@ public class InteractionTileEffectProvider extends InteractionCustomValues { room.updateItem(proxy); }, 500); - room.giveEffect(roomHabbo, effectId, -1); + roomHabbo.giveEffect(effectId, -1); } } 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 b6407a93..a02d58ff 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 @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -35,24 +35,24 @@ public class InteractionTrap extends InteractionDefault { } if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { + if (roomUnit instanceof RoomHabbo roomHabbo) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) { + roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1); return; } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) { + roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1); return; } - roomUnit.setCanWalk(false); + roomHabbo.setCanWalk(false); Emulator.getThreading().run(() -> { - room.giveEffect(roomUnit, 0, -1); + roomHabbo.giveEffect(0, -1); roomUnit.setCanWalk(true); - room.giveEffect(roomUnit, effect, -1); + roomHabbo.giveEffect(effect, -1); }, delay); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index a8b1dd04..1249d52a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -95,9 +95,9 @@ public class InteractionVendingMachine extends RoomItem { giveVendingMachineItem(room, roomAvatar); if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1); if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1); Emulator.getThreading().run(this, 500); }, 1500); 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 506b165c..f81f59b9 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 @@ -41,7 +41,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "") .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername()) - .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") + .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + ""); 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 98edc19c..29cc3fad 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 @@ -41,7 +41,7 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect { .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "") .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "") .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername()) - .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "") + .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName()) .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index faea7fe6..eda70a5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -87,7 +87,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); int count = 1; - while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { + while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { setting.setDirection(this.nextDirection(setting.getDirection())); RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); @@ -103,10 +103,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirectionValue); if(item.getRotation() != setting.getRotation()) { - if(room.furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE) + if(room.getRoomItemManager().furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE) continue; - room.moveFurniTo(item, newTargetTile, setting.getRotation(), null, true); + room.getRoomItemManager().moveFurniTo(item, newTargetTile, setting.getRotation(), null, true, true); } boolean hasRoomUnits = false; @@ -122,11 +122,11 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } } - if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { + if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { if (!hasRoomUnits) { RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); - if(room.moveFurniTo(item, newTargetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveFurniTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index 8f1b71c5..947444e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import java.sql.ResultSet; import java.sql.SQLException; @@ -30,9 +31,11 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { return false; } - if (effectId >= 0) { - room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE); - return true; + if(roomUnit instanceof RoomAvatar roomAvatar) { + if (effectId >= 0) { + roomAvatar.giveEffect(effectId, Integer.MAX_VALUE); + return true; + } } return false; 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 c77e49ca..fde18241 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 @@ -43,7 +43,7 @@ public class WiredEffectKickRoom extends InteractionWiredEffect { return true; } - room.giveEffect(habbo, 4, 2); + habbo.getRoomUnit().giveEffect(4, 2); if (!this.getWiredSettings().getStringParam().isEmpty()) { habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam(), habbo, habbo, RoomChatMessageBubbles.ALERT))); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index db3afbff..4556c482 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -3,9 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -63,8 +66,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int double oldZ = item.getZ(); if(rotation && !position) { - if(item.getRotation() != furniSettings.getRotation() && room.furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) { - room.moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true); + if (item.getRotation() != furniSettings.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) { + room.getRoomItemManager().moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true, true); } } else if(position) { @@ -72,9 +75,10 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int RoomTile newLocation = room.getLayout().getTile((short) furniSettings.getX(), (short) furniSettings.getY()); int newRotation = rotation ? furniSettings.getRotation() : item.getRotation(); - if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { - if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - if(slideAnimation) { + if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { + boolean sendUpdates = !slideAnimation; + if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { + if (slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index 4673ffd9..84458e7e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -73,8 +73,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); - if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { - if(room.moveFurniTo(item, newLocation, item.getRotation(), null, false) == FurnitureMovementError.NONE) { + if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.getRoomItemManager().furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveFurniTo(item, newLocation, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 3e874cbe..13f9399b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -54,7 +54,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if (!layout.tileExists(tile.getX(), tile.getY())) continue; - if (room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE) + if (room.getRoomItemManager().furnitureFitsAt(tile, item, item.getRotation(), true) == FurnitureMovementError.INVALID_MOVE) continue; RoomItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); @@ -200,8 +200,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if(newTile != null) { lastDirections.put(item.getId(), moveDirection); - if(newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { - if (room.moveFurniTo(item, newTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) { + if (newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.getRoomItemManager().furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveFurniTo(item, newTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 4f5b96f0..bc6eb57c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -4,10 +4,13 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; -import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; +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.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.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -63,11 +66,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement boolean slideAnimation = item.getRotation() == newRotation; - FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true); + FurnitureMovementError furniMoveTest = room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, true); if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) { - if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) { - if(slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); + if(room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE) { + boolean sendUpdates = !slideAnimation; + if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { + if (slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); + } } } } 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 b32181c1..fb9804fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -44,7 +44,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; -import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; @@ -53,7 +52,8 @@ import com.eu.habbo.messages.outgoing.rooms.items.*; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer; import com.eu.habbo.plugin.Event; -import com.eu.habbo.plugin.events.furniture.*; +import com.eu.habbo.plugin.events.furniture.FurnitureRolledEvent; +import com.eu.habbo.plugin.events.furniture.FurnitureStackHeightEvent; import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadingEvent; @@ -72,7 +72,6 @@ import io.netty.util.internal.ConcurrentSet; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.math3.util.Pair; import java.awt.*; import java.sql.Connection; @@ -153,6 +152,7 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter @Setter private volatile boolean allowBotsWalk; + @Getter @Setter private volatile boolean allowEffects; @Getter @@ -322,8 +322,8 @@ public class Room implements Comparable, ISerialize, Runnable { log.error(CAUGHT_EXCEPTION, e); } - if (this.itemCount() > Room.MAXIMUM_FURNI) { - log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.itemCount(), Room.MAXIMUM_FURNI); + if (this.getRoomItemManager().getCurrentItems().size() > Room.MAXIMUM_FURNI) { + log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.getRoomItemManager().getCurrentItems().size(), Room.MAXIMUM_FURNI); } } @@ -361,11 +361,11 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new HeightMapUpdateMessageComposer(this, tiles).compose()); } - private RoomTileState calculateTileState(RoomTile tile) { + public RoomTileState calculateTileState(RoomTile tile) { return this.calculateTileState(tile, null); } - private RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) { + public RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) { if (tile == null || tile.getState() == RoomTileState.INVALID) return RoomTileState.INVALID; @@ -427,59 +427,6 @@ public class Room implements Comparable, ISerialize, Runnable { return walkable; } - 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); - item.setRoomId(0); - item.needsUpdate(true); - - if (item.getBaseItem().getType() == FurnitureType.FLOOR) { - this.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.getStackHeight(x, y, false); - RoomTile tile = this.layout.getTile(x, y); - - if (tile != null) { - tile.setStackHeight(stackHeight); - updatedTiles.add(tile); - } - } - } - this.sendComposer(new HeightMapUpdateMessageComposer(this, updatedTiles).compose()); - this.updateTiles(updatedTiles); - updatedTiles.forEach(tile -> { - this.updateHabbosAt(tile); - this.updateBotsAt(tile.getX(), tile.getY()); - }); - } else if (item.getBaseItem().getType() == FurnitureType.WALL) { - this.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 void updateHabbo(Habbo habbo) { this.updateRoomUnit(habbo.getRoomUnit()); } @@ -572,7 +519,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.getRoomUnit().setCurrentZ(topItem.getZ() + Item.getCurrentHeight(topItem)); if (topItem.getBaseItem().allowLay()) { - bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); + bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, String.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight())); } } } else { @@ -854,7 +801,7 @@ public class Room implements Comparable, ISerialize, Runnable { */ if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) { - this.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1) } if (habbo.getRoomUnit().isKicked()) { @@ -1303,7 +1250,7 @@ public class Room implements Comparable, ISerialize, Runnable { if(unit instanceof RoomAvatar roomAvatar) { roomAvatar.setDance(DanceType.NONE); } - unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + ""); + unit.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); unit.setCurrentZ(topItem.getZ()); unit.setRotation(RoomRotation.values()[topItem.getRotation()]); unit.setSitUpdate(false); @@ -1322,7 +1269,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { - unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) + ""); + unit.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); unit.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { @@ -2783,7 +2730,7 @@ public class Room implements Comparable, ISerialize, Runnable { } habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); - habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, flatCtrl.getLevel() + ""); + habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel())); habbo.getRoomUnit().setRightsLevel(flatCtrl); habbo.getRoomUnit().setStatusUpdateNeeded(true); @@ -2867,46 +2814,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) { - if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) { - this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks); - } - } - - public void giveEffect(Habbo habbo, int effectId, int duration) { - if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) { - this.giveEffect(habbo.getRoomUnit(), effectId, duration, false); - } - } - - public void giveEffect(RoomUnit roomUnit, int effectId, int duration) { - this.giveEffect(roomUnit, effectId, duration, false); - } - - public void giveEffect(RoomUnit roomUnit, int effectId, int duration, boolean ignoreChecks) { - if (roomUnit == null || !roomUnit.isInRoom() || !(roomUnit instanceof RoomAvatar roomAvatar)) { - return; - } - - Habbo habbo = this.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); - - if (roomAvatar.getRoomUnitType() == RoomUnitType.HABBO && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) { - return; - } - - if (duration == -1 || duration == Integer.MAX_VALUE) { - duration = Integer.MAX_VALUE; - } else { - duration += Emulator.getIntUnixTimestamp(); - } - - if ((this.allowEffects || ignoreChecks) && !roomAvatar.isSwimming()) { - roomAvatar.setEffectId(effectId); - roomAvatar.setEffectEndTimestamp(duration); - this.sendComposer(new AvatarEffectMessageComposer(roomAvatar).compose()); - } - } - public void updateItem(RoomItem item) { if (!this.isLoaded()) { return; @@ -2981,12 +2888,12 @@ public class Room implements Comparable, ISerialize, Runnable { } for (RoomItem i : items) { - this.pickUpItem(i, null); + this.getRoomItemManager().pickUpItem(i, null); } } public void ejectUserItem(RoomItem item) { - this.pickUpItem(item, null); + this.getRoomItemManager().pickUpItem(item, null); } public void ejectAll() { @@ -3018,7 +2925,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Map.Entry> entrySet : userItemsMap.entrySet()) { for (RoomItem i : entrySet.getValue()) { - this.pickUpItem(i, null); + this.getRoomItemManager().pickUpItem(i, null); } Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey()); @@ -3165,10 +3072,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new HabboBroadcastMessageComposer(message).compose()); } - public int itemCount() { - return this.roomItems.size(); - } - public void setHideWired(boolean hideWired) { this.roomInfo.setHiddenWiredEnabled(hideWired); @@ -3195,358 +3098,4 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getExtras()).compose()); } } - - public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) { - if (this.itemCount() >= Room.MAXIMUM_FURNI) { - 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; - } - - rotation %= 8; - if (this.hasRights(habbo) || this.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { - return FurnitureMovementError.NONE; - } - - if (habbo.getHabboStats().isRentingSpace()) { - RoomItem rentSpace = this.getHabboItem(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.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { - if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) { - return FurnitureMovementError.NONE; - } - } - - return FurnitureMovementError.NO_RIGHTS; - } - - public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation) { - return furnitureFitsAt(tile, item, rotation, true); - } - - public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) { - if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) - return FurnitureMovementError.INVALID_MOVE; - - if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE; - - - THashSet occupiedTiles = this.layout.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.roomUnitManager.hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS; - } - if (checkForUnits) { - if (!this.roomUnitManager.getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS; - } - if (checkForUnits) { - if (this.roomUnitManager.hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS; - } - } - } - - Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); - - List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - - RoomItem topItem = this.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 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)); - - if (event.isCancelled()) { - return FurnitureMovementError.CANCEL_PLUGIN_PLACE; - } - - pluginHelper = event.hasPluginHelper(); - } - - THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - - FurnitureMovementError fits = this.furnitureFitsAt(tile, item, 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); - if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) { - this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername()); - } - - item.needsUpdate(true); - this.addHabboItem(item); - item.setRoomId(this.roomInfo.getId()); - item.onPlace(this); - this.updateTiles(occupiedTiles); - this.sendComposer(new ObjectAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); - - for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t); - this.updateBotsAt(t.getX(), t.getY()); - } - - Emulator.getThreading().run(item); - return FurnitureMovementError.NONE; - } - - public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) { - if (!(this.hasRights(owner) || this.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { - return FurnitureMovementError.NO_RIGHTS; - } - - if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { - Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, null); - Emulator.getPluginManager().fireEvent(furniturePlacedEvent); - - if (furniturePlacedEvent.isCancelled()) - return FurnitureMovementError.CANCEL_PLUGIN_PLACE; - } - - item.setWallPosition(wallPosition); - if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) { - this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername()); - } - this.sendComposer(new ItemAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose()); - item.needsUpdate(true); - this.addHabboItem(item); - item.setRoomId(this.roomInfo.getId()); - item.onPlace(this); - Emulator.getThreading().run(item); - return FurnitureMovementError.NONE; - } - - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) { - return moveFurniTo(item, tile, rotation, actor, true, true); - } - - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { - return moveFurniTo(item, tile, rotation, actor, sendUpdates, true); - } - - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { - RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY()); - - boolean pluginHelper = false; - if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) { - FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile)); - if (event.isCancelled()) { - return FurnitureMovementError.CANCEL_PLUGIN_MOVE; - } - pluginHelper = event.hasPluginHelper(); - } - - boolean magicTile = item instanceof InteractionStackHelper; - - Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); - - //Check if can be placed at new position - THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - THashSet newOccupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - - RoomItem topItem = this.getTopItemAt(occupiedTiles, null); - - if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { - if (oldLocation != tile) { - for (RoomTile t : occupiedTiles) { - RoomItem tileTopItem = this.getTopItemAt(t.getX(), t.getY()); - if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || - (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { - return FurnitureMovementError.CANT_STACK; - } - - if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { - if (checkForUnits && !magicTile) { - if (this.roomUnitManager.hasHabbosAt(t)) - return FurnitureMovementError.TILE_HAS_HABBOS; - if (!this.roomUnitManager.getBotsAt(t).isEmpty()) - return FurnitureMovementError.TILE_HAS_BOTS; - if (this.roomUnitManager.hasPetsAt(t)) - return FurnitureMovementError.TILE_HAS_PETS; - } - } - } - } - - List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - } - - if (!magicTile && !item.canStackAt(tileFurniList)) { - return FurnitureMovementError.CANT_STACK; - } - } - - THashSet oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - - int oldRotation = item.getRotation(); - - if (oldRotation != rotation) { - item.setRotation(rotation); - if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) { - Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); - Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); - - if (furnitureRotatedEvent.isCancelled()) { - item.setRotation(oldRotation); - return FurnitureMovementError.CANCEL_PLUGIN_ROTATE; - } - } - - if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT)) { - item.setRotation(oldRotation); - return FurnitureMovementError.CANT_STACK; - } - - // ) - } - //Place at new position - - double height; - - if (stackHelper.isPresent()) { - height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100); - } else if (item == topItem) { - height = item.getZ(); - } else { - height = this.getStackHeight(tile.getX(), tile.getY(), false, item); - for (RoomTile til : occupiedTiles) { - double sHeight = this.getStackHeight(til.getX(), til.getY(), false, item); - if (sHeight > height) { - height = sHeight; - } - } - } - - if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) - return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor - - if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { - FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); - if (event.hasChangedHeight()) { - height = event.getUpdatedHeight(); - } - } - - if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) - return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor - - item.setX(tile.getX()); - item.setY(tile.getY()); - item.setZ(height); - if (magicTile) { - item.setZ(tile.getZ()); - item.setExtradata("" + item.getZ() * 100); - } - if (item.getZ() > MAXIMUM_FURNI_HEIGHT) { - item.setZ(MAXIMUM_FURNI_HEIGHT); - } - - - //Update Furniture - item.onMove(this, oldLocation, tile); - item.needsUpdate(true); - Emulator.getThreading().run(item); - - if (sendUpdates) { - this.sendComposer(new ObjectUpdateMessageComposer(item).compose()); - } - - //Update old & new tiles - occupiedTiles.removeAll(oldOccupiedTiles); - occupiedTiles.addAll(oldOccupiedTiles); - this.updateTiles(occupiedTiles); - - //Update Habbos at old position - for (RoomTile t : occupiedTiles) { - this.updateHabbosAt( - t.getX(), - t.getY(), - new ArrayList<>(this.roomUnitManager.getHabbosAt(t)) - /*.stream() - .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t) - .collect(Collectors.toCollection(THashSet::new))*/ - ); - this.updateBotsAt(t.getX(), t.getY()); - } - if (Emulator.getConfig().getBoolean("wired.place.under", false)) { - for (RoomTile t : newOccupiedTiles) { - for (Habbo h : this.roomUnitManager.getHabbosAt(t)) { - try { - item.onWalkOn(h.getRoomUnit(), this, null); - } catch (Exception ignored) { - - } - } - } - } - return FurnitureMovementError.NONE; - } } 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 c3c5a236..cf99396d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -3,6 +3,7 @@ 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.Item; 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; @@ -20,13 +21,9 @@ 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.messages.outgoing.rooms.items.*; 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 com.eu.habbo.plugin.events.furniture.*; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -265,6 +262,12 @@ public class RoomItemManager { } public FurnitureMovementError placeFloorItemAt(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)); @@ -278,7 +281,7 @@ public class RoomItemManager { THashSet occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - FurnitureMovementError fits = this.furnitureFitsAt(item, tile, rotation); + FurnitureMovementError fits = this.furnitureFitsAt(tile, item, rotation, true); if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) { return fits; @@ -322,6 +325,202 @@ public class RoomItemManager { return FurnitureMovementError.NONE; } + public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) { + if (!(this.room.hasRights(owner) || this.room.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + return FurnitureMovementError.NO_RIGHTS; + } + + if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) { + Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, null); + Emulator.getPluginManager().fireEvent(furniturePlacedEvent); + + if (furniturePlacedEvent.isCancelled()) + return FurnitureMovementError.CANCEL_PLUGIN_PLACE; + } + + item.setWallPosition(wallPosition); + if (!this.room.getFurniOwnerNames().containsKey(item.getUserId()) && owner != null) { + this.room.getFurniOwnerNames().put(item.getUserId(), owner.getHabboInfo().getUsername()); + } + this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose()); + item.needsUpdate(true); + this.addRoomItem(item); + item.setRoomId(this.room.getRoomInfo().getId()); + item.onPlace(this.room); + Emulator.getThreading().run(item); + return FurnitureMovementError.NONE; + } + + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) { + return moveFurniTo(item, tile, rotation, actor, true, true); + } + + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { + return moveFurniTo(item, tile, rotation, actor, sendUpdates, true); + } + + public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { + RoomTile oldLocation = this.room.getLayout().getTile(item.getX(), item.getY()); + + boolean pluginHelper = false; + if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) { + FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile)); + if (event.isCancelled()) { + return FurnitureMovementError.CANCEL_PLUGIN_MOVE; + } + pluginHelper = event.hasPluginHelper(); + } + + boolean magicTile = item instanceof InteractionStackHelper; + + Optional stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + + //Check if can be placed at new position + THashSet occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + THashSet newOccupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + + RoomItem topItem = this.room.getTopItemAt(occupiedTiles, null); + + if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { + if (oldLocation != tile) { + for (RoomTile t : occupiedTiles) { + RoomItem tileTopItem = this.room.getTopItemAt(t.getX(), t.getY()); + if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || + (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.room.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { + return FurnitureMovementError.CANT_STACK; + } + + if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { + if (checkForUnits && !magicTile) { + if (this.room.getRoomUnitManager().hasHabbosAt(t)) + return FurnitureMovementError.TILE_HAS_HABBOS; + if (!this.room.getRoomUnitManager().getBotsAt(t).isEmpty()) + return FurnitureMovementError.TILE_HAS_BOTS; + if (this.room.getRoomUnitManager().hasPetsAt(t)) + return FurnitureMovementError.TILE_HAS_PETS; + } + } + } + } + + List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { + tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); + } + + if (!magicTile && !item.canStackAt(tileFurniList)) { + return FurnitureMovementError.CANT_STACK; + } + } + + THashSet oldOccupiedTiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + + int oldRotation = item.getRotation(); + + if (oldRotation != rotation) { + item.setRotation(rotation); + if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) { + Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); + Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); + + if (furnitureRotatedEvent.isCancelled()) { + item.setRotation(oldRotation); + return FurnitureMovementError.CANCEL_PLUGIN_ROTATE; + } + } + + if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > Room.MAXIMUM_FURNI_HEIGHT)) { + item.setRotation(oldRotation); + return FurnitureMovementError.CANT_STACK; + } + + // ) + } + //Place at new position + + double height; + + if (stackHelper.isPresent()) { + height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100); + } else if (item == topItem) { + height = item.getZ(); + } else { + height = this.room.getStackHeight(tile.getX(), tile.getY(), false, item); + for (RoomTile til : occupiedTiles) { + double sHeight = this.room.getStackHeight(til.getX(), til.getY(), false, item); + if (sHeight > height) { + height = sHeight; + } + } + } + + if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; + if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) + return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor + + if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { + FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); + if (event.hasChangedHeight()) { + height = event.getUpdatedHeight(); + } + } + + if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; + if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) + return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor + + item.setX(tile.getX()); + item.setY(tile.getY()); + item.setZ(height); + if (magicTile) { + item.setZ(tile.getZ()); + item.setExtradata("" + item.getZ() * 100); + } + if (item.getZ() > Room.MAXIMUM_FURNI_HEIGHT) { + item.setZ(Room.MAXIMUM_FURNI_HEIGHT); + } + + + //Update Furniture + item.onMove(this.room, oldLocation, tile); + item.needsUpdate(true); + Emulator.getThreading().run(item); + + if (sendUpdates) { + this.room.sendComposer(new ObjectUpdateMessageComposer(item).compose()); + } + + //Update old & new tiles + occupiedTiles.removeAll(oldOccupiedTiles); + occupiedTiles.addAll(oldOccupiedTiles); + this.room.updateTiles(occupiedTiles); + + //Update Habbos at old position + for (RoomTile t : occupiedTiles) { + this.room.updateHabbosAt( + t.getX(), + t.getY(), + new ArrayList<>(this.room.getRoomUnitManager().getHabbosAt(t)) + /*.stream() + .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t) + .collect(Collectors.toCollection(THashSet::new))*/ + ); + this.room.updateBotsAt(t.getX(), t.getY()); + } + if (Emulator.getConfig().getBoolean("wired.place.under", false)) { + for (RoomTile t : newOccupiedTiles) { + for (Habbo h : this.room.getRoomUnitManager().getHabbosAt(t)) { + try { + item.onWalkOn(h.getRoomUnit(), this.room, null); + } catch (Exception ignored) { + + } + } + } + } + return FurnitureMovementError.NONE; + } + public void pickUpItem(RoomItem item, Habbo picker) { if (item == null) return; @@ -375,11 +574,7 @@ public class RoomItemManager { 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) { + public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) { if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index e442474f..75714ae2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -712,7 +712,7 @@ public class RoomManager { } int effect = habbo.getInventory().getEffectsComponent().getActivatedEffect(); - room.giveEffect(habbo.getRoomUnit(), effect, -1); + habbo.getRoomUnit().giveEffect(effect, -1); } 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 e25e5225..ee9bed04 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -85,7 +85,9 @@ public class RoomUnitManager { bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); bot.getRoomUnit().setInRoom(true); - this.room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE); + + bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false); + this.addRoomUnit(bot); } } 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 7f359c50..429e386e 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 @@ -349,22 +349,22 @@ public abstract class RoomItem implements Runnable, IEventTriggers { for (Habbo habbo : room.getHabbosOnItem(this)) { if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, nextEffectM, -1); + habbo.getRoomUnit().giveEffect(nextEffectM, -1); } if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, nextEffectF, -1); + habbo.getRoomUnit().giveEffect(nextEffectF, -1); } } RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); for (Bot bot : room.getRoomUnitManager().getBotsAt(tile)) { if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { - room.giveEffect(bot.getRoomUnit(), nextEffectM, -1); + bot.getRoomUnit().giveEffect(nextEffectM, -1); } if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { - room.giveEffect(bot.getRoomUnit(), nextEffectF, -1); + bot.getRoomUnit().giveEffect(nextEffectF, -1); } } } @@ -404,39 +404,39 @@ public abstract class RoomItem implements Runnable, IEventTriggers { oldHabbos.forEach(habbo -> { if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, finalNextEffectM, -1); + habbo.getRoomUnit().giveEffect(finalNextEffectM, -1); } if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, finalNextEffectF, -1); + habbo.getRoomUnit().giveEffect(finalNextEffectF, -1); } }); newHabbos.forEach(habbo -> { if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1); } if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1); } }); oldBots.forEach(bot -> { if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { - room.giveEffect(bot.getRoomUnit(), finalNextEffectM, -1); + bot.getRoomUnit().giveEffect(finalNextEffectM, -1); } if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) { - room.giveEffect(bot.getRoomUnit(), finalNextEffectF, -1); + bot.getRoomUnit().giveEffect(finalNextEffectF, -1); } }); newBots.forEach(bot -> { if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); + bot.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1); } if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); + bot.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1); } }); } 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 ec1fb767..dafe9ca1 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 @@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.Event; @@ -298,6 +299,37 @@ public class RoomAvatar extends RoomUnit { return this; } + public void giveEffect(int effectId, int duration) { + this.giveEffect(effectId, duration, false); + } + + public void giveEffect(int effectId, int duration, boolean forceEffect) { + if (!this.isInRoom()) { + return; + } else { + RoomAvatar roomAvatar = this; + } + + if(this instanceof RoomHabbo) { + Habbo habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(this); + if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) { + return; + } + } + + if (duration == -1 || duration == Integer.MAX_VALUE) { + duration = Integer.MAX_VALUE; + } else { + duration += Emulator.getIntUnixTimestamp(); + } + + if ((this.getRoom().isAllowEffects() || forceEffect) && !this.isSwimming()) { + this.setEffectId(effectId); + this.setEffectEndTimestamp(duration); + this.getRoom().sendComposer(new AvatarEffectMessageComposer(this).compose()); + } + } + private void handleSitStatus(RoomItem topItem) { if(!this.isCmdSitEnabled()) { if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) { 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 2f6bf88d..3f64b505 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -290,8 +290,7 @@ public class HabboInfo implements Runnable { riding.setTask(PetTasks.FREE); this.setRiding(null); - if (room != null) - room.giveEffect(habbo, 0, -1); + habbo.getRoomUnit().giveEffect(0, -1); RoomUnit roomUnit = habbo.getRoomUnit(); if (roomUnit == null) @@ -300,8 +299,8 @@ public class HabboInfo implements Runnable { roomUnit.setCurrentZ(riding.getRoomUnit().getCurrentZ()); roomUnit.setPreviousLocationZ(riding.getRoomUnit().getCurrentZ()); roomUnit.stopWalking(); - if (room != null) - room.sendComposer(new UserUpdateComposer(roomUnit).compose()); + + room.sendComposer(new UserUpdateComposer(roomUnit).compose()); List availableTiles = isRemoving ? new ArrayList<>() : room.getLayout().getWalkableTilesAround(roomUnit.getCurrentPosition()); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 6f4f4d91..1f70dc16 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -140,7 +140,7 @@ public class EffectsComponent { this.activatedEffect = effectId; if (this.habbo.getRoomUnit().getRoom() != null) { - this.habbo.getRoomUnit().getRoom().giveEffect(this.habbo, effectId, effect.remainingTime()); + this.habbo.getRoomUnit().giveEffect(effectId, effect.remainingTime()); } this.habbo.getClient().sendResponse(new AvatarEffectActivatedMessageComposer(effect)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java index fc967f9c..ecb89fd5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java @@ -26,14 +26,14 @@ public class MoveObjectEvent extends MessageHandler { int rotation = this.packet.readInt(); RoomTile tile = room.getLayout().getTile((short) x, (short) y); - FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); + FurnitureMovementError error = room.getRoomItemManager().canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); this.client.sendResponse(new ObjectUpdateMessageComposer(item)); return; } - error = room.moveFurniTo(item, tile, rotation, this.client.getHabbo()); + error = room.getRoomItemManager().moveFurniTo(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); this.client.sendResponse(new ObjectUpdateMessageComposer(item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index 7260604d..6c75a2e4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -26,7 +26,7 @@ public class PickupObjectEvent extends MessageHandler { return; if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { - room.pickUpItem(item, this.client.getHabbo()); + room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); } else { if (room.hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { 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 e6c83653..ff9583eb 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 @@ -93,7 +93,7 @@ public class PlaceObjectEvent extends MessageHandler { } } - FurnitureMovementError error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo()); + FurnitureMovementError error = room.getRoomItemManager().placeFloorItemAt(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); @@ -101,7 +101,7 @@ public class PlaceObjectEvent extends MessageHandler { } } else { - FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); + FurnitureMovementError error = room.getRoomItemManager().placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java index 91e190fa..03834112 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/AvatarEffectSelectedEvent.java @@ -15,7 +15,7 @@ public class AvatarEffectSelectedEvent extends MessageHandler { this.client.getHabbo().getInventory().getEffectsComponent().setActivatedEffect(0); if (this.client.getHabbo().getRoomUnit().getRoom() != null) { - this.client.getHabbo().getRoomUnit().getRoom().giveEffect(this.client.getHabbo().getRoomUnit(), 0, -1); + this.client.getHabbo().getRoomUnit().giveEffect(0, -1); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 20b952e8..7a0c290d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -75,18 +75,19 @@ public class ApplySnapshotEvent extends MessageHandler { // Match Position & Rotation if (wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { - if (matchItem.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) { - room.moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true); + if (matchItem.getRotation() != setting.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) { + room.getRoomItemManager().moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true, true); } } else if (wired.shouldMatchPosition()) { boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.getRotation(); RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY()); int newRotation = wired.shouldMatchRotation() ? setting.getRotation() : matchItem.getRotation(); - if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) - && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE - && room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE && slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { + boolean sendUpdates = !slideAnimation; + if (room.getRoomItemManager().moveFurniTo(matchItem, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE && slideAnimation) { + room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + } } } }); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 7d30c4a8..78dfebf2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -23,7 +23,7 @@ public class RoomUnitRidePet implements Runnable { if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) { habbo.getRoomUnit().stopWalking(); - habbo.getRoomUnit().getRoom().giveEffect(habbo, 77, -1); + habbo.getRoomUnit().giveEffect(77, -1); habbo.getHabboInfo().setRiding(pet); habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition()); habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentPosition()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java index e7847c9b..3db77017 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java @@ -81,7 +81,7 @@ public class YouAreAPirate implements Runnable { this.habbo = habbo; this.room = room; this.oldEffect = this.habbo.getRoomUnit().getEffectId(); - this.room.giveEffect(this.habbo, 161, -1); + this.habbo.getRoomUnit().giveEffect(161, -1); } @Override @@ -93,7 +93,7 @@ public class YouAreAPirate implements Runnable { this.index++; if (this.index == iamapirate.length) { - this.room.giveEffect(this.habbo, this.oldEffect, -1); + this.habbo.getRoomUnit().giveEffect(this.oldEffect, -1); return; } From a46b38920e425203a9aa4fc4edcf45483c8a8613 Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 20 Jul 2023 18:33:30 -0500 Subject: [PATCH 22/42] Item Pick up fix --- .../java/com/eu/habbo/habbohotel/rooms/Room.java | 6 +----- .../eu/habbo/habbohotel/rooms/RoomItemManager.java | 4 ++++ .../incoming/rooms/items/PickupObjectEvent.java | 13 ++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) 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 fb9804fa..090d7336 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -801,7 +801,7 @@ public class Room implements Comparable, ISerialize, Runnable { */ if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) { - habbo.getRoomUnit().giveEffect(0, -1) + habbo.getRoomUnit().giveEffect(0, -1); } if (habbo.getRoomUnit().isKicked()) { @@ -2892,10 +2892,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void ejectUserItem(RoomItem item) { - this.getRoomItemManager().pickUpItem(item, null); - } - public void ejectAll() { this.ejectAll(null); } 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 cf99396d..de49838e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -574,6 +574,10 @@ public class RoomItemManager { Emulator.getThreading().run(item); } + public void ejectUserItem(RoomItem item) { + this.pickUpItem(item, null); + } + public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) { if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index 6c75a2e4..7d9564cf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -14,16 +14,15 @@ public class PickupObjectEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } RoomItem item = room.getHabboItem(itemId); - if (item == null) - return; - - if (item instanceof InteractionPostIt) + if (item == null || item instanceof InteractionPostIt) { return; + } if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); @@ -32,14 +31,14 @@ public class PickupObjectEvent extends MessageHandler { if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { item.setUserId(this.client.getHabbo().getHabboInfo().getId()); } else { - if (this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) { + if (!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { if (item.getUserId() == room.getRoomInfo().getOwnerInfo().getId()) { return; } } } - room.ejectUserItem(item); + room.getRoomItemManager().ejectUserItem(item); } } } From 4c5b362b87f891d42648304bd77ea6557fd19d6a Mon Sep 17 00:00:00 2001 From: Stankman Date: Fri, 21 Jul 2023 16:37:33 -0500 Subject: [PATCH 23/42] Room.java clean-up --- .../com/eu/habbo/habbohotel/bots/Bot.java | 19 +---- .../eu/habbo/habbohotel/bots/ButlerBot.java | 2 +- .../catalog/marketplace/MarketPlace.java | 6 +- .../commands/list/RedeemCommand.java | 2 +- .../commands/list/RoomSitCommand.java | 2 +- .../habbohotel/commands/list/SitCommand.java | 2 +- .../commands/list/StandCommand.java | 2 +- .../interactions/InteractionBlackHole.java | 6 +- .../interactions/InteractionBuildArea.java | 6 +- .../interactions/InteractionCrackable.java | 2 +- .../items/interactions/InteractionFXBox.java | 4 +- .../InteractionRentableSpace.java | 2 +- .../interactions/InteractionVikingCotie.java | 2 +- .../bunnyrun/InteractionBunnyrunField.java | 2 +- .../tag/icetag/InteractionIceTagField.java | 2 +- .../InteractionRollerskateField.java | 2 +- .../totems/InteractionTotemPlanet.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 73 +++++-------------- .../habbohotel/rooms/RoomItemManager.java | 10 +-- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 4 +- .../habbo/habbohotel/rooms/TraxManager.java | 4 +- .../rooms/entities/items/RoomItem.java | 42 +++++------ .../rooms/entities/units/RoomUnit.java | 52 ++++++++++--- .../com/eu/habbo/habbohotel/units/Unit.java | 2 +- .../modtool/CallForHelpFromPhotoEvent.java | 2 +- .../rooms/items/AddSpamWallPostItEvent.java | 6 +- .../rooms/items/CreditFurniRedeemEvent.java | 2 +- .../items/CustomizeAvatarWithFurniEvent.java | 2 +- .../rooms/items/PickupObjectEvent.java | 6 +- .../rooms/items/PlacePostItEvent.java | 2 +- .../incoming/rooms/items/RemoveItemEvent.java | 2 +- .../rooms/pets/OpenPetPackageEvent.java | 4 +- .../rooms/users/ChangePostureEvent.java | 3 +- .../incoming/rooms/users/LookToEvent.java | 2 - .../incoming/rooms/users/MoveAvatarEvent.java | 4 +- .../items/ItemRemoveMessageComposer.java | 2 +- .../items/ItemUpdateMessageComposer.java | 2 +- .../rooms/items/ObjectAddMessageComposer.java | 2 +- .../items/ObjectUpdateMessageComposer.java | 2 +- .../rooms/items/ObjectsMessageComposer.java | 2 +- .../rooms/items/RemoveFloorItemComposer.java | 2 +- .../threading/runnables/ClearRentedSpace.java | 4 +- .../threading/runnables/CrackableExplode.java | 4 +- .../runnables/HabboGiveHandItemToHabbo.java | 1 - .../habbo/threading/runnables/OpenGift.java | 4 +- 45 files changed, 148 insertions(+), 164 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 49cc2bb8..ae978039 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; -import com.eu.habbo.habbohotel.rooms.*; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; @@ -412,19 +414,6 @@ public class Bot extends Unit implements Runnable { this.canWalk = canWalk; } - public void lookAt(Habbo habbo) { - this.lookAt(habbo.getRoomUnit().getCurrentPosition()); - } - - public void lookAt(RoomUnit roomUnit) { - this.lookAt(roomUnit.getCurrentPosition()); - } - - public void lookAt(RoomTile tile) { - this.getRoomUnit().lookAtPoint(tile); - this.getRoomUnit().setStatusUpdateNeeded(true); - } - public void onPlaceUpdate() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { statement.setString(1, this.name); diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index c5148bc4..a4ad12ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -86,7 +86,7 @@ public class ButlerBot extends Bot { final Bot bot = this; // Step 1: Look at Habbo - bot.lookAt(serveEvent.getHabbo()); + bot.getRoomUnit().lookAtPoint(serveEvent.getHabbo().getRoomUnit().getCurrentPosition()); // Step 2: Prepare tasks for when the Bot (carrying the handitem) reaches the Habbo final List tasks = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index e0acb682..b852fd30 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.catalog.marketplace; import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.catalog.marketplace.GetMarketplaceOffersEvent; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceBuyOfferResultComposer; @@ -281,7 +281,7 @@ public class MarketPlace { } event.price = calculateCommision(event.price); - item.setUserId(client.getHabbo().getHabboInfo().getId()); + item.setOwnerId(client.getHabbo().getHabboInfo().getId()); item.needsUpdate(true); Emulator.getThreading().run(item); @@ -362,7 +362,7 @@ public class MarketPlace { MarketPlaceOffer offer = new MarketPlaceOffer(event.getItem(), event.getPrice(), client.getHabbo()); client.getHabbo().getInventory().addMarketplaceOffer(offer); client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.getItem()); - item.setUserId(-1); + item.setOwnerId(-1); item.needsUpdate(true); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java index 91e9a483..3f89bb8e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java @@ -30,7 +30,7 @@ public class RedeemCommand extends Command { TIntIntMap points = new TIntIntHashMap(); for (RoomItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) { - if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getUserId() == gameClient.getHabbo().getHabboInfo().getId()) { + if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getOwnerId() == gameClient.getHabbo().getHabboInfo().getId()) { items.add(item); if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java index 0938a9eb..bbe77246 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java @@ -17,7 +17,7 @@ public class RoomSitCommand extends Command { } else if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { return; } - gameClient.getHabbo().getRoomUnit().getRoom().makeSit(habbo); + gameClient.getHabbo().getRoomUnit().makeSit(); }); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java index 5994315a..7ef27f24 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java @@ -11,7 +11,7 @@ public class SitCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled - gameClient.getHabbo().getRoomUnit().getRoom().makeSit(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().makeSit(); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java index 7d47c562..bb0eeb9f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java @@ -11,7 +11,7 @@ public class StandCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getHabboInfo().getRiding() == null) - gameClient.getHabbo().getRoomUnit().getRoom().makeStand(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().makeStand(); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java index 7fcfeace..672d77e8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java @@ -24,10 +24,10 @@ public class InteractionBlackHole extends InteractionGate { Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount"); int holesCountProgress = 0; - Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getUserId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerId()); if (owner == null) { - holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), holeCountAchievement); + holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), holeCountAchievement); } else { holesCountProgress = owner.getHabboStats().getAchievementProgress(holeCountAchievement); } @@ -37,7 +37,7 @@ public class InteractionBlackHole extends InteractionGate { if (owner != null) { AchievementManager.progressAchievement(owner, holeCountAchievement, holeDifference); } else { - AchievementManager.progressAchievement(this.getUserId(), holeCountAchievement, holeDifference); + AchievementManager.progressAchievement(this.getOwnerId(), holeCountAchievement, holeDifference); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index b81bf641..5a513769 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -80,7 +80,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (RoomTile tile : this.tiles) { THashSet tileItems = room.getItemsAt(tile); for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } @@ -130,7 +130,7 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet tileItems = room.getItemsAt(tile); if (newTiles.contains(tile)) continue; for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } @@ -204,7 +204,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (RoomTile tile : oldTiles) { THashSet tileItems = room.getItemsAt(tile); for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index e6b6664e..3909c88f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -92,7 +92,7 @@ public class InteractionCrackable extends RoomItem { public void onTick(Habbo habbo, Room room) { if (this.cracked) return; - if (this.allowAnyone() || this.getUserId() == habbo.getHabboInfo().getId()) { + if (this.allowAnyone() || this.getOwnerId() == habbo.getHabboInfo().getId()) { CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId()); if (rewardData != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index 59bcf230..a4037a09 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.users.HabboGender; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -25,7 +25,7 @@ public class InteractionFXBox extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) { + if (client != null && this.getOwnerId() == client.getHabbo().getHabboInfo().getId()) { if(this.getExtradata().equals("1")) return; 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 5103f749..181ed3e7 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 @@ -166,7 +166,7 @@ public class InteractionRentableSpace extends RoomItem { } for (RoomItem item : items) { - if (item.getUserId() == this.renterId) { + if (item.getOwnerId() == this.renterId) { room.getRoomItemManager().pickUpItem(item, null); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java index b79a675b..11f9d80c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java @@ -24,7 +24,7 @@ public class InteractionVikingCotie extends InteractionDefault { this.setExtradata("0"); } - if (client != null && client.getHabbo().getHabboInfo().getId() == this.getUserId()) { + if (client != null && client.getHabbo().getHabboInfo().getId() == this.getOwnerId()) { if (client.getHabbo().getRoomUnit().getEffectId() == 172 || client.getHabbo().getRoomUnit().getEffectId() == 173) { int state = Integer.parseInt(this.getExtradata()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java index df20b8d3..6c2f5bca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java @@ -24,7 +24,7 @@ public class InteractionBunnyrunField extends InteractionTagField { public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbBunnyTag")); 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 b811d7b8..0e24397f 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 @@ -48,7 +48,7 @@ public class InteractionIceTagField extends InteractionTagField { public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagA")); 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 e98f9044..34bd18a3 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 @@ -48,7 +48,7 @@ public class InteractionRollerskateField extends InteractionTagField { public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagA")); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index 52103f5f..0fd6abc7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -31,7 +31,7 @@ public class InteractionTotemPlanet extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if(client.getHabbo().getHabboInfo().getId() != this.getUserId()) { + if(client.getHabbo().getHabboInfo().getId() != this.getOwnerId()) { super.onClick(client, room, objects); return; } 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 090d7336..7820e4ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1453,17 +1453,17 @@ public class Room implements Comparable, ISerialize, Runnable { } synchronized (this.furniOwnerCount) { - this.furniOwnerCount.put(item.getUserId(), this.furniOwnerCount.get(item.getUserId()) + 1); + this.furniOwnerCount.put(item.getOwnerId(), this.furniOwnerCount.get(item.getOwnerId()) + 1); } synchronized (this.furniOwnerNames) { - if (!this.furniOwnerNames.containsKey(item.getUserId())) { - HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getUserId()); + if (!this.furniOwnerNames.containsKey(item.getOwnerId())) { + HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getOwnerId()); if (habbo != null) { - this.furniOwnerNames.put(item.getUserId(), habbo.getUsername()); + this.furniOwnerNames.put(item.getOwnerId(), habbo.getUsername()); } else { - log.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); + log.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getOwnerId()); } } } @@ -1610,13 +1610,13 @@ public class Room implements Comparable, ISerialize, Runnable { if (i != null) { synchronized (this.furniOwnerCount) { synchronized (this.furniOwnerNames) { - int count = this.furniOwnerCount.get(i.getUserId()); + int count = this.furniOwnerCount.get(i.getOwnerId()); if (count > 1) - this.furniOwnerCount.put(i.getUserId(), count - 1); + this.furniOwnerCount.put(i.getOwnerId(), count - 1); else { - this.furniOwnerCount.remove(i.getUserId()); - this.furniOwnerNames.remove(i.getUserId()); + this.furniOwnerCount.remove(i.getOwnerId()); + this.furniOwnerNames.remove(i.getOwnerId()); } } } @@ -2176,8 +2176,9 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) { THashSet items = new THashSet<>(0); - if (tile == null) + if (tile == null) { return items; + } if (this.loaded) { THashSet cachedItems = this.tileCache.get(tile); @@ -2497,8 +2498,8 @@ public class Room implements Comparable, ISerialize, Runnable { return tallestItem.getBaseItem().allowSit(); } - public boolean canLayAt(int x, int y) { - return this.canLayAt(this.getItemsAt(x, y)); + public boolean canLayAt(RoomTile tile) { + return this.canLayAt(this.getItemsAt(tile)); } boolean canLayAt(THashSet items) { @@ -2535,14 +2536,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void sendComposerToHabbosWithRights(ServerMessage message) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { - if (this.hasRights(habbo)) { - habbo.getClient().sendResponse(message); - } - } - } - public void petChat(ServerMessage message) { for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (!habbo.getHabboStats().isIgnorePets()) @@ -2788,32 +2781,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.bannedHabbos.put(roomBan.getUserId(), roomBan); } - public void makeSit(Habbo habbo) { - if (habbo.getRoomUnit() == null) return; - - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) || !habbo.getRoomUnit().canForcePosture()) { - return; - } - - habbo.getRoomUnit().setDance(DanceType.NONE); - habbo.getRoomUnit().setCmdSitEnabled(true); - habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); - habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + ""); - this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); - } - - public void makeStand(Habbo habbo) { - if (habbo.getRoomUnit() == null) return; - - RoomItem item = this.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); - if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { - habbo.getRoomUnit().setCmdStandEnabled(true); - habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); - habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); - this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); - } - } - public void updateItem(RoomItem item) { if (!this.isLoaded()) { return; @@ -2856,7 +2823,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet items = new THashSet<>(); for (RoomItem item : this.roomItems.valueCollection()) { - if (!items.contains(item.getBaseItem()) && item.getUserId() == userId) items.add(item.getBaseItem()); + if (!items.contains(item.getBaseItem()) && item.getOwnerId() == userId) items.add(item.getBaseItem()); } return items.size(); @@ -2874,7 +2841,7 @@ public class Room implements Comparable, ISerialize, Runnable { break; } - if (iterator.value().getUserId() == userId) { + if (iterator.value().getOwnerId() == userId) { items.add(iterator.value()); iterator.value().setRoomId(0); } @@ -2892,11 +2859,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void ejectAll() { - this.ejectAll(null); + public void ejectAllFurni() { + this.ejectAllFurni(null); } - public void ejectAll(Habbo habbo) { + public void ejectAllFurni(Habbo habbo) { THashMap> userItemsMap = new THashMap<>(); synchronized (this.roomItems) { @@ -2909,13 +2876,13 @@ public class Room implements Comparable, ISerialize, Runnable { break; } - if (habbo != null && iterator.value().getUserId() == habbo.getHabboInfo().getId()) + if (habbo != null && iterator.value().getOwnerId() == habbo.getHabboInfo().getId()) continue; if (iterator.value() instanceof InteractionPostIt) continue; - userItemsMap.computeIfAbsent(iterator.value().getUserId(), k -> new THashSet<>()).add(iterator.value()); + userItemsMap.computeIfAbsent(iterator.value().getOwnerId(), k -> new THashSet<>()).add(iterator.value()); } } 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 de49838e..1ef6246e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -314,7 +314,7 @@ public class RoomItemManager { item.onPlace(this.room); this.room.updateTiles(occupiedTiles); - this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose()); + this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerId())).compose()); for (RoomTile t : occupiedTiles) { this.room.updateHabbosAt(t); @@ -339,10 +339,10 @@ public class RoomItemManager { } item.setWallPosition(wallPosition); - if (!this.room.getFurniOwnerNames().containsKey(item.getUserId()) && owner != null) { - this.room.getFurniOwnerNames().put(item.getUserId(), owner.getHabboInfo().getUsername()); + if (!this.room.getFurniOwnerNames().containsKey(item.getOwnerId()) && owner != null) { + this.room.getFurniOwnerNames().put(item.getOwnerId(), owner.getHabboInfo().getUsername()); } - this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose()); + this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerId())).compose()); item.needsUpdate(true); this.addRoomItem(item); item.setRoomId(this.room.getRoomInfo().getId()); @@ -565,7 +565,7 @@ public class RoomItemManager { this.room.sendComposer(new ItemRemoveMessageComposer(item).compose()); } - Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getUserId())); + Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getOwnerId())); if (habbo != null) { habbo.getInventory().getItemsComponent().addItem(item); habbo.getClient().sendResponse(new UnseenItemsComposer(item)); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 5ee43e00..4d7d9020 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -183,7 +183,7 @@ public class RoomTrade { try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) { try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO room_trade_log_items (id, item_id, user_id) VALUES (?, ?, ?)")) { for (RoomItem item : userOne.getItems()) { - item.setUserId(userTwoId); + item.setOwnerId(userTwoId); statement.setInt(1, userTwoId); statement.setInt(2, item.getId()); statement.addBatch(); @@ -197,7 +197,7 @@ public class RoomTrade { } for (RoomItem item : userTwo.getItems()) { - item.setUserId(userOneId); + item.setOwnerId(userOneId); statement.setInt(1, userOneId); statement.setInt(2, item.getId()); statement.addBatch(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 60caf827..aa4df6af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -298,7 +298,7 @@ public class TraxManager implements Disposable { musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getUserId()); + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerId()); if (owner != null) { owner.getInventory().getItemsComponent().addItem(musicDisc); @@ -328,7 +328,7 @@ public class TraxManager implements Disposable { musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getUserId()); + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerId()); if (owner != null) { owner.getInventory().getItemsComponent().addItem(musicDisc); 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 429e386e..4b33f295 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 @@ -46,20 +46,11 @@ import java.util.List; @Slf4j public abstract class RoomItem implements Runnable, IEventTriggers { - - @SuppressWarnings("rawtypes") - private static final Class[] TOGGLING_INTERACTIONS = new Class[]{ - InteractionGameTimer.class, - InteractionWired.class, - InteractionWiredHighscore.class, - InteractionMultiHeight.class - }; - @Getter private final int id; @Getter @Setter - private int userId; + private int ownerId; @Getter @Setter private int roomId; @@ -89,10 +80,17 @@ public abstract class RoomItem implements Runnable, IEventTriggers { private boolean needsUpdate = false; private boolean needsDelete = false; private boolean isFromGift = false; + @SuppressWarnings("rawtypes") + private static final Class[] TOGGLING_INTERACTIONS = new Class[]{ + InteractionGameTimer.class, + InteractionWired.class, + InteractionWiredHighscore.class, + InteractionMultiHeight.class + }; public RoomItem(ResultSet set, Item baseItem) throws SQLException { this.id = set.getInt("id"); - this.userId = set.getInt(DatabaseConstants.USER_ID); + this.ownerId = set.getInt(DatabaseConstants.USER_ID); this.roomId = set.getInt("room_id"); this.baseItem = baseItem; this.wallPosition = set.getString("wall_pos"); @@ -109,9 +107,9 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } } - public RoomItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + public RoomItem(int id, int ownerId, Item item, String extradata, int limitedStack, int limitedSells) { this.id = id; - this.userId = userId; + this.ownerId = ownerId; this.roomId = 0; this.baseItem = item; this.wallPosition = ""; @@ -163,7 +161,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { serverMessage.appendString(this.extradata); serverMessage.appendInt(-1); serverMessage.appendInt(this.isUsable()); - serverMessage.appendInt(this.getUserId()); + serverMessage.appendInt(this.getOwnerId()); } public int getGiftAdjustedId() { @@ -216,7 +214,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } } else if (this.needsUpdate) { try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) { - statement.setInt(1, this.userId); + statement.setInt(1, this.ownerId); statement.setInt(2, this.roomId); statement.setString(3, this.wallPosition); statement.setInt(4, this.x); @@ -299,21 +297,21 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public void onPlace(Room room) { //TODO: IMPORTANT: MAKE THIS GENERIC. (HOLES, ICE SKATE PATCHES, BLACK HOLE, BUNNY RUN FIELD, FOOTBALL FIELD) Achievement roomDecoAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFurniCount"); - Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getUserId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerId()); int furniCollecterProgress; if (owner == null) { - furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), roomDecoAchievement); + furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), roomDecoAchievement); } else { furniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoAchievement); } - int difference = room.getUserFurniCount(this.getUserId()) - furniCollecterProgress; + int difference = room.getUserFurniCount(this.getOwnerId()) - furniCollecterProgress; if (difference > 0) { if (owner != null) { AchievementManager.progressAchievement(owner, roomDecoAchievement, difference); } else { - AchievementManager.progressAchievement(this.getUserId(), roomDecoAchievement, difference); + AchievementManager.progressAchievement(this.getOwnerId(), roomDecoAchievement, difference); } } @@ -321,17 +319,17 @@ public abstract class RoomItem implements Runnable, IEventTriggers { int uniqueFurniCollecterProgress; if (owner == null) { - uniqueFurniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), roomDecoUniqueAchievement); + uniqueFurniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), roomDecoUniqueAchievement); } else { uniqueFurniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoUniqueAchievement); } - int uniqueDifference = room.getUserUniqueFurniCount(this.getUserId()) - uniqueFurniCollecterProgress; + int uniqueDifference = room.getUserUniqueFurniCount(this.getOwnerId()) - uniqueFurniCollecterProgress; if (uniqueDifference > 0) { if (owner != null) { AchievementManager.progressAchievement(owner, roomDecoUniqueAchievement, uniqueDifference); } else { - AchievementManager.progressAchievement(this.getUserId(), roomDecoUniqueAchievement, uniqueDifference); + AchievementManager.progressAchievement(this.getOwnerId(), roomDecoUniqueAchievement, uniqueDifference); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index bdc11e53..5342d800 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -11,6 +11,9 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent; @@ -144,6 +147,7 @@ public abstract class RoomUnit extends RoomEntity { public void setRotation(RoomRotation rotation) { this.bodyRotation = rotation; this.headRotation = rotation; + this.statusUpdateNeeded = true; } public void clearWalking() { @@ -157,7 +161,7 @@ public abstract class RoomUnit extends RoomEntity { public void stopWalking() { synchronized (this.statuses) { this.statuses.remove(RoomUnitStatus.MOVE); - this.setStatusUpdateNeeded(true); + this.statusUpdateNeeded = true; this.setGoalLocation(this.getCurrentPosition()); } } @@ -249,12 +253,14 @@ public abstract class RoomUnit extends RoomEntity { public RoomUnit removeStatus(RoomUnitStatus key) { this.statuses.remove(key); + this.statusUpdateNeeded = true; return this; } public void setStatus(RoomUnitStatus key, String value) { if (key != null && value != null) { this.statuses.put(key, value); + this.statusUpdateNeeded = true; } } @@ -262,6 +268,32 @@ public abstract class RoomUnit extends RoomEntity { return this.statuses.containsKey(key); } + public void makeStand() { + RoomItem item = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { + this.setCmdStandEnabled(true); + this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); + this.removeStatus(RoomUnitStatus.SIT); + this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + } + } + + public void makeSit() { + if (this.hasStatus(RoomUnitStatus.SIT) || !this.canForcePosture()) { + return; + } + + this.setCmdSitEnabled(true); + this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); + this.setStatus(RoomUnitStatus.SIT, 0.5 + ""); + + if(this instanceof RoomAvatar roomAvatar) { + roomAvatar.setDance(DanceType.NONE); + } + + this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + } + public void clearStatuses() { this.statuses.clear(); } @@ -311,10 +343,6 @@ public abstract class RoomUnit extends RoomEntity { return this.idleTicks > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds. } - public int getIdleTicks() { - return this.idleTicks; - } - public void resetIdleTimer() { this.idleTicks = 0; } @@ -324,7 +352,9 @@ public abstract class RoomUnit extends RoomEntity { } public void lookAtPoint(RoomTile location) { - if (!this.isCanRotate()) return; + if (!this.isCanRotate()) { + return; + } if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) { Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.getRoom(), this, location); @@ -338,15 +368,17 @@ public abstract class RoomUnit extends RoomEntity { return; } - if (!this.statuses.containsKey(RoomUnitStatus.SIT)) { - this.bodyRotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]); - } - RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]); + if (!this.statuses.containsKey(RoomUnitStatus.SIT)) { + this.bodyRotation = rotation; + } + if (Math.abs(rotation.getValue() - this.bodyRotation.getValue()) <= 1) { this.headRotation = rotation; } + + this.statusUpdateNeeded = true; } public boolean canOverrideTile(RoomTile tile) { diff --git a/src/main/java/com/eu/habbo/habbohotel/units/Unit.java b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java index 04b99d71..52e6e721 100644 --- a/src/main/java/com/eu/habbo/habbohotel/units/Unit.java +++ b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java @@ -8,4 +8,4 @@ import lombok.Setter; @Setter public class Unit { private RoomUnit roomUnit; -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java index 05eb4e67..ee011d2f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java @@ -40,7 +40,7 @@ public class CallForHelpFromPhotoEvent extends MessageHandler { if (!(item instanceof InteractionExternalImage)) return; - HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getUserId()); + HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getOwnerId()); if (photoOwner == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index e3fa9574..e58998bf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -37,8 +37,8 @@ public class AddSpamWallPostItEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); RoomItem sticky = room.getHabboItem(itemId); - if (sticky != null && sticky.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { - sticky.setUserId(room.getRoomInfo().getOwnerInfo().getId()); + if (sticky != null && sticky.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { + sticky.setOwnerId(room.getRoomInfo().getOwnerInfo().getId()); if (color.equalsIgnoreCase(PostItColor.YELLOW.hexColor)) { color = PostItColor.randomColorNotYellow().hexColor; @@ -47,7 +47,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { text = InteractionPostIt.STICKYPOLE_PREFIX_TEXT.replace("\\r", "\r").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%timestamp%", LocalDate.now().toString()) + text; } - sticky.setUserId(room.getRoomInfo().getOwnerInfo().getId()); + sticky.setOwnerId(room.getRoomInfo().getOwnerInfo().getId()); sticky.setExtradata(color + " " + text); sticky.needsUpdate(true); room.updateItem(sticky); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java index 53dad411..f83c40a9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java @@ -25,7 +25,7 @@ public class CreditFurniRedeemEvent extends MessageHandler { if (room != null) { RoomItem item = room.getHabboItem(itemId); - if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getUserId()) { + if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getOwnerId()) { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); FurnitureRedeemedEvent furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), 0, FurnitureRedeemedEvent.CREDITS); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index 290987c9..a4815ffa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -30,7 +30,7 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); - if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { if (item instanceof InteractionClothing) { ClothItem clothing = Emulator.getGameEnvironment().getCatalogManager().getClothing(item.getBaseItem().getName()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index 7d9564cf..bdef0b03 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -24,15 +24,15 @@ public class PickupObjectEvent extends MessageHandler { return; } - if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); } else { if (room.hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - item.setUserId(this.client.getHabbo().getHabboInfo().getId()); + item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); } else { if (!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { - if (item.getUserId() == room.getRoomInfo().getOwnerInfo().getId()) { + if (item.getOwnerId() == room.getRoomInfo().getOwnerInfo().getId()) { return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index 2b97acc9..a3d18d9a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -31,7 +31,7 @@ public class PlacePostItEvent extends MessageHandler { item.setExtradata("FFFF33"); item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); item.setWallPosition(location); - item.setUserId(this.client.getHabbo().getHabboInfo().getId()); + item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); item.needsUpdate(true); room.sendComposer(new ItemAddMessageComposer(item, this.client.getHabbo().getHabboInfo().getUsername()).compose()); this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index 67548297..d2758f8f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -23,7 +23,7 @@ public class RemoveItemEvent extends MessageHandler { RoomItem item = room.getHabboItem(itemId); if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { - if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { item.setRoomId(0); room.removeHabboItem(item); room.sendComposer(new ItemRemoveMessageComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index cee8c416..7671d60e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -22,7 +22,7 @@ public class OpenPetPackageEvent extends MessageHandler { if (room != null) { RoomItem item = room.getHabboItem(itemId); - if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { if (!name.matches("^[a-zA-Z0-9]*$")) { this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", ""))); return; @@ -66,7 +66,7 @@ public class OpenPetPackageEvent extends MessageHandler { RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); room.sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); - item.setUserId(0); + item.setOwnerId(0); } else { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java index d4392ecd..7f5d8f23 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java @@ -11,7 +11,8 @@ public class ChangePostureEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().isWalking()) { this.client.getHabbo().getRoomUnit().stopWalking(); } - this.client.getHabbo().getRoomUnit().getRoom().makeSit(this.client.getHabbo()); + + this.client.getHabbo().getRoomUnit().makeSit(); UserIdleEvent event = new UserIdleEvent(this.client.getHabbo(), UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java index 263131fb..8f3c9f64 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java @@ -51,8 +51,6 @@ public class LookToEvent extends MessageHandler { if (tile != null) { roomUnit.lookAtPoint(tile); - roomUnit.setStatusUpdateNeeded(true); - //room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index d1e2ce4b..bbff7d6b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -127,7 +127,7 @@ public class MoveAvatarEvent extends MessageHandler { return; } - if (room.canLayAt(tile.getX(), tile.getY())) { + if (room.canLayAt(tile)) { RoomItem bed = room.getTopItemAt(tile.getX(), tile.getY()); if (bed != null && bed.getBaseItem().allowLay()) { @@ -138,7 +138,7 @@ public class MoveAvatarEvent extends MessageHandler { default -> room.getLayout().getTile(bed.getX(), bed.getY()); }; - if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) { + if (pillow != null && room.canLayAt(pillow)) { roomUnit.setGoalLocation(pillow); return; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java index 79954732..128e1ffe 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java @@ -14,7 +14,7 @@ public class ItemRemoveMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.itemRemoveMessageComposer); this.response.appendString(this.item.getId() + ""); - this.response.appendInt(this.item.getUserId()); + this.response.appendInt(this.item.getOwnerId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java index 52a974e7..2a45013a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java @@ -15,7 +15,7 @@ public class ItemUpdateMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.itemUpdateMessageComposer); this.item.serializeWallData(this.response); - this.response.appendString(this.item.getUserId() + ""); + this.response.appendString(this.item.getOwnerId() + ""); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java index e6776dbc..527e88f1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java @@ -21,7 +21,7 @@ public class ObjectAddMessageComposer extends MessageComposer { this.item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(this.item instanceof InteractionTeleport || this.item instanceof InteractionSwitch || this.item instanceof InteractionSwitchRemoteControl || this.item instanceof InteractionVendingMachine || this.item instanceof InteractionInformationTerminal || this.item instanceof InteractionPostIt || this.item instanceof InteractionSpinningBottle || this.item instanceof InteractionPuzzleBox ? 2 : this.item.isUsable() ? 1 : 0); - this.response.appendInt(this.item.getUserId()); + this.response.appendInt(this.item.getOwnerId()); this.response.appendString(this.itemOwnerName); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java index 1dcf506d..54c35d29 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java @@ -21,7 +21,7 @@ public class ObjectUpdateMessageComposer extends MessageComposer { this.item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(0); - this.response.appendInt(this.item.getUserId()); + this.response.appendInt(this.item.getOwnerId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java index 30062513..f8cd51b1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java @@ -43,7 +43,7 @@ public class ObjectsMessageComposer extends MessageComposer { item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(item instanceof InteractionTeleport || item instanceof InteractionSwitch || item instanceof InteractionSwitchRemoteControl || item instanceof InteractionVendingMachine || item instanceof InteractionInformationTerminal || item instanceof InteractionPostIt || item instanceof InteractionSpinningBottle || item instanceof InteractionPuzzleBox ? 2 : item.isUsable() ? 1 : 0); - this.response.appendInt(item.getUserId()); + this.response.appendInt(item.getOwnerId()); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java index 36e7daf8..b5674944 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java @@ -23,7 +23,7 @@ public class RemoveFloorItemComposer extends MessageComposer { this.response.appendString(this.item.getId() + ""); this.response.appendBoolean(false); - this.response.appendInt(this.noUser ? 0 : this.item.getUserId()); + this.response.appendInt(this.noUser ? 0 : this.item.getOwnerId()); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index 233f312d..c16b7415 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionRentableSpace; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; @@ -21,7 +21,7 @@ public class ClearRentedSpace implements Runnable { for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { for (RoomItem i : this.room.getItemsAt(t)) { - if (i.getUserId() == this.item.getRenterId()) { + if (i.getOwnerId() == this.item.getRenterId()) { items.add(i); i.setRoomId(0); i.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index bd9619a9..70eae5cf 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -40,7 +40,7 @@ public class CrackableExplode implements Runnable { Item rewardItem = Emulator.getGameEnvironment().getItemManager().getCrackableReward(this.habboItem.getBaseItem().getId()); if (rewardItem != null) { - RoomItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getUserId(), rewardItem, 0, 0, ""); + RoomItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getOwnerId(), rewardItem, 0, 0, ""); if (newItem != null) { //Add to inventory in case if isn't possible place the item or in case is wall item @@ -56,7 +56,7 @@ public class CrackableExplode implements Runnable { newItem.needsUpdate(true); this.room.addHabboItem(newItem); this.room.updateItem(newItem); - this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getUserId())).compose()); + this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerId())).compose()); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java index 4e114026..b4cdd327 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java @@ -24,7 +24,6 @@ public class HabboGiveHandItemToHabbo implements Runnable { this.from.getRoomUnit().setHandItem(0); this.from.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(this.from.getRoomUnit()).compose()); this.target.getRoomUnit().lookAtPoint(this.from.getRoomUnit().getCurrentPosition()); - this.target.getRoomUnit().setStatusUpdateNeeded(true); this.target.getClient().sendResponse(new HandItemReceivedMessageComposer(this.from.getRoomUnit(), itemId)); this.target.getRoomUnit().setHandItem(itemId); this.target.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(this.target.getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 5434592c..7abe486c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.inventory.FurniListAddOrUpdateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -37,7 +37,7 @@ public class OpenGift implements Runnable { if (inside == null) inside = i; - i.setUserId(this.habbo.getHabboInfo().getId()); + i.setOwnerId(this.habbo.getHabboInfo().getId()); i.needsUpdate(true); i.run(); } From 2eec0dc0baba35d8c5397a08ceccb0012507fd70 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 22 Jul 2023 17:04:48 -0500 Subject: [PATCH 24/42] Room.java clean-up --- .../habbohotel/commands/CommandsManager.java | 2 +- .../habbohotel/commands/list/BotsCommand.java | 2 +- .../commands/list/DiagonalCommand.java | 2 +- .../commands/list/EjectAllCommand.java | 2 +- .../commands/list/HideWiredCommand.java | 2 +- .../commands/list/PickallCommand.java | 2 +- .../commands/list/SetSpeedCommand.java | 2 +- .../InteractionBackgroundToner.java | 2 +- .../interactions/InteractionColorWheel.java | 4 +- .../interactions/InteractionDefault.java | 2 +- .../interactions/InteractionEffectToggle.java | 2 +- .../interactions/InteractionFireworks.java | 2 +- .../items/interactions/InteractionGate.java | 3 +- .../interactions/InteractionMultiHeight.java | 2 +- .../interactions/InteractionMuteArea.java | 2 +- .../interactions/InteractionVoteCounter.java | 4 +- .../items/interactions/InteractionWired.java | 2 +- .../interactions/InteractionWiredExtra.java | 2 +- .../InteractionWiredHighscore.java | 4 +- .../games/InteractionGameTimer.java | 4 +- .../totems/InteractionTotemHead.java | 2 +- .../totems/InteractionTotemLegs.java | 2 +- .../wired/effects/WiredEffectMuteRoom.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 229 ++---------------- .../habbohotel/rooms/RoomItemManager.java | 6 +- .../habbo/habbohotel/rooms/RoomManager.java | 21 +- .../habbohotel/rooms/RoomRightsManager.java | 207 ++++++++++++++++ .../habbohotel/rooms/RoomWiredManager.java | 17 +- .../rooms/entities/units/RoomUnit.java | 5 + .../guilds/AddAdminRightsToMemberEvent.java | 2 +- .../guilds/ApproveMembershipRequestEvent.java | 2 +- .../incoming/guilds/CreateGuildEvent.java | 2 +- .../incoming/guilds/JoinHabboGroupEvent.java | 2 +- .../incoming/guilds/KickMemberEvent.java | 2 +- .../RemoveAdminRightsFromMemberEvent.java | 3 +- .../incoming/navigator/DeleteRoomEvent.java | 2 +- .../rooms/GetCustomRoomFilterEvent.java | 2 +- .../incoming/rooms/LetUserInEvent.java | 2 +- .../incoming/rooms/RemoveAllRightsEvent.java | 6 +- .../rooms/RemoveOwnRoomRightsRoomEvent.java | 4 +- .../rooms/RequestRoomPropertySet.java | 2 +- .../SetRoomBackgroundColorDataEvent.java | 2 +- .../items/CustomizeAvatarWithFurniEvent.java | 3 +- .../rooms/items/MoveWallItemEvent.java | 2 +- .../rooms/items/PickupObjectEvent.java | 2 +- .../rooms/items/PlaceObjectEvent.java | 2 +- .../rooms/items/PlacePostItEvent.java | 2 +- .../items/RoomDimmerChangeStateEvent.java | 2 +- .../items/RoomDimmerSavePresetEvent.java | 2 +- .../items/SetCustomStackingHeightEvent.java | 2 +- .../rooms/items/SetItemDataEvent.java | 4 +- .../rooms/items/SetObjectDataEvent.java | 2 +- .../items/jukebox/AddJukeboxDiskEvent.java | 2 +- .../incoming/rooms/pets/MovePetEvent.java | 2 +- .../rooms/promotions/PurchaseRoomAdEvent.java | 2 +- .../rooms/users/AssignRightsEvent.java | 15 +- .../rooms/users/RemoveRightsEvent.java | 2 +- .../rooms/users/RoomUserKickEvent.java | 2 +- .../rooms/users/RoomUserMuteEvent.java | 2 +- .../incoming/wired/ApplySnapshotEvent.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 2 +- .../incoming/wired/UpdateConditionEvent.java | 2 +- .../incoming/wired/UpdateTriggerEvent.java | 2 +- .../rooms/FlatControllersComposer.java | 4 +- .../rooms/GetGuestRoomResultComposer.java | 2 +- 65 files changed, 341 insertions(+), 296 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java index 8a996d27..8217405f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java @@ -88,7 +88,7 @@ public class CommandsManager { String commandKey = parts[0]; Room currentRoom = gameClient.getHabbo().getRoomUnit().getRoom(); boolean hasRights = currentRoom != null && - (currentRoom.hasRights(gameClient.getHabbo())) || + (currentRoom.getRoomRightsManager().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasRight(Permission.ACC_PLACEFURNI) || currentRoom.getRoomInfo().getGuild().getId() > 0 && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java index 7db71e8b..fc882898 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java @@ -12,7 +12,7 @@ public class BotsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) + if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) return false; StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomBots().values().size()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java index 7e1ca0f3..d49942e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java @@ -11,7 +11,7 @@ public class DiagonalCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) { gameClient.getHabbo().getRoomUnit().getRoom().setDiagonalMoveEnabled(!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled()); if (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java index f0927824..88ecc8ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java @@ -17,7 +17,7 @@ public class EjectAllCommand extends Command { if (room != null) { if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { - room.ejectAll(gameClient.getHabbo()); + room.ejectAllFurni(gameClient.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java index 1c1246e4..b837f485 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java @@ -17,7 +17,7 @@ public class HideWiredCommand extends Command { } if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) { - room.setHideWired(!room.getRoomInfo().isHiddenWiredEnabled()); + room.getRoomItemManager().getWiredManager().setHideWired(!room.getRoomInfo().isHiddenWiredEnabled()); gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_hidewired." + (room.getRoomInfo().isHiddenWiredEnabled() ? "hidden" : "shown"))); } else { gameClient.getHabbo().whisper(getTextsValue("commands.errors.cmd_hidewired.permission")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java index 9e7037fe..2d3c9e37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java @@ -18,7 +18,7 @@ public class PickallCommand extends Command { } if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) { - room.ejectAll(); + room.ejectAllFurni(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java index b8bbffea..bf826518 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java @@ -13,7 +13,7 @@ public class SetSpeedCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().hasRights(gameClient.getHabbo())) { + if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); int oldSpeed = room.getRoomInfo().getRollerSpeed(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java index 3fb3dc39..6506c596 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java @@ -61,7 +61,7 @@ public class InteractionBackgroundToner extends RoomItem { if(client != null) { - if (!client.getHabbo().getRoomUnit().getRoom().hasRights(client.getHabbo())) { + if (!client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(client.getHabbo())) { ScripterManager.scripterDetected( client, Emulator.getTexts().getValue("scripter.warning.item.bgtoner.permission").replace("%username%", client.getHabbo().getHabboInfo().getUsername()) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java index 34d511f5..1a7d9f06 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.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 com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer; import com.eu.habbo.threading.runnables.RandomDiceNumber; @@ -46,7 +46,7 @@ public class InteractionColorWheel extends RoomItem { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (!room.hasRights(client.getHabbo())) + if (!room.getRoomRightsManager().hasRights(client.getHabbo())) return; if (this.rollTaks == null && !this.getExtradata().equalsIgnoreCase("-1")) { 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 a01185e8..facf2436 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 @@ -215,7 +215,7 @@ public class InteractionDefault extends RoomItem { } public boolean canToggle(Habbo habbo, Room room) { - if (room.hasRights(habbo)) return true; + if (room.getRoomRightsManager().hasRights(habbo)) return true; if (!habbo.getHabboStats().isRentingSpace()) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java index 3084f3e4..d003bb94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java @@ -24,7 +24,7 @@ public class InteractionEffectToggle extends InteractionDefault { } if (client != null) { - if (room.hasRights(client.getHabbo())) { + if (room.getRoomRightsManager().hasRights(client.getHabbo())) { if (Integer.parseInt(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) { if ((client.getHabbo().getHabboInfo().getGender() == HabboGender.M && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) || (client.getHabbo().getHabboInfo().getGender() == HabboGender.F && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectF())) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 6fa14604..777811bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -115,7 +115,7 @@ public class InteractionFireworks extends InteractionDefault { @Override public boolean canToggle(Habbo habbo, Room room) { - return room.hasRights(habbo) || RoomLayout.tilesAdjecent( + return room.getRoomRightsManager().hasRights(habbo) || RoomLayout.tilesAdjecent( room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition() ); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index c0fdc759..d22864bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -41,8 +41,7 @@ public class InteractionGate extends RoomItem { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE); - if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired) - return; + if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !executedByWired) return; // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) 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 312bc875..216ce2e2 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 @@ -49,7 +49,7 @@ public class InteractionMultiHeight extends RoomItem { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && !room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) + if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) return; if (objects.length <= 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index 7199df40..8ff653eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -48,7 +48,7 @@ public class InteractionMuteArea extends InteractionCustomValues { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.hasRights(client.getHabbo()))) { + if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.getRoomRightsManager().hasRights(client.getHabbo()))) { this.values.put("state", this.values.get("state").equals("0") ? "1" : "0"); room.sendComposer(new ObjectDataUpdateMessageComposer(this).compose()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java index e15150a0..d77c5307 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.messages.ServerMessage; @@ -68,7 +68,7 @@ public class InteractionVoteCounter extends RoomItem { @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) + if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; this.frozen = !this.frozen; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 5b8824e6..78af151f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -79,7 +79,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi this.wiredSettings.getItems(room); if (client != null) { - if (room.hasRights(client.getHabbo())) { + if (room.getRoomRightsManager().hasRights(client.getHabbo())) { MessageComposer composer = null; if(this instanceof InteractionWiredEffect) { composer = new WiredEffectDataComposer((InteractionWiredEffect) this, room); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java index 9259b857..d89937c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java @@ -20,7 +20,7 @@ public abstract class InteractionWiredExtra extends InteractionWired { @Override public void onClick(GameClient client, Room room, Object[] objects) { if (client != null) { - if (room.hasRights(client.getHabbo())) { + if (room.getRoomRightsManager().hasRights(client.getHabbo())) { this.activateBox(room); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index a98b9245..6836e782 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; 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.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.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -81,7 +81,7 @@ public class InteractionWiredHighscore extends RoomItem { @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) + if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 0cb454db..4e78d220 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.permissions.Permission; 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.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -232,7 +232,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { Emulator.getThreading().run(new GameTimer(this), 1000); } } else if (client != null) { - if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER))) + if (!(room.getRoomRightsManager().hasRights(client.getHabbo()) || client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER))) return; InteractionGameTimerAction state = InteractionGameTimerAction.START_STOP; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index ff39f9ab..4662e46e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -74,7 +74,7 @@ public class InteractionTotemHead extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) + if (!((client != null && room != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; TotemType newType = TotemType.fromInt(getTotemType().getType() + 1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index 1dcf58f6..ec4c0ffc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -51,7 +51,7 @@ public class InteractionTotemLegs extends InteractionDefault { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) + if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; updateHead(room, room.getLayout().getTile(this.getX(), this.getY())); 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 73f98575..a7917d16 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 @@ -36,7 +36,7 @@ public class WiredEffectMuteRoom extends InteractionWiredEffect { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { - if (room.hasRights(habbo)) + if (room.getRoomRightsManager().hasRights(habbo)) return false; room.muteHabbo(habbo, 60); 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 7820e4ac..3d10393e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -22,7 +22,6 @@ 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.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -47,8 +46,13 @@ import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; -import com.eu.habbo.messages.outgoing.rooms.*; -import com.eu.habbo.messages.outgoing.rooms.items.*; +import com.eu.habbo.messages.outgoing.rooms.FlatAccessDeniedMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; +import com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.ObjectUpdateMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer; import com.eu.habbo.plugin.Event; @@ -57,11 +61,13 @@ import com.eu.habbo.plugin.events.furniture.FurnitureStackHeightEvent; import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadingEvent; -import com.eu.habbo.plugin.events.users.*; +import com.eu.habbo.plugin.events.users.UserExitRoomEvent; +import com.eu.habbo.plugin.events.users.UserIdleEvent; +import com.eu.habbo.plugin.events.users.UserRolledEvent; +import com.eu.habbo.plugin.events.users.UsernameTalkEvent; import com.eu.habbo.threading.runnables.YouAreAPirate; import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; -import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.TIntIntMap; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; @@ -96,6 +102,8 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter private final RoomItemManager roomItemManager; @Getter + private final RoomRightsManager roomRightsManager; + @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(); @@ -118,8 +126,6 @@ public class Room implements Comparable, ISerialize, Runnable { @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 @@ -184,6 +190,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomInfo = new RoomInfo(set); this.roomUnitManager = new RoomUnitManager(this); this.roomItemManager = new RoomItemManager(this); + this.roomRightsManager = new RoomRightsManager(this); this.layoutName = set.getString("model"); this.bannedHabbos = new TIntObjectHashMap<>(); @@ -219,7 +226,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.games = new ConcurrentSet<>(); this.activeTrades = new THashSet<>(0); - this.rights = new TIntArrayList(); this.userVotes = new ArrayList<>(); this.triggersOnRoom = new HashMap<>(); @@ -238,7 +244,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes = new RoomSpecialTypes(); this.loadLayout(); - this.loadRights(connection); + this.roomRightsManager.load(connection); //TODO Deprecated this.loadItems(connection); @@ -1791,7 +1797,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean isMuted(Habbo habbo) { - if (this.getRoomInfo().isRoomOwner(habbo) || this.hasRights(habbo)) + if (this.getRoomInfo().isRoomOwner(habbo) || this.roomRightsManager.hasRights(habbo)) return false; if (this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) { @@ -1905,7 +1911,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (!habbo.hasRight(Permission.ACC_NOMUTE)) { - if (this.isMuted() && !this.hasRights(habbo)) { + if (this.isMuted() && !this.roomRightsManager.hasRights(habbo)) { return; } @@ -1935,7 +1941,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (chatCounter > 3) { final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); - final boolean hasRights = this.hasRights(habbo); + final boolean hasRights = this.roomRightsManager.hasRights(habbo); if (floodRights || !hasRights) { if (this.roomInfo.getChatProtection() == 0 || (this.roomInfo.getChatProtection() == 1 && chatCounter > 4) || (this.roomInfo.getChatProtection() == 2 && chatCounter > 5)) { @@ -2005,7 +2011,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Habbo h : this.roomUnitManager.getRoomHabbos()) { if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= this.roomInfo.getChatDistance() || h.equals(habbo) || - this.hasRights(h) || + this.roomRightsManager.hasRights(h) || noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { @@ -2528,6 +2534,10 @@ public class Room implements Comparable, ISerialize, Runnable { return null; } + public void alert(String message) { + this.sendComposer(new HabboBroadcastMessageComposer(message).compose()); + } + public void sendComposer(ServerMessage message) { for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if (habbo.getClient() == null) continue; @@ -2555,22 +2565,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private void loadRights(Connection connection) { - this.rights.clear(); - try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - this.rights.add(set.getInt(DatabaseConstants.USER_ID)); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - private void loadBans(Connection connection) { this.bannedHabbos.clear(); @@ -2607,150 +2601,6 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomRightLevels.NONE; } - public boolean hasRights(Habbo habbo) { - return this.getRoomInfo().isRoomOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())); - } - - public void giveRights(Habbo habbo) { - if (habbo != null) { - this.giveRights(habbo.getHabboInfo().getId()); - } - } - - public void giveRights(int userId) { - if (this.rights.contains(userId)) - return; - - if (this.rights.add(userId)) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { - statement.setInt(1, this.roomInfo.getId()); - statement.setInt(2, userId); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } - - Habbo habbo = this.roomUnitManager.getRoomHabboById(userId); - - if (habbo != null) { - this.refreshRightsForHabbo(habbo); - - this.sendComposer(new FlatControllerAddedComposer(this, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername()).compose()); - } else { - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.roomInfo.getOwnerInfo().getId()); - - if (owner != null) { - MessengerBuddy buddy = owner.getMessenger().getFriend(userId); - - if (buddy != null) { - this.sendComposer(new FlatControllerAddedComposer(this, userId, buddy.getUsername()).compose()); - } - } - } - } - - public void removeRights(int userId) { - Habbo habbo = this.roomUnitManager.getRoomHabboById(userId); - - if (Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.roomUnitManager.getRoomHabboById(this.roomInfo.getOwnerInfo().getId()), userId, habbo)).isCancelled()) - return; - - this.sendComposer(new FlatControllerRemovedComposer(this, userId).compose()); - - if (this.rights.remove(userId)) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - statement.setInt(2, userId); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } - - if (habbo != null) { - this.ejectUserFurni(habbo.getHabboInfo().getId()); - habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); - habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); - this.refreshRightsForHabbo(habbo); - } - } - - public void removeAllRights() { - for (int userId : rights.toArray()) { - this.ejectUserFurni(userId); - } - - this.rights.clear(); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - - this.refreshRightsInRoom(); - } - - void refreshRightsInRoom() { - Room room = this; - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { - if (habbo.getRoomUnit().getRoom() == room) { - this.refreshRightsForHabbo(habbo); - } - } - } - - public void refreshRightsForHabbo(Habbo habbo) { - RoomItem item; - RoomRightLevels flatCtrl = RoomRightLevels.NONE; - if (habbo.getHabboStats().isRentingSpace()) { - item = this.getHabboItem(habbo.getHabboStats().getRentedItemId()); - - if (item != null) { - return; - } - } - - if (habbo.hasRight(Permission.ACC_ANYROOMOWNER) || this.getRoomInfo().isRoomOwner(habbo)) { - habbo.getClient().sendResponse(new YouAreOwnerMessageComposer()); - flatCtrl = RoomRightLevels.MODERATOR; - } else if (this.hasRights(habbo) && !this.roomInfo.hasGuild()) { - flatCtrl = RoomRightLevels.RIGHTS; - } else if (this.roomInfo.hasGuild()) { - flatCtrl = this.getGuildRightLevel(habbo); - } - - habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); - habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel())); - habbo.getRoomUnit().setRightsLevel(flatCtrl); - habbo.getRoomUnit().setStatusUpdateNeeded(true); - - if (flatCtrl.equals(RoomRightLevels.MODERATOR)) { - habbo.getClient().sendResponse(new FlatControllersComposer(this)); - } - } - - public THashMap getUsersWithRights() { - THashMap rightsMap = new THashMap<>(); - - if (!this.rights.isEmpty()) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - rightsMap.put(set.getInt(DatabaseConstants.USER_ID), set.getString("username")); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } - - return rightsMap; - } - public void unbanHabbo(int userId) { RoomBan ban = this.bannedHabbos.remove(userId); @@ -2940,7 +2790,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) && (!(habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_MOVEROTATE)))) - this.refreshRightsForHabbo(habbo); + this.getRoomRightsManager().refreshRightsForHabbo(habbo); } } @@ -3030,35 +2880,4 @@ public class Room implements Comparable, ISerialize, Runnable { public boolean hasVotedInWordQuiz(Habbo habbo) { return this.userVotes.contains(habbo.getHabboInfo().getId()); } - - public void alert(String message) { - this.sendComposer(new HabboBroadcastMessageComposer(message).compose()); - } - - public void setHideWired(boolean hideWired) { - this.roomInfo.setHiddenWiredEnabled(hideWired); - - if (this.roomInfo.isHiddenWiredEnabled()) { - for (RoomItem item : this.roomSpecialTypes.getTriggers()) { - this.sendComposer(new RemoveFloorItemComposer(item).compose()); - } - - for (RoomItem item : this.roomSpecialTypes.getEffects()) { - this.sendComposer(new RemoveFloorItemComposer(item).compose()); - } - - for (RoomItem item : this.roomSpecialTypes.getConditions()) { - this.sendComposer(new RemoveFloorItemComposer(item).compose()); - } - - for (RoomItem item : this.roomSpecialTypes.getExtras()) { - this.sendComposer(new RemoveFloorItemComposer(item).compose()); - } - } else { - this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getTriggers()).compose()); - this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getEffects()).compose()); - this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getConditions()).compose()); - this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getExtras()).compose()); - } - } } 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 1ef6246e..04655e0e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -65,7 +65,7 @@ public class RoomItemManager { public RoomItemManager(Room room) { this.room = room; this.currentItems = new ConcurrentHashMap<>(); - this.wiredManager = new RoomWiredManager(); + this.wiredManager = new RoomWiredManager(room); this.floorItems = new ConcurrentHashMap<>(); this.wallItems = new ConcurrentHashMap<>(); @@ -236,7 +236,7 @@ public class RoomItemManager { } rotation %= 8; - if (this.room.hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { + if (this.room.getRoomRightsManager().hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { return FurnitureMovementError.NONE; } @@ -326,7 +326,7 @@ public class RoomItemManager { } public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) { - if (!(this.room.hasRights(owner) || this.room.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + if (!(this.room.getRoomRightsManager().hasRights(owner) || this.room.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { return FurnitureMovementError.NO_RIGHTS; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 75714ae2..71476116 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -497,7 +497,7 @@ public class RoomManager { } //If room is full AND user doesn't have Permissions can't enter to room - if (room.getRoomUnitManager().getRoomHabbosCount() >= room.getRoomInfo().getMaxUsers() && !room.hasRights(habbo) && !habbo.hasRight(Permission.ACC_FULLROOMS)) { + if (room.getRoomUnitManager().getRoomHabbosCount() >= room.getRoomInfo().getMaxUsers() && !room.getRoomRightsManager().hasRights(habbo) && !habbo.hasRight(Permission.ACC_FULLROOMS)) { habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_GUESTROOM_FULL)); return; } @@ -517,14 +517,14 @@ public class RoomManager { * If habbo has permissions open room * If habbo has guild rights open room */ - if (forceEnter || room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().getState() == RoomState.OPEN || habbo.hasRight(Permission.ACC_ENTERANYROOM) || room.hasRights(habbo) || (room.getRoomInfo().getState().equals(RoomState.INVISIBLE) && room.hasRights(habbo)) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + if (forceEnter || room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().getState() == RoomState.OPEN || habbo.hasRight(Permission.ACC_ENTERANYROOM) || room.getRoomRightsManager().hasRights(habbo) || (room.getRoomInfo().getState().equals(RoomState.INVISIBLE) && room.getRoomRightsManager().hasRights(habbo)) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { this.openRoom(habbo, room, spawnLocation); } else if (room.getRoomInfo().getState() == RoomState.LOCKED) { boolean habbosWithRights = false; synchronized (room.getRoomUnitManager().roomUnitLock) { for (Habbo current : room.getRoomUnitManager().getRoomHabbos()) { - if (room.hasRights(current) || current.getHabboInfo().getId() == room.getRoomInfo().getOwnerInfo().getId() || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(current).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + if (room.getRoomRightsManager().hasRights(current) || current.getHabboInfo().getId() == room.getRoomInfo().getOwnerInfo().getId() || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(current).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { current.getClient().sendResponse(new DoorbellMessageComposer(habbo.getHabboInfo().getUsername())); habbosWithRights = true; } @@ -623,11 +623,11 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomPropertyMessageComposer("landscape", room.getRoomInfo().getLandscapePaint())); - room.refreshRightsForHabbo(habbo); + room.getRoomRightsManager().refreshRightsForHabbo(habbo); habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room))); - roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.hasCommand("cmd_fastwalk", room.hasRights(habbo))); + roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.hasCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); if (room.isPromoted()) { habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion())); @@ -657,7 +657,7 @@ public class RoomManager { roomHabbo.setRoom(room); roomHabbo.setLoadingRoom(null); - room.refreshRightsForHabbo(habbo); + room.getRoomRightsManager().refreshRightsForHabbo(habbo); if (habbo.getRoomUnit().isKicked() && !habbo.getRoomUnit().isCanWalk()) { habbo.getRoomUnit().setCanWalk(true); @@ -823,7 +823,7 @@ public class RoomManager { habbo.getClient().sendResponse(new HabboGroupBadgesMessageComposer(guildBadges)); - if ((room.hasRights(habbo) + if ((room.getRoomRightsManager().hasRights(habbo) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) && !room.getHabboQueue().isEmpty()) { @@ -1162,7 +1162,7 @@ public class RoomManager { if (room != null) { if (room.getRoomInfo().getState() == RoomState.INVISIBLE) { room.loadData(); - if (!room.hasRights(habbo)) return true; + if (!room.getRoomRightsManager().hasRights(habbo)) return true; } rooms.add(room); } @@ -1226,7 +1226,7 @@ public class RoomManager { if (friend == null || friend.getHabboInfo() == null) continue; Room room = friend.getRoomUnit().getRoom(); - if (room != null && !rooms.contains(room) && room.hasRights(habbo)) rooms.add(room); + if (room != null && !rooms.contains(room) && room.getRoomRightsManager().hasRights(habbo)) rooms.add(room); if (rooms.size() >= limit) break; } @@ -1362,8 +1362,7 @@ public class RoomManager { if (room == null) return; - if (rights != null && !room.hasRights(rights)) - return; + if (rights != null && !room.getRoomRightsManager().hasRights(rights)) return; String name = ""; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java new file mode 100644 index 00000000..cb465298 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -0,0 +1,207 @@ +package com.eu.habbo.habbohotel.rooms; + +import com.eu.habbo.Emulator; +import com.eu.habbo.database.DatabaseConstants; +import com.eu.habbo.habbohotel.messenger.MessengerBuddy; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.rooms.*; +import com.eu.habbo.plugin.events.users.UserRightsTakenEvent; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +@Getter +@Setter +public class RoomRightsManager { + private final Room room; + private final List rights; + + public RoomRightsManager(Room room) { + this.room = room; + this.rights = new ArrayList<>(); + } + + public synchronized void load(Connection connection) { + this.loadRights(connection); + } + + private void loadRights(Connection connection) { + this.rights.clear(); + try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.rights.add(set.getInt(DatabaseConstants.USER_ID)); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + public boolean hasRights(Habbo habbo) { + return this.room.getRoomInfo().isRoomOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.room.getRoomUnitManager().getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())); + } + + public HashMap getUsersWithRights() { + HashMap rightsMap = new HashMap<>(); + + if (this.rights.isEmpty()) { + return rightsMap; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + PreparedStatement statement = connection.prepareStatement("SELECT users.username AS username, users.id AS user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + int userId = set.getInt("user_id"); + String username = set.getString("username"); + rightsMap.put(userId, username); + } + } + } catch (SQLException e) { + log.error("Error while fetching users with rights:", e); + } + + return rightsMap; + } + + public void giveRights(Habbo habbo) { + if (this.rights.contains(habbo.getHabboInfo().getId())) { + return; + } + + if (this.rights.add(habbo.getHabboInfo().getId())) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setInt(2, habbo.getHabboInfo().getId()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + + this.room.getRoomRightsManager().refreshRightsForHabbo(habbo); + this.room.sendComposer(new FlatControllerAddedComposer(this.room, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername()).compose()); + } + + public void giveRights(MessengerBuddy buddy) { + if (this.rights.contains(buddy.getId())) { + return; + } + + this.rights.add(buddy.getId()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setInt(2, buddy.getId()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + + Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getRoomInfo().getOwnerInfo().getId()); + + if (roomOwner != null) { + this.room.sendComposer(new FlatControllerAddedComposer(this.room, buddy.getId(), buddy.getUsername()).compose()); + } + } + + public void removeRights(int userId) { + Habbo habbo = this.room.getRoomUnitManager().getRoomHabboById(userId); + + if (Emulator.getPluginManager().fireEvent(new UserRightsTakenEvent(this.room.getRoomUnitManager().getRoomHabboById(this.room.getRoomInfo().getOwnerInfo().getId()), userId, habbo)).isCancelled()) + return; + + this.room.sendComposer(new FlatControllerRemovedComposer(this.room, userId).compose()); + + if (this.rights.remove(Integer.valueOf(userId))) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setInt(2, userId); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + + if (habbo != null) { + this.room.ejectUserFurni(habbo.getHabboInfo().getId()); + habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); + habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); + this.refreshRightsForHabbo(habbo); + } + } + + public void removeAllRights() { + for (int userId : this.rights) { + this.room.ejectUserFurni(userId); + } + + this.rights.clear(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + + this.refreshRightsInRoom(); + } + + private void refreshRightsInRoom() { + for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { + if (habbo.getRoomUnit().getRoom() == room) { + this.refreshRightsForHabbo(habbo); + } + } + } + + public void refreshRightsForHabbo(Habbo habbo) { + RoomItem item; + RoomRightLevels flatCtrl = RoomRightLevels.NONE; + + if (habbo.getHabboStats().isRentingSpace()) { + item = this.room.getRoomItemManager().getCurrentItems().get(habbo.getHabboStats().getRentedItemId()); + + if (item != null) { + return; + } + } + + if (habbo.hasRight(Permission.ACC_ANYROOMOWNER) || this.room.getRoomInfo().isRoomOwner(habbo)) { + habbo.getClient().sendResponse(new YouAreOwnerMessageComposer()); + flatCtrl = RoomRightLevels.MODERATOR; + } else if (this.hasRights(habbo) && !this.room.getRoomInfo().hasGuild()) { + flatCtrl = RoomRightLevels.RIGHTS; + } else if (this.room.getRoomInfo().hasGuild()) { + flatCtrl = this.room.getGuildRightLevel(habbo); + } + + habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); + + habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel())); + habbo.getRoomUnit().setRightsLevel(flatCtrl); + + if (flatCtrl.equals(RoomRightLevels.MODERATOR)) { + habbo.getClient().sendResponse(new FlatControllersComposer(this.room)); + } + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java index cbc80553..816a1adb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWiredManager.java @@ -14,13 +14,15 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j @Getter public class RoomWiredManager { + private final Room room; private final ConcurrentHashMap currentWireds; private final ConcurrentHashMap> currentWiredTriggers; private final ConcurrentHashMap> currentWiredEffects; private final ConcurrentHashMap> currentWiredConditions; private final ConcurrentHashMap currentWiredExtras; - public RoomWiredManager() { + public RoomWiredManager(Room room) { + this.room = room; this.currentWireds = new ConcurrentHashMap<>(0); this.currentWiredTriggers = new ConcurrentHashMap<>(0); this.currentWiredEffects = new ConcurrentHashMap<>(0); @@ -113,6 +115,19 @@ public class RoomWiredManager { currentWiredExtras.remove(extra.getId()); } + public void setHideWired(boolean hideWired) { + //TODO FIX THIS +// this.room.getRoomInfo().setHiddenWiredEnabled(hideWired); +// +// if (this.room.getRoomInfo().isHiddenWiredEnabled()) { +// for (RoomItem item : this.currentWireds.values()) { +// this.room.sendComposer(new RemoveFloorItemComposer(item).compose()); +// } +// } else { +// this.room.sendComposer(new ObjectsMessageComposer(this.room.getFurniOwnerNames(), this.currentWireds).compose()); +// } + } + public void clear() { this.currentWireds.clear(); this.currentWiredTriggers.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 5342d800..cd55ed13 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -264,6 +264,11 @@ public abstract class RoomUnit extends RoomEntity { } } + public void setRightsLevel(RoomRightLevels rightsLevel) { + this.rightsLevel = rightsLevel; + this.statusUpdateNeeded = true; + } + public boolean hasStatus(RoomUnitStatus key) { return this.statuses.containsKey(key); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java index 73804bdd..ed67736f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java @@ -32,7 +32,7 @@ public class AddAdminRightsToMemberEvent extends MessageHandler { Room room = habbo.getRoomUnit().getRoom(); if (room != null) { if (room.getRoomInfo().getGuild().getId() == guildId) { - room.refreshRightsForHabbo(habbo); + room.getRoomRightsManager().refreshRightsForHabbo(habbo); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java index cf4b6fd2..53fd051d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java @@ -59,7 +59,7 @@ public class ApproveMembershipRequestEvent extends MessageHandler { if (habbo != null && userInfo.isOnline() && habbo.getRoomUnit().getRoom() != null) { if (habbo.getRoomUnit().getRoom().getRoomInfo().getGuild().getId() == guildId) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); - habbo.getRoomUnit().getRoom().refreshRightsForHabbo(habbo); + habbo.getRoomUnit().getRoom().getRoomRightsManager().refreshRightsForHabbo(habbo); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java index ea3f508f..0cbdf539 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java @@ -63,7 +63,7 @@ public class CreateGuildEvent extends GuildBadgeEvent { Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getRoomInfo().getName(), name, description, badge.toString(), colorOne, colorTwo); r.getRoomInfo().setGuild(guild); - r.removeAllRights(); + r.getRoomRightsManager().removeAllRights(); //TODO Check if this is needed r.setNeedsUpdate(true); if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java index 1563de2e..7471e5ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/JoinHabboGroupEvent.java @@ -34,6 +34,6 @@ public class JoinHabboGroupEvent extends MessageHandler { if (room == null || room.getRoomInfo().getGuild().getId() != guildId) return; - room.refreshRightsForHabbo(this.client.getHabbo()); + room.getRoomRightsManager().refreshRightsForHabbo(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java index 584ae61f..e4181b66 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java @@ -49,7 +49,7 @@ public class KickMemberEvent extends MessageHandler { if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit() != null) habbo.getRoomUnit().getRoom().sendComposer(new FavoriteMembershipUpdateMessageComposer(habbo.getRoomUnit(), null).compose()); if (habbo.getRoomUnit().getRoom() == room) - room.refreshRightsForHabbo(habbo); + room.getRoomRightsManager().refreshRightsForHabbo(habbo); } habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, null)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java index ecfb8c29..3e9c8ba7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java @@ -36,7 +36,8 @@ public class RemoveAdminRightsFromMemberEvent extends MessageHandler { if (habbo != null) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId))); - if (room != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) room.refreshRightsForHabbo(habbo); + if (room != null && habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) + room.getRoomRightsManager().refreshRightsForHabbo(habbo); } GuildMember guildMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index c3a8854b..ac8bb7f1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -39,7 +39,7 @@ public class DeleteRoomEvent extends MessageHandler { return; } - room.ejectAll(); + room.ejectAllFurni(); room.ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomBots().values()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java index 7d966d46..29c75138 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetCustomRoomFilterEvent.java @@ -11,7 +11,7 @@ public class GetCustomRoomFilterEvent extends MessageHandler { public void handle() { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); - if (room != null && room.hasRights(this.client.getHabbo())) { + if (room != null && room.getRoomRightsManager().hasRights(this.client.getHabbo())) { this.client.sendResponse(new RoomFilterSettingsMessageComposer(room)); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModRoomFilterSeen")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java index f6952e6f..2804975f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/LetUserInEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; public class LetUserInEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { String username = this.packet.readString(); boolean accepted = this.packet.readBoolean(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java index 254da30a..ba0dfc2c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java @@ -18,7 +18,7 @@ public class RemoveAllRightsEvent extends MessageHandler { return; if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - room.getRights().forEach(value -> { + room.getRoomRightsManager().getRights().forEach(value -> { Habbo habbo = room.getRoomUnitManager().getRoomHabboById(value); if (habbo != null) { @@ -26,11 +26,9 @@ public class RemoveAllRightsEvent extends MessageHandler { habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); habbo.getClient().sendResponse(new YouAreControllerMessageComposer(RoomRightLevels.NONE)); } - - return true; }); - room.removeAllRights(); + room.getRoomRightsManager().removeAllRights(); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java index 67b0df6d..fef6a27e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveOwnRoomRightsRoomEvent.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; public class RemoveOwnRoomRightsRoomEvent extends MessageHandler { @@ -8,6 +9,7 @@ public class RemoveOwnRoomRightsRoomEvent extends MessageHandler { public void handle() { int roomId = this.packet.readInt(); - Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId).removeRights(this.client.getHabbo().getHabboInfo().getId()); + Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); + room.getRoomRightsManager().removeRights(this.client.getHabbo().getHabboInfo().getId()); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 202e7c75..8f735bee 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -17,7 +17,7 @@ public class RequestRoomPropertySet extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { int itemId = this.packet.readInt(); RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index e784eb25..2facfd82 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -16,7 +16,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { if (room == null) return; - if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { RoomItem item = room.getHabboItem(itemId); if (item == null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index a4815ffa..650cd1e2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -26,8 +26,7 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - if (this.client.getHabbo().getRoomUnit().getRoom() != null && - this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { + if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index 5dfd49bc..263a213a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -17,7 +17,7 @@ public class MoveWallItemEvent extends MessageHandler { if (room == null) return; - if (!room.hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (!room.getRoomRightsManager().hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { if (!(room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index bdef0b03..fd43b788 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -27,7 +27,7 @@ public class PickupObjectEvent extends MessageHandler { if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); } else { - if (room.hasRights(this.client.getHabbo())) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); } else { 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 ff9583eb..32d35fd9 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 @@ -75,7 +75,7 @@ public class PlaceObjectEvent extends MessageHandler { rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); } - if ((rentSpace != null || buildArea != null) && !room.hasRights(this.client.getHabbo())) { + if ((rentSpace != null || buildArea != null) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) { if (item instanceof InteractionRoller || item instanceof InteractionStackHelper || item instanceof InteractionWired || diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index a3d18d9a..9463ab22 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -22,7 +22,7 @@ public class PlacePostItEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || !room.getRoomSpecialTypes().getItemsOfType(InteractionStickyPole.class).isEmpty()) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || !room.getRoomSpecialTypes().getItemsOfType(InteractionStickyPole.class).isEmpty()) { RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item instanceof InteractionPostIt) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java index 301d36c2..b50d4b55 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java @@ -14,7 +14,7 @@ public class RoomDimmerChangeStateEvent extends MessageHandler { public void handle() { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if ((room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) return; for (RoomItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java index 51a72b1c..98fc6e7d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java @@ -22,7 +22,7 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { public void handle() { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if ((room.getRoomInfo().getGuild().getId() <= 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getRoomInfo().getGuild().getId() <= 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) return; int id = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 06294c71..076cc132 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -17,7 +17,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() || this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) { + if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() || this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); if (item instanceof InteractionStackHelper) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index 2626b663..744683da 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -39,12 +39,12 @@ public class SetItemDataEvent extends MessageHandler { if (!(item instanceof InteractionPostIt)) return; - if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.hasRights(this.client.getHabbo())) { + if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) { if (!text.startsWith(item.getExtradata().replace(item.getExtradata().split(" ")[0], ""))) { return; } } else { - if (!room.hasRights(this.client.getHabbo())) + if (!room.getRoomRightsManager().hasRights(this.client.getHabbo())) return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index 28a65bea..e37204cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -16,7 +16,7 @@ public class SetObjectDataEvent extends MessageHandler { if (room == null) return; - if (!room.hasRights(this.client.getHabbo())) + if (!room.getRoomRightsManager().hasRights(this.client.getHabbo())) return; RoomItem item = room.getHabboItem(this.packet.readInt()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java index d24eb1b2..da552cef 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java @@ -8,7 +8,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class AddJukeboxDiskEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().getRoomUnit().getRoom().hasRights(this.client.getHabbo())) return; + if (!this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) return; int itemId = this.packet.readInt(); int slotId = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index a29be34b..94a18293 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -15,7 +15,7 @@ public class MovePetEvent extends MessageHandler { if (pet != null) { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room != null && room.hasRights(this.client.getHabbo())) { + if (room != null && room.getRoomRightsManager().hasRights(this.client.getHabbo())) { if (pet.getRoomUnit() != null) { int x = this.packet.readInt(); int y = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java index 65a2e257..43ca691d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java @@ -38,7 +38,7 @@ public class PurchaseRoomAdEvent extends MessageHandler { if (this.client.getHabbo().getHabboInfo().canBuy(item)) { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); - if (!(room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || room.hasRights(this.client.getHabbo()) || room.getGuildRightLevel(this.client.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { + if (!(room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getGuildRightLevel(this.client.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java index f1f9f177..59e81e05 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java @@ -11,25 +11,26 @@ import com.eu.habbo.plugin.events.users.UserRightsGivenEvent; public class AssignRightsEvent extends MessageHandler { @Override public void handle() { - int userId = this.packet.readInt(); + int targetId = this.packet.readInt(); Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - Habbo target = room.getRoomUnitManager().getRoomHabboById(userId); + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + Habbo target = room.getRoomUnitManager().getRoomHabboById(targetId); if (target != null) { if (!Emulator.getPluginManager().fireEvent(new UserRightsGivenEvent(this.client.getHabbo(), target)).isCancelled()) { - room.giveRights(target); + room.getRoomRightsManager().giveRights(target); } } else { - MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(userId); + MessengerBuddy buddy = this.client.getHabbo().getMessenger().getFriend(targetId); if (buddy != null) { - room.giveRights(userId); + room.getRoomRightsManager().giveRights(buddy); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java index 867779e6..2880090c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java @@ -18,7 +18,7 @@ public class RemoveRightsEvent extends MessageHandler { for (int i = 0; i < amount; i++) { int userId = this.packet.readInt(); - room.removeRights(userId); + room.getRoomRightsManager().removeRights(userId); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java index 33f27912..25edefc0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java @@ -41,7 +41,7 @@ public class RoomUserKickEvent extends MessageHandler { if (event.isCancelled()) return; - if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { if (target.hasRight(Permission.ACC_UNKICKABLE)) return; room.kickHabbo(target, true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java index 8aac4969..df85e19e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java @@ -18,7 +18,7 @@ public class RoomUserMuteEvent extends MessageHandler { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || this.client.getHabbo().hasCommand("cmd_mute") || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasCommand("cmd_mute") || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { Habbo habbo = room.getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 7a0c290d..0ef83ca4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -38,7 +38,7 @@ public class ApplySnapshotEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); // Executing Habbo should be able to edit wireds - if (room == null || (!room.hasRights(this.client.getHabbo()) && !room.getRoomInfo().isRoomOwner(this.client.getHabbo()))) { + if (room == null || (!room.getRoomRightsManager().hasRights(this.client.getHabbo()) && !room.getRoomInfo().isRoomOwner(this.client.getHabbo()))) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index 32fd699b..7763edbb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -16,7 +16,7 @@ public class UpdateActionEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { //TODO Check SUPER WIRED PERMISSIONS TOO InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index 96d3be2a..d3c73dad 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -16,7 +16,7 @@ public class UpdateConditionEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index b277efb1..5948d043 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -16,7 +16,7 @@ public class UpdateTriggerEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java index 77a70991..264d923e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/FlatControllersComposer.java @@ -4,9 +4,9 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.map.hash.THashMap; import lombok.AllArgsConstructor; +import java.util.HashMap; import java.util.Map; @AllArgsConstructor @@ -18,7 +18,7 @@ public class FlatControllersComposer extends MessageComposer { this.response.init(Outgoing.flatControllersComposer); this.response.appendInt(this.room.getRoomInfo().getId()); - THashMap rightsMap = this.room.getUsersWithRights(); + HashMap rightsMap = this.room.getRoomRightsManager().getUsersWithRights(); this.response.appendInt(rightsMap.size()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java index e2a73ccf..1948ced2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java @@ -37,7 +37,7 @@ public class GetGuestRoomResultComposer extends MessageComposer { this.response.appendInt(this.room.getRoomInfo().getWhoCanKickOption()); this.response.appendInt(this.room.getRoomInfo().getWhoCanBanOption()); - this.response.appendBoolean(this.room.hasRights(this.habbo)); //mute all button + this.response.appendBoolean(this.room.getRoomRightsManager().hasRights(this.habbo)); //mute all button this.response.appendInt(this.room.getRoomInfo().getChatMode()); this.response.appendInt(this.room.getRoomInfo().getChatWeight()); From 4d81fc9dd047897580e5c37515e7fb4d7ef15dae Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 22 Jul 2023 19:23:03 -0500 Subject: [PATCH 25/42] Room.java clean-up --- .../habbohotel/catalog/CatalogManager.java | 4 +- .../catalog/layouts/RoomBundleLayout.java | 8 +- .../commands/list/EjectAllCommand.java | 5 +- .../commands/list/PickallCommand.java | 4 +- .../com/eu/habbo/habbohotel/games/Game.java | 2 +- .../games/battlebanzai/BattleBanzaiGame.java | 4 +- .../habbohotel/games/freeze/FreezeGame.java | 2 +- .../interactions/InteractionDefault.java | 2 +- .../items/interactions/InteractionFXBox.java | 2 +- .../items/interactions/InteractionGift.java | 8 +- .../pets/InteractionPetBreedingNest.java | 2 +- .../interactions/wired/WiredSettings.java | 2 +- .../effects/WiredEffectBotWalkToFurni.java | 6 +- .../WiredEffectChangeFurniDirection.java | 4 +- .../wired/effects/WiredEffectMatchFurni.java | 4 +- .../effects/WiredEffectMoveFurniAway.java | 2 +- .../effects/WiredEffectMoveFurniTowards.java | 2 +- .../effects/WiredEffectMoveRotateFurni.java | 2 +- .../pets/actions/ActionPlayFootball.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 357 +----------------- .../habbohotel/rooms/RoomItemManager.java | 196 ++++++---- .../habbohotel/rooms/RoomLayoutManager.java | 4 + .../habbo/habbohotel/rooms/RoomManager.java | 2 +- .../habbohotel/rooms/RoomRightsManager.java | 4 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 7 +- .../habbo/habbohotel/rooms/RoomTradeUser.java | 14 +- .../rooms/entities/units/RoomUnit.java | 1 - .../com/eu/habbo/habbohotel/users/Habbo.java | 8 - .../users/inventory/ItemsComponent.java | 5 +- .../catalog/recycler/PresentOpenEvent.java | 5 +- .../incoming/crafting/CraftEvent.java | 2 +- .../incoming/crafting/CraftSecretEvent.java | 2 +- .../crafting/GetCraftingRecipeEvent.java | 2 +- .../GetCraftingRecipesAvailableEvent.java | 2 +- .../GetGuildFurniContextMenuInfoEvent.java | 2 +- .../incoming/guilds/KickMemberEvent.java | 2 +- .../modtool/CallForHelpFromPhotoEvent.java | 2 +- .../incoming/navigator/DeleteRoomEvent.java | 4 +- .../SetRoomBackgroundColorDataEvent.java | 2 +- .../rooms/items/AddSpamWallPostItEvent.java | 2 +- .../rooms/items/CreditFurniRedeemEvent.java | 6 +- .../items/CustomizeAvatarWithFurniEvent.java | 4 +- .../incoming/rooms/items/DiceOffEvent.java | 2 +- .../rooms/items/EnterOneWayDoorEvent.java | 2 +- .../rooms/items/GetItemDataEvent.java | 2 +- .../incoming/rooms/items/MoveObjectEvent.java | 22 +- .../rooms/items/MoveWallItemEvent.java | 2 +- .../rooms/items/PickupObjectEvent.java | 2 +- .../rooms/items/PlaceObjectEvent.java | 4 +- .../rooms/items/PlacePostItEvent.java | 2 +- .../incoming/rooms/items/RemoveItemEvent.java | 4 +- .../items/SetClothingChangeDataEvent.java | 3 +- .../items/SetCustomStackingHeightEvent.java | 2 +- .../rooms/items/SetItemDataEvent.java | 2 +- .../rooms/items/SetMannequinFigureEvent.java | 3 +- .../rooms/items/SetMannequinNameEvent.java | 3 +- .../rooms/items/SetObjectDataEvent.java | 3 +- .../rooms/items/SetRandomStateEvent.java | 2 +- .../rooms/items/SpinWheelOfFortuneEvent.java | 2 +- .../incoming/rooms/items/ThrowDiceEvent.java | 2 +- .../rooms/items/UseFurnitureEvent.java | 4 +- .../rooms/items/UseWallItemEvent.java | 2 +- .../lovelock/FriendFurniConfirmLockEvent.java | 2 +- .../RentableSpaceCancelRentEvent.java | 2 +- .../rentablespace/RentableSpaceRentEvent.java | 2 +- .../ControlYoutubeDisplayPlaybackEvent.java | 2 +- .../youtube/GetYoutubeDisplayStatusEvent.java | 2 +- .../SetYoutubeDisplayPlaylistEvent.java | 2 +- .../rooms/pets/CancelPetBreedingEvent.java | 2 +- .../rooms/pets/CompostPlantEvent.java | 2 +- .../rooms/pets/ConfirmPetBreedingEvent.java | 2 +- .../pets/CustomizePetWithFurniEvent.java | 10 +- .../rooms/pets/OpenPetPackageEvent.java | 4 +- .../incoming/rooms/users/SignEvent.java | 2 +- .../incoming/wired/ApplySnapshotEvent.java | 6 +- .../inventory/UnseenItemsComposer.java | 6 +- .../outgoing/rooms/items/ItemsComposer.java | 5 +- .../inventory/InventoryItemsAddedEvent.java | 9 +- .../UserCatalogFurnitureBoughtEvent.java | 9 +- .../UserCatalogItemPurchasedEvent.java | 8 +- .../threading/runnables/ClearRentedSpace.java | 5 +- .../threading/runnables/CrackableExplode.java | 4 +- .../habbo/threading/runnables/OpenGift.java | 8 +- .../threading/runnables/PetEatAction.java | 2 +- .../runnables/RemoveFloorItemTask.java | 2 +- .../runnables/TeleportInteraction.java | 4 +- .../runnables/hopper/HopperActionThree.java | 2 +- .../teleport/TeleportActionThree.java | 3 +- .../runnables/teleport/TeleportActionTwo.java | 3 +- 89 files changed, 302 insertions(+), 580 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayoutManager.java diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 81b32f9c..6d5eac7f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -14,10 +14,10 @@ import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboGender; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; @@ -846,7 +846,7 @@ public class CatalogManager { } } - THashSet itemsList = new THashSet<>(); + HashSet itemsList = new HashSet<>(); if (amount > 1 && !CatalogItem.haveOffer(item)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index 7d4de245..23c88dbf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -73,7 +73,7 @@ public class RoomBundleLayout extends SingleBundle { THashMap items = new THashMap<>(); - for (RoomItem i : this.room.getFloorItems()) { + for (RoomItem i : this.room.getRoomItemManager().getFloorItems().values()) { if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } @@ -81,7 +81,7 @@ public class RoomBundleLayout extends SingleBundle { items.put(i.getBaseItem(), items.get(i.getBaseItem()) + 1); } - for (RoomItem i : this.room.getWallItems()) { + for (RoomItem i : this.room.getRoomItemManager().getWallItems().values()) { if (!items.contains(i.getBaseItem())) { items.put(i.getBaseItem(), 0); } @@ -141,11 +141,11 @@ public class RoomBundleLayout extends SingleBundle { this.room.save(); - for (RoomItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) { item.run(); } - for (RoomItem item : this.room.getWallItems()) { + for (RoomItem item : this.room.getRoomItemManager().getWallItems().values()) { item.run(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java index 88ecc8ae..01a05e9f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java @@ -15,9 +15,8 @@ public class EjectAllCommand extends Command { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) - || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { - room.ejectAllFurni(gameClient.getHabbo()); + if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) { + room.getRoomItemManager().ejectAllFurni(gameClient.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java index 2d3c9e37..f07f1bc1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java @@ -18,11 +18,11 @@ public class PickallCommand extends Command { } if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) { - room.ejectAllFurni(); + room.getRoomItemManager().ejectAllFurni(); return true; } - room.ejectUserFurni(gameClient.getHabbo().getHabboInfo().getId()); + room.getRoomItemManager().ejectUserFurni(gameClient.getHabbo().getHabboInfo().getId()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index e9acec7b..deae2ce4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -209,7 +209,7 @@ public abstract class Game implements Runnable { this.state = GameState.IDLE; boolean gamesActive = false; - for (RoomItem timer : room.getFloorItems()) { + for (RoomItem timer : room.getRoomItemManager().getFloorItems().values()) { if (timer instanceof InteractionGameTimer) { if (((InteractionGameTimer) timer).isRunning()) gamesActive = true; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index 27b98156..edb0fe5e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -11,8 +11,8 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker; import gnu.trove.map.hash.THashMap; @@ -226,7 +226,7 @@ public class BattleBanzaiGame extends Game { private synchronized void resetMap() { this.tileCount = 0; - for (RoomItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionBattleBanzaiTile) { item.setExtradata("1"); this.room.updateItemState(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 292c95a4..385b552f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -78,7 +78,7 @@ public class FreezeGame extends Game { } synchronized void resetMap() { - for (RoomItem item : this.room.getFloorItems()) { + for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) { item.setExtradata("0"); this.room.updateItemState(item); 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 facf2436..ff280b15 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 @@ -219,7 +219,7 @@ public class InteractionDefault extends RoomItem { if (!habbo.getHabboStats().isRentingSpace()) return false; - RoomItem rentSpace = room.getHabboItem(habbo.getHabboStats().getRentedItemId()); + RoomItem rentSpace = room.getRoomItemManager().getRoomItemById(habbo.getHabboStats().getRentedItemId()); return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index a4037a09..89d7e53d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -54,7 +54,7 @@ public class InteractionFXBox extends InteractionDefault { this.setExtradata("1"); room.updateItemState(this); - room.removeHabboItem(this); + room.getRoomItemManager().removeRoomItem(this); RoomItem item = this; Emulator.getThreading().run(() -> { new QueryDeleteHabboItem(item.getId()).run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java index 42bc59a1..991fbcd4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java @@ -4,15 +4,15 @@ import com.eu.habbo.Emulator; 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.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 lombok.Getter; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashSet; @Slf4j public class InteractionGift extends RoomItem { @@ -121,8 +121,8 @@ public class InteractionGift extends RoomItem { } } - public THashSet loadItems() { - THashSet items = new THashSet<>(); + public HashSet loadItems() { + HashSet items = new HashSet<>(); for (int anItemId : this.itemId) { if (anItemId == 0) continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index e23d338e..75ec69b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -156,7 +156,7 @@ public class InteractionPetBreedingNest extends RoomItem { offspring.setNeedsUpdate(true); offspring.run(); InteractionPetBreedingNest.this.freePets(); - habbo.getRoomUnit().getRoom().removeHabboItem(box); + habbo.getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(box); habbo.getClient().sendResponse(new NestBreedingSuccessComposer(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring))); if (box.getBaseItem().getName().startsWith("pet_breeding_")) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index a4e799bd..1521880d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -61,7 +61,7 @@ public class WiredSettings implements IWiredSettings { } for(int i = 0; i < this.itemIds.size(); i++) { - RoomItem item = room.getHabboItem(this.itemIds.get(i)); + RoomItem item = room.getRoomItemManager().getRoomItemById(this.itemIds.get(i)); if(item == null || item.getRoomId() == 0) { this.itemIds.remove(i); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index 2e3d0dc9..52d798df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -37,7 +37,11 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } Bot bot = bots.get(0); - this.getWiredSettings().getItems(room).removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()).getHabboItem(item.getId()) == null); + this.getWiredSettings().getItems(room).removeIf(item -> { + if (item == null || item.getRoomId() != this.getRoomId()) return true; + Room room1 = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + return room1.getRoomItemManager().getRoomItemById(item.getId()) == null; + }); // Bots shouldn't walk to the tile they are already standing on List possibleItems = this.getWiredSettings().getItems(room).stream() diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index eda70a5e..314e81e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -106,7 +106,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { if(room.getRoomItemManager().furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE) continue; - room.getRoomItemManager().moveFurniTo(item, newTargetTile, setting.getRotation(), null, true, true); + room.getRoomItemManager().moveItemTo(item, newTargetTile, setting.getRotation(), null, true, true); } boolean hasRoomUnits = false; @@ -126,7 +126,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { if (!hasRoomUnits) { RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); double oldZ = item.getZ(); - if (room.getRoomItemManager().moveFurniTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveItemTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 4556c482..b7e72b6a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -67,7 +67,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int if(rotation && !position) { if (item.getRotation() != furniSettings.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) { - room.getRoomItemManager().moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true, true); + room.getRoomItemManager().moveItemTo(item, oldLocation, furniSettings.getRotation(), null, true, true); } } else if(position) { @@ -77,7 +77,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) { boolean sendUpdates = !slideAnimation; - if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveItemTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { if (slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index 84458e7e..fea4a33f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -74,7 +74,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { double oldZ = item.getZ(); if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.getRoomItemManager().furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { - if (room.getRoomItemManager().moveFurniTo(item, newLocation, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveItemTo(item, newLocation, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 13f9399b..9e9209cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -201,7 +201,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if(newTile != null) { lastDirections.put(item.getId(), moveDirection); if (newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.getRoomItemManager().furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { - if (room.getRoomItemManager().moveFurniTo(item, newTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveItemTo(item, newTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index bc6eb57c..24346c91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -70,7 +70,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) { if(room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE) { boolean sendUpdates = !slideAnimation; - if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { + if (room.getRoomItemManager().moveItemTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { if (slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java index 10b82412..b77523c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java @@ -23,7 +23,7 @@ public class ActionPlayFootball extends PetAction { RoomItem foundBall = null; - for(RoomItem item : room.getFloorItems()) { + for(RoomItem item : room.getRoomItemManager().getFloorItems().values()) { if(item instanceof InteractionPushable) { foundBall = item; } 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 3d10393e..6dfc6e41 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -12,16 +12,7 @@ import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; 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.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.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -33,8 +24,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ISerialize; @@ -43,7 +32,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; -import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; import com.eu.habbo.messages.outgoing.rooms.FlatAccessDeniedMessageComposer; @@ -70,7 +58,6 @@ import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntIntMap; import gnu.trove.map.TIntObjectMap; -import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; @@ -319,7 +306,8 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(1, this.roomInfo.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - this.addHabboItem(Emulator.getGameEnvironment().getItemManager().loadHabboItem(set)); + RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); + this.getRoomItemManager().addRoomItem(item); } } } catch (SQLException e) { @@ -1446,274 +1434,6 @@ public class Room implements Comparable, ISerialize, Runnable { return true; } - public void addHabboItem(RoomItem item) { - if (item == null) - return; - - synchronized (this.roomItems) { - try { - this.roomItems.put(item.getId(), item); - } catch (Exception ignored) { - - } - } - - synchronized (this.furniOwnerCount) { - this.furniOwnerCount.put(item.getOwnerId(), this.furniOwnerCount.get(item.getOwnerId()) + 1); - } - - synchronized (this.furniOwnerNames) { - if (!this.furniOwnerNames.containsKey(item.getOwnerId())) { - HabboInfo habbo = HabboManager.getOfflineHabboInfo(item.getOwnerId()); - - if (habbo != null) { - this.furniOwnerNames.put(item.getOwnerId(), habbo.getUsername()); - } else { - log.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getOwnerId()); - } - } - } - - //TODO: Move this list - synchronized (this.roomSpecialTypes) { - if (item instanceof ICycleable) { - this.roomSpecialTypes.addCycleTask((ICycleable) item); - } - - if (item instanceof InteractionWiredTrigger interactionWiredTrigger) { - this.roomSpecialTypes.addTrigger(interactionWiredTrigger); - } else if (item instanceof InteractionWiredEffect interactionWiredEffect) { - this.roomSpecialTypes.addEffect(interactionWiredEffect); - } else if (item instanceof InteractionWiredCondition interactionWiredCondition) { - this.roomSpecialTypes.addCondition(interactionWiredCondition); - } else if (item instanceof InteractionWiredExtra interactionWiredExtra) { - this.roomSpecialTypes.addExtra(interactionWiredExtra); - } else if (item instanceof InteractionBattleBanzaiTeleporter interactionBattleBanzaiTeleporter) { - this.roomSpecialTypes.addBanzaiTeleporter(interactionBattleBanzaiTeleporter); - } else if (item instanceof InteractionRoller interactionRoller) { - this.roomSpecialTypes.addRoller(interactionRoller); - } else if (item instanceof InteractionGameScoreboard interactionGameScoreboard) { - this.roomSpecialTypes.addGameScoreboard(interactionGameScoreboard); - } else if (item instanceof InteractionGameGate interactionGameGate) { - this.roomSpecialTypes.addGameGate(interactionGameGate); - } else if (item instanceof InteractionGameTimer interactionGameTimer) { - this.roomSpecialTypes.addGameTimer(interactionGameTimer); - } else if (item instanceof InteractionFreezeExitTile interactionFreezeExitTile) { - this.roomSpecialTypes.addFreezeExitTile(interactionFreezeExitTile); - } else if (item instanceof InteractionNest interactionNest) { - this.roomSpecialTypes.addNest(interactionNest); - } else if (item instanceof InteractionPetDrink interactionPetDrink) { - this.roomSpecialTypes.addPetDrink(interactionPetDrink); - } else if (item instanceof InteractionPetFood interactionPetFood) { - this.roomSpecialTypes.addPetFood(interactionPetFood); - } else if (item instanceof InteractionPetToy interactionPetToy) { - this.roomSpecialTypes.addPetToy(interactionPetToy); - } else if (item instanceof InteractionPetTree) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionPetTrampoline) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionMoodLight) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionPyramid) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionMusicDisc) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionBattleBanzaiSphere) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTalkingFurniture) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionWater) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionWaterItem) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionMuteArea) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionBuildArea) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTagPole) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTagField) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionJukeBox) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionPetBreedingNest) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionBlackHole) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionWiredHighscore) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionStickyPole) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof WiredBlob) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionTent) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionSnowboardSlope) { - this.roomSpecialTypes.addUndefined(item); - } else if (item instanceof InteractionFireworks) { - this.roomSpecialTypes.addUndefined(item); - } - - } - } - - public RoomItem getHabboItem(int id) { - if (this.roomItems == null || this.roomSpecialTypes == null) - return null; // room not loaded completely - - RoomItem item; - synchronized (this.roomItems) { - item = this.roomItems.get(id); - } - - if (item == null) - item = this.roomSpecialTypes.getBanzaiTeleporter(id); - - if (item == null) - item = this.roomSpecialTypes.getTrigger(id); - - if (item == null) - item = this.roomSpecialTypes.getEffect(id); - - if (item == null) - item = this.roomSpecialTypes.getCondition(id); - - if (item == null) - item = this.roomSpecialTypes.getGameGate(id); - - if (item == null) - item = this.roomSpecialTypes.getGameScorebord(id); - - if (item == null) - item = this.roomSpecialTypes.getGameTimer(id); - - if (item == null) - item = this.roomSpecialTypes.getFreezeExitTiles().get(id); - - if (item == null) - item = this.roomSpecialTypes.getRoller(id); - - if (item == null) - item = this.roomSpecialTypes.getNest(id); - - if (item == null) - item = this.roomSpecialTypes.getPetDrink(id); - - if (item == null) - item = this.roomSpecialTypes.getPetFood(id); - - return item; - } - - public void removeHabboItem(RoomItem item) { - if (item != null) { - - RoomItem i; - synchronized (this.roomItems) { - i = this.roomItems.remove(item.getId()); - } - - if (i != null) { - synchronized (this.furniOwnerCount) { - synchronized (this.furniOwnerNames) { - int count = this.furniOwnerCount.get(i.getOwnerId()); - - if (count > 1) - this.furniOwnerCount.put(i.getOwnerId(), count - 1); - else { - this.furniOwnerCount.remove(i.getOwnerId()); - this.furniOwnerNames.remove(i.getOwnerId()); - } - } - } - - if (item instanceof ICycleable) { - this.roomSpecialTypes.removeCycleTask((ICycleable) item); - } - - if (item instanceof InteractionBattleBanzaiTeleporter) { - this.roomSpecialTypes.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item); - } else if (item instanceof InteractionWiredTrigger) { - this.roomSpecialTypes.removeTrigger((InteractionWiredTrigger) item); - } else if (item instanceof InteractionWiredEffect) { - this.roomSpecialTypes.removeEffect((InteractionWiredEffect) item); - } else if (item instanceof InteractionWiredCondition) { - this.roomSpecialTypes.removeCondition((InteractionWiredCondition) item); - } else if (item instanceof InteractionWiredExtra) { - this.roomSpecialTypes.removeExtra((InteractionWiredExtra) item); - } else if (item instanceof InteractionRoller) { - this.roomSpecialTypes.removeRoller((InteractionRoller) item); - } else if (item instanceof InteractionGameScoreboard) { - this.roomSpecialTypes.removeScoreboard((InteractionGameScoreboard) item); - } else if (item instanceof InteractionGameGate) { - this.roomSpecialTypes.removeGameGate((InteractionGameGate) item); - } else if (item instanceof InteractionGameTimer) { - this.roomSpecialTypes.removeGameTimer((InteractionGameTimer) item); - } else if (item instanceof InteractionFreezeExitTile) { - this.roomSpecialTypes.removeFreezeExitTile((InteractionFreezeExitTile) item); - } else if (item instanceof InteractionNest) { - this.roomSpecialTypes.removeNest((InteractionNest) item); - } else if (item instanceof InteractionPetDrink) { - this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item); - } else if (item instanceof InteractionPetFood) { - this.roomSpecialTypes.removePetFood((InteractionPetFood) item); - } else if (item instanceof InteractionPetToy) { - this.roomSpecialTypes.removePetToy((InteractionPetToy) item); - } else if (item instanceof InteractionPetTree) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionPetTrampoline) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionMoodLight) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionPyramid) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionMusicDisc) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionBattleBanzaiSphere) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionTalkingFurniture) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionWaterItem) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionWater) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionMuteArea) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionTagPole) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionTagField) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionJukeBox) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionPetBreedingNest) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionBlackHole) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionWiredHighscore) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionStickyPole) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof WiredBlob) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionTent) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionSnowboardSlope) { - this.roomSpecialTypes.removeUndefined(item); - } else if (item instanceof InteractionBuildArea) { - this.roomSpecialTypes.removeUndefined(item); - } - } - } - } - - public List getFloorItems() { - return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getType() == FurnitureType.FLOOR).toList(); - } - - public List getWallItems() { - return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getType() == FurnitureType.WALL).toList(); - } - public List getPostItNotes() { return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); } @@ -2679,77 +2399,6 @@ public class Room implements Comparable, ISerialize, Runnable { return items.size(); } - public void ejectUserFurni(int userId) { - THashSet items = new THashSet<>(); - - TIntObjectIterator iterator = this.roomItems.iterator(); - - for (int i = this.roomItems.size(); i-- > 0; ) { - try { - iterator.advance(); - } catch (Exception e) { - break; - } - - if (iterator.value().getOwnerId() == userId) { - items.add(iterator.value()); - iterator.value().setRoomId(0); - } - } - - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - - if (habbo != null) { - habbo.getInventory().getItemsComponent().addItems(items); - habbo.getClient().sendResponse(new UnseenItemsComposer(items)); - } - - for (RoomItem i : items) { - this.getRoomItemManager().pickUpItem(i, null); - } - } - - public void ejectAllFurni() { - this.ejectAllFurni(null); - } - - public void ejectAllFurni(Habbo habbo) { - THashMap> userItemsMap = new THashMap<>(); - - synchronized (this.roomItems) { - TIntObjectIterator iterator = this.roomItems.iterator(); - - for (int i = this.roomItems.size(); i-- > 0; ) { - try { - iterator.advance(); - } catch (Exception e) { - break; - } - - if (habbo != null && iterator.value().getOwnerId() == habbo.getHabboInfo().getId()) - continue; - - if (iterator.value() instanceof InteractionPostIt) - continue; - - userItemsMap.computeIfAbsent(iterator.value().getOwnerId(), k -> new THashSet<>()).add(iterator.value()); - } - } - - for (Map.Entry> entrySet : userItemsMap.entrySet()) { - for (RoomItem i : entrySet.getValue()) { - this.getRoomItemManager().pickUpItem(i, null); - } - - Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey()); - - if (user != null) { - user.getInventory().getItemsComponent().addItems(entrySet.getValue()); - user.getClient().sendResponse(new UnseenItemsComposer(entrySet.getValue())); - } - } - } - public void refreshGuild(Guild guild) { if (guild.getRoomId() == this.roomInfo.getId()) { THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); @@ -2770,7 +2419,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (guild.getRoomId() == this.roomInfo.getId()) { TIntObjectIterator iterator = this.roomItems.iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) { + for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) { try { iterator.advance(); } catch (Exception e) { 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 04655e0e..96b7f61b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -115,6 +115,10 @@ public class RoomItemManager { } } + public RoomItem getRoomItemById(int itemId) { + return this.currentItems.get(itemId); + } + 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); @@ -131,7 +135,7 @@ public class RoomItemManager { } } - public void removeHabboItem(RoomItem item) { + public void removeRoomItem(RoomItem item) { if (item != null) { RoomItem i; @@ -222,23 +226,17 @@ public class RoomItemManager { 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()) { + } else if (item instanceof InteractionMoodLight && !this.getItemsOfType(InteractionMoodLight.class).isEmpty()) { return FurnitureMovementError.MAX_DIMMERS; - } - if (item instanceof InteractionJukeBox && !this.getItemsOfType(InteractionJukeBox.class).isEmpty()) { + } else if (item instanceof InteractionJukeBox && !this.getItemsOfType(InteractionJukeBox.class).isEmpty()) { return FurnitureMovementError.MAX_SOUNDFURNI; - } - - if (tile == null || tile.getState() == RoomTileState.INVALID) { + } else if (tile == null || tile.getState() == RoomTileState.INVALID) { return FurnitureMovementError.INVALID_MOVE; + } else if (this.room.getRoomRightsManager().hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { + return FurnitureMovementError.NONE; } rotation %= 8; - if (this.room.getRoomRightsManager().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()); @@ -252,6 +250,7 @@ public class RoomItemManager { } } + //TODO CHECK THIS SITUATION for (RoomItem area : this.getItemsOfType(InteractionBuildArea.class)) { if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) { return FurnitureMovementError.NONE; @@ -261,16 +260,17 @@ public class RoomItemManager { return FurnitureMovementError.NO_RIGHTS; } - public FurnitureMovementError placeFloorItemAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) { - FurnitureMovementError error = this.canPlaceFurnitureAt(item, owner, tile, rotation); + public FurnitureMovementError placeFloorItemAt(RoomItem item, RoomTile tile, int rotation, Habbo actor) { + FurnitureMovementError error = this.canPlaceFurnitureAt(item, actor, 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)); + FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, actor, tile)); if (event.isCancelled()) { return FurnitureMovementError.CANCEL_PLUGIN_PLACE; @@ -297,7 +297,7 @@ public class RoomItemManager { } if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { - FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height)); + FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); if (event.hasChangedHeight()) { height = event.getUpdatedHeight(); } @@ -325,7 +325,7 @@ public class RoomItemManager { return FurnitureMovementError.NONE; } - public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) { + public FurnitureMovementError placeWallItemAt(RoomItem item, String wallPosition, Habbo owner) { if (!(this.room.getRoomRightsManager().hasRights(owner) || this.room.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { return FurnitureMovementError.NO_RIGHTS; } @@ -351,20 +351,22 @@ public class RoomItemManager { return FurnitureMovementError.NONE; } - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) { - return moveFurniTo(item, tile, rotation, actor, true, true); + public FurnitureMovementError moveItemTo(RoomItem item, RoomTile targetTile, int rotation, Habbo actor) { + return moveItemTo(item, targetTile, rotation, actor, true, true); } - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { - return moveFurniTo(item, tile, rotation, actor, sendUpdates, true); - } + public FurnitureMovementError moveItemTo(RoomItem item, RoomTile targetTile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { + FurnitureMovementError error = this.canPlaceFurnitureAt(item, actor, targetTile, rotation); + + if(!error.equals(FurnitureMovementError.NONE)) { + return error; + } - public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { RoomTile oldLocation = this.room.getLayout().getTile(item.getX(), item.getY()); boolean pluginHelper = false; if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) { - FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile)); + FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, targetTile)); if (event.isCancelled()) { return FurnitureMovementError.CANCEL_PLUGIN_MOVE; } @@ -373,16 +375,22 @@ public class RoomItemManager { boolean magicTile = item instanceof InteractionStackHelper; - Optional stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); //Check if can be placed at new position - THashSet occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - THashSet newOccupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + THashSet occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + THashSet newOccupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + + FurnitureMovementError fits = this.furnitureFitsAt(targetTile, item, rotation, true); + + if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) { + return fits; + } RoomItem topItem = this.room.getTopItemAt(occupiedTiles, null); if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { - if (oldLocation != tile) { + if (oldLocation != targetTile) { for (RoomTile t : occupiedTiles) { RoomItem tileTopItem = this.room.getTopItemAt(t.getX(), t.getY()); if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || @@ -404,6 +412,7 @@ public class RoomItemManager { } List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); } @@ -419,6 +428,7 @@ public class RoomItemManager { if (oldRotation != rotation) { item.setRotation(rotation); + if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) { Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); @@ -445,7 +455,7 @@ public class RoomItemManager { } else if (item == topItem) { height = item.getZ(); } else { - height = this.room.getStackHeight(tile.getX(), tile.getY(), false, item); + height = this.room.getStackHeight(targetTile.getX(), targetTile.getY(), false, item); for (RoomTile til : occupiedTiles) { double sHeight = this.room.getStackHeight(til.getX(), til.getY(), false, item); if (sHeight > height) { @@ -454,9 +464,13 @@ public class RoomItemManager { } } - if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) + if (height > Room.MAXIMUM_FURNI_HEIGHT) { + return FurnitureMovementError.CANT_STACK; + } + + if (height < this.room.getLayout().getHeightAtSquare(targetTile.getX(), targetTile.getY())) { return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor + } if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); @@ -465,25 +479,31 @@ public class RoomItemManager { } } - if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK; - if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY())) - return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor + if (height > Room.MAXIMUM_FURNI_HEIGHT) { + return FurnitureMovementError.CANT_STACK; + } - item.setX(tile.getX()); - item.setY(tile.getY()); + if (height < this.room.getLayout().getHeightAtSquare(targetTile.getX(), targetTile.getY())) { + return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor + } + + item.setX(targetTile.getX()); + item.setY(targetTile.getY()); item.setZ(height); + if (magicTile) { - item.setZ(tile.getZ()); + item.setZ(targetTile.getZ()); item.setExtradata("" + item.getZ() * 100); } + if (item.getZ() > Room.MAXIMUM_FURNI_HEIGHT) { item.setZ(Room.MAXIMUM_FURNI_HEIGHT); } - //Update Furniture - item.onMove(this.room, oldLocation, tile); + item.onMove(this.room, oldLocation, targetTile); item.needsUpdate(true); + Emulator.getThreading().run(item); if (sendUpdates) { @@ -493,20 +513,15 @@ public class RoomItemManager { //Update old & new tiles occupiedTiles.removeAll(oldOccupiedTiles); occupiedTiles.addAll(oldOccupiedTiles); + this.room.updateTiles(occupiedTiles); //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.room.updateHabbosAt( - t.getX(), - t.getY(), - new ArrayList<>(this.room.getRoomUnitManager().getHabbosAt(t)) - /*.stream() - .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t) - .collect(Collectors.toCollection(THashSet::new))*/ - ); + this.room.updateHabbosAt(t.getX(), t.getY(), new ArrayList<>(this.room.getRoomUnitManager().getHabbosAt(t))); this.room.updateBotsAt(t.getX(), t.getY()); } + if (Emulator.getConfig().getBoolean("wired.place.under", false)) { for (RoomTile t : newOccupiedTiles) { for (Habbo h : this.room.getRoomUnitManager().getHabbosAt(t)) { @@ -518,6 +533,7 @@ public class RoomItemManager { } } } + return FurnitureMovementError.NONE; } @@ -533,7 +549,7 @@ public class RoomItemManager { return; } - this.removeHabboItem(item); + this.removeRoomItem(item); item.onPickUp(this.room); item.setRoomId(0); item.needsUpdate(true); @@ -578,32 +594,86 @@ public class RoomItemManager { this.pickUpItem(item, null); } - public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) { - if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) + public void ejectUserFurni(int userId) { + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); + HashSet userItems = this.currentItems.values().stream().filter(item -> item.getOwnerId() == userId).collect(Collectors.toCollection(HashSet::new)); + + if (habbo != null) { + habbo.getInventory().getItemsComponent().addItems(userItems); + habbo.getClient().sendResponse(new UnseenItemsComposer(userItems)); + } + + for (RoomItem i : userItems) { + this.pickUpItem(i, null); + } + } + + public void ejectAllFurni() { + this.ejectAllFurni(null); + } + + public void ejectAllFurni(Habbo habbo) { + ConcurrentHashMap> userItemsMap = new ConcurrentHashMap<>(); + + for (RoomItem item : this.currentItems.values()) { + if ((habbo != null && item.getOwnerId() == habbo.getHabboInfo().getId()) || item instanceof InteractionPostIt) { + continue; + } + + userItemsMap.computeIfAbsent(item.getOwnerId(), k -> new HashSet<>()).add(item); + } + + for (Map.Entry> entrySet : userItemsMap.entrySet()) { + for (RoomItem i : entrySet.getValue()) { + this.pickUpItem(i, null); + } + + Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey()); + + if (user != null) { + user.getInventory().getItemsComponent().addItems(entrySet.getValue()); + user.getClient().sendResponse(new UnseenItemsComposer(entrySet.getValue())); + } + } + } + + public FurnitureMovementError furnitureFitsAt(RoomTile targetTile, RoomItem item, int rotation, boolean checkForUnits) { + RoomLayout layout = this.room.getLayout(); + boolean wiredPlaceUnder = Emulator.getConfig().getBoolean("wired.place.under", false); + Item baseItem = item.getBaseItem(); + + if (!layout.fitsOnMap(targetTile, baseItem.getWidth(), baseItem.getLength(), rotation)) { return FurnitureMovementError.INVALID_MOVE; + } - if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE; + if (item instanceof InteractionStackHelper) { + return FurnitureMovementError.NONE; + } + THashSet occupiedTiles = this.room.getLayout().getTilesAt(targetTile, baseItem.getWidth(), baseItem.getLength(), rotation); - 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 (t.getState() == RoomTileState.INVALID) { + return FurnitureMovementError.INVALID_MOVE; + } + + if (!wiredPlaceUnder || (!item.isWalkable() && !baseItem.allowSit() && !baseItem.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; + if (this.room.getRoomUnitManager().hasHabbosAt(t)) { + return FurnitureMovementError.TILE_HAS_HABBOS; + } else if (this.room.getRoomUnitManager().hasBotsAt(t)) { + return FurnitureMovementError.TILE_HAS_BOTS; + } else if (this.room.getRoomUnitManager().hasPetsAt(t)) { + return FurnitureMovementError.TILE_HAS_PETS; + } } } } - Optional stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); @@ -612,7 +682,7 @@ public class RoomItemManager { 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))) { + if ((stackHelper.isPresent() && baseItem.getInteractionType().getType() == InteractionWater.class) || topItem != null && (topItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (baseItem.getInteractionType().getType() == InteractionWater.class || baseItem.getInteractionType().getType() != InteractionWaterItem.class))) { return FurnitureMovementError.CANT_STACK; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayoutManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayoutManager.java new file mode 100644 index 00000000..c6a4c36d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayoutManager.java @@ -0,0 +1,4 @@ +package com.eu.habbo.habbohotel.rooms; + +public class RoomLayoutManager { +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 71476116..82e4da6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -735,7 +735,7 @@ public class RoomManager { final THashSet floorItems = new THashSet<>(); - THashSet allFloorItems = new THashSet<>(room.getFloorItems()); + THashSet allFloorItems = new THashSet<>(room.getRoomItemManager().getFloorItems().values()); if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) { RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems)); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java index cb465298..d69e5f17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -142,7 +142,7 @@ public class RoomRightsManager { } if (habbo != null) { - this.room.ejectUserFurni(habbo.getHabboInfo().getId()); + this.room.getRoomItemManager().ejectUserFurni(habbo.getHabboInfo().getId()); habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); this.refreshRightsForHabbo(habbo); @@ -151,7 +151,7 @@ public class RoomRightsManager { public void removeAllRights() { for (int userId : this.rights) { - this.room.ejectUserFurni(userId); + this.room.getRoomItemManager().ejectUserFurni(userId); } this.rights.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 4d7d9020..6033a796 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; import java.sql.*; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; @@ -221,14 +222,14 @@ public class RoomTrade { log.error("Caught SQL exception", e); } - THashSet itemsUserOne = new THashSet<>(userOne.getItems()); - THashSet itemsUserTwo = new THashSet<>(userTwo.getItems()); + HashSet itemsUserOne = new HashSet<>(userOne.getItems()); + HashSet itemsUserTwo = new HashSet<>(userTwo.getItems()); userOne.clearItems(); userTwo.clearItems(); int creditsForUserTwo = 0; - THashSet creditFurniUserOne = new THashSet<>(); + HashSet creditFurniUserOne = new HashSet<>(); for (RoomItem item : itemsUserOne) { int worth = RoomTrade.getCreditsByItem(item); if (worth > 0) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java index 309b3087..339757af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java @@ -1,15 +1,17 @@ package com.eu.habbo.habbohotel.rooms; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import gnu.trove.set.hash.THashSet; +import com.eu.habbo.habbohotel.users.Habbo; import lombok.Getter; import lombok.Setter; +import java.util.HashSet; + public class RoomTradeUser { @Getter private final Habbo habbo; - private final THashSet items; + @Getter + private final HashSet items; @Setter @Getter private int userId; @@ -28,7 +30,7 @@ public class RoomTradeUser { this.accepted = false; this.confirmed = false; - this.items = new THashSet<>(); + this.items = new HashSet<>(); } public void confirm() { @@ -49,10 +51,6 @@ public class RoomTradeUser { return null; } - public THashSet getItems() { - return this.items; - } - public void putItemsIntoInventory() { this.habbo.getInventory().getItemsComponent().addItems(this.items); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index cd55ed13..4a8084de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -112,7 +112,6 @@ public abstract class RoomUnit extends RoomEntity { //RoomHabbo private int idleTicks; @Getter - @Setter private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private final THashSet overridableTiles; 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 18c2bc3d..25c2c215 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -28,7 +28,6 @@ import com.eu.habbo.plugin.events.users.UserGetIPAddressEvent; import com.eu.habbo.plugin.events.users.UserPointsEvent; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; -import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -333,13 +332,6 @@ public class Habbo extends Unit implements Runnable { } - public void addFurniture(THashSet items) { - this.inventory.getItemsComponent().addItems(items); - this.client.sendResponse(new UnseenItemsComposer(items)); - this.client.sendResponse(new FurniListInvalidateComposer()); - } - - public void removeFurniture(RoomItem item) { this.inventory.getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getId())); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index 5b82df81..f6d1ec1f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.users.inventory; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInventory; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.plugin.events.inventory.InventoryItemAddedEvent; import com.eu.habbo.plugin.events.inventory.InventoryItemRemovedEvent; import com.eu.habbo.plugin.events.inventory.InventoryItemsAddedEvent; @@ -21,6 +21,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashSet; import java.util.NoSuchElementException; @Slf4j @@ -79,7 +80,7 @@ public class ItemsComponent { } } - public void addItems(THashSet items) { + public void addItems(HashSet items) { InventoryItemsAddedEvent event = new InventoryItemsAddedEvent(this.inventory, items); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) { return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index 932d65fe..613c6c33 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -23,7 +23,8 @@ public class PresentOpenEvent extends MessageHandler { return; if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - RoomItem item = room.getHabboItem(this.packet.readInt()); + int id = this.packet.readInt(); + RoomItem item = room.getRoomItemManager().getRoomItemById(id); if (item == null) return; @@ -50,7 +51,7 @@ public class PresentOpenEvent extends MessageHandler { } } room.sendComposer(new RemoveFloorItemComposer(item).compose()); - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java index f56aaa20..14abb152 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftEvent.java @@ -21,7 +21,7 @@ public class CraftEvent extends MessageHandler { @Override public void handle() { int craftingTable = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(craftingTable); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(craftingTable); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); CraftingRecipe recipe = altar.getRecipe(this.packet.readString()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java index d20db53d..29b5143a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftSecretEvent.java @@ -25,7 +25,7 @@ public class CraftSecretEvent extends MessageHandler { int altarId = this.packet.readInt(); int count = this.packet.readInt(); - RoomItem craftingAltar = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(altarId); + RoomItem craftingAltar = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(altarId); if (craftingAltar != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(craftingAltar.getBaseItem()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java index a87b6e17..85515bfd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipeEvent.java @@ -10,7 +10,7 @@ public class GetCraftingRecipeEvent extends MessageHandler { @Override public void handle() { int itemId = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item != null) { CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java index ecd3605f..fd8044c1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/GetCraftingRecipesAvailableEvent.java @@ -16,7 +16,7 @@ public class GetCraftingRecipesAvailableEvent extends MessageHandler { public void handle() { int altarId = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(altarId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(altarId); CraftingAltar altar = Emulator.getGameEnvironment().getCraftingManager().getAltar(item.getBaseItem()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java index 6917a1f8..923d93d2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildFurniContextMenuInfoEvent.java @@ -13,7 +13,7 @@ public class GetGuildFurniContextMenuInfoEvent extends MessageHandler { int guildId = this.packet.readInt(); if (this.client.getHabbo().getRoomUnit().getRoom() != null) { - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (item != null && guild != null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java index e4181b66..50e1b524 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java @@ -57,7 +57,7 @@ public class KickMemberEvent extends MessageHandler { if (room != null) { if (room.getRoomInfo().getGuild().getId() == guildId) { - room.ejectUserFurni(userId); + room.getRoomItemManager().ejectUserFurni(userId); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java index ee011d2f..71c0de71 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java @@ -36,7 +36,7 @@ public class CallForHelpFromPhotoEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionExternalImage)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index ac8bb7f1..e65c8dff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -39,8 +39,8 @@ public class DeleteRoomEvent extends MessageHandler { return; } - room.ejectAllFurni(); - room.ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); + room.getRoomItemManager().ejectAllFurni(); + room.getRoomItemManager().ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomBots().values()); for (Bot bot : bots) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index 2facfd82..a32d7ddf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -17,7 +17,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { return; if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index e58998bf..b492b970 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -35,7 +35,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { String text = this.packet.readString(); Room room = this.client.getHabbo().getRoomUnit().getRoom(); - RoomItem sticky = room.getHabboItem(itemId); + RoomItem sticky = room.getRoomItemManager().getRoomItemById(itemId); if (sticky != null && sticky.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { sticky.setOwnerId(room.getRoomInfo().getOwnerInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java index f83c40a9..42183db6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java @@ -23,7 +23,7 @@ public class CreditFurniRedeemEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getOwnerId()) { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); @@ -93,10 +93,10 @@ public class CreditFurniRedeemEvent extends MessageHandler { if (furniRedeemEvent.amount < 1) return; - if (room.getHabboItem(item.getId()) == null) // plugins may cause a lag between which time the item can be removed from the room + if (room.getRoomItemManager().getRoomItemById(item.getId()) == null) // plugins may cause a lag between which time the item can be removed from the room return; - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item).compose()); RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); t.setStackHeight(room.getStackHeight(item.getX(), item.getY(), false)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index 650cd1e2..87ce4df9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -27,7 +27,7 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { int itemId = this.packet.readInt(); if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { if (item instanceof InteractionClothing) { @@ -37,7 +37,7 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) { item.setRoomId(0); RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getX(), item.getY()); - this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java index b24375ff..71379105 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java @@ -18,7 +18,7 @@ public class DiceOffEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item != null) { if (item instanceof InteractionDice) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java index c55d66a7..ebab2d5a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java @@ -11,7 +11,7 @@ public class EnterOneWayDoorEvent extends MessageHandler { return; int itemId = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java index 85d8c969..83599fa7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/GetItemDataEvent.java @@ -14,7 +14,7 @@ public class GetItemDataEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPostIt) { this.client.sendResponse(new ItemDataUpdateMessageComposer((InteractionPostIt) item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java index ecb89fd5..bc81c26d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveObjectEvent.java @@ -14,26 +14,26 @@ public class MoveObjectEvent extends MessageHandler { public void handle() { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } - int furniId = this.packet.readInt(); - RoomItem item = room.getHabboItem(furniId); - if (item == null) return; + int itemId = this.packet.readInt(); + + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); + + if (item == null) { + return; + } int x = this.packet.readInt(); int y = this.packet.readInt(); int rotation = this.packet.readInt(); + RoomTile tile = room.getLayout().getTile((short) x, (short) y); - FurnitureMovementError error = room.getRoomItemManager().canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); - if (!error.equals(FurnitureMovementError.NONE)) { - this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); - this.client.sendResponse(new ObjectUpdateMessageComposer(item)); - return; - } + FurnitureMovementError error = room.getRoomItemManager().moveItemTo(item, tile, rotation, this.client.getHabbo()); - error = room.getRoomItemManager().moveFurniTo(item, tile, rotation, this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); this.client.sendResponse(new ObjectUpdateMessageComposer(item)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index 263a213a..4c80574a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -30,7 +30,7 @@ public class MoveWallItemEvent extends MessageHandler { if (itemId <= 0 || wallPosition.length() <= 13) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index fd43b788..afb2ac66 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -18,7 +18,7 @@ public class PickupObjectEvent extends MessageHandler { return; } - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null || item instanceof InteractionPostIt) { return; 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 32d35fd9..988fa148 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 @@ -72,7 +72,7 @@ public class PlaceObjectEvent extends MessageHandler { RoomItem rentSpace = null; if (this.client.getHabbo().getHabboStats().isRentingSpace()) { - rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId()); + rentSpace = room.getRoomItemManager().getRoomItemById(this.client.getHabbo().getHabboStats().getRentedItemId()); } if ((rentSpace != null || buildArea != null) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) { @@ -101,7 +101,7 @@ public class PlaceObjectEvent extends MessageHandler { } } else { - FurnitureMovementError error = room.getRoomItemManager().placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); + FurnitureMovementError error = room.getRoomItemManager().placeWallItemAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo()); if (!error.equals(FurnitureMovementError.NONE)) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode())); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index 9463ab22..b2c5a382 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -27,7 +27,7 @@ public class PlacePostItEvent extends MessageHandler { if (item instanceof InteractionPostIt) { if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) { - room.addHabboItem(item); + room.getRoomItemManager().addRoomItem(item); item.setExtradata("FFFF33"); item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); item.setWallPosition(location); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index d2758f8f..8b6ddd47 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -20,12 +20,12 @@ public class RemoveItemEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { item.setRoomId(0); - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new ItemRemoveMessageComposer(item).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java index 6fbb679e..f2fec1cc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetClothingChangeDataEvent.java @@ -13,7 +13,8 @@ public class SetClothingChangeDataEvent extends MessageHandler { if (room == null || this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) return; - RoomItem item = room.getHabboItem(this.packet.readInt()); + int id = this.packet.readInt(); + RoomItem item = room.getRoomItemManager().getRoomItemById(id); if (!(item instanceof InteractionFootballGate)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 076cc132..48f1b97c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -18,7 +18,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { return; if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() || this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionStackHelper) { Room room = this.client.getHabbo().getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index 744683da..8739eb13 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -34,7 +34,7 @@ public class SetItemDataEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionPostIt)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java index 19e632ab..5270f139 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java @@ -15,7 +15,8 @@ public class SetMannequinFigureEvent extends MessageHandler { if (room == null || !room.getRoomInfo().isRoomOwner(habbo)) return; - RoomItem item = room.getHabboItem(this.packet.readInt()); + int id = this.packet.readInt(); + RoomItem item = room.getRoomItemManager().getRoomItemById(id); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java index c43b5f3d..77d17e51 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java @@ -12,7 +12,8 @@ public class SetMannequinNameEvent extends MessageHandler { if (room == null || !room.getRoomInfo().isRoomOwner(this.client.getHabbo())) return; - RoomItem item = room.getHabboItem(this.packet.readInt()); + int id = this.packet.readInt(); + RoomItem item = room.getRoomItemManager().getRoomItemById(id); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index e37204cd..75555eeb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -19,7 +19,8 @@ public class SetObjectDataEvent extends MessageHandler { if (!room.getRoomRightsManager().hasRights(this.client.getHabbo())) return; - RoomItem item = room.getHabboItem(this.packet.readInt()); + int id = this.packet.readInt(); + RoomItem item = room.getRoomItemManager().getRoomItemById(id); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java index 89044cc3..2055f5b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetRandomStateEvent.java @@ -17,7 +17,7 @@ public class SetRandomStateEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionRandomState randomStateItem)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java index 93558204..a753cfed 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SpinWheelOfFortuneEvent.java @@ -15,7 +15,7 @@ public class SpinWheelOfFortuneEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionColorWheel) { item.onClick(this.client, room, null); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java index 7cd7a3aa..da54a9e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java @@ -18,7 +18,7 @@ public class ThrowDiceEvent extends MessageHandler { return; } - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item != null) { if (item instanceof InteractionDice || item instanceof InteractionSpinningBottle) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index b2acd4df..6459545e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -34,7 +34,7 @@ public class UseFurnitureEvent extends MessageHandler { int itemId = this.packet.readInt(); int state = this.packet.readInt(); - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null || item instanceof InteractionDice || item instanceof InteractionSpinningBottle) return; @@ -71,7 +71,7 @@ public class UseFurnitureEvent extends MessageHandler { MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); room.getRoomUnitManager().placePet(pet, room, item.getX(), item.getY(), item.getZ()); pet.cycle(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java index 2ae4f89e..882351b3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java @@ -18,7 +18,7 @@ public class UseWallItemEvent extends MessageHandler { int itemId = this.packet.readInt(); int state = this.packet.readInt(); - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java index 62fd5e46..a8950b2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/lovelock/FriendFurniConfirmLockEvent.java @@ -16,7 +16,7 @@ public class FriendFurniConfirmLockEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java index b7df07a5..31521de5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java @@ -16,7 +16,7 @@ public class RentableSpaceCancelRentEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java index 5c1b2cd3..4e300bd2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceRentEvent.java @@ -15,7 +15,7 @@ public class RentableSpaceRentEvent extends MessageHandler { if (room == null) return; - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionRentableSpace)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java index 457f1714..e373ea29 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java @@ -46,7 +46,7 @@ public class ControlYoutubeDisplayPlaybackEvent extends YoutubeEvent { if(!validate(habbo)) return; Room room = habbo.getRoomUnit().getRoom(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionYoutubeTV tv)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java index 0da80f51..ceb1e91c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/GetYoutubeDisplayStatusEvent.java @@ -20,7 +20,7 @@ public class GetYoutubeDisplayStatusEvent extends MessageHandler { int itemId = this.packet.readInt(); if (this.client.getHabbo().getRoomUnit().getRoom() != null) { - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionYoutubeTV tv) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java index d14a1e33..9f60330b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java @@ -24,7 +24,7 @@ public class SetYoutubeDisplayPlaylistEvent extends YoutubeEvent { Room room = habbo.getRoomUnit().getRoom(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (!(item instanceof InteractionYoutubeTV)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java index a31733ad..a6532b0e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CancelPetBreedingEvent.java @@ -9,7 +9,7 @@ public class CancelPetBreedingEvent extends MessageHandler { public void handle() { int itemId = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPetBreedingNest) { ((InteractionPetBreedingNest) item).stopBreeding(this.client.getHabbo()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java index 816225f6..6682fa31 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java @@ -37,7 +37,7 @@ public class CompostPlantEvent extends MessageHandler { compost.setY(pet.getRoomUnit().getCurrentPosition().getY()); compost.setZ(pet.getRoomUnit().getCurrentZ()); compost.setRotation(pet.getRoomUnit().getBodyRotation().getValue()); - room.addHabboItem(compost); + room.getRoomItemManager().addRoomItem(compost); room.sendComposer(new ObjectAddMessageComposer(compost, this.client.getHabbo().getHabboInfo().getUsername()).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java index fa412627..d5023547 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java @@ -13,7 +13,7 @@ public class ConfirmPetBreedingEvent extends MessageHandler { int petOneId = this.packet.readInt(); int petTwoId = this.packet.readInt(); - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPetBreedingNest) { ((InteractionPetBreedingNest) item).breed(this.client.getHabbo(), name); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 692bdfa3..6ee20822 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -24,7 +24,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { if (room == null) return; - RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getHabboItem(itemId); + RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); if (item == null) return; @@ -83,7 +83,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { Emulator.getThreading().run(pet); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose()); - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); item.setRoomId(0); Emulator.getGameEnvironment().getItemManager().deleteItem(item); @@ -96,7 +96,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev"); pet.setPacketUpdate(true); - this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); @@ -112,7 +112,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { pet.cycle(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "spd"); pet.getRoomUnit().setStatus(RoomUnitStatus.fromString("grw" + ((MonsterplantPet) pet).getGrowthStage()), ""); - this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); @@ -134,7 +134,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "reb"); - this.client.getHabbo().getRoomUnit().getRoom().removeHabboItem(item); + this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index 7671d60e..4dfb082d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -21,7 +21,7 @@ public class OpenPetPackageEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - RoomItem item = room.getHabboItem(itemId); + RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { if (!name.matches("^[a-zA-Z0-9]*$")) { this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", ""))); @@ -61,7 +61,7 @@ public class OpenPetPackageEvent extends MessageHandler { pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getX(), item.getY())); pet.getRoomUnit().setCurrentZ(item.getZ()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); - room.removeHabboItem(item); + room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item).compose()); RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java index 428089c9..40407dfd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java @@ -26,7 +26,7 @@ public class SignEvent extends MessageHandler { if(signId <= 10) { int userId = this.client.getHabbo().getHabboInfo().getId(); - for (RoomItem item : room.getFloorItems()) { + for (RoomItem item : room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionVoteCounter) { ((InteractionVoteCounter)item).vote(room, userId, signId); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 0ef83ca4..4daf1e0e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -62,7 +62,7 @@ public class ApplySnapshotEvent extends MessageHandler { // Try to apply the set settings to each item wired.getMatchSettings().forEach(setting -> { - RoomItem matchItem = room.getHabboItem(setting.getItem_id()); + RoomItem matchItem = room.getRoomItemManager().getRoomItemById(setting.getItem_id()); // Match state if (wired.shouldMatchState() && matchItem.allowWiredResetState() && !setting.getState().equals(" ") && !matchItem.getExtradata().equals(setting.getState())) { @@ -76,7 +76,7 @@ public class ApplySnapshotEvent extends MessageHandler { // Match Position & Rotation if (wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { if (matchItem.getRotation() != setting.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) { - room.getRoomItemManager().moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true, true); + room.getRoomItemManager().moveItemTo(matchItem, oldLocation, setting.getRotation(), null, true, true); } } else if (wired.shouldMatchPosition()) { boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.getRotation(); @@ -85,7 +85,7 @@ public class ApplySnapshotEvent extends MessageHandler { if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { boolean sendUpdates = !slideAnimation; - if (room.getRoomItemManager().moveFurniTo(matchItem, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE && slideAnimation) { + if (room.getRoomItemManager().moveItemTo(matchItem, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE && slideAnimation) { room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java index 2f7313ef..b5116f3b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UnseenItemsComposer.java @@ -4,19 +4,19 @@ import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.set.hash.THashSet; +import java.util.HashSet; import java.util.List; import java.util.Map; public class UnseenItemsComposer extends MessageComposer { - private THashSet itemsList; + private HashSet itemsList; private RoomItem item; private int[] ids; private AddHabboItemCategory category; private Map> entries; - public UnseenItemsComposer(THashSet itemsList) { + public UnseenItemsComposer(HashSet itemsList) { this.itemsList = itemsList; this.category = AddHabboItemCategory.OWNED_FURNI; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java index 64ab747a..cfefa0e5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsComposer.java @@ -10,7 +10,7 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import lombok.AllArgsConstructor; -import java.util.List; +import java.util.Collection; import java.util.Map; import java.util.NoSuchElementException; @@ -18,7 +18,6 @@ import java.util.NoSuchElementException; public class ItemsComposer extends MessageComposer { private final Room room; - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.itemsComposer); @@ -42,7 +41,7 @@ public class ItemsComposer extends MessageComposer { this.response.appendString(set.getValue()); } - List items = this.room.getWallItems(); + Collection items = this.room.getRoomItemManager().getWallItems().values(); this.response.appendInt(items.size()); for (RoomItem item : items) { diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java index 4bf32cfd..22e5b667 100644 --- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java @@ -1,13 +1,14 @@ package com.eu.habbo.plugin.events.inventory; -import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import gnu.trove.set.hash.THashSet; +import com.eu.habbo.habbohotel.users.HabboInventory; + +import java.util.HashSet; public class InventoryItemsAddedEvent extends InventoryEvent { - public final THashSet items; + public final HashSet items; - public InventoryItemsAddedEvent(HabboInventory inventory, THashSet items) { + public InventoryItemsAddedEvent(HabboInventory inventory, HashSet items) { super(inventory); this.items = items; } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java index df686a54..eff807d8 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogFurnitureBoughtEvent.java @@ -1,16 +1,17 @@ package com.eu.habbo.plugin.events.users.catalog; import com.eu.habbo.habbohotel.catalog.CatalogItem; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import gnu.trove.set.hash.THashSet; +import com.eu.habbo.habbohotel.users.Habbo; + +import java.util.HashSet; public class UserCatalogFurnitureBoughtEvent extends UserCatalogEvent { - public final THashSet furniture; + public final HashSet furniture; - public UserCatalogFurnitureBoughtEvent(Habbo habbo, CatalogItem catalogItem, THashSet furniture) { + public UserCatalogFurnitureBoughtEvent(Habbo habbo, CatalogItem catalogItem, HashSet furniture) { super(habbo, catalogItem); this.furniture = furniture; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java index 1895d858..c7aefcc2 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/catalog/UserCatalogItemPurchasedEvent.java @@ -1,23 +1,23 @@ package com.eu.habbo.plugin.events.users.catalog; import com.eu.habbo.habbohotel.catalog.CatalogItem; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import gnu.trove.set.hash.THashSet; +import com.eu.habbo.habbohotel.users.Habbo; import lombok.Getter; +import java.util.HashSet; import java.util.List; @Getter public class UserCatalogItemPurchasedEvent extends UserCatalogEvent { - public final THashSet itemsList; + public final HashSet itemsList; private final int totalCredits; private final int totalPoints; private final List badges; - public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, THashSet itemsList, int totalCredits, int totalPoints, List badges) { + public UserCatalogItemPurchasedEvent(Habbo habbo, CatalogItem catalogItem, HashSet itemsList, int totalCredits, int totalPoints, List badges) { super(habbo, catalogItem); this.itemsList = itemsList; diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index c16b7415..81dffe91 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -7,9 +7,10 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; -import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; +import java.util.HashSet; + @AllArgsConstructor public class ClearRentedSpace implements Runnable { private final InteractionRentableSpace item; @@ -17,7 +18,7 @@ public class ClearRentedSpace implements Runnable { @Override public void run() { - THashSet items = new THashSet<>(); + HashSet items = new HashSet<>(); for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { for (RoomItem i : this.room.getItemsAt(t)) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index 70eae5cf..237d4eea 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -29,7 +29,7 @@ public class CrackableExplode implements Runnable { } if (!this.habboItem.resetable()) { - this.room.removeHabboItem(this.habboItem); + this.room.getRoomItemManager().removeRoomItem(this.habboItem); this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose()); this.habboItem.setRoomId(0); Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem); @@ -54,7 +54,7 @@ public class CrackableExplode implements Runnable { newItem.setZ(this.room.getStackHeight(this.x, this.y, false)); newItem.setRoomId(this.room.getRoomInfo().getId()); newItem.needsUpdate(true); - this.room.addHabboItem(newItem); + this.room.getRoomItemManager().addRoomItem(newItem); this.room.updateItem(newItem); this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerId())).compose()); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 7abe486c..710c954f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -10,14 +10,10 @@ import com.eu.habbo.messages.outgoing.inventory.FurniListAddOrUpdateComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.PresentOpenedMessageComposer; -import gnu.trove.set.hash.THashSet; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Slf4j @AllArgsConstructor @@ -32,7 +28,7 @@ public class OpenGift implements Runnable { try { RoomItem inside = null; - THashSet items = ((InteractionGift) this.item).loadItems(); + HashSet items = ((InteractionGift) this.item).loadItems(); for (RoomItem i : items) { if (inside == null) inside = i; diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java index dba130aa..85e8fe8d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java @@ -43,7 +43,7 @@ public class PetEatAction implements Runnable { if (this.food != null && Integer.parseInt(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.food.getId()), 500); if (this.pet.getRoom() != null) { - this.pet.getRoom().removeHabboItem(this.food); + this.pet.getRoom().getRoomItemManager().removeRoomItem(this.food); this.pet.getRoom().sendComposer(new RemoveFloorItemComposer(this.food, true).compose()); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java index 13ac670f..d7eb4e2b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -19,7 +19,7 @@ class RemoveFloorItemTask implements Runnable { return; RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY()); - this.room.removeHabboItem(this.item); + this.room.getRoomItemManager().removeRoomItem(this.item); this.room.updateTile(tile); this.room.sendComposer(new RemoveFloorItemComposer(this.item, true).compose()); this.room.sendComposer(new HeightMapUpdateMessageComposer(this.item.getX(), this.item.getY(), tile.getZ(), tile.relativeHeight()).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index 7f42f831..2752003b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -51,14 +51,14 @@ class TeleportInteraction extends Thread { if (data.length == 2 && data[0] != 0) { if (this.room.getRoomInfo().getId() == data[0]) { this.targetRoom = this.room; - this.teleportTwo = this.room.getHabboItem(data[1]); + this.teleportTwo = this.room.getRoomItemManager().getRoomItemById(data[1]); if (this.teleportTwo == null) { this.teleportTwo = this.teleportOne; } } else { this.targetRoom = Emulator.getGameEnvironment().getRoomManager().getRoom(data[0]); - this.teleportTwo = this.targetRoom.getHabboItem(data[1]); + this.teleportTwo = this.targetRoom.getRoomItemManager().getRoomItemById(data[1]); } } else { this.targetRoom = this.room; diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java index 247d4c26..84335194 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java @@ -32,7 +32,7 @@ class HopperActionThree implements Runnable { Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getRoomInfo().getId(), "", false); } - targetTeleport = targetRoom.getHabboItem(this.targetItemId); + targetTeleport = targetRoom.getRoomItemManager().getRoomItemById(this.targetItemId); if (targetTeleport == null) { this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 38b3e68e..dde2cf2a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -38,7 +38,8 @@ class TeleportActionThree implements Runnable { targetRoom.loadData(); } - targetTeleport = targetRoom.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); + int id = ((InteractionTeleport) this.currentTeleport).getTargetId(); + targetTeleport = targetRoom.getRoomItemManager().getRoomItemById(id); if (targetTeleport == null) { Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 0); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index b86acdd0..fbdc1c36 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -41,7 +41,8 @@ class TeleportActionTwo implements Runnable { this.room.sendComposer(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); if (((InteractionTeleport) this.currentTeleport).getTargetRoomId() > 0 && ((InteractionTeleport) this.currentTeleport).getTargetId() > 0) { - RoomItem item = this.room.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); + int id = ((InteractionTeleport) this.currentTeleport).getTargetId(); + RoomItem item = this.room.getRoomItemManager().getRoomItemById(id); if (item == null) { ((InteractionTeleport) this.currentTeleport).setTargetRoomId(0); ((InteractionTeleport) this.currentTeleport).setTargetId(0); From b80f3da2894916a438be934b14df6043fa9212f4 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 22 Jul 2023 21:42:41 -0500 Subject: [PATCH 26/42] Room.java clean-up --- .../eu/habbo/habbohotel/bots/BotManager.java | 4 +- .../commands/list/CoordsCommand.java | 4 +- .../battlebanzai/BattleBanzaiGameTeam.java | 2 +- .../habbohotel/games/freeze/FreezeGame.java | 2 +- .../games/freeze/FreezeGameTeam.java | 2 +- .../habbo/habbohotel/games/tag/TagGame.java | 4 +- .../habbohotel/games/wired/WiredGame.java | 2 +- .../interactions/InteractionBuildArea.java | 6 +- .../interactions/InteractionDefault.java | 5 +- .../interactions/InteractionGymEquipment.java | 2 +- .../interactions/InteractionMultiHeight.java | 2 +- .../interactions/InteractionObstacle.java | 19 +- .../interactions/InteractionPuzzleBox.java | 5 +- .../InteractionRentableSpace.java | 2 +- .../items/interactions/InteractionWater.java | 2 +- .../interactions/InteractionWaterItem.java | 3 +- .../InteractionBattleBanzaiPuck.java | 4 +- .../games/football/InteractionFootball.java | 10 +- .../games/freeze/InteractionFreezeBlock.java | 4 +- .../totems/InteractionTotemHead.java | 2 +- .../totems/InteractionTotemLegs.java | 2 +- .../totems/InteractionTotemPlanet.java | 4 +- .../WiredConditionFurniHaveFurni.java | 4 +- .../WiredConditionNotFurniHaveFurni.java | 4 +- .../WiredConditionTriggerOnFurni.java | 2 +- .../wired/effects/WiredEffectBotTeleport.java | 1 - .../effects/WiredEffectMoveFurniTowards.java | 2 +- .../wired/effects/WiredEffectTeleport.java | 2 +- .../wired/effects/WiredEffectWhisper.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 354 +++--------------- .../habbohotel/rooms/RoomItemManager.java | 219 ++++++++++- .../habbo/habbohotel/rooms/RoomManager.java | 4 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 61 ++- .../habbohotel/rooms/RoomUnitManager.java | 2 +- .../rooms/entities/IRoomEntity.java | 2 - .../habbohotel/rooms/entities/RoomEntity.java | 28 +- .../rooms/entities/items/RoomItem.java | 4 +- .../rooms/entities/units/RoomUnit.java | 40 +- .../entities/units/types/RoomAvatar.java | 26 +- .../rooms/entities/units/types/RoomHabbo.java | 36 +- .../rooms/entities/units/types/RoomPet.java | 6 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 2 +- .../habbo/habbohotel/wired/WiredHandler.java | 2 +- .../UpdateFloorPropertiesEvent.java | 4 +- .../rooms/users/AvatarExpressionEvent.java | 6 +- .../rooms/users/ChangePostureEvent.java | 2 +- .../incoming/rooms/users/DanceEvent.java | 2 +- .../rooms/users/DropCarryItemEvent.java | 2 +- .../incoming/rooms/users/LookToEvent.java | 18 +- .../incoming/rooms/users/MoveAvatarEvent.java | 43 +-- .../incoming/rooms/users/SignEvent.java | 2 +- .../rooms/users/RoomUnitOnRollerComposer.java | 6 +- .../rooms/users/SleepMessageComposer.java | 8 +- .../runnables/BanzaiRandomTeleport.java | 4 +- .../threading/runnables/ClearRentedSpace.java | 2 +- .../threading/runnables/RoomTrashing.java | 12 +- .../threading/runnables/RoomUnitTeleport.java | 4 +- .../freeze/FreezeHandleSnowballExplosion.java | 2 +- .../teleport/TeleportActionFive.java | 2 +- 59 files changed, 490 insertions(+), 524 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 53261255..de953f17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -131,7 +131,7 @@ public class BotManager { RoomBot roomBot = bot.getRoomUnit(); roomBot.setRotation(RoomRotation.SOUTH); roomBot.setLocation(location); - double stackHeight = room.getTopHeightAt(location.getX(), location.getY()); + double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY()); roomBot.setPreviousLocationZ(stackHeight); roomBot.setCurrentZ(stackHeight); roomBot.setRoom(room); @@ -150,7 +150,7 @@ public class BotManager { habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); bot.onPlace(habbo, room); - RoomItem topItem = room.getTopItemAt(location.getX(), location.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(location.getX(), location.getY()); if (topItem != null) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java index 0cb80a4c..09c043bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java @@ -26,8 +26,8 @@ public class CoordsCommand extends Command { "Tile State: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getState().name() + "\r" + "Tile Walkable: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).isWalkable() + "\r" + "Tile relative height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).relativeHeight() + "\r" + - "Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight()); - + "Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight() + "\r" + + "Tile has Furni: " + (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getItemsAt(gameClient.getHabbo().getRoomUnit().getCurrentPosition()).isEmpty())); } else { RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2])); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java index eecc6df9..f4427915 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java @@ -41,7 +41,7 @@ public class BattleBanzaiGameTeam extends GameTeam { RoomUnit roomUnit = habbo.getRoomUnit(); Room room = roomUnit.getRoom(); if(room == null) return; - RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 385b552f..71ccb521 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -191,7 +191,7 @@ public class FreezeGame extends Game { if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { if (this.getTeamForHabbo(habbo) == null) { - for (RoomItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { + for (RoomItem item : this.room.getRoomItemManager().getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { if (item instanceof InteractionFreezeTile) { RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY())); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index 8385c35d..9993c69f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -29,7 +29,7 @@ public class FreezeGameTeam extends GameTeam { Room room = roomUnit.getRoom(); if(room == null) return; - RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; 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 076b70b3..8cdb6f11 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 @@ -64,7 +64,7 @@ public abstract class TagGame extends Game { @EventHandler public static void onUserWalkEvent(UserTakeStepEvent event) { if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) { - THashSet items = event.habbo.getRoomUnit().getRoom().getItemsAt(event.toLocation); + THashSet items = event.habbo.getRoomUnit().getRoom().getRoomItemManager().getItemsAt(event.toLocation); TagGame game = (TagGame) event.habbo.getRoomUnit().getRoom().getGame(event.habbo.getHabboInfo().getCurrentGame()); @@ -177,7 +177,7 @@ public abstract class TagGame extends Game { Room room = roomUnit.getRoom(); if (room == null) return; - RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 29bc1940..f438461b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -45,7 +45,7 @@ public class WiredGame extends Game { Room room = this.room; if (room == null) return; - RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index 5a513769..a8b5eff1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -78,7 +78,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (!canBuild.isEmpty()) { for (RoomTile tile : this.tiles) { - THashSet tileItems = room.getItemsAt(tile); + THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); @@ -127,7 +127,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (!canBuild.isEmpty()) { for (RoomTile tile : this.tiles) { - THashSet tileItems = room.getItemsAt(tile); + THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); if (newTiles.contains(tile)) continue; for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { @@ -202,7 +202,7 @@ public class InteractionBuildArea extends InteractionCustomValues { } if (!canBuild.isEmpty()) { for (RoomTile tile : oldTiles) { - THashSet tileItems = room.getItemsAt(tile); + THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); for (RoomItem tileItem : tileItems) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); 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 ff280b15..f34df2fe 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 @@ -52,7 +52,7 @@ public class InteractionDefault extends RoomItem { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); - if (room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { + if (room.getRoomItemManager().getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) { if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // If the unit was previously on the furni... @@ -165,7 +165,8 @@ public class InteractionDefault extends RoomItem { if (objects != null && objects.length == 2) { if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) { - RoomItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null); + RoomItem exclude = (objects[0] != objects[1]) ? this : null; + RoomItem topItem = room.getRoomItemManager().getTopItemAt(goalTile.getX(), goalTile.getY(), exclude); if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { return; 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 270c0e65..acf0813b 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 @@ -68,7 +68,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC if (roomUnit != null) { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); - RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; 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 216ce2e2..362793cc 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 @@ -57,7 +57,7 @@ public class InteractionMultiHeight extends RoomItem { } if (objects[0] instanceof Integer && room != null) { - RoomItem topItem = room.getTopItemAt(this.getX(), this.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY()); if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top return; } 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 f2a59ce1..19b388b9 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 @@ -9,7 +9,6 @@ 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.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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; @@ -180,25 +179,23 @@ public class InteractionObstacle extends RoomItem implements ICycleable { } for(RoomTile tile : this.middleTiles) { - for(RoomEntity entity : tile.getEntities()) { - if(!(entity instanceof RoomUnit)) { + for(RoomUnit roomUnit : tile.getRoomUnits()) { + if(roomUnit == null) { continue; } - RoomUnit unit = (RoomUnit) entity; - - if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) { - if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation()) + if(roomUnit.getPath().size() == 0 && !roomUnit.hasStatus(RoomUnitStatus.MOVE)) { + if(roomUnit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue() != this.getRotation()) continue; - RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentPosition(), unit.getBodyRotation().getValue()); + RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue()); if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) { - unit.setGoalLocation(tileInfront); + roomUnit.setGoalLocation(tileInfront); } else { - RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentPosition(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); + RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue()); if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) { - unit.setGoalLocation(tileBehind); + roomUnit.setGoalLocation(tileBehind); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index c56f3287..77412e64 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -64,9 +64,10 @@ public class InteractionPuzzleBox extends RoomItem { if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentPosition(), rotation.getValue()))) return; - RoomItem item = room.getTopItemAt(tile.getX(), tile.getY()); + RoomItem item = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); - if (item != null && !room.getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return; + if (item != null && !room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) + return; this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); this.needsUpdate(true); 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 181ed3e7..fa1ea0fa 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 @@ -161,7 +161,7 @@ public class InteractionRentableSpace extends RoomItem { THashSet items = new THashSet<>(); for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { - items.addAll(room.getItemsAt(i, j, this.getZ())); + items.addAll(room.getRoomItemManager().getItemsAt(i, j, this.getZ())); } } 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 4e6003c3..f032fd25 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 @@ -285,7 +285,7 @@ public class InteractionWater extends InteractionDefault { } private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) { - for (RoomItem item : room.getItemsAt(x, y, z)) { + for (RoomItem item : room.getRoomItemManager().getItemsAt(x, y, z)) { if (item instanceof InteractionWater water) { // Take out picked up water from the recalculation. diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java index d479c4ea..6573f64b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java @@ -60,7 +60,8 @@ public class InteractionWaterItem extends InteractionMultiHeight { for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) { for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) { boolean tile = false; - THashSet items = room.getItemsAt(room.getLayout().getTile(x, y)); + RoomTile tile1 = room.getLayout().getTile(x, y); + THashSet items = room.getRoomItemManager().getItemsAt(tile1); for (RoomItem item : items) { if (item instanceof InteractionWater) { 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 a5dd1fb6..ff46ef08 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 @@ -128,7 +128,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { if (to == null) return false; - RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this); return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); @@ -158,7 +158,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { if (game != null) { GameTeam team = game.getTeamForHabbo(habbo); if (team != null) { - RoomItem item = room.getTopItemAt(to.getX(), to.getY()); + RoomItem item = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY()); try { item.onWalkOn(kicker, room, null); } catch (Exception e) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java index aae57b11..9ba08b4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java @@ -149,7 +149,7 @@ public class InteractionFootball extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { if (to == null || to.getState() == RoomTileState.INVALID) return false; - RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this); // Move is valid if there isnt any furni yet if (topItem == null) { @@ -157,7 +157,7 @@ public class InteractionFootball extends InteractionPushable { } // If any furni on tile is not stackable, move is invalid (tested on 22-03-2022) - if (room.getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) { + if (room.getRoomItemManager().getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) { return false; } @@ -215,8 +215,8 @@ public class InteractionFootball extends InteractionPushable { return; } } - RoomItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this); - RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); + RoomItem currentTopItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this); if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) { GameTeamColors color = interactionFootballGoal.teamColor; game.onScore(kicker, color); @@ -239,7 +239,7 @@ public class InteractionFootball extends InteractionPushable { @Override public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { - RoomItem topItem = room.getTopItemAt(from.getX(), from.getY(), this); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this); return !((Emulator.getRandom().nextInt(10) >= 3 && room.getRoomUnitManager().hasHabbosAt(to)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); } 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 b464673f..3dc26e13 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,6 +8,7 @@ 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.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; @@ -34,7 +35,8 @@ public class InteractionFreezeBlock extends RoomItem { return; RoomItem item = null; - THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); + RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + THashSet items = room.getRoomItemManager().getItemsAt(tile); for (RoomItem i : items) { if (i instanceof InteractionFreezeTile) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index 4662e46e..f71e82b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -50,7 +50,7 @@ public class InteractionTotemHead extends InteractionDefault { private void update(Room room, RoomTile tile) { InteractionTotemLegs legs = null; - for(RoomItem item : room.getItemsAt(tile)) { + for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) { if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) legs = (InteractionTotemLegs)item; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index ec4c0ffc..6648d9d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -41,7 +41,7 @@ public class InteractionTotemLegs extends InteractionDefault { } private void updateHead(Room room, RoomTile tile) { - for(RoomItem item : room.getItemsAt(tile)) { + for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) { if(item instanceof InteractionTotemHead && item.getZ() > this.getZ()) ((InteractionTotemHead)item).updateTotemState(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index 0fd6abc7..45bd77df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import gnu.trove.set.hash.THashSet; @@ -39,7 +40,8 @@ public class InteractionTotemPlanet extends InteractionDefault { InteractionTotemLegs legs = null; InteractionTotemHead head = null; - THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); + RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + THashSet items = room.getRoomItemManager().getItemsAt(tile); for(RoomItem item : items) { if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 97bab4d9..b64aa729 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -34,13 +34,13 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { return this.getWiredSettings().getItems(room).stream().allMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); }); } else { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); }); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index a79043d7..38441142 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -35,14 +35,14 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { return this.getWiredSettings().getItems(room).stream().allMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); }); } else { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { double minZ = item.getZ() + Item.getCurrentHeight(item); THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); }); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index 63957d88..e1601d17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -31,7 +31,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { return false; } - THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentPosition()); + THashSet itemsAtUser = room.getRoomItemManager().getItemsAt(roomUnit.getCurrentPosition()); return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains); } 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 457c08bd..a45622a4 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,6 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { return; } - 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/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index 9e9209cc..b6041ae0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -57,7 +57,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { if (room.getRoomItemManager().furnitureFitsAt(tile, item, item.getRotation(), true) == FurnitureMovementError.INVALID_MOVE) continue; - RoomItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); if (topItem != null && !topItem.getBaseItem().allowStack()) continue; 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 3becaf04..7f75979d 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().getRoomUnitManager().getHabboByRoomUnit(roomHabbo)); + roomHabbo.unIdle(); 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/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 2c8a259e..b6348162 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 @@ -40,7 +40,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg })); if (habbo.getRoomUnit().isIdle()) { - habbo.getRoomUnit().getRoom().unIdle(habbo); + habbo.getRoomUnit().unIdle(); } return true; } 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 6dfc6e41..99b7d616 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -16,12 +16,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; -import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -364,7 +364,7 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; - THashSet items = this.getItemsAt(tile); + THashSet items = this.roomItemManager.getItemsAt(tile); if (items == null) return RoomTileState.INVALID; @@ -426,7 +426,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateRoomUnit(RoomUnit roomUnit) { - RoomItem item = this.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem item = this.roomItemManager.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit())) roomUnit.removeStatus(RoomUnitStatus.SIT); @@ -459,7 +459,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateHabbosAt(short x, short y, List habbos) { - RoomItem item = this.getTopItemAt(x, y); + RoomItem item = this.roomItemManager.getTopItemAt(x, y); for (Habbo habbo : habbos) { @@ -498,7 +498,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateBotsAt(short x, short y) { - RoomItem topItem = this.getTopItemAt(x, y); + RoomItem topItem = this.roomItemManager.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); @@ -778,8 +778,6 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet updatedUnit = new THashSet<>(); ArrayList toKick = new ArrayList<>(); - final Room room = this; - final long millis = System.currentTimeMillis(); for (Habbo habbo : this.roomUnitManager.getCurrentRoomHabbos().values()) { @@ -802,14 +800,14 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().setKickCount(habbo.getRoomUnit().getKickCount() + 1); if (habbo.getRoomUnit().getKickCount() >= 5) { - this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room)); + this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this)); continue; } } if (Emulator.getConfig().getBoolean("hotel.rooms.auto.idle")) { if (!habbo.getRoomUnit().isIdle()) { - habbo.getRoomUnit().increaseIdleTimer(); + habbo.getRoomUnit().incrementIdleTicks(); if (habbo.getRoomUnit().isIdle()) { boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE); @@ -819,7 +817,7 @@ public class Room implements Comparable, ISerialize, Runnable { WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } } else { - habbo.getRoomUnit().increaseIdleTimer(); + habbo.getRoomUnit().incrementIdleTicks(); if (!this.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= Room.IDLE_CYCLES_KICK) { UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE); @@ -947,7 +945,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet itemsOnRoller = new THashSet<>(); - for (RoomItem item : getItemsAt(rollerTile)) { + for (RoomItem item : this.roomItemManager.getItemsAt(rollerTile)) { if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { itemsOnRoller.add(item); } @@ -976,12 +974,12 @@ public class Room implements Comparable, ISerialize, Runnable { return true; THashSet itemsNewTile = new THashSet<>(); - itemsNewTile.addAll(getItemsAt(tileInFront)); + itemsNewTile.addAll(this.roomItemManager.getItemsAt(tileInFront)); itemsNewTile.removeAll(itemsOnRoller); itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); - RoomItem topItem = Room.this.getTopItemAt(tileInFront.getX(), tileInFront.getY()); + RoomItem topItem = this.roomItemManager.getTopItemAt(tileInFront.getX(), tileInFront.getY()); boolean allowUsers = true; boolean allowFurniture = true; @@ -1027,46 +1025,34 @@ public class Room implements Comparable, ISerialize, Runnable { roomUserRolledEvent = new UserRolledEvent(null, null, null); } - ArrayList unitsOnTile = new ArrayList<>(rollerTile.getEntities()); + ArrayList unitsOnTile = new ArrayList<>(rollerTile.getRoomUnits()); - for (RoomEntity entity : rollerTile.getEntities()) { - if(!(entity instanceof RoomUnit)) { - continue; - } - - RoomUnit unit = (RoomUnit) entity; - - if (unit.getRoomUnitType() == RoomUnitType.PET) { - Pet pet = this.roomUnitManager.getPetByRoomUnit(unit); + for (RoomUnit roomUnit : rollerTile.getRoomUnits()) { + if (roomUnit instanceof RoomPet) { + Pet pet = this.roomUnitManager.getPetByRoomUnit(roomUnit); if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) { - unitsOnTile.remove(unit); + unitsOnTile.remove(roomUnit); } } } THashSet usersRolledThisTile = new THashSet<>(); - for (RoomEntity entity : unitsOnTile) { - if(!(entity instanceof RoomUnit)) { - continue; - } - - RoomUnit unit = (RoomUnit) entity; - - if (rolledUnitIds.contains(unit.getVirtualId())) continue; + for (RoomUnit roomUnit : unitsOnTile) { + if (rolledUnitIds.contains(roomUnit.getVirtualId())) continue; if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable())) continue; - if (unit.hasStatus(RoomUnitStatus.MOVE)) + if (roomUnit.hasStatus(RoomUnitStatus.MOVE)) continue; - double newZ = unit.getCurrentZ() + zOffset; + double newZ = roomUnit.getCurrentZ() + zOffset; - if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.HABBO) { - roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(unit), roller, tileInFront); + if (roomUserRolledEvent != null && roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { + roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(roomUnit), roller, tileInFront); Emulator.getPluginManager().fireEvent(roomUserRolledEvent); if (roomUserRolledEvent.isCancelled()) @@ -1075,8 +1061,8 @@ public class Room implements Comparable, ISerialize, Runnable { // horse riding boolean isRiding = false; - if (unit.getRoomUnitType() == RoomUnitType.HABBO) { - Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(unit); + if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { + Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); if (riding != null) { @@ -1084,25 +1070,25 @@ public class Room implements Comparable, ISerialize, Runnable { newZ = ridingUnit.getCurrentZ() + zOffset; rolledUnitIds.add(ridingUnit.getVirtualId()); updatedUnit.remove(ridingUnit); - messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentPosition(), ridingUnit.getCurrentZ(), tileInFront, newZ, room)); + messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentPosition(), ridingUnit.getCurrentZ(), tileInFront, newZ, this)); isRiding = true; } } } - usersRolledThisTile.add(unit.getVirtualId()); - rolledUnitIds.add(unit.getVirtualId()); - updatedUnit.remove(unit); - messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentPosition(), unit.getCurrentZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), room)); + usersRolledThisTile.add(roomUnit.getVirtualId()); + rolledUnitIds.add(roomUnit.getVirtualId()); + updatedUnit.remove(roomUnit); + messages.add(new RoomUnitOnRollerComposer(roomUnit, roller, roomUnit.getCurrentPosition(), roomUnit.getCurrentZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), this)); if (itemsOnRoller.isEmpty()) { - RoomItem item = room.getTopItemAt(tileInFront.getX(), tileInFront.getY()); + RoomItem item = this.getRoomItemManager().getTopItemAt(tileInFront.getX(), tileInFront.getY()); if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) { Emulator.getThreading().run(() -> { - if (unit.getGoalLocation() == rollerTile) { + if (roomUnit.getGoalLocation() == rollerTile) { try { - item.onWalkOn(unit, room, new Object[]{rollerTile, tileInFront}); + item.onWalkOn(roomUnit, this, new Object[]{rollerTile, tileInFront}); } catch (Exception e) { log.error(CAUGHT_EXCEPTION, e); } @@ -1111,15 +1097,15 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (unit.hasStatus(RoomUnitStatus.SIT)) { - unit.setSitUpdate(true); + if (roomUnit.hasStatus(RoomUnitStatus.SIT)) { + roomUnit.setSitUpdate(true); } } } if (!messages.isEmpty()) { for (MessageComposer message : messages) { - room.sendComposer(message.compose()); + this.sendComposer(message.compose()); } messages.clear(); } @@ -1145,7 +1131,7 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } - messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, room)); + messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, this)); rollerFurniIds.add(item.getId()); } } @@ -1155,7 +1141,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (!messages.isEmpty()) { for (MessageComposer message : messages) { - room.sendComposer(message.compose()); + this.sendComposer(message.compose()); } messages.clear(); } @@ -1233,7 +1219,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (!unit.isWalking() && !unit.isCmdSitEnabled()) { RoomTile thisTile = this.getLayout().getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); - RoomItem topItem = this.getTallestChair(thisTile); + RoomItem topItem = this.roomItemManager.getTallestChair(thisTile); if (topItem == null || !topItem.getBaseItem().allowSit()) { if (unit.hasStatus(RoomUnitStatus.SIT)) { @@ -1254,7 +1240,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (!unit.isWalking() && !unit.isCmdLayEnabled()) { - RoomItem topItem = this.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); + RoomItem topItem = this.roomItemManager.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); if (topItem == null || !topItem.getBaseItem().allowLay()) { if (unit.hasStatus(RoomUnitStatus.LAY)) { @@ -1291,12 +1277,11 @@ public class Room implements Comparable, ISerialize, Runnable { public Color getBackgroundTonerColor() { Color color = new Color(0, 0, 0); - TIntObjectIterator iterator = this.roomItems.iterator(); + Iterator iterator = this.roomItemManager.getCurrentItems().values().iterator(); - for (int i = this.roomItems.size(); i > 0; i--) { + for (int i = this.roomItemManager.getCurrentItems().size(); i > 0; i--) { try { - iterator.advance(); - RoomItem object = iterator.value(); + RoomItem object = iterator.next(); if (object instanceof InteractionBackgroundToner) { String[] extraData = object.getExtradata().split(":"); @@ -1435,7 +1420,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public List getPostItNotes() { - return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); + return this.roomItemManager.getCurrentItems().values().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); } public void kickHabbo(Habbo habbo, boolean alert) { @@ -1556,7 +1541,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - RoomItem doorTileTopItem = this.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); + RoomItem doorTileTopItem = this.roomItemManager.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); @@ -1608,7 +1593,7 @@ public class Room implements Comparable, ISerialize, Runnable { Emulator.getPluginManager().fireEvent(event); if (!event.isCancelled() && !event.isIdle()) { - this.unIdle(habbo); + habbo.getRoomUnit().unIdle(); } this.sendComposer(new UserTypingMessageComposer(habbo.getRoomUnit(), false).compose()); @@ -1839,14 +1824,13 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getLockedTiles() { THashSet lockedTiles = new THashSet<>(); - TIntObjectIterator iterator = this.roomItems.iterator(); + Iterator iterator = this.roomItemManager.getCurrentItems().values().iterator(); - for (int i = this.roomItems.size(); i-- > 0; ) { + for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) { RoomItem item; try { - iterator.advance(); - item = iterator.value(); + item = iterator.next(); } catch (Exception e) { break; } @@ -1884,214 +1868,6 @@ public class Room implements Comparable, ISerialize, Runnable { return lockedTiles; } - @Deprecated - public THashSet getItemsAt(int x, int y) { - RoomTile tile = this.getLayout().getTile((short) x, (short) y); - - if (tile != null) { - return this.getItemsAt(tile); - } - - return new THashSet<>(0); - } - - public THashSet getItemsAt(RoomTile tile) { - return getItemsAt(tile, false); - } - - public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) { - THashSet items = new THashSet<>(0); - - if (tile == null) { - return items; - } - - if (this.loaded) { - THashSet cachedItems = this.tileCache.get(tile); - if (cachedItems != null) - return cachedItems; - } - - TIntObjectIterator iterator = this.roomItems.iterator(); - - for (int i = this.roomItems.size(); i-- > 0; ) { - RoomItem item; - try { - iterator.advance(); - item = iterator.value(); - } catch (Exception e) { - break; - } - - if (item == null) - continue; - - if (item.getBaseItem().getType() != FurnitureType.FLOOR) - continue; - - int width, length; - - if (item.getRotation() != 2 && item.getRotation() != 6) { - width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1; - length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1; - } else { - width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1; - length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1; - } - - if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1)) - continue; - - items.add(item); - - if (returnOnFirst) { - return items; - } - } - - if (this.loaded) { - this.tileCache.put(tile, items); - } - - return items; - } - - public THashSet getItemsAt(int x, int y, double minZ) { - THashSet items = new THashSet<>(); - - for (RoomItem item : this.getItemsAt(x, y)) { - if (item.getZ() < minZ) - continue; - - items.add(item); - } - return items; - } - - public THashSet getItemsAt(Class type, int x, int y) { - THashSet items = new THashSet<>(); - - for (RoomItem item : this.getItemsAt(x, y)) { - if (!item.getClass().equals(type)) - continue; - - items.add(item); - } - return items; - } - - public boolean hasItemsAt(int x, int y) { - RoomTile tile = this.getLayout().getTile((short) x, (short) y); - - if (tile == null) - return false; - - return !this.getItemsAt(tile, true).isEmpty(); - } - - public RoomItem getTopItemAt(RoomTile tile) { - if(tile == null) { - return null; - } - - return this.getTopItemAt(tile.getX(), tile.getY(), null); - } - - public RoomItem getTopItemAt(int x, int y) { - return this.getTopItemAt(x, y, null); - } - - public RoomItem getTopItemAt(int x, int y, RoomItem exclude) { - RoomTile tile = this.getLayout().getTile((short) x, (short) y); - - if (tile == null) - return null; - - RoomItem highestItem = null; - - for (RoomItem item : this.getItemsAt(x, y)) { - if (exclude != null && exclude == item) - continue; - - if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; - - highestItem = item; - } - - return highestItem; - } - - public RoomItem getTopItemAt(THashSet tiles, RoomItem exclude) { - RoomItem highestItem = null; - for (RoomTile tile : tiles) { - - if (tile == null) - continue; - - for (RoomItem item : this.getItemsAt(tile.getX(), tile.getY())) { - if (exclude != null && exclude == item) - continue; - - if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; - - highestItem = item; - } - } - - return highestItem; - } - - public double getTopHeightAt(int x, int y) { - RoomItem item = this.getTopItemAt(x, y); - if (item != null) { - return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); - } else { - return this.layout.getHeightAtSquare(x, y); - } - } - - public RoomItem getLowestChair(RoomTile tile) { - RoomItem lowestChair = null; - - THashSet items = this.getItemsAt(tile); - if (items != null && !items.isEmpty()) { - for (RoomItem item : items) { - - if (!item.getBaseItem().allowSit()) - continue; - - if (lowestChair != null && lowestChair.getZ() < item.getZ()) - continue; - - lowestChair = item; - } - } - - return lowestChair; - } - - public RoomItem getTallestChair(RoomTile tile) { - RoomItem lowestChair = null; - - THashSet items = this.getItemsAt(tile); - if (items != null && !items.isEmpty()) { - for (RoomItem item : items) { - - if (!item.getBaseItem().allowSit()) - continue; - - if (lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) > item.getZ() + Item.getCurrentHeight(item)) - continue; - - lowestChair = item; - } - } - - return lowestChair; - } - public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) { if (x < 0 || y < 0 || this.layout == null) @@ -2107,7 +1883,7 @@ public class Room implements Comparable, ISerialize, Runnable { double height = this.layout.getHeightAtSquare(x, y); boolean canStack = true; - THashSet stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y); + THashSet stackHelpers = this.roomItemManager.getItemsAt(InteractionStackHelper.class, x, y); for (RoomItem item : stackHelpers) { @@ -2116,7 +1892,7 @@ public class Room implements Comparable, ISerialize, Runnable { } - RoomItem item = this.getTopItemAt(x, y, exclude); + RoomItem item = this.roomItemManager.getTopItemAt(x, y, exclude); if (item != null) { canStack = item.getBaseItem().allowStack(); height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); @@ -2134,7 +1910,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean hasObjectTypeAt(Class type, int x, int y) { - THashSet items = this.getItemsAt(x, y); + THashSet items = this.roomItemManager.getItemsAt(x, y); for (RoomItem item : items) { if (item.getClass() == type) { @@ -2155,7 +1931,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.roomUnitManager.hasHabbosAt(tile)) return false; - THashSet items = this.getItemsAt(x, y); + THashSet items = this.roomItemManager.getItemsAt(x, y); return this.canSitAt(items) || this.canLayAt(items); } @@ -2170,7 +1946,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.roomUnitManager.hasHabbosAt(tile)) return false; - return this.canSitAt(this.getItemsAt(x, y)); + return this.canSitAt(this.roomItemManager.getItemsAt(x, y)); } boolean canWalkAt(RoomTile roomTile) { @@ -2183,7 +1959,7 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem topItem = null; boolean canWalk = true; - THashSet items = this.getItemsAt(roomTile); + THashSet items = this.roomItemManager.getItemsAt(roomTile); if (items != null) { for (RoomItem item : items) { if (topItem == null) { @@ -2225,7 +2001,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canLayAt(RoomTile tile) { - return this.canLayAt(this.getItemsAt(tile)); + return this.canLayAt(this.roomItemManager.getItemsAt(tile)); } boolean canLayAt(THashSet items) { @@ -2443,24 +2219,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void idle(Habbo habbo) { - habbo.getRoomUnit().setIdle(); - - if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) { - habbo.getRoomUnit().setDance(DanceType.NONE); - } - - this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose()); - WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); - } - - public void unIdle(Habbo habbo) { - if (habbo == null || habbo.getRoomUnit() == null) return; - habbo.getRoomUnit().resetIdleTimer(); - this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose()); - WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); - } - public void addToWordFilter(String word) { synchronized (this.wordFilterWords) { if (this.wordFilterWords.contains(word)) @@ -2529,4 +2287,4 @@ public class Room implements Comparable, ISerialize, Runnable { public boolean hasVotedInWordQuiz(Habbo habbo) { return this.userVotes.contains(habbo.getHabboInfo().getId()); } -} +} \ No newline at end of file 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 96b7f61b..db0b8345 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -375,7 +375,7 @@ public class RoomItemManager { boolean magicTile = item instanceof InteractionStackHelper; - Optional stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); //Check if can be placed at new position THashSet occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); @@ -387,12 +387,12 @@ public class RoomItemManager { return fits; } - RoomItem topItem = this.room.getTopItemAt(occupiedTiles, null); + RoomItem topItem = this.getTopItemAt(occupiedTiles, null); if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { if (oldLocation != targetTile) { for (RoomTile t : occupiedTiles) { - RoomItem tileTopItem = this.room.getTopItemAt(t.getX(), t.getY()); + RoomItem tileTopItem = this.getTopItemAt(t.getX(), t.getY()); if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.room.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { return FurnitureMovementError.CANT_STACK; @@ -414,7 +414,7 @@ public class RoomItemManager { List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); + tileFurniList.add(Pair.create(t, this.getItemsAt(t))); } if (!magicTile && !item.canStackAt(tileFurniList)) { @@ -670,14 +670,14 @@ public class RoomItemManager { } } - Optional stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); + tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - RoomItem topItem = this.room.getTopItemAt(t.getX(), t.getY(), item); + RoomItem topItem = this.getTopItemAt(t.getX(), t.getY(), item); if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { return FurnitureMovementError.CANT_STACK; } @@ -694,6 +694,211 @@ public class RoomItemManager { return FurnitureMovementError.NONE; } + @Deprecated + public THashSet getItemsAt(int x, int y) { + RoomTile tile = this.room.getLayout().getTile((short) x, (short) y); + + if (tile != null) { + return this.getItemsAt(tile); + } + + return new THashSet<>(0); + } + + public THashSet getItemsAt(RoomTile tile) { + return getItemsAt(tile, false); + } + + public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) { + THashSet items = new THashSet<>(0); + + if (tile == null) { + return items; + } + + if (this.room.isLoaded()) { + THashSet cachedItems = this.room.tileCache.get(tile); + if (cachedItems != null) + return cachedItems; + } + + Iterator iterator = this.currentItems.values().iterator(); + + for (int i = this.currentItems.size(); i-- > 0; ) { + RoomItem item; + try { + item = iterator.next(); + } catch (Exception e) { + break; + } + + if (item == null || item.getBaseItem().getType() != FurnitureType.FLOOR) { + continue; + } + + int width, length; + + if (item.getRotation() != 2 && item.getRotation() != 6) { + width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1; + length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1; + } else { + width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1; + length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1; + } + + if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1)) + continue; + + items.add(item); + + if (returnOnFirst) { + return items; + } + } + + if (this.room.isLoaded()) { + this.room.tileCache.put(tile, items); + } + + return items; + } + + public THashSet getItemsAt(int x, int y, double minZ) { + THashSet items = new THashSet<>(); + + for (RoomItem item : this.getItemsAt(x, y)) { + if (item.getZ() < minZ) + continue; + + items.add(item); + } + return items; + } + + public THashSet getItemsAt(Class type, int x, int y) { + THashSet items = new THashSet<>(); + + for (RoomItem item : this.getItemsAt(x, y)) { + if (!item.getClass().equals(type)) + continue; + + items.add(item); + } + return items; + } + + public boolean hasItemsAt(int x, int y) { + RoomTile tile = this.room.getLayout().getTile((short) x, (short) y); + + if (tile == null) + return false; + + return !this.getItemsAt(tile, true).isEmpty(); + } + + public RoomItem getTopItemAt(RoomTile tile) { + if(tile == null) { + return null; + } + + return this.getTopItemAt(tile.getX(), tile.getY(), null); + } + + public RoomItem getTopItemAt(int x, int y) { + return this.getTopItemAt(x, y, null); + } + + public RoomItem getTopItemAt(int x, int y, RoomItem exclude) { + RoomTile tile = this.room.getLayout().getTile((short) x, (short) y); + + if (tile == null) + return null; + + RoomItem highestItem = null; + + for (RoomItem item : this.getItemsAt(x, y)) { + if (exclude != null && exclude == item) + continue; + + if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) + continue; + + highestItem = item; + } + + return highestItem; + } + + public RoomItem getTopItemAt(THashSet tiles, RoomItem exclude) { + RoomItem highestItem = null; + for (RoomTile tile : tiles) { + + if (tile == null) + continue; + + for (RoomItem item : this.getItemsAt(tile.getX(), tile.getY())) { + if (exclude != null && exclude == item) + continue; + + if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) + continue; + + highestItem = item; + } + } + + return highestItem; + } + + public double getTopHeightAt(int x, int y) { + RoomItem item = this.getTopItemAt(x, y); + if (item != null) { + return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); + } else { + return this.room.getLayout().getHeightAtSquare(x, y); + } + } + + public RoomItem getLowestChair(RoomTile tile) { + RoomItem lowestChair = null; + + THashSet items = this.getItemsAt(tile); + if (items != null && !items.isEmpty()) { + for (RoomItem item : items) { + + if (!item.getBaseItem().allowSit()) + continue; + + if (lowestChair != null && lowestChair.getZ() < item.getZ()) + continue; + + lowestChair = item; + } + } + + return lowestChair; + } + + public RoomItem getTallestChair(RoomTile tile) { + RoomItem lowestChair = null; + + THashSet items = this.getItemsAt(tile); + if (items != null && !items.isEmpty()) { + for (RoomItem item : items) { + + if (!item.getBaseItem().allowSit()) + continue; + + if (lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) > item.getZ() + Item.getCurrentHeight(item)) + continue; + + lowestChair = item; + } + } + + return lowestChair; + } + public void addCycleTask(ICycleable task) { this.cycleTasks.add(task); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 82e4da6e..d300ab2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -588,7 +588,7 @@ public class RoomManager { if(spawnLocation != null) { roomHabbo.setCanLeaveRoomByDoor(false); roomHabbo.setTeleporting(true); - RoomItem topItem = room.getTopItemAt(spawnLocation); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(spawnLocation); if(topItem != null) { spawnDirection = RoomRotation.values()[topItem.getRotation()]; @@ -674,7 +674,7 @@ public class RoomManager { } } - roomHabbo.resetIdleTimer(); + roomHabbo.resetIdleTicks(); roomHabbo.setInvisible(false); room.getRoomUnitManager().addRoomUnit(habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index f333c89c..1c4563f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -1,7 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.Getter; import lombok.Setter; @@ -17,7 +17,8 @@ public class RoomTile { private final short y; @Getter private final short z; - private final HashSet units; + private final HashSet roomUnits; + private final HashSet roomItems; @Setter @Getter private RoomTileState state; @@ -39,7 +40,8 @@ public class RoomTile { this.stackHeight = z; this.state = state; this.setAllowStack(allowStack); - this.units = new HashSet<>(); + this.roomUnits = new HashSet<>(); + this.roomItems = new HashSet<>(); } public RoomTile(RoomTile tile) { @@ -56,20 +58,8 @@ public class RoomTile { if (this.state == RoomTileState.INVALID) { this.allowStack = false; } - this.units = tile.units; - } - - public RoomTile() { - x = 0; - y = 0; - z = 0; - this.stackHeight = 0; - this.state = RoomTileState.INVALID; - this.allowStack = false; - this.diagonally = false; - this.gCosts = 0; - this.hCosts = 0; - this.units = null; + this.roomUnits = tile.roomUnits; + this.roomItems = tile.roomItems; } public double getStackHeight() { @@ -175,36 +165,41 @@ public class RoomTile { return this.x == x && this.y == y; } - public List getEntities() { - synchronized (this.units) { - return new ArrayList<>(this.units); + public List getRoomUnits() { + synchronized (this.roomUnits) { + return new ArrayList<>(this.roomUnits); } } - public void addUnit(RoomEntity entity) { - synchronized (this.units) { - if (!this.units.contains(entity)) { - this.units.add(entity); + public void addRoomUnit(RoomUnit roomUnit) { + synchronized (this.roomUnits) { + if (!this.roomUnits.contains(roomUnit)) { + this.roomUnits.add(roomUnit); } } } - public void removeUnit(RoomEntity entity) { - synchronized (this.units) { - this.units.remove(entity); + public void removeUnit(RoomUnit roomUnit) { + synchronized (this.roomUnits) { + this.roomUnits.remove(roomUnit); } } public boolean hasUnits() { - synchronized (this.units) { - return this.units.size() > 0; + synchronized (this.roomUnits) { + return !this.roomUnits.isEmpty(); } } - public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) { - if ((unit.getCurrentPosition().getX() < this.x || unit.getCurrentPosition().getX() >= this.x + item.getLength())) + public boolean unitIsOnFurniOnTile(RoomUnit roomUnit, Item item) { + if ((roomUnit.getCurrentPosition().getX() < this.x || roomUnit.getCurrentPosition().getX() >= this.x + item.getLength())) { return false; - if (unit.getCurrentPosition().getY() < this.y) return false; - return unit.getCurrentPosition().getY() < this.y + item.getWidth(); + } + + if (roomUnit.getCurrentPosition().getY() < this.y) { + return false; + } + + return roomUnit.getCurrentPosition().getY() < this.y + item.getWidth(); } } \ No newline at end of file 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 ee9bed04..af72d1b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -307,7 +307,7 @@ public class RoomUnitManager { roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); - RoomItem item = roomHabbo.getRoom().getTopItemAt(roomHabbo.getCurrentPosition()); + RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition()); if (item != null) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java index 5902ba08..1846f7f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java @@ -25,7 +25,5 @@ public interface IRoomEntity { double getTargetZ(); RoomEntity setTargetZ(double targetZ); - void setTargetTile(short x, short y); - void incrementTilesMoved(); } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java index c7f35994..781ba10e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java @@ -12,7 +12,7 @@ import java.util.LinkedList; @Getter @Setter @Accessors(chain = true) -public class RoomEntity implements IRoomEntity { +public abstract class RoomEntity implements IRoomEntity { private Room room; private RoomTile previousPosition; private double previousZ; @@ -23,32 +23,6 @@ public class RoomEntity implements IRoomEntity { private Deque path = new LinkedList<>(); private int tilesMoved; - public RoomEntity setCurrentPosition(RoomTile tile) { - if (this.currentPosition != null) { - this.currentPosition.removeUnit(this); - } - - this.currentPosition = tile; - - if(this.currentPosition != null) { - tile.addUnit(this); - } - - return this; - } - - public void setTargetTile(short x, short y) { - RoomTile targetTile = this.getRoom().getLayout().getTile(x, y); - - if(this.getCurrentPosition().equals(targetTile)) { - return; - } - - if (targetTile.isWalkable()) { - this.setTargetPosition(targetTile); - } - } - public synchronized void incrementTilesMoved() { this.tilesMoved++; } 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 4b33f295..b84f73b5 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 @@ -336,7 +336,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public void onPickUp(Room room) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - RoomItem topItem2 = room.getTopItemAt(this.getX(), this.getY(), this); + RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY(), this); int nextEffectM = 0; int nextEffectF = 0; @@ -370,7 +370,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - RoomItem topItem2 = room.getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); + RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); int nextEffectM = 0; int nextEffectF = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 4a8084de..2914f22e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -80,7 +80,6 @@ public abstract class RoomUnit extends RoomEntity { private boolean sitUpdate = false; @Setter private boolean isKicked; - @Getter @Setter private int kickCount = 0; @Getter @@ -109,8 +108,6 @@ public abstract class RoomUnit extends RoomEntity { private int previousEffectId; private int previousEffectEndTimestamp; private int timeInRoom; - //RoomHabbo - private int idleTicks; @Getter private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private final THashSet overridableTiles; @@ -143,6 +140,21 @@ public abstract class RoomUnit extends RoomEntity { public abstract boolean cycle(Room room); + @Override + public RoomUnit setCurrentPosition(RoomTile tile) { + if (this.getCurrentPosition() != null) { + this.getCurrentPosition().removeUnit(this); + } + + super.setCurrentPosition(tile); + + if(this.getCurrentPosition() != null) { + tile.addRoomUnit(this); + } + + return this; + } + public void setRotation(RoomRotation rotation) { this.bodyRotation = rotation; this.headRotation = rotation; @@ -273,7 +285,7 @@ public abstract class RoomUnit extends RoomEntity { } public void makeStand() { - RoomItem item = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem item = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { this.setCmdStandEnabled(true); this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); @@ -339,22 +351,6 @@ public abstract class RoomUnit extends RoomEntity { this.timeInRoom = 0; } - public void increaseIdleTimer() { - this.idleTicks++; - } - - public boolean isIdle() { - return this.idleTicks > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds. - } - - public void resetIdleTimer() { - this.idleTicks = 0; - } - - public void setIdle() { - this.idleTicks = Room.IDLE_CYCLES + 1; - } - public void lookAtPoint(RoomTile location) { if (!this.isCanRotate()) { return; @@ -388,7 +384,7 @@ public abstract class RoomUnit extends RoomEntity { public boolean canOverrideTile(RoomTile tile) { if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false; - if (this.getRoom().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile))) + if (this.getRoom().getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile))) return true; int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); @@ -412,7 +408,7 @@ public abstract class RoomUnit extends RoomEntity { public boolean canForcePosture() { if (this.getRoom() == null) return false; - RoomItem topItem = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); } 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 dafe9ca1..e56fd718 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 @@ -130,13 +130,14 @@ public class RoomAvatar extends RoomUnit { this.removeStatus(RoomUnitStatus.DEAD); if (habbo != null) { - if (this.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); + if(this instanceof RoomHabbo roomHabbo) { + if (roomHabbo.isIdle()) { + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled() && !event.isIdle()) { - room.unIdle(habbo); - this.resetIdleTimer();; + if (!event.isCancelled() && !event.isIdle()) { + roomHabbo.unIdle(); + } } } @@ -152,7 +153,7 @@ public class RoomAvatar extends RoomUnit { } } - RoomItem item = room.getTopItemAt(next.getX(), next.getY()); + RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { @@ -172,7 +173,7 @@ public class RoomAvatar extends RoomUnit { boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); if (canSitNextTile) { - RoomItem tallestChair = room.getTallestChair(next); + RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next); if (tallestChair != null) item = tallestChair; @@ -190,7 +191,7 @@ public class RoomAvatar extends RoomUnit { zHeight += 1.0D; } - RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); @@ -255,10 +256,13 @@ public class RoomAvatar extends RoomUnit { this.setCurrentZ(zHeight); this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); - this.resetIdleTimer(); + + if(this instanceof RoomHabbo roomHabbo) { + roomHabbo.resetIdleTicks(); + } if(habbo != null) { - RoomItem topItem = room.getTopItemAt(next.getX(), next.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java index d5c71c0e..518ec753 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java @@ -2,6 +2,10 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.SleepMessageComposer; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -45,14 +49,42 @@ public class RoomHabbo extends RoomAvatar { this.kickCount++; } - public void incrementIdleTick() { - this.idleTicks++; + public void idle() { + this.setIdle(); + + if (this.getDanceType() != DanceType.NONE) { + this.setDance(DanceType.NONE); + } + + this.getRoom().sendComposer(new SleepMessageComposer(this).compose()); + + WiredHandler.handle(WiredTriggerType.IDLES, this, this.getRoom(), new Object[]{this}); + } + + public void unIdle() { + this.resetIdleTicks(); + + this.getRoom().sendComposer(new SleepMessageComposer(this).compose()); + + WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.getRoom(), new Object[]{this}); } public boolean isIdle() { return this.idleTicks > Room.IDLE_CYCLES; } + public void setIdle() { + this.idleTicks = Room.IDLE_CYCLES + 1; + } + + public void incrementIdleTicks() { + this.idleTicks++; + } + + public void resetIdleTicks() { + this.idleTicks = 0; + } + public RoomUnitType getRoomUnitType() { return RoomUnitType.HABBO; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 25d079b1..a7784834 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -89,7 +89,7 @@ public class RoomPet extends RoomUnit { this.removeStatus(RoomUnitStatus.DEAD); - RoomItem item = room.getTopItemAt(next.getX(), next.getY()); + RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { @@ -109,7 +109,7 @@ public class RoomPet extends RoomUnit { boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); if (canSitNextTile) { - RoomItem tallestChair = room.getTallestChair(next); + RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next); if (tallestChair != null) item = tallestChair; @@ -123,7 +123,7 @@ public class RoomPet extends RoomUnit { double zHeight = 0.0D; - RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); 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 25c2c215..a5b1535f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -460,7 +460,7 @@ public class Habbo extends Unit implements Runnable { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven")); AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned")); - this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().unIdle(); this.client.getHabbo().getRoomUnit().setDance(DanceType.NONE); } } 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 9687c708..c3ce78f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -255,7 +255,7 @@ public class WiredHandler { public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { for (RoomTile tile : tiles) { if (room != null) { - THashSet items = room.getItemsAt(tile); + THashSet items = room.getRoomItemManager().getItemsAt(tile); long millis = room.getCycleTimestamp(); for (final RoomItem item : items) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index bf1ead0a..0720bc16 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -111,7 +111,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { String square = String.valueOf(mapRows[y].charAt(x)); short height; - if (square.equalsIgnoreCase("x") && room.getTopItemAt(x, y) != null) { + if (square.equalsIgnoreCase("x") && room.getRoomItemManager().getTopItemAt(x, y) != null) { errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); break blockingRoomItemScan; } else { @@ -124,7 +124,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { } } - if (tile != null && tile.getState() != RoomTileState.INVALID && height != tile.getZ() && room.getTopItemAt(x, y) != null) { + if (tile != null && tile.getState() != RoomTileState.INVALID && height != tile.getZ() && room.getRoomItemManager().getTopItemAt(x, y) != null) { errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); break blockingRoomItemScan; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java index aa1fcca1..cb01fb1c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AvatarExpressionEvent.java @@ -36,9 +36,9 @@ public class AvatarExpressionEvent extends MessageHandler { if (!event.isCancelled()) { if (event.isIdle()) { - room.idle(habbo); + habbo.getRoomUnit().idle(); } else { - room.unIdle(habbo); + habbo.getRoomUnit().unIdle(); } } } else { @@ -46,7 +46,7 @@ public class AvatarExpressionEvent extends MessageHandler { Emulator.getPluginManager().fireEvent(event); if (!event.isCancelled() && !event.isIdle()) { - room.unIdle(habbo); + habbo.getRoomUnit().unIdle(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java index 7f5d8f23..94fac702 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChangePostureEvent.java @@ -19,7 +19,7 @@ public class ChangePostureEvent extends MessageHandler { if (!event.isCancelled()) { if (!event.isIdle()) { - this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().unIdle(); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java index d92262fc..15c8834c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DanceEvent.java @@ -36,7 +36,7 @@ public class DanceEvent extends MessageHandler { if (!event.isCancelled()) { if (!event.isIdle()) { - this.client.getHabbo().getRoomUnit().getRoom().unIdle(habbo); + this.client.getHabbo().getRoomUnit().unIdle(); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java index 24f382da..83b4d64d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/DropCarryItemEvent.java @@ -10,7 +10,7 @@ public class DropCarryItemEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); this.client.getHabbo().getRoomUnit().setHandItem(0); if (room != null) { - room.unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().unIdle(); room.sendComposer(new CarryObjectMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java index 8f3c9f64..d49b8b54 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/LookToEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; @@ -26,31 +26,31 @@ public class LookToEvent extends MessageHandler { } } - RoomUnit roomUnit = habbo.getRoomUnit(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); - if (!roomUnit.isCanWalk()) + if (!roomHabbo.isCanWalk()) return; - if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) + if (roomHabbo.isWalking() || roomHabbo.hasStatus(RoomUnitStatus.MOVE)) return; - if (roomUnit.isCmdLayEnabled() || roomUnit.hasStatus(RoomUnitStatus.LAY)) + if (roomHabbo.isCmdLayEnabled() || roomHabbo.hasStatus(RoomUnitStatus.LAY)) return; - if (roomUnit.isIdle()) + if (roomHabbo.isIdle()) return; int x = this.packet.readInt(); int y = this.packet.readInt(); - if (x == roomUnit.getCurrentPosition().getX()) { - if (y == roomUnit.getCurrentPosition().getY()) return; + if (x == roomHabbo.getCurrentPosition().getX()) { + if (y == roomHabbo.getCurrentPosition().getY()) return; } RoomTile tile = habbo.getRoomUnit().getRoom().getLayout().getTile((short) x, (short) y); if (tile != null) { - roomUnit.lookAtPoint(tile); + roomHabbo.lookAtPoint(tile); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index bbff7d6b..5ac62007 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; @@ -37,19 +37,19 @@ public class MoveAvatarEvent extends MessageHandler { } // Get Room Habbo object (Unique GUID?) - RoomUnit roomUnit = this.client.getHabbo().getRoomUnit(); + RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit(); - if(roomUnit == null) { + if(roomHabbo == null) { return; } // If habbo is teleporting, don't calculate a new path - if (roomUnit.isTeleporting()) { + if (roomHabbo.isTeleporting()) { return; } // If habbo is being kicked don't calculate a new path - if (roomUnit.isKicked()) { + if (roomHabbo.isKicked()) { return; } @@ -61,13 +61,13 @@ public class MoveAvatarEvent extends MessageHandler { } // Don't calulcate a new path if are already at the end position - if (x == roomUnit.getCurrentPosition().getX() && y == roomUnit.getCurrentPosition().getY()) { + if (x == roomHabbo.getCurrentPosition().getX() && y == roomHabbo.getCurrentPosition().getY()) { return; } // If habbo has control (im assuming admin, do something else, but we dont care about this part here) - if (roomUnit.getCacheable().get("control") != null) { - habbo = (Habbo) roomUnit.getCacheable().get("control"); + if (roomHabbo.getCacheable().get("control") != null) { + habbo = (Habbo) roomHabbo.getCacheable().get("control"); if (habbo.getRoomUnit().getRoom() != room) { habbo.getRoomUnit().getCacheable().remove("controller"); @@ -77,20 +77,20 @@ public class MoveAvatarEvent extends MessageHandler { } // Recover roomUnit if necessary - roomUnit = habbo.getRoomUnit(); + roomHabbo = habbo.getRoomUnit(); // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path - if (roomUnit != null && roomUnit.isInRoom() && roomUnit.isCanWalk()) { + if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) { //If teleport command is enabled - if(roomUnit.isCmdTeleportEnabled()) { + if(roomHabbo.isCmdTeleportEnabled()) { RoomTile t = room.getLayout().getTile((short) x, (short) y); if (habbo.getHabboInfo().getRiding() != null) { - room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, null, roomUnit.getCurrentPosition(), roomUnit.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose()); + room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, null, roomHabbo.getCurrentPosition(), roomHabbo.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose()); room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose()); } else { - room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose()); + room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, t, room).compose()); } return; @@ -101,14 +101,15 @@ public class MoveAvatarEvent extends MessageHandler { return; // Reset idle status - if (roomUnit.isIdle()) { + if (roomHabbo.isIdle()) { UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); Emulator.getPluginManager().fireEvent(event); if (!event.isCancelled()) { if (!event.isIdle()) { - if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo); - roomUnit.resetIdleTimer(); + if (roomHabbo.getRoom() != null) { + roomHabbo.unIdle(); + } } } } @@ -128,7 +129,7 @@ public class MoveAvatarEvent extends MessageHandler { } if (room.canLayAt(tile)) { - RoomItem bed = room.getTopItemAt(tile.getX(), tile.getY()); + RoomItem bed = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); if (bed != null && bed.getBaseItem().allowLay()) { room.getLayout().getTile(bed.getX(), bed.getY()); @@ -139,17 +140,17 @@ public class MoveAvatarEvent extends MessageHandler { }; if (pillow != null && room.canLayAt(pillow)) { - roomUnit.setGoalLocation(pillow); + roomHabbo.setGoalLocation(pillow); return; } } } - THashSet items = room.getItemsAt(tile); + THashSet items = room.getRoomItemManager().getItemsAt(tile); if (items.size() > 0) { for (RoomItem item : items) { - RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile); + RoomTile overriddenTile = item.getOverrideGoalTile(roomHabbo, room, tile); if (overriddenTile == null) { return; // null cancels the entire event @@ -164,7 +165,7 @@ public class MoveAvatarEvent extends MessageHandler { // This is where we set the end location and begin finding a path if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { - roomUnit.setGoalLocation(tile); + roomHabbo.setGoalLocation(tile); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java index 40407dfd..8fb2926a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java @@ -21,7 +21,7 @@ public class SignEvent extends MessageHandler { UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.getSign() + ""); - this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); + this.client.getHabbo().getRoomUnit().unIdle(); if(signId <= 10) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 34fef1f7..0b45d625 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -36,7 +36,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.newLocation = newLocation; this.newZ = newZ; this.room = room; - oldTopItem = this.room.getTopItemAt(oldLocation.getX(), oldLocation.getY()); + oldTopItem = this.room.getRoomItemManager().getTopItemAt(oldLocation.getX(), oldLocation.getY()); } public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) { @@ -70,8 +70,8 @@ public class RoomUnitOnRollerComposer extends MessageComposer { if (this.roller != null && room.getLayout() != null) { Emulator.getThreading().run(() -> { if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentPosition() == this.oldLocation) { - RoomItem topItem = this.room.getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); - RoomItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); + RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); + RoomItem topItemNewLocation = this.room.getRoomItemManager().getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) { try { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java index 68e9148f..9f09e379 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -8,14 +8,14 @@ import lombok.AllArgsConstructor; @AllArgsConstructor public class SleepMessageComposer extends MessageComposer { - private final RoomUnit roomUnit; + private final RoomHabbo roomHabbo; @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.sleepMessageComposer); - this.response.appendInt(this.roomUnit.getVirtualId()); - this.response.appendBoolean(this.roomUnit.isIdle()); + this.response.appendInt(this.roomHabbo.getVirtualId()); + this.response.appendBoolean(this.roomHabbo.isIdle()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java index 96e781ef..6e66017c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -19,7 +19,7 @@ public class BanzaiRandomTeleport implements Runnable { @Override public void run() { - RoomItem topItemNow = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); + RoomItem topItemNow = this.room.getRoomItemManager().getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); RoomTile lastLocation = this.habbo.getCurrentPosition(); RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY()); @@ -45,7 +45,7 @@ public class BanzaiRandomTeleport implements Runnable { Emulator.getThreading().run(() -> { this.habbo.setCanWalk(true); - RoomItem topItemNext = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); + RoomItem topItemNext = this.room.getRoomItemManager().getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); if(topItemNext != null) { try { diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index 81dffe91..a79a48da 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -21,7 +21,7 @@ public class ClearRentedSpace implements Runnable { HashSet items = new HashSet<>(); for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { - for (RoomItem i : this.room.getItemsAt(t)) { + for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) { if (i.getOwnerId() == this.item.getRenterId()) { items.add(i); i.setRoomId(0); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java index 2d1e5f22..564fcde1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java @@ -40,7 +40,7 @@ public class RoomTrashing implements Runnable { if (event.habbo.getRoomUnit().getRoom().equals(INSTANCE.room)) { THashSet messages = new THashSet<>(); - THashSet items = INSTANCE.room.getItemsAt(event.toLocation); + THashSet items = INSTANCE.room.getRoomItemManager().getItemsAt(event.toLocation); int offset = Emulator.getRandom().nextInt(4) + 2; @@ -56,7 +56,7 @@ public class RoomTrashing implements Runnable { } for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); + double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } @@ -78,11 +78,11 @@ public class RoomTrashing implements Runnable { RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); if (s != null) { - items = INSTANCE.room.getItemsAt(s); + items = INSTANCE.room.getRoomItemManager().getItemsAt(s); } for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); + double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } @@ -101,10 +101,10 @@ public class RoomTrashing implements Runnable { } s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); - items = INSTANCE.room.getItemsAt(s); + items = INSTANCE.room.getRoomItemManager().getItemsAt(s); for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); + double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 2040c680..197c6f89 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -36,7 +36,7 @@ public class RoomUnitTeleport implements Runnable { RoomTile lastLocation = this.roomUnit.getCurrentPosition(); RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y); - RoomItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentPosition().getX(), this.roomUnit.getCurrentPosition().getY()); + RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.roomUnit.getCurrentPosition().getX(), this.roomUnit.getCurrentPosition().getY()); if (topItem != null) { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); @@ -59,7 +59,7 @@ public class RoomUnitTeleport implements Runnable { this.room.updateHabbosAt(newLocation); this.room.updateBotsAt(newLocation.getX(), newLocation.getY()); - topItem = room.getTopItemAt(x, y); + topItem = room.getRoomItemManager().getTopItemAt(x, y); if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) { try { topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this }); diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index abd1673f..2e19b25e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -52,7 +52,7 @@ class FreezeHandleSnowballExplosion implements Runnable { THashSet freezeTiles = new THashSet<>(); for (RoomTile roomTile : tiles) { - THashSet items = this.thrownData.room.getItemsAt(roomTile); + THashSet items = this.thrownData.room.getRoomItemManager().getItemsAt(roomTile); for (RoomItem freezeTile : items) { if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index bed23943..e60b022a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -60,7 +60,7 @@ class TeleportActionFive implements Runnable { Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); - RoomItem teleportTile = this.room.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); + RoomItem teleportTile = this.room.getRoomItemManager().getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); if (teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { try { From cb154377e9bcda8c9691452f1536bd7cb58408c7 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sun, 23 Jul 2023 20:18:43 -0500 Subject: [PATCH 27/42] Room.java clean-up --- .../interactions/InteractionDefault.java | 9 ++- .../interactions/InteractionObstacle.java | 2 +- .../interactions/InteractionOneWayGate.java | 74 +++++++++---------- .../com/eu/habbo/habbohotel/rooms/Room.java | 10 +-- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 2 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 15 +--- .../habbo/habbohotel/rooms/RoomTileState.java | 9 --- .../habbohotel/rooms/RoomUnitManager.java | 5 ++ .../entities/units/types/RoomAvatar.java | 2 +- .../rooms/entities/units/types/RoomPet.java | 2 +- 10 files changed, 57 insertions(+), 73 deletions(-) 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 f34df2fe..55cb7c7f 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 @@ -52,11 +52,16 @@ public class InteractionDefault extends RoomItem { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); + //Check if there a no rollers if (room.getRoomItemManager().getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) { - if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) + if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) { continue; // If the unit was previously on the furni... - if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore... + } + + if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) { + continue; // but is not anymore... + } try { this.onWalkOff(unit, room, new Object[]{oldLocation, newLocation}); // the unit walked off! 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 19b388b9..c6969081 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 @@ -179,7 +179,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable { } for(RoomTile tile : this.middleTiles) { - for(RoomUnit roomUnit : tile.getRoomUnits()) { + for(RoomUnit roomUnit : room.getRoomUnitManager().getRoomUnitsAt(tile)) { if(roomUnit == null) { continue; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index 365a566c..934f166e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -76,51 +76,47 @@ public class InteractionOneWayGate extends RoomItem { if (unit == null) return; - if (tileInfront.getX() == unit.getCurrentPosition().getX()) { - if (tileInfront.getY() == unit.getCurrentPosition().getY()) { - if (!currentLocation.hasUnits()) { - List onSuccess = new ArrayList<>(); - List onFail = new ArrayList<>(); + if (tileInfront.equals(unit.getCurrentPosition()) && !room.getRoomUnitManager().areRoomUnitsAt(currentLocation)) { + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); - onSuccess.add(() -> { - unit.setCanLeaveRoomByDoor(false); - walkable = this.getBaseItem().allowWalk(); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4); - unit.setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); + onSuccess.add(() -> { + unit.setCanLeaveRoomByDoor(false); + walkable = this.getBaseItem().allowWalk(); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4); + unit.setGoalLocation(tile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); - Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500); - }); + Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500); + }); - onFail.add(() -> { - unit.setCanLeaveRoomByDoor(true); - walkable = this.getBaseItem().allowWalk(); - room.updateTile(currentLocation); - room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose()); - unit.removeOverrideTile(currentLocation); - }); + onFail.add(() -> { + unit.setCanLeaveRoomByDoor(true); + walkable = this.getBaseItem().allowWalk(); + room.updateTile(currentLocation); + room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose()); + unit.removeOverrideTile(currentLocation); + }); - walkable = true; - room.updateTile(currentLocation); - unit.addOverrideTile(currentLocation); - unit.setGoalLocation(currentLocation); - Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); - room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose()); + walkable = true; + room.updateTile(currentLocation); + unit.addOverrideTile(currentLocation); + unit.setGoalLocation(currentLocation); + Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); + room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose()); - /* - room.scheduledTasks.add(new Runnable() - { - @Override - public void run() - { - gate.roomUnitID = client.getHabbo().getRoomUnit().getId(); - room.updateTile(gatePosition); - client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4)); - } - }); - */ + /* + room.scheduledTasks.add(new Runnable() + { + @Override + public void run() + { + gate.roomUnitID = client.getHabbo().getRoomUnit().getId(); + room.updateTile(gatePosition); + client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4)); } - } + }); + */ } } } 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 99b7d616..f8fb995b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -414,7 +414,7 @@ public class Room implements Comparable, ISerialize, Runnable { boolean walkable = this.layout.tileWalkable(x, y); RoomTile tile = this.getLayout().getTile(x, y); - if ((walkable && tile != null) && (tile.hasUnits() && !this.roomInfo.isAllowWalkthrough())) { + if ((walkable && tile != null) && (this.roomUnitManager.areRoomUnitsAt(tile) && !this.roomInfo.isAllowWalkthrough())) { walkable = false; } @@ -953,7 +953,7 @@ public class Room implements Comparable, ISerialize, Runnable { itemsOnRoller.remove(roller); - if (!rollerTile.hasUnits() && itemsOnRoller.isEmpty()) + if (!this.roomUnitManager.areRoomUnitsAt(rollerTile) && itemsOnRoller.isEmpty()) return true; RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getX(), roller.getY()), roller.getRotation()); @@ -970,7 +970,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (!tileInFront.getAllowStack() && !(tileInFront.isWalkable() || tileInFront.getState() == RoomTileState.SIT || tileInFront.getState() == RoomTileState.LAY)) return true; - if (tileInFront.hasUnits()) + if (this.roomUnitManager.areRoomUnitsAt(tileInFront)) return true; THashSet itemsNewTile = new THashSet<>(); @@ -1025,9 +1025,9 @@ public class Room implements Comparable, ISerialize, Runnable { roomUserRolledEvent = new UserRolledEvent(null, null, null); } - ArrayList unitsOnTile = new ArrayList<>(rollerTile.getRoomUnits()); + ArrayList unitsOnTile = new ArrayList<>(this.roomUnitManager.getRoomUnitsAt(rollerTile)); - for (RoomUnit roomUnit : rollerTile.getRoomUnits()) { + for (RoomUnit roomUnit : this.roomUnitManager.getRoomUnitsAt(rollerTile)) { if (roomUnit instanceof RoomPet) { Pet pet = this.roomUnitManager.getPetByRoomUnit(roomUnit); if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 935073f7..0ebba443 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -304,7 +304,7 @@ public class RoomLayout { continue; } - if (currentAdj.hasUnits() && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + if (this.room.getRoomUnitManager().areRoomUnitsAt(currentAdj) && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 1c4563f8..121e1a74 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -6,9 +6,7 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import lombok.Getter; import lombok.Setter; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; public class RoomTile { @Getter @@ -165,12 +163,6 @@ public class RoomTile { return this.x == x && this.y == y; } - public List getRoomUnits() { - synchronized (this.roomUnits) { - return new ArrayList<>(this.roomUnits); - } - } - public void addRoomUnit(RoomUnit roomUnit) { synchronized (this.roomUnits) { if (!this.roomUnits.contains(roomUnit)) { @@ -185,12 +177,7 @@ public class RoomTile { } } - public boolean hasUnits() { - synchronized (this.roomUnits) { - return !this.roomUnits.isEmpty(); - } - } - + //TODO Move this to RoomUnit public boolean unitIsOnFurniOnTile(RoomUnit roomUnit, Item item) { if ((roomUnit.getCurrentPosition().getX() < this.x || roomUnit.getCurrentPosition().getX() >= this.x + item.getLength())) { return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java index 634ae4c1..96958ca8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTileState.java @@ -2,18 +2,9 @@ package com.eu.habbo.habbohotel.rooms; public enum RoomTileState { - OPEN, - - BLOCKED, - - INVALID, - - SIT, - - LAY } 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 af72d1b4..0e4dcbed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -160,9 +160,14 @@ public class RoomUnitManager { return this.currentRoomUnits.values().stream().filter(roomUnit -> roomUnit.getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } + public boolean areRoomUnitsAt(RoomTile tile) { + return this.currentRoomUnits.values().stream().anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); + } + public Collection getAvatarsAt(RoomTile tile) { return Stream.concat(this.getHabbosAt(tile).stream(), this.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList()); } + public Collection getRoomHabbos() { return this.currentRoomHabbos.values(); } 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 e56fd718..0286fcfc 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 @@ -88,7 +88,7 @@ public class RoomAvatar extends RoomUnit { if (this.getPath().isEmpty()) { this.setSitUpdate(true); - if (next != null && next.hasUnits() && !overrideChecks) { + if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) { this.setStatusUpdateNeeded(false); return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index a7784834..50af859f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -54,7 +54,7 @@ public class RoomPet extends RoomUnit { if (this.getPath().isEmpty()) { this.setSitUpdate(true); - if (next != null && next.hasUnits() && !overrideChecks) { + if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) { this.setStatusUpdateNeeded(false); return false; } From e2b0299aec184e2eae2c5ac2b6f41e7dffc66fe8 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 24 Jul 2023 17:53:40 -0500 Subject: [PATCH 28/42] Fixed Permissions Reloading and more cleanup --- .../eu/habbo/habbohotel/bots/BotManager.java | 8 +- .../habbohotel/campaign/CalendarManager.java | 2 +- .../habbohotel/catalog/CatalogManager.java | 4 +- .../habbohotel/commands/CommandsManager.java | 13 +- .../commands/list/CalendarCommand.java | 2 +- .../commands/list/ChatTypeCommand.java | 2 +- .../list/EmptyBotsInventoryCommand.java | 2 +- .../commands/list/EmptyInventoryCommand.java | 2 +- .../list/EmptyPetsInventoryCommand.java | 2 +- .../commands/list/EnableCommand.java | 2 +- .../commands/list/FreezeBotsCommand.java | 2 +- .../habbohotel/commands/list/LayCommand.java | 2 +- .../commands/list/MimicCommand.java | 4 +- .../commands/list/RoomKickCommand.java | 2 +- .../commands/list/SoftKickCommand.java | 2 +- .../habbohotel/commands/list/TestCommand.java | 31 ---- .../commands/list/UnloadRoomCommand.java | 2 +- .../commands/list/UserInfoCommand.java | 6 +- .../gameclients/GameClientManager.java | 2 +- .../interactions/InteractionGuildGate.java | 2 +- .../interactions/InteractionJukeBox.java | 14 +- .../interactions/InteractionMusicDisc.java | 6 +- .../games/InteractionGameTimer.java | 2 +- .../InteractionBattleBanzaiPuck.java | 11 +- .../WiredEffectChangeFurniDirection.java | 2 +- .../wired/effects/WiredEffectKickRoom.java | 2 +- .../habbohotel/modtool/ModToolManager.java | 6 +- .../habbo/habbohotel/modtool/WordFilter.java | 2 +- .../navigation/NavigatorHotelFilter.java | 4 +- .../navigation/NavigatorPublicFilter.java | 2 +- .../navigation/NavigatorRoomAdsFilter.java | 2 +- .../permissions/PermissionCommand.java | 6 +- .../permissions/PermissionGroup.java | 54 +++--- .../permissions/PermissionsManager.java | 42 ++++- .../com/eu/habbo/habbohotel/rooms/Room.java | 159 ++++-------------- .../habbohotel/rooms/RoomChatMessage.java | 8 +- .../eu/habbo/habbohotel/rooms/RoomInfo.java | 2 +- .../habbohotel/rooms/RoomItemManager.java | 13 +- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 85 +++------- .../habbo/habbohotel/rooms/RoomManager.java | 12 +- .../habbohotel/rooms/RoomRightsManager.java | 2 +- ...{TraxManager.java => RoomTraxManager.java} | 4 +- .../habbohotel/rooms/RoomUnitManager.java | 6 +- .../habbohotel/rooms/entities/RoomEntity.java | 1 + .../rooms/entities/units/RoomUnit.java | 8 +- .../entities/units/types/RoomAvatar.java | 33 ++-- .../rooms/entities/units/types/RoomPet.java | 2 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 21 +-- .../habbo/habbohotel/users/HabboManager.java | 4 +- .../ambassadors/AmbassadorAlertEvent.java | 2 +- .../ambassadors/FollowFriendEvent.java | 2 +- .../incoming/camera/RenderRoomEvent.java | 2 +- .../camera/RenderRoomThumbnailEvent.java | 2 +- .../incoming/catalog/PurchaseEvent.java | 4 +- .../PurchaseFromCatalogAsGiftEvent.java | 6 +- .../catalog/PurchaseFromCatalogEvent.java | 8 +- .../catalog/recycler/PresentOpenEvent.java | 2 +- .../UpdateFloorPropertiesEvent.java | 4 +- .../incoming/friends/AcceptFriendEvent.java | 4 +- .../incoming/friends/RequestFriendEvent.java | 4 +- .../incoming/friends/VisitUserEvent.java | 2 +- .../guides/GuideSessionOnDutyUpdateEvent.java | 6 +- .../guilds/AddAdminRightsToMemberEvent.java | 2 +- .../guilds/ApproveMembershipRequestEvent.java | 2 +- .../incoming/guilds/CreateGuildEvent.java | 2 +- .../incoming/guilds/DeactivateGuildEvent.java | 2 +- .../incoming/guilds/GetGuildMembersEvent.java | 2 +- .../guilds/GetMemberGuildItemCountEvent.java | 2 +- .../incoming/guilds/KickMemberEvent.java | 2 +- .../guilds/RejectMembershipRequestEvent.java | 2 +- .../RemoveAdminRightsFromMemberEvent.java | 2 +- .../guilds/UpdateGuildBadgeEvent.java | 2 +- .../guilds/UpdateGuildColorsEvent.java | 2 +- .../guilds/UpdateGuildIdentityEvent.java | 2 +- .../guilds/UpdateGuildSettingsEvent.java | 2 +- .../guilds/forums/GetMessagesEvent.java | 2 +- .../guilds/forums/ModerateMessageEvent.java | 2 +- .../guilds/forums/ModerateThreadEvent.java | 2 +- .../guilds/forums/PostMessageEvent.java | 2 +- .../guilds/forums/UpdateThreadEvent.java | 2 +- .../incoming/handshake/SSOTicketEvent.java | 2 +- .../modtool/CloseIssueDefaultActionEvent.java | 2 +- .../incoming/modtool/CloseIssuesEvent.java | 2 +- .../incoming/modtool/GetCfhChatlogEvent.java | 2 +- .../modtool/GetModeratorRoomInfoEvent.java | 2 +- .../modtool/GetModeratorUserInfoEvent.java | 2 +- .../incoming/modtool/GetRoomChatlogEvent.java | 2 +- .../incoming/modtool/GetRoomVisitsEvent.java | 2 +- .../incoming/modtool/GetUserChatlogEvent.java | 2 +- .../incoming/modtool/ModAlertEvent.java | 2 +- .../incoming/modtool/ModBanEvent.java | 2 +- .../incoming/modtool/ModMessageEvent.java | 2 +- .../incoming/modtool/ModMuteEvent.java | 2 +- .../ModToolRequestRoomUserChatlogEvent.java | 2 +- .../modtool/ModToolSanctionEvent.java | 2 +- .../incoming/modtool/ModToolWarnEvent.java | 2 +- .../incoming/modtool/ModTradingLockEvent.java | 2 +- .../incoming/modtool/ModerateRoomEvent.java | 2 +- .../modtool/ModeratorActionEvent.java | 2 +- .../incoming/modtool/PickIssuesEvent.java | 2 +- .../incoming/modtool/ReleaseIssuesEvent.java | 2 +- .../navigator/NewNavigatorSearchEvent.java | 2 +- .../rooms/GetFlatControllersEvent.java | 2 +- .../incoming/rooms/RemoveAllRightsEvent.java | 2 +- .../rooms/RequestRoomPropertySet.java | 2 +- .../SetRoomBackgroundColorDataEvent.java | 2 +- .../rooms/SubmitRoomToCompetitionEvent.java | 2 +- .../incoming/rooms/ToggleStaffPickEvent.java | 2 +- .../incoming/rooms/bots/CommandBotEvent.java | 4 +- .../GetBotCommandConfigurationDataEvent.java | 2 +- .../rooms/items/AddSpamWallPostItEvent.java | 2 +- .../rooms/items/MoveWallItemEvent.java | 2 +- .../rooms/items/PickupObjectEvent.java | 2 +- .../incoming/rooms/items/RemoveItemEvent.java | 2 +- .../rooms/items/SetObjectDataEvent.java | 2 +- .../items/jukebox/AddJukeboxDiskEvent.java | 2 +- .../jukebox/GetJukeboxPlayListEvent.java | 5 - .../items/jukebox/GetNowPlayingEvent.java | 5 - .../rooms/items/jukebox/JukeBoxEventOne.java | 5 - .../rooms/items/jukebox/JukeboxEvent.java | 10 +- .../items/jukebox/RemoveJukeboxDiskEvent.java | 4 +- .../RentableSpaceCancelRentEvent.java | 2 +- .../rooms/items/youtube/YoutubeEvent.java | 2 +- .../incoming/rooms/pets/PlacePetEvent.java | 4 +- .../rooms/pets/RemovePetFromFlatEvent.java | 4 +- .../rooms/promotions/EditEventEvent.java | 2 +- .../rooms/promotions/PurchaseRoomAdEvent.java | 4 +- .../rooms/users/AssignRightsEvent.java | 2 +- .../rooms/users/RemoveRightsEvent.java | 2 +- .../rooms/users/RoomUserKickEvent.java | 6 +- .../rooms/users/RoomUserMuteEvent.java | 2 +- .../incoming/rooms/users/SignEvent.java | 7 +- .../incoming/trading/OpenTradingEvent.java | 2 +- .../users/SetChatStylePreferenceEvent.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 2 +- .../incoming/wired/UpdateConditionEvent.java | 2 +- .../incoming/wired/UpdateTriggerEvent.java | 2 +- .../catalog/CatalogPagesListComposer.java | 2 +- .../friends/MessengerInitComposer.java | 2 +- .../HabboGroupDetailsMessageComposer.java | 2 +- .../forums/ForumDataMessageComposer.java | 2 +- .../modtool/ModeratorInitMessageComposer.java | 16 +- .../outgoing/users/UserPerksComposer.java | 10 +- .../users/UserRightsMessageComposer.java | 2 +- .../com/eu/habbo/plugin/PluginManager.java | 6 +- .../threading/runnables/CannonKickAction.java | 2 +- .../runnables/OneWayGateActionOne.java | 2 +- .../threading/runnables/PetFollowHabbo.java | 2 +- .../threading/runnables/RoomTrashing.java | 143 ---------------- 149 files changed, 395 insertions(+), 639 deletions(-) rename src/main/java/com/eu/habbo/habbohotel/rooms/{TraxManager.java => RoomTraxManager.java} (99%) delete mode 100644 src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index de953f17..d5470959 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -112,8 +112,8 @@ public class BotManager { return; if (room != null && bot != null && habbo != null) { - if (room.getRoomInfo().isRoomOwner(habbo) || habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_PLACEFURNI)) { - if (room.getRoomUnitManager().getCurrentRoomBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS)) { + if (room.getRoomInfo().isRoomOwner(habbo) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomUnitManager().getCurrentRoomBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } @@ -184,8 +184,8 @@ public class BotManager { if (pickedUpEvent.isCancelled()) return; - if (habbo == null || (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasRight(Permission.ACC_ANYROOMOWNER))) { - if (habbo != null && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { + if (habbo == null || (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER))) { + if (habbo != null && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { habbo.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + "")); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java index 39e8d5e3..149edffa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java @@ -122,7 +122,7 @@ public class CalendarManager { if (object == null) return; long daysBetween = ChronoUnit.DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); - if (((daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) && (((daysBetween - day <= 2 || !campaign.getLockExpired()) && daysBetween - day >= 0)) || (force && habbo.hasRight(Permission.ACC_CALENDAR_FORCE)))) { + if (((daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) && (((daysBetween - day <= 2 || !campaign.getLockExpired()) && daysBetween - day >= 0)) || (force && habbo.hasPermissionRight(Permission.ACC_CALENDAR_FORCE)))) { if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) { return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 6d5eac7f..2434c6c6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1050,12 +1050,12 @@ public class CatalogManager { UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges); Emulator.getPluginManager().fireEvent(purchasedEvent); - if (!free && !habbo.getClient().getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS) && purchasedEvent.getTotalCredits() > 0) { + if (!free && !habbo.getClient().getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS) && purchasedEvent.getTotalCredits() > 0) { habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.getTotalCredits()); habbo.getClient().sendResponse(new CreditBalanceComposer(habbo.getClient().getHabbo())); } - if (!free && !habbo.getClient().getHabbo().hasRight(Permission.ACC_INFINITE_POINTS) && purchasedEvent.getTotalPoints() > 0) { + if (!free && !habbo.getClient().getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS) && purchasedEvent.getTotalPoints() > 0) { habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -purchasedEvent.getTotalPoints()); habbo.getClient().sendResponse(new HabboActivityPointNotificationMessageComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -purchasedEvent.getTotalPoints(), item.getPointsType())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java index 8217405f..186db286 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java @@ -87,13 +87,16 @@ public class CommandsManager { String commandKey = parts[0]; Room currentRoom = gameClient.getHabbo().getRoomUnit().getRoom(); - boolean hasRights = currentRoom != null && - (currentRoom.getRoomRightsManager().hasRights(gameClient.getHabbo())) || - gameClient.getHabbo().hasRight(Permission.ACC_PLACEFURNI) || - currentRoom.getRoomInfo().getGuild().getId() > 0 && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS); + if(currentRoom == null) { + return false; + } - if (!gameClient.getHabbo().canExecuteCommand(commandKey, hasRights)) { + boolean hasRights = (currentRoom.getRoomRightsManager().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI) || (currentRoom.getRoomInfo().hasGuild() && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)); + + boolean canExecuteCommand = gameClient.getHabbo().canExecuteCommand(commandKey, hasRights); + + if (!canExecuteCommand) { return false; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java index d996bebc..ae2b119a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java @@ -22,7 +22,7 @@ public class CalendarCommand extends Command { if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { String campaignName = Emulator.getConfig().getValue("hotel.calendar.default"); - if (params.length > 1 && gameClient.getHabbo().hasCommand("cmd_calendar_staff")) { + if (params.length > 1 && gameClient.getHabbo().canExecuteCommand("cmd_calendar_staff")) { campaignName = params[1]; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java index 95e25cef..5bca58a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java @@ -33,7 +33,7 @@ public class ChatTypeCommand extends Command { return true; } - if (!gameClient.getHabbo().hasRight(Permission.ACC_ANYCHATCOLOR)) { + if (!gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYCHATCOLOR)) { for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { if (Integer.parseInt(s) == chatColor) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_chatcolor.banned"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java index d2364227..f6be437c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java @@ -32,7 +32,7 @@ public class EmptyBotsInventoryCommand extends Command { if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) { - Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); + Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); if (habbo != null) { TIntObjectHashMap bots = new TIntObjectHashMap<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java index d6dd555b..9e77470c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java @@ -34,7 +34,7 @@ public class EmptyInventoryCommand extends Command { if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) { - Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); + Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); if (habbo != null) { TIntObjectMap items = new TIntObjectHashMap<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java index 7c74e237..e35daa20 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java @@ -32,7 +32,7 @@ public class EmptyPetsInventoryCommand extends Command { if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) { - Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); + Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo(); if (habbo != null) { TIntObjectHashMap pets = new TIntObjectHashMap<>(habbo.getInventory().getPetsComponent().getPets()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java index fad0c8d9..bfe37b2a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java @@ -31,7 +31,7 @@ public class EnableCommand extends Command { if (target == null) { return true; } - if (target == gameClient.getHabbo() || gameClient.getHabbo().hasRight(Permission.ACC_ENABLE_OTHERS)) { + if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ENABLE_OTHERS)) { try { if (target.getRoomUnit().getRoom() != null && target.getHabboInfo().getRiding() == null) { if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java index ced95a10..3737ee87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java @@ -17,7 +17,7 @@ public class FreezeBotsCommand extends Command { } if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId() - || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { gameClient.getHabbo().getRoomUnit().getRoom().setAllowBotsWalk(!gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk()); gameClient.getHabbo().whisper(gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk() ? getTextsValue("commands.succes.cmd_freeze_bots.unfrozen") : getTextsValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT); } else { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java index 62b402bd..3f2b7d54 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java @@ -20,7 +20,7 @@ public class LayCommand extends Command { return true; gameClient.getHabbo().getRoomUnit().setCmdLayEnabled(true); - gameClient.getHabbo().getRoomUnit().getRoom().updateHabbo(gameClient.getHabbo()); + gameClient.getHabbo().getRoomUnit().getRoom().updateRoomUnit(gameClient.getHabbo().getRoomUnit()); gameClient.getHabbo().getRoomUnit().setCmdSitEnabled(true); gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]); 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 752146a7..f2053acd 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 @@ -29,10 +29,10 @@ public class MimicCommand extends Command { if (habbo == gameClient.getHabbo()) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_mimic.not_self"), RoomChatMessageBubbles.ALERT); return true; - } else if (habbo.hasRight(Permission.ACC_NOT_MIMICED) && !gameClient.getHabbo().hasRight(Permission.ACC_NOT_MIMICED)) { + } else if (habbo.hasPermissionRight(Permission.ACC_NOT_MIMICED) && !gameClient.getHabbo().hasPermissionRight(Permission.ACC_NOT_MIMICED)) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.blocked"), params[1]).replace("%gender_name%", getGenderName(habbo)), RoomChatMessageBubbles.ALERT); return true; - } else if (!habbo.hasRight(Permission.ACC_MIMIC_UNREDEEMED) && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) { + } else if (!habbo.hasPermissionRight(Permission.ACC_MIMIC_UNREDEEMED) && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_mimic.forbidden_clothing"), RoomChatMessageBubbles.ALERT); return true; } else { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java index 924d5c52..aa8d24ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java @@ -25,7 +25,7 @@ public class RoomKickCommand extends Command { } for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { - if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { + if (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, true); } } 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 3cb717c7..7e97d4c1 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 @@ -29,7 +29,7 @@ public class SoftKickCommand extends Command { final Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room != null && (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo)))) { + if (room != null && (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo)))) { room.kickHabbo(habbo, false); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java index 6647cc5e..a7c05e22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java @@ -1,10 +1,7 @@ package com.eu.habbo.habbohotel.commands.list; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.messages.ServerMessage; public class TestCommand extends Command { public TestCommand() { @@ -13,34 +10,6 @@ public class TestCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL) || !Emulator.debugging) - return false; - - int header = Integer.parseInt(params[1]); - - ServerMessage message = new ServerMessage(header); - - for (int i = 1; i < params.length; i++) { - String[] data = params[i].split(":"); - - if (data[0].equalsIgnoreCase("b")) { - message.appendBoolean(data[1].equalsIgnoreCase("1")); - } else if (data[0].equalsIgnoreCase("s")) { - if (data.length > 1) { - message.appendString(data[1]); - } else { - message.appendString(""); - } - } else if (data[0].equals("i")) { - message.appendInt(Integer.parseInt(data[1])); - } else if (data[0].equalsIgnoreCase("by")) { - message.appendByte(Integer.parseInt(data[1])); - } else if (data[0].equalsIgnoreCase("sh")) { - message.appendShort(Integer.parseInt(data[1])); - } - } - - gameClient.sendResponse(message); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java index 31245b31..f8bb0e38 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java @@ -15,7 +15,7 @@ public class UnloadRoomCommand extends Command { public boolean handle(GameClient gameClient, String[] params) { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room != null && (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room != null && (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { room.dispose(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java index 6b89e602..9637e77b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java @@ -44,9 +44,9 @@ public class UserInfoCommand extends Command { getTextsValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" + getTextsValue("command.cmd_userinfo.rank") + ": " + habbo.getPermissionGroup().getName() + " (" + habbo.getPermissionGroup().getId() + ") \r" + getTextsValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" + - ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_MAIL, true)) ? "" : getTextsValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") + - ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_IP, true)) ? "" : getTextsValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") + - ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : getTextsValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") + + ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_MAIL, true)) ? "" : getTextsValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") + + ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_IP, true)) ? "" : getTextsValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") + + ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : getTextsValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") + (onlineHabbo != null ? getTextsValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().getAchievementScore() + "\r" : "")); ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId()); diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java index 354429a3..e39b5fc3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java @@ -152,7 +152,7 @@ public class GameClientManager { continue; if (client.getHabbo() != null) { - if (client.getHabbo().hasRight(minPermission)) { + if (client.getHabbo().hasPermissionRight(minPermission)) { client.sendResponse(message); } } 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 04dbcf76..802049a1 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 @@ -37,7 +37,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); - return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasRight(Permission.ACC_GUILDGATE)); + return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasPermissionRight(Permission.ACC_GUILDGATE)); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index 32550f6e..ccc4287c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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 java.sql.ResultSet; @@ -48,10 +48,10 @@ public class InteractionJukeBox extends RoomItem { if (client != null && objects.length == 1) { if ((Integer) objects[0] == 0) { - if (room.getTraxManager().isPlaying()) { - room.getTraxManager().stop(); + if (room.getRoomTraxManager().isPlaying()) { + room.getRoomTraxManager().stop(); } else { - room.getTraxManager().play(0, client.getHabbo()); + room.getRoomTraxManager().play(0, client.getHabbo()); } } } @@ -61,14 +61,14 @@ public class InteractionJukeBox extends RoomItem { public void onPickUp(Room room) { super.onPickUp(room); this.setExtradata("0"); - room.getTraxManager().removeTraxOnRoom(this); + room.getRoomTraxManager().removeTraxOnRoom(this); } @Override public void onPlace(Room room) { super.onPlace(room); - room.getTraxManager().addTraxOnRoom(this); - if (room.getTraxManager().isPlaying()) { + room.getRoomTraxManager().addTraxOnRoom(this); + if (room.getRoomTraxManager().isPlaying()) { this.setExtradata("1"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index 4781c84d..d81205aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -2,8 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; 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.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; @@ -74,13 +74,13 @@ public class InteractionMusicDisc extends RoomItem { public void onPlace(Room room) { super.onPlace(room); - room.getTraxManager().sendUpdatedSongList(); + room.getRoomTraxManager().sendUpdatedSongList(); } @Override public void onPickUp(Room room) { super.onPickUp(room); - room.getTraxManager().sendUpdatedSongList(); + room.getRoomTraxManager().sendUpdatedSongList(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 4e78d220..4be41c87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -232,7 +232,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { Emulator.getThreading().run(new GameTimer(this), 1000); } } else if (client != null) { - if (!(room.getRoomRightsManager().hasRights(client.getHabbo()) || client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER))) + if (!(room.getRoomRightsManager().hasRights(client.getHabbo()) || client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER))) return; InteractionGameTimerAction state = InteractionGameTimerAction.START_STOP; 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 ff46ef08..b30ecadc 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 @@ -127,11 +127,14 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { - if (to == null) return false; + if (to == null) { + return false; + } + RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this); - return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); - - //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); + + return !(!room.getLayout().tileWalkable(to) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); + //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 314e81e9..38da5f61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -87,7 +87,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); int count = 1; - while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { + while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.getLayout().tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { setting.setDirection(this.nextDirection(setting.getDirection())); RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); 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 fde18241..12523f21 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 @@ -33,7 +33,7 @@ public class WiredEffectKickRoom extends InteractionWiredEffect { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo != null) { - if (habbo.hasRight(Permission.ACC_UNKICKABLE)) { + if (habbo.hasPermissionRight(Permission.ACC_UNKICKABLE)) { habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.unkickable")); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 651513a1..27e7c1d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -386,7 +386,7 @@ public class ModToolManager { } public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) { - if (!moderator.hasRight(Permission.ACC_SUPPORTTOOL)) { + if (!moderator.hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { ScripterManager.scripterDetected(moderator.getClient(), Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message)); return; } @@ -401,7 +401,7 @@ public class ModToolManager { } public void kick(Habbo moderator, Habbo target, String message) { - if (moderator.hasRight(Permission.ACC_SUPPORTTOOL) && !target.hasRight(Permission.ACC_UNKICKABLE)) { + if (moderator.hasPermissionRight(Permission.ACC_SUPPORTTOOL) && !target.hasPermissionRight(Permission.ACC_UNKICKABLE)) { if (target.getRoomUnit().getRoom() != null) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getRoomUnit().getRoom()); } @@ -484,7 +484,7 @@ public class ModToolManager { if (roomActionEvent.isKickUsers()) { for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { - if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { + if (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, false); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 8310645f..5c625d03 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -125,7 +125,7 @@ public class WordFilter { public String filter(String message, Habbo habbo) { String filteredMessage = message; - if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) || (habbo != null && habbo.hasRight(Permission.ACC_CHAT_NO_FILTER))) { + if (!Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) || (habbo != null && habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER))) { return message; } if (Emulator.getConfig().getBoolean("hotel.wordfilter.normalise")) { diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java index 012cce5f..7ae56f39 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java @@ -19,7 +19,7 @@ public class NavigatorHotelFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo) { - boolean showInvisible = habbo.hasRight(Permission.ACC_ENTERANYROOM) || habbo.hasRight(Permission.ACC_ANYROOMOWNER); + boolean showInvisible = habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER); List resultLists = new ArrayList<>(); int i = 0; @@ -41,7 +41,7 @@ public class NavigatorHotelFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) { - boolean showInvisible = habbo.hasRight(Permission.ACC_ENTERANYROOM) || habbo.hasRight(Permission.ACC_ANYROOMOWNER); + boolean showInvisible = habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER); if (!filterField.getDatabaseQuery().isEmpty()) { List resultLists = new ArrayList<>(); int i = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java index 1a50fd4a..8b2a02be 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java @@ -16,7 +16,7 @@ public class NavigatorPublicFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo) { - boolean showInvisible = habbo.hasRight(Permission.ACC_ENTERANYROOM) || habbo.hasRight(Permission.ACC_ANYROOMOWNER); + boolean showInvisible = habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER); List resultLists = new ArrayList<>(); int i = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java index 84baf63f..7ca46762 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java @@ -16,7 +16,7 @@ public class NavigatorRoomAdsFilter extends NavigatorFilter { @Override public List getResult(Habbo habbo) { - boolean showInvisible = habbo.hasRight(Permission.ACC_ENTERANYROOM) || habbo.hasRight(Permission.ACC_ANYROOMOWNER); + boolean showInvisible = habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER); List resultList = new ArrayList<>(); resultList.add(new SearchResultList(0, "categories", "", SearchAction.NONE, habbo.getHabboStats().getNavigatorWindowSettings().getListModeForCategory("categories", ListMode.LIST), habbo.getHabboStats().getNavigatorWindowSettings().getDisplayModeForCategory("official-root", DisplayMode.VISIBLE), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("categories", habbo), false, showInvisible, DisplayOrder.ACTIVITY, 0)); return resultList; diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionCommand.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionCommand.java index b0326644..15355970 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionCommand.java @@ -1,17 +1,17 @@ package com.eu.habbo.habbohotel.permissions; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; +@Slf4j +@Getter public class PermissionCommand { - @Getter private final String name; - private final String description; - @Getter private final String[] keys; public PermissionCommand(ResultSet set) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java index 39966284..87ea6450 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java @@ -4,7 +4,10 @@ import com.eu.habbo.Emulator; import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -29,8 +32,8 @@ public class PermissionGroup { private final String prefix; @Getter private final String prefixColor; - private final Map commands; - private final Map rights; + private final Map commands; + private final Map rights; @Getter final Map timers; @@ -57,13 +60,19 @@ public class PermissionGroup { } private void loadCommands(Map commandsAvailable) { + this.commands.clear(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permission_group_commands WHERE group_id = ?")) { statement.setInt(1, this.id); try(ResultSet set = statement.executeQuery()) { while (set.next()) { String commandName = set.getString("command_name"); PermissionCommand command = commandsAvailable.values().stream().filter(commandAvailable -> commandAvailable.getName().equalsIgnoreCase(commandName)).findFirst().orElse(null); - this.commands.put(command, PermissionSetting.fromString(set.getString("setting_type"))); + + if(command != null) { + PermissionSetting setting = PermissionSetting.fromString(set.getString("setting_type")); + this.commands.put(command.getName(), setting); + } } } } catch (SQLException e) { @@ -72,13 +81,18 @@ public class PermissionGroup { } private void loadRights(Map rightsAvailable) { + this.rights.clear(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permission_group_rights WHERE group_id = ?")) { statement.setInt(1, this.id); try(ResultSet set = statement.executeQuery()) { while (set.next()) { String rightName = set.getString("right_name"); PermissionRight right = rightsAvailable.values().stream().filter(rightAvailable -> rightAvailable.getName().equalsIgnoreCase(rightName)).findFirst().orElse(null); - this.rights.put(right, PermissionSetting.fromString(set.getString("setting_type"))); + + if(right != null) { + this.rights.put(right.getName(), PermissionSetting.fromString(set.getString("setting_type"))); + } } } } catch (SQLException e) { @@ -87,6 +101,8 @@ public class PermissionGroup { } private void loadTimers() { + this.timers.clear(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permission_group_timers WHERE group_id = ? ORDER BY id ASC")) { statement.setInt(1, this.id); try(ResultSet set = statement.executeQuery()) { @@ -112,22 +128,22 @@ public class PermissionGroup { return true; } - PermissionSetting setting = this.commands.get(command); - return setting == PermissionSetting.ALLOWED || (setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights); - } + if(this.commands.containsKey(command.getName())) { + PermissionSetting setting = this.commands.get(command.getName()); - public boolean hasCommand(String name, boolean hasRoomRights) { - PermissionCommand command = Emulator.getGameEnvironment().getPermissionsManager().getCommand(name); - if (this.commands.containsKey(command)) { - PermissionSetting setting = this.commands.get(command); - return (setting == PermissionSetting.ALLOWED || (setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights)); + if(setting == null) { + return false; + } + + return setting == PermissionSetting.ALLOWED || (setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights); } + return false; } - public boolean hasRight(String name, boolean hasRoomRights) { + public boolean hasPermissionRight(String name, boolean hasRoomRights) { PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(name); - if(this.rights.containsKey(right)) { + if(right != null && this.rights.containsKey(right)) { PermissionSetting setting = this.rights.get(right); return (setting == PermissionSetting.ALLOWED || (setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights)); } @@ -143,14 +159,14 @@ public class PermissionGroup { return 0; } - public List getCommands() { - Collection fixedCommands = Emulator.getGameEnvironment().getPermissionsManager().getFixedCommands(); - Set commands = this.commands.keySet(); + public List getCommands() { + Collection fixedCommands = Emulator.getGameEnvironment().getPermissionsManager().getFixedCommands(); + Set commands = this.commands.keySet(); return Stream.concat(fixedCommands.stream(), commands.stream()).collect(Collectors.toList()); } - public Set getRights() { + public Set getRights() { return this.rights.keySet(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index 87baed35..83661432 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -10,12 +10,14 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; @Slf4j public class PermissionsManager { - private final Map permissionGroups; + private final ConcurrentHashMap permissionGroups; private final Map permissionCommands; private final Map fixedCommands; private final Map permissionRights; @@ -23,7 +25,7 @@ public class PermissionsManager { public PermissionsManager() { long millis = System.currentTimeMillis(); - this.permissionGroups = new HashMap<>(); + this.permissionGroups = new ConcurrentHashMap<>(); this.permissionCommands = new HashMap<>(); this.fixedCommands = new HashMap<>(); this.permissionRights = new HashMap<>(); @@ -37,21 +39,34 @@ public class PermissionsManager { this.loadPermissionRights(); this.loadPermissionGroups(); this.loadEnables(); + log.info(this.permissionGroups.size() + " ranks, " + this.permissionCommands.size() + " commands " + this.permissionRights.size() + " rights -> Loaded!"); } + /** + * Load permission groups information, commands and rights + */ private void loadPermissionGroups() { + HashSet currentGroupIds = new HashSet<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permission_groups ORDER BY id ASC")) { while (set.next()) { PermissionGroup permissionGroup = new PermissionGroup(set, this.permissionCommands, this.permissionRights); this.permissionGroups.put(permissionGroup.getId(), permissionGroup); + currentGroupIds.add(permissionGroup.getId()); } } catch (SQLException e) { log.error("Caught SQL exception", e); } + + this.permissionGroups.entrySet().removeIf(entry -> !currentGroupIds.contains(entry.getKey())); } + /** + * Load every available command in the database + */ private void loadPermissionCommands() { + this.permissionCommands.clear(); + this.loadFixedCommands(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permission_commands")) { @@ -62,8 +77,14 @@ public class PermissionsManager { } catch (SQLException e) { log.error("Caught SQL exception", e); } + + log.info("Loaded {} available commands!", this.permissionCommands.size()); } + /** + * Load fixed commands, any command that doesn't require a permission + * these commands are always available for any user + */ private void loadFixedCommands() { String[] fixedCommandNames = { "cmd_about", @@ -75,7 +96,8 @@ public class PermissionsManager { "cmd_mute_pets", "cmd_plugins", "cmd_sit", - "cmd_stand" + "cmd_stand", + "cmd_test" }; for(String command : fixedCommandNames) { @@ -86,11 +108,19 @@ public class PermissionsManager { } } + /** + * Add a fixed command through plugins if you want to include a fixed command + * on main source make use of `loadFixedCommands()` instead + * + * @param fixedCommand A command that will be always available to any user + */ public void addFixedCommand(PermissionCommand fixedCommand) { this.fixedCommands.put(fixedCommand.getName(), fixedCommand); } private void loadPermissionRights() { + this.permissionRights.clear(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permission_rights")) { while (set.next()) { PermissionRight permissionRight = new PermissionRight(set); @@ -99,6 +129,8 @@ public class PermissionsManager { } catch (SQLException e) { log.error("Caught SQL exception", e); } + + log.info("Loaded {} available rights!", this.permissionRights.size()); } private void loadEnables() { @@ -140,8 +172,8 @@ public class PermissionsManager { .orElseGet(() -> null); } - public Collection getFixedCommands() { - return this.fixedCommands.values(); + public Collection getFixedCommands() { + return this.fixedCommands.keySet(); } public boolean isFixedCommand(String name) { 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 f8fb995b..e884a59f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -55,7 +55,6 @@ import com.eu.habbo.plugin.events.users.UserRolledEvent; import com.eu.habbo.plugin.events.users.UsernameTalkEvent; import com.eu.habbo.threading.runnables.YouAreAPirate; import gnu.trove.TCollections; -import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntIntMap; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntIntHashMap; @@ -91,7 +90,7 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter private final RoomRightsManager roomRightsManager; @Getter - private TraxManager traxManager; + private RoomTraxManager roomTraxManager; private static final String CAUGHT_EXCEPTION = "Caught exception"; public static final Comparator SORT_SCORE = (o1, o2) -> o2.roomInfo.getScore() - o1.roomInfo.getScore(); public static final Comparator SORT_ID = (o1, o2) -> o2.roomInfo.getId() - o1.roomInfo.getId(); @@ -122,7 +121,6 @@ public class Room implements Comparable, ISerialize, Runnable { private final TIntIntMap furniOwnerCount; @Getter private final THashSet wordFilterWords; - private final TIntObjectMap roomItems; private final Object loadLock = new Object(); //Use appropriately. Could potentially cause memory leaks when used incorrectly. public volatile boolean preventUnloading = false; @@ -206,7 +204,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.allowEffects = true; this.furniOwnerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); this.furniOwnerCount = TCollections.synchronizedMap(new TIntIntHashMap(0)); - this.roomItems = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); this.wordFilterWords = new THashSet<>(0); this.mutedHabbos = new TIntIntHashMap(); @@ -232,10 +229,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadLayout(); this.roomRightsManager.load(connection); - - //TODO Deprecated - this.loadItems(connection); - this.roomItemManager.load(connection); this.loadHeightmap(); this.roomUnitManager.load(connection); @@ -249,10 +242,10 @@ public class Room implements Comparable, ISerialize, Runnable { log.error(CAUGHT_EXCEPTION, e); } - this.traxManager = new TraxManager(this); + this.roomTraxManager = new RoomTraxManager(this); if (this.roomInfo.isJukeboxEnabled()) { - this.traxManager.play(0); + this.roomTraxManager.play(0); for (RoomItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) { this.updateItem(item.setExtradata("1")); } @@ -299,28 +292,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private synchronized void loadItems(Connection connection) { - this.roomItems.clear(); - - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set); - this.getRoomItemManager().addRoomItem(item); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - - if (this.getRoomItemManager().getCurrentItems().size() > Room.MAXIMUM_FURNI) { - log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.getRoomItemManager().getCurrentItems().size(), Room.MAXIMUM_FURNI); - } - } - private synchronized void loadWordFilter(Connection connection) { this.wordFilterWords.clear(); @@ -406,25 +377,6 @@ public class Room implements Comparable, ISerialize, Runnable { return result; } - public boolean tileWalkable(RoomTile t) { - return this.tileWalkable(t.getX(), t.getY()); - } - - public boolean tileWalkable(short x, short y) { - boolean walkable = this.layout.tileWalkable(x, y); - RoomTile tile = this.getLayout().getTile(x, y); - - if ((walkable && tile != null) && (this.roomUnitManager.areRoomUnitsAt(tile) && !this.roomInfo.isAllowWalkthrough())) { - walkable = false; - } - - return walkable; - } - - public void updateHabbo(Habbo habbo) { - this.updateRoomUnit(habbo.getRoomUnit()); - } - public void updateRoomUnit(RoomUnit roomUnit) { RoomItem item = this.roomItemManager.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); @@ -566,8 +518,8 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.loaded) { try { - if (this.traxManager != null && !this.traxManager.disposed()) { - this.traxManager.dispose(); + if (this.roomTraxManager != null && !this.roomTraxManager.disposed()) { + this.roomTraxManager.dispose(); } this.roomCycleTask.cancel(false); @@ -592,35 +544,17 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomUnitManager.removeAllPetsExceptRoomOwner(); - synchronized (this.roomItems) { - TIntObjectIterator iterator = this.roomItems.iterator(); - - - for (int i = this.roomItems.size(); i-- > 0; ) { - try { - iterator.advance(); - - if (iterator.value().needsUpdate()) - iterator.value().run(); - } catch (NoSuchElementException e) { - break; - } - } - } + this.roomItemManager.dispose(); if (this.roomSpecialTypes != null) { this.roomSpecialTypes.dispose(); } - synchronized (this.roomItems) { - this.roomItems.clear(); - } - synchronized (this.habboQueue) { this.habboQueue.clear(); } - this.roomUnitManager.dispose(this); + this.roomUnitManager.dispose(); } catch (Exception e) { log.error(CAUGHT_EXCEPTION, e); } @@ -851,6 +785,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.cycleRoomUnit(habbo.getRoomUnit())) { + habbo.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(habbo.getRoomUnit()); } } @@ -883,6 +818,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.cycleRoomUnit(bot.getRoomUnit())) { + bot.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(bot.getRoomUnit()); } @@ -905,6 +841,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.cycleRoomUnit(pet.getRoomUnit())) { + pet.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(pet.getRoomUnit()); } @@ -938,7 +875,7 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem newRoller = null; - RoomTile rollerTile = this.getLayout().getTile(roller.getX(), roller.getY()); + RoomTile rollerTile = this.layout.getTile(roller.getX(), roller.getY()); if (rollerTile == null) return true; @@ -1164,7 +1101,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new UserUpdateComposer(updatedUnit).compose()); } - this.traxManager.cycle(); + this.roomTraxManager.cycle(); } else { if (this.roomIdleCycles < 60) @@ -1199,32 +1136,23 @@ public class Room implements Comparable, ISerialize, Runnable { } private boolean cycleRoomUnit(RoomUnit unit) { - boolean update = unit.isStatusUpdateNeeded(); - - if (unit.hasStatus(RoomUnitStatus.SIGN)) { - this.sendComposer(new UserUpdateComposer(unit).compose()); - unit.removeStatus(RoomUnitStatus.SIGN); - } - + //Si esta caminando y su path no es nulo ni esta vacio if (unit.isWalking() && unit.getPath() != null && !unit.getPath().isEmpty()) { - if (!unit.cycle(this)) { - return true; - } + unit.cycle(this); + //Si no esta caminando o su path tiene errores } else { + //Y tiene el status de move, quitaselo y ocupa update if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.isAnimateWalk()) { unit.removeStatus(RoomUnitStatus.MOVE); - - update = true; } if (!unit.isWalking() && !unit.isCmdSitEnabled()) { - RoomTile thisTile = this.getLayout().getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); + RoomTile thisTile = this.layout.getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); RoomItem topItem = this.roomItemManager.getTallestChair(thisTile); if (topItem == null || !topItem.getBaseItem().allowSit()) { if (unit.hasStatus(RoomUnitStatus.SIT)) { unit.removeStatus(RoomUnitStatus.SIT); - update = true; } } else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) { if(unit instanceof RoomAvatar roomAvatar) { @@ -1245,7 +1173,6 @@ public class Room implements Comparable, ISerialize, Runnable { if (topItem == null || !topItem.getBaseItem().allowLay()) { if (unit.hasStatus(RoomUnitStatus.LAY)) { unit.removeStatus(RoomUnitStatus.LAY); - update = true; } } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { @@ -1257,16 +1184,11 @@ public class Room implements Comparable, ISerialize, Runnable { } else { unit.setLocation(this.layout.getTile(topItem.getX(), unit.getCurrentPosition().getY())); } - update = true; } } } - if (update) { - unit.setStatusUpdateNeeded(false); - } - - return update; + return unit.isStatusUpdateNeeded(); } public void setDiagonalMoveEnabled(boolean moveDiagonally) { @@ -1441,7 +1363,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet habbos = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - RoomTile tile = this.getLayout().getTile(x, y); + RoomTile tile = this.layout.getTile(x, y); habbos.addAll(this.roomUnitManager.getHabbosAt(tile)); } } @@ -1453,7 +1375,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet bots = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - RoomTile tile = this.getLayout().getTile(x, y); + RoomTile tile = this.layout.getTile(x, y); bots.addAll(this.roomUnitManager.getBotsAt(tile)); } } @@ -1465,7 +1387,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet pets = new THashSet<>(); for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { - RoomTile tile = this.getLayout().getTile(x, y); + RoomTile tile = this.layout.getTile(x, y); pets.addAll(this.roomUnitManager.getPetsAt(tile)); } } @@ -1601,7 +1523,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals("")) return; - if (!habbo.hasRight(Permission.ACC_NOMUTE) && (!MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) { + if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE) && (!MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) { for (RoomItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentPosition())) { return; @@ -1609,13 +1531,13 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.wordFilterWords.isEmpty() && !habbo.hasRight(Permission.ACC_CHAT_NO_FILTER)) { + if (!this.wordFilterWords.isEmpty() && !habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { for (String string : this.wordFilterWords) { roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); } } - if (!habbo.hasRight(Permission.ACC_NOMUTE)) { + if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE)) { if (this.isMuted() && !this.roomRightsManager.hasRights(habbo)) { return; } @@ -1641,7 +1563,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!habbo.hasRight(Permission.ACC_CHAT_NO_FLOOD)) { + if (!habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FLOOD)) { final int chatCounter = habbo.getHabboStats().getChatCounter().addAndGet(1); if (chatCounter > 3) { @@ -1705,13 +1627,13 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } - if (h.hasRight(Permission.ACC_SEE_WHISPERS)) { + if (h.hasPermissionRight(Permission.ACC_SEE_WHISPERS)) { h.getClient().sendResponse(staffMessage); } } } else if (chatType == RoomChatType.TALK) { ServerMessage message = new ChatMessageComposer(roomChatMessage).compose(); - boolean noChatLimit = habbo.hasRight(Permission.ACC_CHAT_NO_LIMIT); + boolean noChatLimit = habbo.hasPermissionRight(Permission.ACC_CHAT_NO_LIMIT); for (Habbo h : this.roomUnitManager.getRoomHabbos()) { if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= this.roomInfo.getChatDistance() || @@ -1813,7 +1735,7 @@ public class Room implements Comparable, ISerialize, Runnable { * @param tentRectangle The whole tent area from where the sending Habbo is saying something */ private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) { - if (receivingHabbo != null && receivingHabbo.hasRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentPosition())) { + if (receivingHabbo != null && receivingHabbo.hasPermissionRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentPosition())) { RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage()); final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); @@ -1869,7 +1791,6 @@ public class Room implements Comparable, ISerialize, Runnable { } public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) { - if (x < 0 || y < 0 || this.layout == null) return calculateHeightmap ? Short.MAX_VALUE : 0.0; @@ -1922,7 +1843,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canSitOrLayAt(int x, int y) { - RoomTile tile = this.getLayout().getTile((short) x, (short) y); + RoomTile tile = this.layout.getTile((short) x, (short) y); if(tile == null) { return false; @@ -1937,7 +1858,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canSitAt(int x, int y) { - RoomTile tile = this.getLayout().getTile((short) x, (short) y); + RoomTile tile = this.layout.getTile((short) x, (short) y); if(tile == null) { return false; @@ -2110,7 +2031,7 @@ public class Room implements Comparable, ISerialize, Runnable { public boolean isBanned(Habbo habbo) { RoomBan ban = this.bannedHabbos.get(habbo.getHabboInfo().getId()); - boolean banned = ban != null && ban.getEndTimestamp() > Emulator.getIntUnixTimestamp() && !habbo.hasRight(Permission.ACC_ANYROOMOWNER) && !habbo.hasRight(Permission.ACC_ENTERANYROOM); + boolean banned = ban != null && ban.getEndTimestamp() > Emulator.getIntUnixTimestamp() && !habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM); if (!banned && ban != null) { this.unbanHabbo(habbo.getHabboInfo().getId()); @@ -2135,7 +2056,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (item != null && item.getRoomId() == this.roomInfo.getId() && item.getBaseItem() != null) { if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.sendComposer(new ObjectUpdateMessageComposer(item).compose()); - this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new ItemUpdateMessageComposer(item).compose()); } @@ -2153,7 +2074,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (item.getBaseItem().getType() == FurnitureType.FLOOR) { if (this.layout == null) return; - this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); if (item instanceof InteractionMultiHeight interactionMultiHeight) { interactionMultiHeight.updateUnitsOnItem(this); @@ -2168,7 +2089,7 @@ public class Room implements Comparable, ISerialize, Runnable { public int getUserUniqueFurniCount(int userId) { THashSet items = new THashSet<>(); - for (RoomItem item : this.roomItems.valueCollection()) { + for (RoomItem item : this.roomItemManager.getCurrentItems().values()) { if (!items.contains(item.getBaseItem()) && item.getOwnerId() == userId) items.add(item.getBaseItem()); } @@ -2193,16 +2114,10 @@ public class Room implements Comparable, ISerialize, Runnable { public void refreshGuildColors(Guild guild) { if (guild.getRoomId() == this.roomInfo.getId()) { - TIntObjectIterator iterator = this.roomItems.iterator(); + Iterator iterator = this.roomItemManager.getCurrentItems().values().iterator(); for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) { - try { - iterator.advance(); - } catch (Exception e) { - break; - } - - RoomItem roomItem = iterator.value(); + RoomItem roomItem = iterator.next(); if (roomItem instanceof InteractionGuildFurni interactionGuildFurni && interactionGuildFurni.getGuildId() == guild.getId()) { this.updateItem(roomItem); @@ -2214,7 +2129,7 @@ public class Room implements Comparable, ISerialize, Runnable { public void refreshGuildRightsInRoom() { for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) - && (!(habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_MOVEROTATE)))) + && (!(habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_MOVEROTATE)))) this.getRoomRightsManager().refreshRightsForHabbo(habbo); } } 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 e8d0aeca..c3dfb3f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -60,7 +60,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { this.bubble = RoomChatMessageBubbles.NORMAL; } - if (!message.client.getHabbo().hasRight(Permission.ACC_ANYCHATCOLOR)) { + if (!message.client.getHabbo().hasPermissionRight(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { if (i == this.bubble.getType()) { this.bubble = RoomChatMessageBubbles.NORMAL; @@ -155,7 +155,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { @Override public void serialize(ServerMessage message) { if (this.habbo != null && this.bubble.isOverridable()) { - if (!this.habbo.hasRight(Permission.ACC_ANYCHATCOLOR)) { + if (!this.habbo.hasPermissionRight(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { if (i == this.bubble.getType()) { this.bubble = RoomChatMessageBubbles.NORMAL; @@ -166,7 +166,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { } if (!this.getBubble().getPermission().isEmpty()) { - if (this.habbo != null && !this.habbo.hasRight(this.getBubble().getPermission())) { + if (this.habbo != null && !this.habbo.hasPermissionRight(this.getBubble().getPermission())) { this.bubble = RoomChatMessageBubbles.NORMAL; } } @@ -191,7 +191,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { } if (Emulator.getConfig().getBoolean("hotel.wordfilter.enabled", true) && Emulator.getConfig().getBoolean("hotel.wordfilter.rooms")) { - if (!this.habbo.hasRight(Permission.ACC_CHAT_NO_FILTER)) { + if (!this.habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { if (!Emulator.getGameEnvironment().getWordFilter().autoReportCheck(this)) { if (!Emulator.getGameEnvironment().getWordFilter().hideMessageCheck(this.message)) { Emulator.getGameEnvironment().getWordFilter().filter(this, this.habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java index 25464bb7..ac7f27b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomInfo.java @@ -197,7 +197,7 @@ public class RoomInfo { } public boolean isRoomOwner(Habbo owner) { - return this.ownerInfo.getId() == owner.getHabboInfo().getId() || owner.hasRight(Permission.ACC_ANYROOMOWNER); + return this.ownerInfo.getId() == owner.getHabboInfo().getId() || owner.hasPermissionRight(Permission.ACC_ANYROOMOWNER); } public String[] filterAnything() { 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 db0b8345..7aef2ba5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -232,7 +232,7 @@ public class RoomItemManager { return FurnitureMovementError.MAX_SOUNDFURNI; } else if (tile == null || tile.getState() == RoomTileState.INVALID) { return FurnitureMovementError.INVALID_MOVE; - } else if (this.room.getRoomRightsManager().hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) { + } else if (this.room.getRoomRightsManager().hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasPermissionRight(Permission.ACC_MOVEROTATE)) { return FurnitureMovementError.NONE; } @@ -1089,4 +1089,15 @@ public class RoomItemManager { this.addUndefined(item); } } + + public void dispose() { + this.currentItems.values().parallelStream() + .filter(RoomItem::needsUpdate) + .forEach(roomItem -> { + roomItem.run(); + this.currentItems.remove(roomItem.getId()); + }); + + this.currentItems.clear(); + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 0ebba443..8969b489 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -3,6 +3,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import java.awt.*; @@ -17,16 +19,30 @@ public class RoomLayout { public static double MAXIMUM_STEP_HEIGHT = 1.1; public static boolean ALLOW_FALLING = true; public boolean CANMOVEDIAGONALY = true; + @Getter private String name; + @Getter + @Setter private short doorX; + @Getter + @Setter private short doorY; + @Getter private short doorZ; + @Getter + @Setter private int doorDirection; + @Getter + @Setter private String heightmap; + @Getter private int mapSize; + @Getter private int mapSizeX; + @Getter private int mapSizeY; private RoomTile[][] roomTiles; + @Getter private RoomTile doorTile; private final Room room; @@ -143,62 +159,6 @@ public class RoomLayout { } } - public String getName() { - return this.name; - } - - public short getDoorX() { - return this.doorX; - } - - public void setDoorX(short doorX) { - this.doorX = doorX; - } - - public short getDoorY() { - return this.doorY; - } - - public void setDoorY(short doorY) { - this.doorY = doorY; - } - - public int getDoorZ() { - return this.doorZ; - } - - public RoomTile getDoorTile() { - return this.doorTile; - } - - public int getDoorDirection() { - return this.doorDirection; - } - - public void setDoorDirection(int doorDirection) { - this.doorDirection = doorDirection; - } - - public String getHeightmap() { - return this.heightmap; - } - - public void setHeightmap(String heightMap) { - this.heightmap = heightMap; - } - - public int getMapSize() { - return this.mapSize; - } - - public int getMapSizeX() { - return this.mapSizeX; - } - - public int getMapSizeY() { - return this.mapSizeY; - } - public short getHeightAtSquare(int x, int y) { if (x < 0 || y < 0 || @@ -241,8 +201,19 @@ public class RoomLayout { return !(x < 0 || y < 0 || x >= this.getMapSizeX() || y >= this.getMapSizeY()); } + public boolean tileWalkable(RoomTile tile) { + return this.tileWalkable(tile.getX(), tile.getY()); + } + public boolean tileWalkable(short x, short y) { - return this.tileExists(x, y) && this.roomTiles[x][y].getState() == RoomTileState.OPEN && this.roomTiles[x][y].isWalkable(); + boolean walkable = false; + + if(this.tileExists(x, y)) { + RoomTile tile = this.getTile(x, y); + walkable = tile.getState().equals(RoomTileState.OPEN) && tile.isWalkable() && (this.room.getRoomUnitManager().areRoomUnitsAt(tile) && !this.room.getRoomInfo().isAllowWalkthrough()); + } + + return walkable; } public boolean isVoidTile(short x, short y) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index d300ab2d..1c346abc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -491,13 +491,13 @@ public class RoomManager { } //If Habbo is banned AND doesn't have Permissions can't enter to room - if (room.isBanned(habbo) && !room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasRight(Permission.ACC_ENTERANYROOM)) { + if (room.isBanned(habbo) && !room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM)) { habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED)); return; } //If room is full AND user doesn't have Permissions can't enter to room - if (room.getRoomUnitManager().getRoomHabbosCount() >= room.getRoomInfo().getMaxUsers() && !room.getRoomRightsManager().hasRights(habbo) && !habbo.hasRight(Permission.ACC_FULLROOMS)) { + if (room.getRoomUnitManager().getRoomHabbosCount() >= room.getRoomInfo().getMaxUsers() && !room.getRoomRightsManager().hasRights(habbo) && !habbo.hasPermissionRight(Permission.ACC_FULLROOMS)) { habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_GUESTROOM_FULL)); return; } @@ -517,7 +517,7 @@ public class RoomManager { * If habbo has permissions open room * If habbo has guild rights open room */ - if (forceEnter || room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().getState() == RoomState.OPEN || habbo.hasRight(Permission.ACC_ENTERANYROOM) || room.getRoomRightsManager().hasRights(habbo) || (room.getRoomInfo().getState().equals(RoomState.INVISIBLE) && room.getRoomRightsManager().hasRights(habbo)) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { + if (forceEnter || room.getRoomInfo().isRoomOwner(habbo) || room.getRoomInfo().getState() == RoomState.OPEN || habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM) || room.getRoomRightsManager().hasRights(habbo) || (room.getRoomInfo().getState().equals(RoomState.INVISIBLE) && room.getRoomRightsManager().hasRights(habbo)) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(habbo).isGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { this.openRoom(habbo, room, spawnLocation); } else if (room.getRoomInfo().getState() == RoomState.LOCKED) { boolean habbosWithRights = false; @@ -627,7 +627,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room))); - roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.hasCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); + roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); if (room.isPromoted()) { habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion())); @@ -1368,7 +1368,7 @@ public class RoomManager { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { - if (habbo.hasRight(Permission.ACC_UNKICKABLE)) { + if (habbo.hasPermissionRight(Permission.ACC_UNKICKABLE)) { return; } @@ -1377,7 +1377,7 @@ public class RoomManager { HabboInfo info = HabboManager.getOfflineHabboInfo(userId); if (info != null) { - if (info.getPermissionGroup().hasRight(Permission.ACC_UNKICKABLE, false)) { + if (info.getPermissionGroup().hasPermissionRight(Permission.ACC_UNKICKABLE, false)) { return; } name = info.getUsername(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java index d69e5f17..dfbb3c12 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -186,7 +186,7 @@ public class RoomRightsManager { } } - if (habbo.hasRight(Permission.ACC_ANYROOMOWNER) || this.room.getRoomInfo().isRoomOwner(habbo)) { + if (habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.room.getRoomInfo().isRoomOwner(habbo)) { habbo.getClient().sendResponse(new YouAreOwnerMessageComposer()); flatCtrl = RoomRightLevels.MODERATOR; } else if (this.hasRights(habbo) && !this.room.getRoomInfo().hasGuild()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java similarity index 99% rename from src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java index aa4df6af..4c84821f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.stream.Collectors; @Slf4j -public class TraxManager implements Disposable { +public class RoomTraxManager implements Disposable { public static int NORMAL_JUKEBOX_LIMIT = 10; public static int LARGE_JUKEBOX_LIMIT = 20; private final Room room; @@ -47,7 +47,7 @@ public class TraxManager implements Disposable { private boolean disposed = false; - public TraxManager(Room room) { + public RoomTraxManager(Room room) { this.room = room; //Check if room has a Jukebox already on DB 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 0e4dcbed..4a2c87f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -416,12 +416,12 @@ public class RoomUnitManager { } } - public void dispose(Room room) { + public void dispose() { for(Habbo habbo : this.currentRoomHabbos.values()) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room); + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); } - room.sendComposer(new CloseConnectionMessageComposer().compose()); + this.room.sendComposer(new CloseConnectionMessageComposer().compose()); this.currentRoomHabbos.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java index 781ba10e..c4665a0b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java @@ -26,6 +26,7 @@ public abstract class RoomEntity implements IRoomEntity { public synchronized void incrementTilesMoved() { this.tilesMoved++; } + public synchronized void decrementTilesMoved() { this.tilesMoved--; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 2914f22e..ef25ca41 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -263,8 +263,12 @@ public abstract class RoomUnit extends RoomEntity { } public RoomUnit removeStatus(RoomUnitStatus key) { - this.statuses.remove(key); - this.statusUpdateNeeded = true; + String statusRemoved = this.statuses.remove(key); + + if(statusRemoved != null) { + this.statusUpdateNeeded = true; + } + return this; } 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 0286fcfc..3d9e61e4 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 @@ -59,6 +59,11 @@ public class RoomAvatar extends RoomUnit { @Override public boolean cycle(Room room) { try { + if (this.hasStatus(RoomUnitStatus.SIGN)) { + this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + this.removeStatus(RoomUnitStatus.SIGN); + } + Habbo habboT = room.getRoomUnitManager().getHabboByRoomUnit(this); if (!this.isWalking() && !this.isKicked() && this.removeStatus(RoomUnitStatus.MOVE) == null && habboT != null) { @@ -66,9 +71,6 @@ public class RoomAvatar extends RoomUnit { return true; } - if (this.removeStatus(RoomUnitStatus.SIT) != null || this.removeStatus(RoomUnitStatus.MOVE) != null || this.removeStatus(RoomUnitStatus.LAY) != null) - this.setStatusUpdateNeeded(true); - for (Map.Entry set : this.getStatuses().entrySet()) { if (set.getKey().isRemoveWhenWalking()) { this.removeStatus(set.getKey()); @@ -76,27 +78,28 @@ public class RoomAvatar extends RoomUnit { } if (this.getPath() == null || this.getPath().isEmpty()) { - this.setStatusUpdateNeeded(true); return true; } boolean canFastWalk = habboT == null || habboT.getHabboInfo().getRiding() == null; RoomTile next = this.getPath().poll(); - boolean overrideChecks = next != null && this.canOverrideTile(next); + + boolean overrideTile = next != null && this.canOverrideTile(next); if (this.getPath().isEmpty()) { this.setSitUpdate(true); - if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) { - this.setStatusUpdateNeeded(false); + if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideTile) { return false; } } Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); - if (peekPath == null) peekPath = new LinkedList<>(); + if (peekPath == null) { + peekPath = new LinkedList<>(); + } if (peekPath.size() >= 3) { if (this.getPath().isEmpty()) { @@ -156,14 +159,13 @@ public class RoomAvatar extends RoomUnit { RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); - if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.setRoom(room); + + if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.getPath().clear(); this.findPath(); if (this.getPath().isEmpty()) { this.removeStatus(RoomUnitStatus.MOVE); - this.setStatusUpdateNeeded(false); return false; } next = this.getPath().pop(); @@ -179,9 +181,8 @@ public class RoomAvatar extends RoomUnit { item = tallestChair; } - if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideTile && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.removeStatus(RoomUnitStatus.MOVE); - this.setStatusUpdateNeeded(false); return false; } @@ -199,6 +200,7 @@ public class RoomAvatar extends RoomUnit { this.incrementTilesMoved(); RoomRotation oldRotation = this.getBodyRotation(); + this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); if (item != null) { if (item != roomItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { @@ -215,7 +217,6 @@ public class RoomAvatar extends RoomUnit { conditionalGate.onRejected(this, this.getRoom(), new Object[]{}); } - this.setStatusUpdateNeeded(false); return false; } } else { @@ -273,16 +274,14 @@ public class RoomAvatar extends RoomUnit { } } - this.setStatusUpdateNeeded(false); return false; } catch (Exception e) { log.error("Caught exception", e); - this.setStatusUpdateNeeded(false); return false; } } - + public void setDance(DanceType danceType) { if (this.danceType != danceType) { boolean isDancing = !this.danceType.equals(DanceType.NONE); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 50af859f..53efc1a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -92,7 +92,7 @@ public class RoomPet extends RoomUnit { RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); - if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.setRoom(room); this.getPath().clear(); this.findPath(); 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 a5b1535f..6d9b98e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -193,28 +193,19 @@ public class Habbo extends Unit implements Runnable { } public boolean canExecuteCommand(String key) { - return this.getHabboInfo().getPermissionGroup().canExecuteCommand(key, false); + return this.canExecuteCommand(key, false); } public boolean canExecuteCommand(String key, boolean hasRoomRights) { return this.getHabboInfo().getPermissionGroup().canExecuteCommand(key, hasRoomRights); } - public boolean hasCommand(String key) { - return this.hasCommand(key, false); + public boolean hasPermissionRight(String key) { + return this.hasPermissionRight(key, false); } - - public boolean hasCommand(String name, boolean hasRoomRights) { - return this.getHabboInfo().getPermissionGroup().hasCommand(name, hasRoomRights); - } - - public boolean hasRight(String key) { - return this.hasRight(key, false); - } - - public boolean hasRight(String key, boolean hasRoomRights) { - return this.getHabboInfo().getPermissionGroup().hasRight(key, hasRoomRights); + public boolean hasPermissionRight(String key, boolean hasRoomRights) { + return this.getHabboInfo().getPermissionGroup().hasPermissionRight(key, hasRoomRights); } @@ -403,7 +394,7 @@ public class Habbo extends Unit implements Runnable { return; } - if (!this.hasRight(Permission.ACC_NO_MUTE)) { + if (!this.hasPermissionRight(Permission.ACC_NO_MUTE)) { int remaining = this.habboStats.addMuteTime(seconds); this.client.sendResponse(new FloodControlMessageComposer(remaining)); this.client.sendResponse(new RemainingMutePeriodComposer(remaining)); 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 5795b45a..ef88b747 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -177,7 +177,7 @@ public class HabboManager { public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) { synchronized (this.onlineHabbos) { for (Habbo habbo : this.onlineHabbos.values()) { - if (habbo.hasRight(perm)) { + if (habbo.hasPermissionRight(perm)) { habbo.getClient().sendResponse(message); } } @@ -262,7 +262,7 @@ public class HabboManager { habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo)); habbo.getClient().sendResponse(new UserPerksComposer(habbo)); - if (habbo.hasRight(Permission.ACC_SUPPORTTOOL)) { + if (habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { habbo.getClient().sendResponse(new ModeratorInitMessageComposer(habbo)); } habbo.getHabboInfo().run(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java index 35bc2470..183cabae 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertEvent.java @@ -12,7 +12,7 @@ import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; public class AmbassadorAlertEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_AMBASSADOR)) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java index 7fbd9fc6..16a316fc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/FollowFriendEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.outgoing.rooms.RoomForwardMessageComposer; public class FollowFriendEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_AMBASSADOR)) { String username = this.packet.readString(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username); diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java index 87b4b354..bcb4d0ea 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.util.crypto.ZIP; public class RenderRoomEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().hasRight(Permission.ACC_CAMERA)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_CAMERA)) { this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java index f95d53bd..32bf44cd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/RenderRoomThumbnailEvent.java @@ -11,7 +11,7 @@ import com.eu.habbo.util.crypto.ZIP; public class RenderRoomThumbnailEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().hasRight(Permission.ACC_CAMERA)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_CAMERA)) { this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java index 508253eb..cd76b923 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java @@ -19,10 +19,10 @@ public abstract class PurchaseEvent extends MessageHandler { if (this.client.getHabbo().getHabboInfo().getCredits() < totalCredits) return; - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS)) + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) this.client.getHabbo().giveCredits(-totalCredits); - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_POINTS)) + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS)) this.client.getHabbo().givePoints(deal.getPointsType(), -totalDuckets); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java index 830d410b..c3c0995a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java @@ -347,15 +347,15 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { AchievementManager.progressAchievement(userId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftReceiver")); } - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) { if (totalCredits > 0) { this.client.getHabbo().giveCredits(-totalCredits); } } if (totalPoints > 0) { - if (item.getPointsType() == 0 && !this.client.getHabbo().hasRight(Permission.ACC_INFINITE_PIXELS)) { + if (item.getPointsType() == 0 && !this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_PIXELS)) { this.client.getHabbo().givePixels(-totalPoints); - } else if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_POINTS)) { + } else if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS)) { this.client.getHabbo().givePoints(item.getPointsType(), -totalPoints); } this.client.sendResponse(new HabboActivityPointNotificationMessageComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -totalPoints, item.getPointsType())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java index b0652399..7f4c5de9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java @@ -100,11 +100,11 @@ public class PurchaseFromCatalogEvent extends PurchaseEvent { return; } ((RoomBundleLayout) page).buyRoom(this.client.getHabbo()); - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS)) { //if the player has this perm disabled + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) { //if the player has this perm disabled this.client.getHabbo().getHabboInfo().addCredits(-roomBundleItem.getCredits()); // takes their credits away this.client.sendResponse(new CreditBalanceComposer(this.client.getHabbo())); // Sends the updated currency composer window } - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_POINTS)) { //if the player has this perm disabled + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS)) { //if the player has this perm disabled this.client.getHabbo().getHabboInfo().addCurrencyAmount(roomBundleItem.getPointsType(), -roomBundleItem.getPoints()); // takes their points away this.client.sendResponse(new ActivityPointsMessageComposer(this.client.getHabbo())); // Sends the updated currency composer window } @@ -172,13 +172,13 @@ public class PurchaseFromCatalogEvent extends PurchaseEvent { item = page.getCatalogItem(itemId); // temp patch, can a dev with better knowledge than me look into this asap pls. if (page instanceof BotsLayout) { - if (!this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_BOTS) && this.client.getHabbo().getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && this.client.getHabbo().getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { this.client.getHabbo().alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + "")); return; } } if (page instanceof PetsLayout) { // checks it's the petlayout - if (!this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index 613c6c33..14d0c0c4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -22,7 +22,7 @@ public class PresentOpenEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { int id = this.packet.readInt(); RoomItem item = room.getRoomItemManager().getRoomItemById(id); diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index 0720bc16..df4c02b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -23,7 +23,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { @Override public void handle() { - if (!this.client.getHabbo().hasRight(Permission.ACC_FLOORPLAN_EDITOR)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_FLOORPLAN_EDITOR)) { this.client.sendResponse(new HabboBroadcastMessageComposer(Emulator.getTexts().getValue("floorplan.permission"))); return; } @@ -33,7 +33,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { StringJoiner errors = new StringJoiner("
"); String map = this.packet.readString(); map = map.replace("X", "x"); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java index 19b443a5..8f55d0e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java @@ -65,12 +65,12 @@ public class AcceptFriendEvent extends MessageHandler { continue; } - if(this.client.getHabbo().getMessenger().getFriends().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasRight(Permission.ACC_INFINITE_FRIENDS)) { + if(this.client.getHabbo().getMessenger().getFriends().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_FRIENDS)) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_OWN_FULL)); break; } - if(target.getMessenger().getFriends().size() >= target.getHabboStats().getMaxFriends() && !target.hasRight(Permission.ACC_INFINITE_FRIENDS)) { + if(target.getMessenger().getFriends().size() >= target.getHabboStats().getMaxFriends() && !target.hasPermissionRight(Permission.ACC_INFINITE_FRIENDS)) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_TARGET_FULL)); continue; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java index a299ac62..eb969b52 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/RequestFriendEvent.java @@ -64,13 +64,13 @@ public class RequestFriendEvent extends MessageHandler { } // You can only have x friends - if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasRight(Permission.ACC_INFINITE_FRIENDS)) { + if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().getMaxFriends() && !this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_FRIENDS)) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_OWN_FULL)); return; } // Check if targets friendlist is full - if (targetHabbo.getMessenger().getFriends().values().size() >= targetHabbo.getHabboStats().getMaxFriends() && !targetHabbo.hasRight(Permission.ACC_INFINITE_FRIENDS)) { + if (targetHabbo.getMessenger().getFriends().values().size() >= targetHabbo.getHabboStats().getMaxFriends() && !targetHabbo.hasPermissionRight(Permission.ACC_INFINITE_FRIENDS)) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.FRIEND_LIST_TARGET_FULL)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java index ab51be7f..f3363673 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java @@ -30,7 +30,7 @@ public class VisitUserEvent extends MessageHandler { return; } - if (habbo.getHabboStats().isBlockFollowing() && !this.client.getHabbo().hasRight(Permission.ACC_CAN_STALK)) { + if (habbo.getHabboStats().isBlockFollowing() && !this.client.getHabbo().hasPermissionRight(Permission.ACC_CAN_STALK)) { this.client.sendResponse(new FollowFriendFailedComposer(FollowFriendFailedComposer.FRIEND_BLOCKED_STALKING)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionOnDutyUpdateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionOnDutyUpdateEvent.java index a3a50337..f0ad7d85 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionOnDutyUpdateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guides/GuideSessionOnDutyUpdateEvent.java @@ -15,13 +15,13 @@ public class GuideSessionOnDutyUpdateEvent extends MessageHandler { boolean helperRequests = this.packet.readBoolean(); boolean bullyReports = this.packet.readBoolean(); - if (!this.client.getHabbo().hasRight(Permission.ACC_HELPER_USE_GUIDE_TOOL)) + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_HELPER_USE_GUIDE_TOOL)) return; - if (helperRequests && !this.client.getHabbo().hasRight(Permission.ACC_HELPER_GIVE_GUIDE_TOURS)) + if (helperRequests && !this.client.getHabbo().hasPermissionRight(Permission.ACC_HELPER_GIVE_GUIDE_TOURS)) helperRequests = false; - if (bullyReports && !this.client.getHabbo().hasRight(Permission.ACC_HELPER_JUDGE_CHAT_REVIEWS)) + if (bullyReports && !this.client.getHabbo().hasPermissionRight(Permission.ACC_HELPER_JUDGE_CHAT_REVIEWS)) bullyReports = false; if (helperRequests) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java index ed67736f..fce7cd7d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/AddAdminRightsToMemberEvent.java @@ -18,7 +18,7 @@ public class AddAdminRightsToMemberEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - if (guild != null && (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN))) { + if (guild != null && (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN))) { Emulator.getGameEnvironment().getGuildManager().setAdmin(guild, userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java index 53fd051d..7d87c024 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java @@ -30,7 +30,7 @@ public class ApproveMembershipRequestEvent extends MessageHandler { else userInfo = habbo.getHabboInfo(); - if (userInfo == null || groupMember == null || userId == this.client.getHabbo().getHabboInfo().getId() || (!this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !groupMember.getRank().equals(GuildRank.ADMIN) && !groupMember.getRank().equals(GuildRank.OWNER))) + if (userInfo == null || groupMember == null || userId == this.client.getHabbo().getHabboInfo().getId() || (!this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !groupMember.getRank().equals(GuildRank.ADMIN) && !groupMember.getRank().equals(GuildRank.OWNER))) return; if (!userInfo.getHabboStats().hasGuild(guild.getId())) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java index 0cbdf539..998afd70 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java @@ -31,7 +31,7 @@ public class CreateGuildEvent extends GuildBadgeEvent { return; } - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) { int guildPrice = Emulator.getConfig().getInt("catalog.guild.price"); if (this.client.getHabbo().getHabboInfo().getCredits() >= guildPrice) { this.client.getHabbo().giveCredits(-guildPrice); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java index d2637bfb..98e5f5ba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/DeactivateGuildEvent.java @@ -20,7 +20,7 @@ public class DeactivateGuildEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override. + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override. { THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java index 1fdfe6f4..5f284bb7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetGuildMembersEvent.java @@ -19,7 +19,7 @@ public class GetGuildMembersEvent extends MessageHandler { Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(groupId); if (g != null) { - boolean isAdmin = this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN); + boolean isAdmin = this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN); if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); isAdmin = member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java index 9fb09b0a..f906d76d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GetMemberGuildItemCountEvent.java @@ -19,7 +19,7 @@ public class GetMemberGuildItemCountEvent extends MessageHandler { if (guild == null) return; GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN))) || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN))) || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); int count = 0; if (room != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java index 50e1b524..6223a6bd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/KickMemberEvent.java @@ -24,7 +24,7 @@ public class KickMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(removedMemberEvent); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java index 62b74fdf..6fae2b7d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RejectMembershipRequestEvent.java @@ -23,7 +23,7 @@ public class RejectMembershipRequestEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)|| member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)|| member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { guild.decreaseRequestCount(); Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, ""))); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java index 3e9c8ba7..8eb4c250 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RemoveAdminRightsFromMemberEvent.java @@ -19,7 +19,7 @@ public class RemoveAdminRightsFromMemberEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { int userId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java index 4148080c..e1ddab4f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java @@ -13,7 +13,7 @@ public class UpdateGuildBadgeEvent extends GuildBadgeEvent { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); if (room == null || room.getRoomInfo().getId() != guild.getRoomId()) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java index faa95180..7df79c8b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildColorsEvent.java @@ -15,7 +15,7 @@ public class UpdateGuildColorsEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { GuildChangedColorsEvent colorsEvent = new GuildChangedColorsEvent(guild, this.packet.readInt(), this.packet.readInt()); Emulator.getPluginManager().fireEvent(colorsEvent); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java index 4047240f..324b9c44 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java @@ -15,7 +15,7 @@ public class UpdateGuildIdentityEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { GuildChangedNameEvent nameEvent = new GuildChangedNameEvent(guild, this.packet.readString(), this.packet.readString()); Emulator.getPluginManager().fireEvent(nameEvent); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java index 895fec66..ffa95de7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildSettingsEvent.java @@ -16,7 +16,7 @@ public class UpdateGuildSettingsEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); if (guild != null) { - if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN)) { + if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN)) { GuildChangedSettingsEvent settingsEvent = new GuildChangedSettingsEvent(guild, this.packet.readInt(), this.packet.readInt() == 0); Emulator.getPluginManager().fireEvent(settingsEvent); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java index 81b7c012..e6c6f8fd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java @@ -27,7 +27,7 @@ public class GetMessagesEvent extends MessageHandler { Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - boolean hasStaffPermissions = this.client.getHabbo().hasRight(Permission.ACC_MODTOOL_TICKET_Q); + boolean hasStaffPermissions = this.client.getHabbo().hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); if (guild == null || thread == null) { this.client.sendResponse(new ErrorReportComposer(404)); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java index 5a23932d..66d8074a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java @@ -37,7 +37,7 @@ public class ModerateMessageEvent extends MessageHandler { return; } - boolean hasStaffPermissions = this.client.getHabbo().hasRight(Permission.ACC_MODTOOL_TICKET_Q); + boolean hasStaffPermissions = this.client.getHabbo().hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); if (member == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java index fa36ff78..a53e4c5f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java @@ -33,7 +33,7 @@ public class ModerateThreadEvent extends MessageHandler { } GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); - boolean hasStaffPerms = this.client.getHabbo().hasRight(Permission.ACC_MODTOOL_TICKET_Q); // check for if they have staff perm + boolean hasStaffPerms = this.client.getHabbo().hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); // check for if they have staff perm boolean isGuildAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java index 90723b3d..915dcd38 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/PostMessageEvent.java @@ -39,7 +39,7 @@ public class PostMessageEvent extends MessageHandler { return; } - boolean isStaff = this.client.getHabbo().hasRight(Permission.ACC_MODTOOL_TICKET_Q); + boolean isStaff = this.client.getHabbo().hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java index 9f3b433b..10f5d877 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java @@ -30,7 +30,7 @@ public class UpdateThreadEvent extends MessageHandler { return; } - boolean isStaff = this.client.getHabbo().hasRight(Permission.ACC_MODTOOL_TICKET_Q); + boolean isStaff = this.client.getHabbo().hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); if (member == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java index 7b4ddfdb..1b5694c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SSOTicketEvent.java @@ -217,7 +217,7 @@ public class SSOTicketEvent extends MessageHandler { messages.add(new ScrSendUserInfoComposer(this.client.getHabbo(), SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_LOGIN).compose()); - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { messages.add(new ModeratorInitMessageComposer(this.client.getHabbo()).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java index 50458749..8801cc1d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssueDefaultActionEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class CloseIssueDefaultActionEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int issueId = this.packet.readInt(); int unknown = this.packet.readInt(); int category = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java index 48b78115..e31d03b1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CloseIssuesEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class CloseIssuesEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int state = this.packet.readInt(); int something = this.packet.readInt(); int ticketId = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java index de8dd024..e7c525b3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; public class GetCfhChatlogEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt()); if (issue != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java index e9058210..1ab7715a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorRoomInfoEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.outgoing.modtool.ModeratorRoomInfoComposer; public class GetModeratorRoomInfoEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorUserInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorUserInfoEvent.java index 5b234a01..f0f0f3ef 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorUserInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetModeratorUserInfoEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class GetModeratorUserInfoEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { ModToolManager.requestUserInfo(this.client, this.packet); } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.userinfo").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java index 01f8f452..739a07c6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomChatlogEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.outgoing.modtool.RoomChatlogComposer; public class GetRoomChatlogEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomVisitsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomVisitsEvent.java index 449df7c5..03dd2445 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomVisitsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetRoomVisitsEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.outgoing.modtool.RoomVisitsComposer; public class GetRoomVisitsEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java index 355ae337..c7cf5143 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.outgoing.modtool.UserChatlogComposer; public class GetUserChatlogEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); String username = HabboManager.getOfflineHabboInfo(userId).getUsername(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java index 99df9398..65b030b4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java @@ -18,7 +18,7 @@ public class ModAlertEvent extends MessageHandler { String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); - if (!this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) return; + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) return; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java index 8e3ec701..fe872516 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java @@ -52,7 +52,7 @@ public class ModBanEvent extends MessageHandler { case BAN_AVATAR_ONLY_100_YEARS: duration = Emulator.getIntUnixTimestamp(); } - if (!this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMessageEvent.java index 6b041f63..73c795d1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMessageEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; public class ModMessageEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); if (alertedUser != null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java index 4bca6e02..f83917c4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModMuteEvent.java @@ -20,7 +20,7 @@ public class ModMuteEvent extends MessageHandler { String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); - if (!this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) return; + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) return; Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo == null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java index 0dcf9b93..d98d76ea 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomUserChatlogEvent.java @@ -11,7 +11,7 @@ import com.eu.habbo.messages.outgoing.modtool.RoomChatlogComposer; public class ModToolRequestRoomUserChatlogEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionEvent.java index a9c62836..df40a20c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.threading.runnables.UpdateModToolIssue; public class ModToolSanctionEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int ticketId = this.packet.readInt(); int unknownInt = this.packet.readInt(); int categoryId = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java index ee1e38aa..6d0e3224 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; public class ModToolWarnEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); if (alertedUser != null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java index 2a0fbf6f..0f0f649a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java @@ -19,7 +19,7 @@ public class ModTradingLockEvent extends MessageHandler { int duration = this.packet.readInt(); int cfhTopic = this.packet.readInt(); - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java index 882b918c..8ee92553 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModerateRoomEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class ModerateRoomEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.packet.readInt()); if (room != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java index f58da46c..7437889d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModeratorActionEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class ModeratorActionEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int type = this.packet.readInt(); Room room = this.client.getHabbo().getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/PickIssuesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/PickIssuesEvent.java index df10877e..832298f1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/PickIssuesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/PickIssuesEvent.java @@ -13,7 +13,7 @@ public class PickIssuesEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { this.packet.readInt(); ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReleaseIssuesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReleaseIssuesEvent.java index 2a832cfc..a6554ea5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReleaseIssuesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReleaseIssuesEvent.java @@ -10,7 +10,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class ReleaseIssuesEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int count = this.packet.readInt(); while (count != 0) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java index 484bae60..dc5b6117 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/NewNavigatorSearchEvent.java @@ -128,7 +128,7 @@ public class NewNavigatorSearchEvent extends MessageHandler { } } - SearchResultList list = new SearchResultList(0, "query", "", SearchAction.NONE, ListMode.LIST, DisplayMode.VISIBLE, new ArrayList<>(searchRooms.values()), true, this.client.getHabbo().hasRight(Permission.ACC_ENTERANYROOM) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER), DisplayOrder.ACTIVITY, -1); + SearchResultList list = new SearchResultList(0, "query", "", SearchAction.NONE, ListMode.LIST, DisplayMode.VISIBLE, new ArrayList<>(searchRooms.values()), true, this.client.getHabbo().hasPermissionRight(Permission.ACC_ENTERANYROOM) || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER), DisplayOrder.ACTIVITY, -1); nList.add(list); return nList; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java index 32874859..d02b8377 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/GetFlatControllersEvent.java @@ -13,7 +13,7 @@ public class GetFlatControllersEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { this.client.sendResponse(new FlatControllersComposer(room)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java index ba0dfc2c..a2b43d4d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RemoveAllRightsEvent.java @@ -17,7 +17,7 @@ public class RemoveAllRightsEvent extends MessageHandler { if (room == null || room.getRoomInfo().getId() != this.packet.readInt()) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { room.getRoomRightsManager().getRights().forEach(value -> { Habbo habbo = room.getRoomUnitManager().getRoomHabboById(value); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 8f735bee..2f771bfd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -17,7 +17,7 @@ public class RequestRoomPropertySet extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI)) { int itemId = this.packet.readInt(); RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index a32d7ddf..cd81a0e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -16,7 +16,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { if (room == null) return; - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI)) { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item == null) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java index 25c9d8fe..6fd1c161 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SubmitRoomToCompetitionEvent.java @@ -12,7 +12,7 @@ import com.eu.habbo.messages.outgoing.rooms.GetGuestRoomResultComposer; public class SubmitRoomToCompetitionEvent extends MessageHandler { @Override public void handle() { - if (this.client.getHabbo().hasRight(Permission.ACC_STAFF_PICK)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_STAFF_PICK)) { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java index 9c4ca8d4..4cafbafe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/ToggleStaffPickEvent.java @@ -12,7 +12,7 @@ import com.eu.habbo.messages.outgoing.rooms.GetGuestRoomResultComposer; public class ToggleStaffPickEvent extends MessageHandler { @Override public void handle() throws Exception { - if (this.client.getHabbo().hasRight(Permission.ACC_STAFF_PICK)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_STAFF_PICK)) { int roomId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java index 1290c6de..ab11a546 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java @@ -26,7 +26,7 @@ public class CommandBotEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); @@ -74,7 +74,7 @@ public class CommandBotEvent extends MessageHandler { String result = Emulator.getGameEnvironment().getWordFilter().filter(s, this.client.getHabbo()); if (!result.isEmpty()) { - if (!this.client.getHabbo().hasRight(Permission.ACC_CHAT_NO_FILTER)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { result = Emulator.getGameEnvironment().getWordFilter().filter(result, this.client.getHabbo()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java index f88fc392..7c9f337b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/GetBotCommandConfigurationDataEvent.java @@ -14,7 +14,7 @@ public class GetBotCommandConfigurationDataEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index b492b970..583ddae5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -22,7 +22,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { this.packet.readString(); String color = this.packet.readString(); if (itemId == -1234) { - if (this.client.getHabbo().hasCommand("cmd_multi")) { + if (this.client.getHabbo().canExecuteCommand("cmd_multi")) { String[] commands = this.packet.readString().split("\r"); Arrays.stream(commands) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index 4c80574a..d8869f6d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -17,7 +17,7 @@ public class MoveWallItemEvent extends MessageHandler { if (room == null) return; - if (!room.getRoomRightsManager().hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI)) { + if (!room.getRoomRightsManager().hasRights(this.client.getHabbo()) && !this.client.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI)) { if (!(room.getRoomInfo().getGuild().getId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index afb2ac66..87ec232e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -28,7 +28,7 @@ public class PickupObjectEvent extends MessageHandler { room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); } else { if (room.getRoomRightsManager().hasRights(this.client.getHabbo())) { - if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); } else { if (!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index 8b6ddd47..9ba6aa6c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -23,7 +23,7 @@ public class RemoveItemEvent extends MessageHandler { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { - if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { item.setRoomId(0); room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new ItemRemoveMessageComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index 75555eeb..e15581c7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -24,7 +24,7 @@ public class SetObjectDataEvent extends MessageHandler { if (item == null) return; - if (item instanceof InteractionRoomAds && !this.client.getHabbo().hasRight(Permission.ACC_ADS_BACKGROUND)) { + if (item instanceof InteractionRoomAds && !this.client.getHabbo().hasPermissionRight(Permission.ACC_ADS_BACKGROUND)) { this.client.getHabbo().alert(Emulator.getTexts().getValue("hotel.error.roomads.nopermission")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java index da552cef..a477037a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/AddJukeboxDiskEvent.java @@ -19,7 +19,7 @@ public class AddJukeboxDiskEvent extends MessageHandler { RoomItem item = habbo.getInventory().getItemsComponent().getHabboItem(itemId); if (item instanceof InteractionMusicDisc interactionMusicDisc && item.getRoomId() == 0) { - this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().addSong(interactionMusicDisc, habbo); + this.client.getHabbo().getRoomUnit().getRoom().getRoomTraxManager().addSong(interactionMusicDisc, habbo); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java index 6368a05e..49d556eb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java @@ -1,10 +1,5 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; -import com.eu.habbo.habbohotel.rooms.TraxManager; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; - public class GetJukeboxPlayListEvent extends JukeboxEvent { @Override public void handle() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java index 4659c61d..ce2bacba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java @@ -1,10 +1,5 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; -import com.eu.habbo.habbohotel.rooms.TraxManager; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; - public class GetNowPlayingEvent extends JukeboxEvent { @Override public void handle() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java index 8d2ada31..161cbf9d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java @@ -1,10 +1,5 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; -import com.eu.habbo.habbohotel.rooms.TraxManager; -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; - public class JukeBoxEventOne extends JukeboxEvent { @Override public void handle() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java index 31640475..cbd3d700 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java @@ -1,15 +1,15 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; -import com.eu.habbo.habbohotel.rooms.TraxManager; +import com.eu.habbo.habbohotel.rooms.RoomTraxManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer; public abstract class JukeboxEvent extends MessageHandler { protected void updateHabboWithCurrentPlaying() { - TraxManager traxManager = this.client.getHabbo().getRoomUnit().getRoom().getTraxManager(); - this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength())); - this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo()))); - this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); + RoomTraxManager roomTraxManager = this.client.getHabbo().getRoomUnit().getRoom().getRoomTraxManager(); + this.client.sendResponse(new JukeboxSongDisksMessageComposer(roomTraxManager.getSongs(), roomTraxManager.totalLength())); + this.client.sendResponse(new UserSongDisksInventoryMessageComposer(roomTraxManager.myList(this.client.getHabbo()))); + this.client.getHabbo().getRoomUnit().getRoom().getRoomTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java index 454880bb..47ded455 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/RemoveJukeboxDiskEvent.java @@ -8,10 +8,10 @@ public class RemoveJukeboxDiskEvent extends MessageHandler { public void handle() { int index = this.packet.readInt(); - InteractionMusicDisc musicDisc = this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().getSongs().get(index); + InteractionMusicDisc musicDisc = this.client.getHabbo().getRoomUnit().getRoom().getRoomTraxManager().getSongs().get(index); if (musicDisc != null) { - this.client.getHabbo().getRoomUnit().getRoom().getTraxManager().removeSong(musicDisc.getId()); + this.client.getHabbo().getRoomUnit().getRoom().getRoomTraxManager().removeSong(musicDisc.getId()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java index 31521de5..6c9547eb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/rentablespace/RentableSpaceCancelRentEvent.java @@ -19,7 +19,7 @@ public class RentableSpaceCancelRentEvent extends MessageHandler { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || - this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { if (item instanceof InteractionRentableSpace) { ((InteractionRentableSpace) item).endRent(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java index ec893441..ab8e8a34 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java @@ -17,7 +17,7 @@ public abstract class YoutubeEvent extends MessageHandler { if (room == null) { return false; } - if (!room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasRight(Permission.ACC_ANYROOMOWNER)) { + if (!room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { return false; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index ab3185ea..8cb46f19 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -23,7 +23,7 @@ public class PlacePetEvent extends MessageHandler { return; if (this.client.getHabbo().getHabboInfo().getId() != room.getRoomInfo().getOwnerInfo().getId()) { - if (!room.getRoomInfo().isAllowPets() && !(this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_PLACEFURNI))) { + if (!room.getRoomInfo().isAllowPets() && !(this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI))) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_PETS_FORBIDDEN_IN_FLAT)); return; } @@ -36,7 +36,7 @@ public class PlacePetEvent extends MessageHandler { if (pet == null) { return; } - if (room.getRoomUnitManager().getCurrentRoomPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS)) { + if (room.getRoomUnitManager().getCurrentRoomPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS)) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_MAX_PETS)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java index d7744512..3975ab77 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java @@ -23,8 +23,8 @@ public class RemovePetFromFlatEvent extends MessageHandler { Pet pet = room.getRoomUnitManager().getRoomPetById(petId); if (pet != null) { - if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { - if (!this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { + if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java index 600dc8b0..177e3b06 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java @@ -19,7 +19,7 @@ public class EditEventEvent extends MessageHandler { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(id); - if (room == null || room.getRoomInfo().getOwnerInfo().getId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room == null || room.getRoomInfo().getOwnerInfo().getId() != this.client.getHabbo().getHabboInfo().getId() || !this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java index 43ca691d..b1797e73 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java @@ -49,11 +49,11 @@ public class PurchaseRoomAdEvent extends MessageHandler { } if (room.isPromoted()) { - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) { this.client.getHabbo().giveCredits(-item.getCredits()); } - if (!this.client.getHabbo().hasRight(Permission.ACC_INFINITE_POINTS)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS)) { this.client.getHabbo().givePoints(item.getPointsType(), -item.getPoints()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java index 59e81e05..9198050c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/AssignRightsEvent.java @@ -19,7 +19,7 @@ public class AssignRightsEvent extends MessageHandler { return; } - if (room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { Habbo target = room.getRoomUnitManager().getRoomHabboById(targetId); if (target != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java index 2880090c..43adff72 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RemoveRightsEvent.java @@ -14,7 +14,7 @@ public class RemoveRightsEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { for (int i = 0; i < amount; i++) { int userId = this.packet.readInt(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java index 25edefc0..a6689aa9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java @@ -26,7 +26,7 @@ public class RoomUserKickEvent extends MessageHandler { if (target == null) return; - if (target.hasRight(Permission.ACC_UNKICKABLE)) { + if (target.hasPermissionRight(Permission.ACC_UNKICKABLE)) { this.client.sendResponse(new WhisperMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("commands.error.cmd_kick.unkickable").replace("%username%", target.getHabboInfo().getUsername()), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); return; } @@ -41,8 +41,8 @@ public class RoomUserKickEvent extends MessageHandler { if (event.isCancelled()) return; - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { - if (target.hasRight(Permission.ACC_UNKICKABLE)) return; + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_AMBASSADOR)) { + if (target.hasPermissionRight(Permission.ACC_UNKICKABLE)) return; room.kickHabbo(target, true); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModKickSeen")); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java index df85e19e..b238cdad 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java @@ -18,7 +18,7 @@ public class RoomUserMuteEvent extends MessageHandler { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); if (room != null) { - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().hasCommand("cmd_mute") || this.client.getHabbo().hasRight(Permission.ACC_AMBASSADOR)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || this.client.getHabbo().canExecuteCommand("cmd_mute") || this.client.getHabbo().hasPermissionRight(Permission.ACC_AMBASSADOR)) { Habbo habbo = room.getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java index 8fb2926a..11885a68 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java @@ -15,16 +15,17 @@ public class SignEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); + if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { - this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.getSign() + ""); + this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, String.valueOf(event.getSign())); this.client.getHabbo().getRoomUnit().unIdle(); if(signId <= 10) { - int userId = this.client.getHabbo().getHabboInfo().getId(); for (RoomItem item : room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionVoteCounter) { 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 431d2619..9973b33e 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 @@ -21,7 +21,7 @@ public class OpenTradingEvent extends MessageHandler { if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getVirtualId()) { Habbo targetUser = room.getRoomUnitManager().getHabboByVirtualId(userId); - boolean tradeAnywhere = this.client.getHabbo().hasRight(Permission.ACC_TRADE_ANYWHERE); + boolean tradeAnywhere = this.client.getHabbo().hasPermissionRight(Permission.ACC_TRADE_ANYWHERE); if (!RoomTrade.TRADING_ENABLED && !tradeAnywhere) { this.client.sendResponse(new TradingOpenFailedComposer(TradingOpenFailedComposer.HOTEL_TRADING_NOT_ALLOWED)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java index ed7add4e..c8ec2257 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/SetChatStylePreferenceEvent.java @@ -10,7 +10,7 @@ public class SetChatStylePreferenceEvent extends MessageHandler { public void handle() { int chatBubble = this.packet.readInt(); - if (!this.client.getHabbo().hasRight(Permission.ACC_ANYCHATCOLOR)) { + if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYCHATCOLOR)) { for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) { if (Integer.parseInt(s) == chatBubble) { return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index 7763edbb..a889df0d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -16,7 +16,7 @@ public class UpdateActionEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_MOVEROTATE)) { //TODO Check SUPER WIRED PERMISSIONS TOO InteractionWiredEffect effect = room.getRoomSpecialTypes().getEffect(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index d3c73dad..de5a7571 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -16,7 +16,7 @@ public class UpdateConditionEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_MOVEROTATE)) { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index 5948d043..d5572b6c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -16,7 +16,7 @@ public class UpdateTriggerEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room != null) { - if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasRight(Permission.ACC_MOVEROTATE)) { + if (room.getRoomRightsManager().hasRights(this.client.getHabbo()) || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER) || this.client.getHabbo().hasPermissionRight(Permission.ACC_MOVEROTATE)) { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); try { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java index ed282c32..3c838951 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java @@ -21,7 +21,7 @@ public class CatalogPagesListComposer extends MessageComposer { public CatalogPagesListComposer(Habbo habbo, String mode) { this.habbo = habbo; this.mode = mode; - this.hasPermission = this.habbo.hasRight(Permission.ACC_CATALOG_IDS); + this.hasPermission = this.habbo.hasPermissionRight(Permission.ACC_CATALOG_IDS); } @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java index 1e6125fa..17388e1f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java @@ -19,7 +19,7 @@ public class MessengerInitComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.messengerInitComposer); - if (this.habbo.hasRight(Permission.ACC_INFINITE_FRIENDS)) { + if (this.habbo.hasPermissionRight(Permission.ACC_INFINITE_FRIENDS)) { this.response.appendInt(Integer.MAX_VALUE); this.response.appendInt(1337); this.response.appendInt(Integer.MAX_VALUE); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java index 84fb7bbe..62385357 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/HabboGroupDetailsMessageComposer.java @@ -23,7 +23,7 @@ public class HabboGroupDetailsMessageComposer extends MessageComposer { private final GuildMember member; @Override protected ServerMessage composeInternal() { - boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasRight(Permission.ACC_GUILD_ADMIN) || Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(this.client.getHabbo().getHabboInfo().getId()) != null; + boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermissionRight(Permission.ACC_GUILD_ADMIN) || Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(this.client.getHabbo().getHabboInfo().getId()) != null; this.response.init(Outgoing.habboGroupDetailsMessageComposer); this.response.appendInt(this.guild.getId()); this.response.appendBoolean(true); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java index 840a9e1b..b71b7f56 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ForumDataMessageComposer.java @@ -107,7 +107,7 @@ public class ForumDataMessageComposer extends MessageComposer { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); boolean isAdmin = member != null && (member.getRank().getType() < GuildRank.MEMBER.getType() || guild.getOwnerId() == this.habbo.getHabboInfo().getId()); - boolean isStaff = this.habbo.hasRight(Permission.ACC_MODTOOL_TICKET_Q); + boolean isStaff = this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q); String errorRead = ""; String errorPost = ""; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java index 5ae705f4..08cb98fb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorInitMessageComposer.java @@ -24,7 +24,7 @@ public class ModeratorInitMessageComposer extends MessageComposer implements TOb protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorInitMessageComposer); - if (this.habbo.hasRight(Permission.ACC_MODTOOL_TICKET_Q)) { + if (this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q)) { THashSet openTickets = new THashSet<>(); THashMap tickets = Emulator.getGameEnvironment().getModToolManager().getTickets(); @@ -62,13 +62,13 @@ public class ModeratorInitMessageComposer extends MessageComposer implements TOb Emulator.getGameEnvironment().getModToolManager().getCategory().forEachValue(this); - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_TICKET_Q)); //ticketQueueueuhuehuehuehue - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_USER_LOGS)); //user chatlogs - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_USER_ALERT)); //can send caution - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_USER_KICK)); //can send kick - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_USER_BAN)); //can send ban - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_ROOM_INFO)); //room info ??Not sure - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_MODTOOL_ROOM_LOGS)); //room chatlogs ??Not sure + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_TICKET_Q)); //ticketQueueueuhuehuehuehue + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_USER_LOGS)); //user chatlogs + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_USER_ALERT)); //can send caution + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_USER_KICK)); //can send kick + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_USER_BAN)); //can send ban + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_ROOM_INFO)); //room info ??Not sure + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_MODTOOL_ROOM_LOGS)); //room chatlogs ??Not sure synchronized (Emulator.getGameEnvironment().getModToolManager().getPresets()) { this.response.appendInt(Emulator.getGameEnvironment().getModToolManager().getPresets().get("room").size()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java index e6f88c7e..9d1ef4d4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserPerksComposer.java @@ -17,16 +17,16 @@ public class UserPerksComposer extends MessageComposer { this.response.appendString("USE_GUIDE_TOOL"); this.response.appendString("requirement.unfulfilled.helper_level_4"); - this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasRight(Permission.ACC_HELPER_USE_GUIDE_TOOL, false)); + this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasPermissionRight(Permission.ACC_HELPER_USE_GUIDE_TOOL, false)); this.response.appendString("GIVE_GUIDE_TOURS"); this.response.appendString(""); - this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasRight(Permission.ACC_HELPER_GIVE_GUIDE_TOURS, false)); + this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasPermissionRight(Permission.ACC_HELPER_GIVE_GUIDE_TOURS, false)); this.response.appendString("JUDGE_CHAT_REVIEWS"); this.response.appendString("requirement.unfulfilled.helper_level_6"); - this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasRight(Permission.ACC_HELPER_JUDGE_CHAT_REVIEWS, false)); + this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasPermissionRight(Permission.ACC_HELPER_JUDGE_CHAT_REVIEWS, false)); this.response.appendString("VOTE_IN_COMPETITIONS"); this.response.appendString("requirement.unfulfilled.helper_level_2"); @@ -46,7 +46,7 @@ public class UserPerksComposer extends MessageComposer { this.response.appendString("HEIGHTMAP_EDITOR_BETA"); this.response.appendString("requirement.unfulfilled.feature_disabled"); - this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasRight(Permission.ACC_FLOORPLAN_EDITOR, false)); + this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasPermissionRight(Permission.ACC_FLOORPLAN_EDITOR, false)); this.response.appendString("BUILDER_AT_WORK"); this.response.appendString(""); @@ -58,7 +58,7 @@ public class UserPerksComposer extends MessageComposer { this.response.appendString("CAMERA"); this.response.appendString(""); - this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasRight(Permission.ACC_CAMERA, false)); + this.response.appendBoolean(this.habbo.getHabboInfo().getPermissionGroup().hasPermissionRight(Permission.ACC_CAMERA, false)); this.response.appendString("NAVIGATOR_PHASE_TWO_2014"); this.response.appendString(""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserRightsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserRightsMessageComposer.java index 087f293f..b3e763c3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserRightsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserRightsMessageComposer.java @@ -21,7 +21,7 @@ public class UserRightsMessageComposer extends MessageComposer { this.response.init(Outgoing.userRightsMessageComposer); this.response.appendInt(this.clubLevel); this.response.appendInt(this.habbo.getHabboInfo().getPermissionGroup().getLevel()); - this.response.appendBoolean(this.habbo.hasRight(Permission.ACC_AMBASSADOR)); + this.response.appendBoolean(this.habbo.hasPermissionRight(Permission.ACC_AMBASSADOR)); return this.response; } } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 62ab70cc..28b7d0d1 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -41,7 +41,6 @@ import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.users.*; -import com.eu.habbo.threading.runnables.RoomTrashing; import com.eu.habbo.threading.runnables.ShutdownEmulator; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -115,8 +114,8 @@ public class PluginManager { NavigatorManager.MAXIMUM_RESULTS_PER_PAGE = Emulator.getConfig().getInt("hotel.navigator.search.maxresults"); NavigatorManager.CATEGORY_SORT_USING_ORDER_NUM = Emulator.getConfig().getBoolean("hotel.navigator.sort.ordernum"); RoomChatMessage.MAXIMUM_LENGTH = Emulator.getConfig().getInt("hotel.chat.max.length"); - TraxManager.LARGE_JUKEBOX_LIMIT = Emulator.getConfig().getInt("hotel.jukebox.limit.large"); - TraxManager.NORMAL_JUKEBOX_LIMIT = Emulator.getConfig().getInt("hotel.jukebox.limit.normal"); + RoomTraxManager.LARGE_JUKEBOX_LIMIT = Emulator.getConfig().getInt("hotel.jukebox.limit.large"); + RoomTraxManager.NORMAL_JUKEBOX_LIMIT = Emulator.getConfig().getInt("hotel.jukebox.limit.normal"); String[] bannedBubbles = Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";"); RoomChatMessage.BANNED_BUBBLES = new int[bannedBubbles.length]; @@ -409,7 +408,6 @@ public class PluginManager { private void registerDefaultEvents() { try { - this.methods.add(RoomTrashing.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); this.methods.add(Easter.class.getMethod("onUserChangeMotto", UserSavedMottoEvent.class)); this.methods.add(TagGame.class.getMethod("onUserLookAtPoint", RoomUnitLookAtPointEvent.class)); this.methods.add(TagGame.class.getMethod("onUserWalkEvent", UserTakeStepEvent.class)); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java index 65970b1f..cb2b4365 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -38,7 +38,7 @@ public class CannonKickAction implements Runnable { for (RoomTile t : tiles) { for (Habbo habbo : this.room.getRoomUnitManager().getHabbosAt(t)) { - if (!habbo.hasRight(Permission.ACC_UNKICKABLE)) { + if (!habbo.hasPermissionRight(Permission.ACC_UNKICKABLE)) { if (!this.room.getRoomInfo().isRoomOwner(habbo)) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); habbo.getClient().sendResponse(message); //kicked composer diff --git a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java index 36a01410..59e0251c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -26,7 +26,7 @@ public class OneWayGateActionOne implements Runnable { } if (t.isWalkable()) { - if (this.room.tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getY()) { + if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getY()) { this.client.getHabbo().getRoomUnit().setGoalLocation(t); if (!this.oneWayGate.getExtradata().equals("0")) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java index ec9c04e3..edc3ab1a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -29,7 +29,7 @@ public class PetFollowHabbo implements Runnable { target = this.habbo.getRoomUnit().getRoom().getLayout().getTileInFront(this.habbo.getRoomUnit().getCurrentPosition(), this.habbo.getRoomUnit().getBodyRotation().getValue()); if (target.getX() >= 0 && target.getY() >= 0) { - if (this.pet.getRoom().getLayout().tileWalkable(target.getX(), target.getY())) { + if (this.pet.getRoom().getLayout().tileWalkable(target)) { this.pet.getRoomUnit().setGoalLocation(target); this.pet.getRoomUnit().setCanWalk(true); this.pet.setTask(PetTasks.FOLLOW); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java b/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java deleted file mode 100644 index 564fcde1..00000000 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomTrashing.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.eu.habbo.threading.runnables; - -import com.eu.habbo.Emulator; -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.users.Habbo; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import com.eu.habbo.plugin.EventHandler; -import com.eu.habbo.plugin.events.users.UserTakeStepEvent; -import gnu.trove.set.hash.THashSet; - -public class RoomTrashing implements Runnable { - public static RoomTrashing INSTANCE; - - private Habbo habbo; - private Room room; - - public RoomTrashing(Habbo habbo, Room room) { - this.habbo = habbo; - this.room = room; - - RoomTrashing.INSTANCE = this; - } - - @EventHandler - public static void onUserWalkEvent(UserTakeStepEvent event) { - if (INSTANCE == null) - return; - - if (INSTANCE.habbo == null) - return; - - if (!INSTANCE.habbo.isOnline()) - INSTANCE.habbo = null; - - if (INSTANCE.habbo == event.habbo) { - if (event.habbo.getRoomUnit().getRoom() != null) { - if (event.habbo.getRoomUnit().getRoom().equals(INSTANCE.room)) { - THashSet messages = new THashSet<>(); - - THashSet items = INSTANCE.room.getRoomItemManager().getItemsAt(event.toLocation); - - int offset = Emulator.getRandom().nextInt(4) + 2; - - RoomTile t = null; - while (offset > 0) { - t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.getX(), event.toLocation.getY()), event.habbo.getRoomUnit().getBodyRotation().getValue(), (short) offset); - - if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { - offset--; - } else { - break; - } - } - - for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); - - messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); - } - - - offset = Emulator.getRandom().nextInt(4) + 2; - - t = null; - while (offset > 0) { - t = INSTANCE.room.getLayout().getTileInFront(INSTANCE.room.getLayout().getTile(event.toLocation.getX(), event.toLocation.getY()), event.habbo.getRoomUnit().getBodyRotation().getValue() + 7, (short) offset); - - if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { - offset--; - } else { - break; - } - } - - RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); - - if (s != null) { - items = INSTANCE.room.getRoomItemManager().getItemsAt(s); - } - - for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); - - messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); - } - - offset = Emulator.getRandom().nextInt(4) + 2; - - t = null; - while (offset > 0) { - t = INSTANCE.getRoom().getLayout().getTileInFront(event.toLocation, event.habbo.getRoomUnit().getBodyRotation().getValue() + 1, (short) offset); - - if (!INSTANCE.room.getLayout().tileWalkable(t.getX(), t.getY())) { - offset--; - } else { - break; - } - } - - s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); - items = INSTANCE.room.getRoomItemManager().getItemsAt(s); - - for (RoomItem item : items) { - double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ(); - - messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); - } - - for (ServerMessage message : messages) { - INSTANCE.room.sendComposer(message); - } - } else { - INSTANCE.habbo = null; - INSTANCE.room = null; - } - } - } - } - - @Override - public void run() { - - } - - public Habbo getHabbo() { - return this.habbo; - } - - public void setHabbo(Habbo habbo) { - this.habbo = habbo; - } - - public Room getRoom() { - return this.room; - } - - public void setRoom(Room room) { - this.room = room; - } -} From ff2cfc2498638b6c200493ce4fc7f10bdfa8bb47 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 24 Jul 2023 17:55:25 -0500 Subject: [PATCH 29/42] Refactored Permissions Groups, changed command and rights keys --- .../habbohotel/commands/list/CommandsCommand.java | 14 ++++++++++---- .../habbohotel/commands/list/RightsCommand.java | 11 +++++++++-- .../habbohotel/permissions/PermissionsManager.java | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java index 32a6727f..a6fe139a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java @@ -1,11 +1,11 @@ package com.eu.habbo.habbohotel.commands.list; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.PermissionCommand; import java.util.Collections; -import java.util.Comparator; import java.util.List; public class CommandsCommand extends Command { @@ -17,13 +17,19 @@ public class CommandsCommand extends Command { public boolean handle(GameClient gameClient, String[] params) { StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_commands.text")); - List commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands(); + List commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands(); - Collections.sort(commands, Comparator.comparing(PermissionCommand::getName)); + Collections.sort(commands); message.append("(").append(commands.size()).append("):\r\n"); - for(PermissionCommand command : commands) { + for(String commandName : commands) { + PermissionCommand command = Emulator.getGameEnvironment().getPermissionsManager().getCommand(commandName); + + if(command == null) { + continue; + } + message.append(command.getDescription()).append("\r"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java index 70ad2b80..7c75c86e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.commands.list; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.PermissionRight; @@ -15,11 +16,17 @@ public class RightsCommand extends Command { public boolean handle(GameClient gameClient, String[] params) throws Exception { StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_rights.text")); - Set rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights(); + Set rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights(); message.append("(").append(rights.size()).append("):\r\n"); - for(PermissionRight right : rights) { + for(String rightName : rights) { + PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(rightName); + + if(right == null) { + continue; + } + message.append(right.getName()).append(" - ").append(right.getDescription()).append("\r"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index 83661432..771a41ab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -58,6 +58,7 @@ public class PermissionsManager { log.error("Caught SQL exception", e); } + //TODO if Group is eliminated every user that has this rank must update to lowest Rank this.permissionGroups.entrySet().removeIf(entry -> !currentGroupIds.contains(entry.getKey())); } From 4fee1bccf3aa19f2323f5b5242b1dadec49a6dcd Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 25 Jul 2023 11:17:15 -0500 Subject: [PATCH 30/42] Room.java Clean-Up --- .../habbohotel/commands/list/TestCommand.java | 14 +++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 4 +- .../habbohotel/rooms/RoomItemManager.java | 24 ++------ .../entities/units/types/RoomAvatar.java | 58 ++++++++++++++----- 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java index a7c05e22..a397ccbe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java @@ -2,6 +2,10 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; + +import java.util.Map; +import java.util.Set; public class TestCommand extends Command { public TestCommand() { @@ -10,7 +14,17 @@ public class TestCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { + StringBuilder message = new StringBuilder("RoomUnit Statuses"); + Set> statuses = gameClient.getHabbo().getRoomUnit().getStatuses().entrySet(); + + message.append("(").append(statuses.size()).append("):\r\n"); + + for(Map.Entry status : statuses) { + message.append(status.getKey().toString()).append("\r"); + } + + gameClient.getHabbo().alert(new String[]{message.toString()}); return true; } } 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 e884a59f..952527d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -784,7 +784,9 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getHabboStats().getChatCounter().decrementAndGet(); } - if (this.cycleRoomUnit(habbo.getRoomUnit())) { + habbo.getRoomUnit().cycle(this); + + if(habbo.getRoomUnit().isStatusUpdateNeeded()) { habbo.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(habbo.getRoomUnit()); } 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 7aef2ba5..67c88d87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -381,12 +381,6 @@ public class RoomItemManager { THashSet occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); THashSet newOccupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - FurnitureMovementError fits = this.furnitureFitsAt(targetTile, item, rotation, true); - - if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) { - return fits; - } - RoomItem topItem = this.getTopItemAt(occupiedTiles, null); if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { @@ -652,21 +646,15 @@ public class RoomItemManager { THashSet occupiedTiles = this.room.getLayout().getTilesAt(targetTile, baseItem.getWidth(), baseItem.getLength(), rotation); - for (RoomTile t : occupiedTiles) { - if (t.getState() == RoomTileState.INVALID) { + for (RoomTile occupiedTile : occupiedTiles) { + if (occupiedTile.getState() == RoomTileState.INVALID) { return FurnitureMovementError.INVALID_MOVE; } - if (!wiredPlaceUnder || (!item.isWalkable() && !baseItem.allowSit() && !baseItem.allowLay())) { - if (checkForUnits) { - if (this.room.getRoomUnitManager().hasHabbosAt(t)) { - return FurnitureMovementError.TILE_HAS_HABBOS; - } else if (this.room.getRoomUnitManager().hasBotsAt(t)) { - return FurnitureMovementError.TILE_HAS_BOTS; - } else if (this.room.getRoomUnitManager().hasPetsAt(t)) { - return FurnitureMovementError.TILE_HAS_PETS; - } - } + 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 && this.room.getRoomUnitManager().hasHabbosAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_HABBOS; + if (checkForUnits && this.room.getRoomUnitManager().hasBotsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_BOTS; + if (checkForUnits && this.room.getRoomUnitManager().hasPetsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_PETS; } } 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 3d9e61e4..38b17b0e 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 @@ -64,6 +64,17 @@ public class RoomAvatar extends RoomUnit { this.removeStatus(RoomUnitStatus.SIGN); } + if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) { + if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) { + this.removeStatus(RoomUnitStatus.MOVE); + } + + if(!this.isWalking()) { + RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition()); + return this.handleSitStatus(topItem) || this.handleLayStatus(topItem); + } + } + Habbo habboT = room.getRoomUnitManager().getHabboByRoomUnit(this); if (!this.isWalking() && !this.isKicked() && this.removeStatus(RoomUnitStatus.MOVE) == null && habboT != null) { @@ -263,7 +274,7 @@ public class RoomAvatar extends RoomUnit { } if(habbo != null) { - RoomItem topItem = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(next); boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); @@ -333,28 +344,49 @@ public class RoomAvatar extends RoomUnit { } } - private void handleSitStatus(RoomItem topItem) { + private boolean handleSitStatus(RoomItem topItem) { + if(topItem == null || !topItem.getBaseItem().allowSit()) { + return false; + } + if(!this.isCmdSitEnabled()) { - if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) { - this.removeStatus(RoomUnitStatus.SIT); - this.setStatusUpdateNeeded(true); - } else if(this.getCurrentPosition().getState() == RoomTileState.SIT && (!this.hasStatus(RoomUnitStatus.SIT))) { + if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); - this.setStatusUpdateNeeded(true); + this.setCurrentZ(topItem.getZ()); + this.setRotation(RoomRotation.values()[topItem.getRotation()]); + return true; + } else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { + this.removeStatus(RoomUnitStatus.SIT); + return true; } } + + return false; } - private void handleLayStatus(RoomItem topItem) { + private boolean handleLayStatus(RoomItem topItem) { + if(topItem == null || !topItem.getBaseItem().allowLay()) { + return false; + } + if(!this.isCmdLayEnabled()) { - if((topItem == null || !topItem.getBaseItem().allowLay()) && this.hasStatus(RoomUnitStatus.LAY)) { - this.removeStatus(RoomUnitStatus.LAY); - this.setStatusUpdateNeeded(true); - } else if(!this.hasStatus(RoomUnitStatus.LAY)) { + if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); - this.setStatusUpdateNeeded(true); + this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); + + if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { + this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getY())); + } else { + this.setLocation(this.getRoom().getLayout().getTile(topItem.getX(), this.getCurrentPosition().getY())); + } + return true; + } else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { + this.removeStatus(RoomUnitStatus.LAY); + return true; } } + + return false; } @Override From 9f40ce0a43d8eb7b42572783b9abf9bda97cedda Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 25 Jul 2023 11:57:29 -0500 Subject: [PATCH 31/42] Removed cycleRoomUnit for RoomAvatars --- .../com/eu/habbo/habbohotel/bots/Bot.java | 11 ++++ .../eu/habbo/habbohotel/bots/BotManager.java | 2 - .../com/eu/habbo/habbohotel/rooms/Room.java | 5 +- .../entities/units/types/RoomAvatar.java | 2 - .../rooms/entities/units/types/RoomBot.java | 59 +++++++++++++++++++ 5 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index ae978039..cff434d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -57,8 +57,12 @@ public class Bot extends Unit implements Runnable { private boolean chatRandom; @Getter private short chatDelay; + @Getter + @Setter private int chatTimeOut; private int chatTimestamp; + @Getter + @Setter private short lastChatIndex; private final int bubble; @Getter @@ -445,4 +449,11 @@ public class Bot extends Unit implements Runnable { } } + public void incrementLastChatIndex() { + this.lastChatIndex++; + } + + public void resetLastChatIndex() { + this.lastChatIndex = 0; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index d5470959..aca10bfa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -159,8 +159,6 @@ public class BotManager { log.error("Caught exception", e); } } - - bot.cycle(false); } else { habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); } 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 952527d7..e8f5f1bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -816,10 +816,9 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } - bot.cycle(this.allowBotsWalk); + bot.getRoomUnit().cycle(this); - - if (this.cycleRoomUnit(bot.getRoomUnit())) { + if(bot.getRoomUnit().isStatusUpdateNeeded()) { bot.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(bot.getRoomUnit()); } 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 38b17b0e..4cbfe873 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 @@ -320,8 +320,6 @@ public class RoomAvatar extends RoomUnit { public void giveEffect(int effectId, int duration, boolean forceEffect) { if (!this.isInRoom()) { return; - } else { - RoomAvatar roomAvatar = this; } if(this instanceof RoomHabbo) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java index ee62ecf2..9ca00a75 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java @@ -1,6 +1,11 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.Getter; @Getter @@ -9,6 +14,60 @@ public class RoomBot extends RoomAvatar { super(); } + @Override + public boolean cycle(Room room) { + Bot bot = this.getRoom().getRoomUnitManager().getBotByRoomUnit(this); + + if(bot == null) { + return false; + } + + if (this.getRoom().isAllowBotsWalk()) { + if(bot.canWalk()) { + if (!this.isWalking()) { + if (this.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && bot.getFollowingHabboId() == 0) { + this.setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.getRoom().getLayout().getTile(this.getBotStartLocation().getX(), this.getBotStartLocation().getY()), this.getRoom(), Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile()); + int timeOut = Emulator.getRandom().nextInt(20) * 2; + this.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); + } + } + } + } + + if (!bot.getChatLines().isEmpty() && bot.getChatTimeOut() <= Emulator.getIntUnixTimestamp() && bot.isChatAuto()) { + if (this.getRoom() != null) { + short test = 0; + + if(bot.isChatRandom()) { + bot.setLastChatIndex((short) Emulator.getRandom().nextInt(bot.getChatLines().size())); + } else if(bot.getLastChatIndex() == bot.getChatLines().size() - 1) { + bot.resetLastChatIndex(); + } else { + bot.incrementLastChatIndex(); + } + + if (bot.getLastChatIndex() >= bot.getChatLines().size()) { + bot.resetLastChatIndex(); + } + + String message = bot.getChatLines().get(bot.getLastChatIndex()) + .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.getRoom().getRoomInfo().getOwnerInfo().getUsername()) + .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), String.valueOf(this.getRoom().getRoomItemManager().getCurrentItems().size())) + .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), bot.getName()) + .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.getRoom().getRoomInfo().getName()) + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), String.valueOf(this.getRoom().getRoomUnitManager().getRoomHabbosCount())); + + if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this, room, new Object[]{ message })) { + bot.talk(message); + } + + bot.setChatTimeOut(Emulator.getIntUnixTimestamp() + bot.getChatDelay()); + } + } + + return super.cycle(room); + } + public RoomUnitType getRoomUnitType() { return RoomUnitType.BOT; } From 3c771a1dd45b2e80754e3c1f05fde66f1df3e07c Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 25 Jul 2023 19:00:43 -0500 Subject: [PATCH 32/42] Room.java clean-up --- .../eu/habbo/habbohotel/bots/BotManager.java | 2 +- .../catalog/layouts/RoomBundleLayout.java | 4 +- .../habbohotel/commands/CommandsManager.java | 6 +- .../habbohotel/commands/list/BotsCommand.java | 4 +- .../commands/list/PetInfoCommand.java | 2 +- .../commands/list/ReloadRoomCommand.java | 2 +- .../commands/list/RoomDanceCommand.java | 2 +- .../commands/list/RoomEffectCommand.java | 2 +- .../commands/list/RoomItemCommand.java | 2 +- .../commands/list/RoomKickCommand.java | 2 +- .../commands/list/RoomSitCommand.java | 2 +- .../commands/list/SayAllCommand.java | 2 +- .../commands/list/ShoutAllCommand.java | 2 +- .../commands/list/badge/RoomBadgeCommand.java | 2 +- .../list/credits/RoomCreditsCommand.java | 2 +- .../commands/list/gift/RoomGiftCommand.java | 2 +- .../list/pixels/RoomPixelsCommand.java | 2 +- .../list/points/RoomPointsCommand.java | 2 +- .../habbohotel/games/freeze/FreezeGame.java | 2 +- .../interactions/InteractionMultiHeight.java | 3 +- .../WiredConditionFurniHaveRoom.java | 6 +- .../WiredConditionNotFurniHaveRoom.java | 6 +- .../wired/effects/WiredEffectWhisper.java | 2 +- .../habbohotel/modtool/ModToolManager.java | 2 +- .../permissions/PermissionGroup.java | 13 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 32 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 474 +++++++----------- .../habbo/habbohotel/rooms/RoomManager.java | 24 +- .../habbohotel/rooms/RoomRightsManager.java | 4 +- .../habbohotel/rooms/RoomTraxManager.java | 2 +- .../habbohotel/rooms/RoomUnitManager.java | 106 ++-- .../rooms/entities/units/RoomUnit.java | 61 ++- .../entities/units/types/RoomAvatar.java | 122 ++--- .../rooms/entities/units/types/RoomPet.java | 35 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 43 -- .../UpdateFloorPropertiesEvent.java | 2 +- .../incoming/guilds/CreateGuildEvent.java | 2 +- .../guilds/UpdateGuildIdentityEvent.java | 2 +- .../incoming/navigator/DeleteRoomEvent.java | 6 +- .../rooms/items/UseFurnitureEvent.java | 2 +- .../incoming/rooms/pets/MountPetEvent.java | 16 +- .../incoming/rooms/pets/PlacePetEvent.java | 2 +- .../rooms/pets/RemovePetFromFlatEvent.java | 2 +- .../pets/TogglePetRidingPermissionEvent.java | 2 +- .../incoming/rooms/users/MoveAvatarEvent.java | 5 + .../modtool/ModeratorRoomInfoComposer.java | 2 +- .../threading/runnables/RoomUnitRidePet.java | 2 +- .../teleport/TeleportActionThree.java | 1 - 48 files changed, 458 insertions(+), 569 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index aca10bfa..4fed28b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -113,7 +113,7 @@ public class BotManager { if (room != null && bot != null && habbo != null) { if (room.getRoomInfo().isRoomOwner(habbo) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_PLACEFURNI)) { - if (room.getRoomUnitManager().getCurrentRoomBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { + if (room.getRoomUnitManager().getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index 23c88dbf..f86d8612 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -190,10 +190,10 @@ public class RoomBundleLayout extends SingleBundle { if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { - synchronized (this.room.getRoomUnitManager().getCurrentRoomBots()) { + synchronized (this.room.getRoomUnitManager().getCurrentBots()) { statement.setInt(1, userId); statement.setInt(2, roomId); - for (Bot bot : this.room.getRoomUnitManager().getCurrentRoomBots().values()) { + for (Bot bot : this.room.getRoomUnitManager().getCurrentBots().values()) { statement.setString(3, bot.getName()); statement.setString(4, bot.getMotto()); statement.setString(5, bot.getFigure()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java index 186db286..8d717d63 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java @@ -149,11 +149,11 @@ public class CommandsManager { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room.getRoomUnitManager().getCurrentRoomPets().isEmpty()) { + if (room.getRoomUnitManager().getCurrentPets().isEmpty()) { return false; } - for(Pet pet : room.getRoomUnitManager().getCurrentRoomPets().values()) { + for(Pet pet : room.getRoomUnitManager().getCurrentPets().values()) { if (pet != null && pet.getName().equalsIgnoreCase(args[0])) { StringBuilder commandBuilder = new StringBuilder(); @@ -166,7 +166,7 @@ public class CommandsManager { for (PetCommand command : pet.getPetData().getPetCommands()) { if (command.getKey().equalsIgnoreCase(commandKey)) { if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) { - rideablePet.getRider().getHabboInfo().dismountPet(room); + rideablePet.getRider().getRoomUnit().dismountPet(false); break; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java index fc882898..494aab57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java @@ -15,9 +15,9 @@ public class BotsCommand extends Command { if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) return false; - StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomBots().values().size()); + StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values().size()); - for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomBots().values()) { + for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values()) { data.append("\r"); data.append(""); data.append(Emulator.getTexts().getValue("generic.bot.name")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java index b7e27792..e93e7602 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java @@ -21,7 +21,7 @@ public class PetInfoCommand extends Command { String name = params[1]; - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentRoomPets().forEach((a, pet) -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentPets().forEach((a, pet) -> { if (pet.getName().equalsIgnoreCase(name)) { gameClient.getHabbo().alert("" + getTextsValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java index 371a0e7d..a9a67383 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java @@ -21,7 +21,7 @@ public class ReloadRoomCommand extends Command { Emulator.getThreading().run(() -> { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { - Collection habbos = new ArrayList<>(room.getRoomUnitManager().getRoomHabbos()); + Collection habbos = new ArrayList<>(room.getRoomUnitManager().getCurrentHabbos().values()); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java index 90ef6b57..f2cad1cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java @@ -28,7 +28,7 @@ public class RoomDanceCommand extends Command { return true; } - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> { habbo.getRoomUnit().setDanceType(DanceType.values()[danceId]); habbo.getRoomUnit().getRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose()); }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java index 946ebac7..2ba5902c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java @@ -22,7 +22,7 @@ public class RoomEffectCommand extends Command { if (effectId >= 0) { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> habbo.getRoomUnit().giveEffect(effectId, -1)); + room.getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> habbo.getRoomUnit().giveEffect(effectId, -1)); } else { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java index d58b7e89..e7f5670e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java @@ -29,7 +29,7 @@ public class RoomItemCommand extends Command { } } - for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) { habbo.getRoomUnit().setHandItem(itemId); habbo.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java index aa8d24ca..f7caa38b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java @@ -24,7 +24,7 @@ public class RoomKickCommand extends Command { room.sendComposer(new HabboBroadcastMessageComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose()); } - for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : room.getRoomUnitManager().getCurrentHabbos().values()) { if (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, true); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java index bbe77246..8071ffa5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java @@ -11,7 +11,7 @@ public class RoomSitCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> { if (habbo.getRoomUnit().isWalking()) { habbo.getRoomUnit().stopWalking(); } else if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java index ed798452..d4127436 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java @@ -21,7 +21,7 @@ public class SayAllCommand extends Command { String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> habbo.talk(message)); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> habbo.talk(message)); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java index 73befe08..40d79756 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java @@ -22,7 +22,7 @@ public class ShoutAllCommand extends Command { String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()); - for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) { habbo.shout(message); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java index ee2ee8c8..62c777a9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java @@ -20,7 +20,7 @@ public class RoomBadgeCommand extends BaseBadgeCommand { if (!badge.isEmpty()) { ServerMessage message = createServerMessage(badge); - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos() + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values() .forEach(habbo -> sendBadgeToClient(badge, message, habbo)); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java index d3193eb5..1296233d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java @@ -22,7 +22,7 @@ public class RoomCreditsCommand extends BaseCreditsCommand { if (amount != 0) { final String message = replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), amount + ""); - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> { habbo.giveCredits(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java index a590effb..edc30c8e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java @@ -17,7 +17,7 @@ public class RoomGiftCommand extends BaseGiftCommand { final String finalMessage = getFinalMessage(params); - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> { createGift(finalMessage, habbo, params); habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_ITEM)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java index 518e3bb4..b5ec0e96 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java @@ -22,7 +22,7 @@ public class RoomPixelsCommand extends BasePixelsCommand { if (amount != 0) { final String message = replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), amount + ""); - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos().forEach(habbo -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> { habbo.givePixels(amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java index e431be43..8b50d3d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java @@ -55,7 +55,7 @@ public class RoomPointsCommand extends BasePointsCommand { if (amount != 0) { final String message = replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type)); - for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) { habbo.givePoints(type, amount); habbo.whisper(message, RoomChatMessageBubbles.ALERT); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 71ccb521..2abe1ff4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -189,7 +189,7 @@ public class FreezeGame extends Game { super.start(); if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { - for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : this.room.getRoomUnitManager().getCurrentHabbos().values()) { if (this.getTeamForHabbo(habbo) == null) { for (RoomItem item : this.room.getRoomItemManager().getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { if (item instanceof InteractionFreezeTile) { 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 362793cc..3095e6f0 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 @@ -83,8 +83,9 @@ public class InteractionMultiHeight extends RoomItem { Collection unitsOnItem = room.getRoomUnitManager().getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY())); for (RoomUnit unit : unitsOnItem) { - if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoalLocation() != tile) + if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoalLocation() != tile) { continue; + } if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) { unit.setSitUpdate(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java index 96732a4c..be439213 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java @@ -30,9 +30,9 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition { return true; } - Collection habbos = room.getRoomUnitManager().getRoomHabbos(); - Collection bots = room.getRoomUnitManager().getCurrentRoomBots().values(); - Collection pets = room.getRoomUnitManager().getCurrentRoomPets().values(); + Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values(); + Collection bots = room.getRoomUnitManager().getCurrentBots().values(); + Collection pets = room.getRoomUnitManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().allMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java index cd64c515..60d9c148 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java @@ -30,9 +30,9 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition { return true; } - Collection habbos = room.getRoomUnitManager().getRoomHabbos(); - Collection bots = room.getRoomUnitManager().getCurrentRoomBots().values(); - Collection pets = room.getRoomUnitManager().getCurrentRoomPets().values(); + Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values(); + Collection bots = room.getRoomUnitManager().getCurrentBots().values(); + Collection pets = room.getRoomUnitManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().noneMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); 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 b6348162..c810d135 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 @@ -45,7 +45,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect { return true; } } else { - for (Habbo h : room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo h : room.getRoomUnitManager().getCurrentHabbos().values()) { h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED))); } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 27e7c1d5..d298f236 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -483,7 +483,7 @@ public class ModToolManager { } if (roomActionEvent.isKickUsers()) { - for (Habbo habbo : room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : room.getRoomUnitManager().getCurrentHabbos().values()) { if (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) { room.kickHabbo(habbo, false); } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java index 87ea6450..c3e61a77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionGroup.java @@ -116,9 +116,9 @@ public class PermissionGroup { } } - public boolean canExecuteCommand(String key, boolean hasRoomRights) { + public boolean canExecuteCommand(String commandName, boolean hasRoomRights) { PermissionsManager permissionsManager = Emulator.getGameEnvironment().getPermissionsManager(); - PermissionCommand command = permissionsManager.getCommandByKey(key); + PermissionCommand command = permissionsManager.getCommandByKey(commandName); if(command == null) { return false; @@ -141,11 +141,10 @@ public class PermissionGroup { return false; } - public boolean hasPermissionRight(String name, boolean hasRoomRights) { - PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(name); - if(right != null && this.rights.containsKey(right)) { - PermissionSetting setting = this.rights.get(right); - return (setting == PermissionSetting.ALLOWED || (setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights)); + public boolean hasPermissionRight(String rightName, boolean hasRoomRights) { + if(this.rights.containsKey(rightName)) { + PermissionSetting setting = this.rights.get(rightName); + return setting == PermissionSetting.ALLOWED || setting == PermissionSetting.HAS_ROOM_RIGHTS && hasRoomRights; } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 8b804076..4b09df66 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -334,16 +334,16 @@ public class Pet extends Unit implements ISerialize, Runnable { public void cycle() { this.idleCommandTicks++; - int time = Emulator.getIntUnixTimestamp(); + int currentTime = Emulator.getIntUnixTimestamp(); + if (this.getRoomUnit() != null && this.task != PetTasks.RIDE) { - if (time - this.gestureTickTimeout > 5 && this.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { + if (currentTime - this.gestureTickTimeout > 5 && this.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { this.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); - this.setPacketUpdate(true); } - if (time - this.postureTimeout > 1 && this.task == null) { + if (currentTime - this.postureTimeout > 1 && this.task == null) { this.clearPosture(); - this.postureTimeout = time + 120; + this.postureTimeout = currentTime + 120; } if (this.freeCommandTicks > 0) { @@ -355,7 +355,7 @@ public class Pet extends Unit implements ISerialize, Runnable { } if (!this.getRoomUnit().isWalking()) { - if (this.getRoomUnit().getWalkTimeOut() < time && this.canWalk()) { + if (this.getRoomUnit().getWalkTimeOut() < currentTime && this.canWalk()) { RoomTile tile = this.room.getRandomWalkableTile(); if (tile != null) { @@ -379,7 +379,7 @@ public class Pet extends Unit implements ISerialize, Runnable { this.getRoomUnit().setGoalLocation(this.room.getRandomWalkableTile()); this.task = null; this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); - this.gestureTickTimeout = time; + this.gestureTickTimeout = currentTime; } } /* this is regeneration, add back if needed else if (this.tickTimeout >= 5) { @@ -401,7 +401,7 @@ public class Pet extends Unit implements ISerialize, Runnable { this.getRoomUnit().setCanWalk(true); } } else { - this.getRoomUnit().setWalkTimeOut(20 + time); + this.getRoomUnit().setWalkTimeOut(20 + currentTime); if (this.energy >= 2) this.addEnergy(-1); @@ -413,20 +413,20 @@ public class Pet extends Unit implements ISerialize, Runnable { if (this.levelThirst < 100) this.levelThirst++; - if (this.happiness > 0 && time - this.happinessDelay >= 30) { + if (this.happiness > 0 && currentTime - this.happinessDelay >= 30) { this.happiness--; - this.happinessDelay = time; + this.happinessDelay = currentTime; } } - if (time - this.gestureTickTimeout > 15) { - this.updateGesture(time); - } else if (time - this.randomActionTickTimeout > 30) { + if (currentTime - this.gestureTickTimeout > 15) { + this.updateGesture(currentTime); + } else if (currentTime - this.randomActionTickTimeout > 30) { this.randomAction(); - this.randomActionTickTimeout = time + (10 * Emulator.getRandom().nextInt(60)); + this.randomActionTickTimeout = currentTime + (10 * Emulator.getRandom().nextInt(60)); } - if (!this.muted && this.chatTimeout <= time) { + if (!this.muted && this.chatTimeout <= currentTime) { if (this.energy <= 30) { this.say(this.petData.randomVocal(PetVocalsType.TIRED)); if (this.energy <= 10) @@ -444,7 +444,7 @@ public class Pet extends Unit implements ISerialize, Runnable { } int timeOut = Emulator.getRandom().nextInt(30); - this.chatTimeout = time + (timeOut < 3 ? 30 : timeOut); + this.chatTimeout = currentTime + (timeOut < 3 ? 30 : timeOut); } } } 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 e8f5f1bf..b27bd14e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -20,7 +20,6 @@ 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.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; @@ -92,9 +91,11 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter private RoomTraxManager roomTraxManager; private static final String CAUGHT_EXCEPTION = "Caught exception"; - public static final Comparator SORT_SCORE = (o1, o2) -> o2.roomInfo.getScore() - o1.roomInfo.getScore(); - public static final Comparator SORT_ID = (o1, o2) -> o2.roomInfo.getId() - o1.roomInfo.getId(); - //Configuration. Loaded from database & updated accordingly. + public static final Comparator SORT_SCORE = Comparator.comparingInt(room -> room.roomInfo.getScore()); + public static final Comparator SORT_ID = Comparator.comparingInt(room -> room.roomInfo.getId()); + public static final Comparator SORT_USERS_COUNT = Comparator + .comparingInt((Room room) -> room.roomUnitManager.getRoomHabbosCount()) + .thenComparing(Room.SORT_ID); public static boolean HABBO_CHAT_DELAY = false; public static int MAXIMUM_BOTS = 10; public static int MAXIMUM_PETS = 10; @@ -507,171 +508,6 @@ public class Room implements Comparable, ISerialize, Runnable { return null; } - public synchronized void dispose() { - synchronized (this.loadLock) { - if (this.preventUnloading) - return; - - if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) - return; - - if (this.loaded) { - try { - - if (this.roomTraxManager != null && !this.roomTraxManager.disposed()) { - this.roomTraxManager.dispose(); - } - - this.roomCycleTask.cancel(false); - this.scheduledTasks.clear(); - this.scheduledComposers.clear(); - this.loaded = false; - - this.tileCache.clear(); - - synchronized (this.mutedHabbos) { - this.mutedHabbos.clear(); - } - - for (InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) { - timer.setRunning(false); - } - - for (Game game : this.games) { - game.dispose(); - } - this.games.clear(); - - this.roomUnitManager.removeAllPetsExceptRoomOwner(); - - this.roomItemManager.dispose(); - - if (this.roomSpecialTypes != null) { - this.roomSpecialTypes.dispose(); - } - - synchronized (this.habboQueue) { - this.habboQueue.clear(); - } - - this.roomUnitManager.dispose(); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - - try { - this.wordQuiz = ""; - this.yesVotes = 0; - this.noVotes = 0; - this.updateDatabaseUserCount(); - this.preLoaded = true; - this.layout = null; - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - - Emulator.getPluginManager().fireEvent(new RoomUnloadedEvent(this)); - } - - @Override - public int compareTo(Room o) { - if (o.roomUnitManager.getRoomHabbosCount() != this.roomUnitManager.getRoomHabbosCount()) { - return o.roomUnitManager.getCurrentRoomHabbos().size() - this.roomUnitManager.getCurrentRoomHabbos().size(); - } - - return this.roomInfo.getId() - o.roomInfo.getId(); - } - - @Override - public void serialize(ServerMessage message) { - message.appendInt(this.roomInfo.getId()); - message.appendString(this.roomInfo.getName()); - - if (this.roomInfo.isPublicRoom()) { - message.appendInt(0); - message.appendString(""); - } else { - message.appendInt(this.roomInfo.getOwnerInfo().getId()); - message.appendString(this.roomInfo.getOwnerInfo().getUsername()); - } - - message.appendInt(this.roomInfo.getState().ordinal()); - message.appendInt(this.roomUnitManager.getRoomHabbosCount()); - message.appendInt(this.roomInfo.getMaxUsers()); - message.appendString(this.roomInfo.getDescription()); - message.appendInt(this.roomInfo.getTradeMode()); - message.appendInt(this.roomInfo.getScore()); - message.appendInt(0); - message.appendInt(this.roomInfo.getCategory().getId()); - - String[] tags = Arrays.stream(this.roomInfo.getTags().split(";")).filter(t -> !t.isEmpty()).toArray(String[]::new); - message.appendInt(tags.length); - for (String s : tags) { - message.appendString(s); - } - - int base = 0; - - if (this.roomInfo.hasGuild()) { - base = base | 2; - } - - if (this.roomInfo.isPromoted()) { - base = base | 4; - } - - if (!this.roomInfo.isPublicRoom()) { - base = base | 8; - } - - if (this.roomInfo.isAllowPets()) { - base = base | 16; - } - - message.appendInt(base); - - - if (this.roomInfo.hasGuild()) { - message.appendInt(this.roomInfo.getGuild().getId()); - message.appendString(this.roomInfo.getGuild().getName()); - message.appendString(this.roomInfo.getGuild().getBadge()); - } - - if (this.roomInfo.isPromoted()) { - message.appendString(this.promotion.getTitle()); - message.appendString(this.promotion.getDescription()); - message.appendInt((this.promotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); - } - } - - @Override - public void run() { - synchronized (this.loadLock) { - if (this.loaded) { - try { - Emulator.getThreading().run(Room.this::cycle); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - } - - this.save(); - } - - public void save() { - if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - this.roomInfo.update(connection); - this.needsUpdate = false; - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } - } - public void updateDatabaseUserCount() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET users = ? WHERE id = ? LIMIT 1")) { statement.setInt(1, this.roomUnitManager.getRoomHabbosCount()); @@ -686,7 +522,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.cycleOdd = !this.cycleOdd; this.cycleTimestamp = System.currentTimeMillis(); final boolean[] foundRightHolder = {false}; - + boolean loaded; synchronized (this.loadLock) { loaded = this.loaded; @@ -706,7 +542,7 @@ public class Room implements Comparable, ISerialize, Runnable { task.cycle(this); } - if (!this.roomUnitManager.getCurrentRoomHabbos().isEmpty()) { + if (!this.roomUnitManager.getCurrentHabbos().isEmpty()) { this.roomIdleCycles = 0; THashSet updatedUnit = new THashSet<>(); @@ -714,18 +550,11 @@ public class Room implements Comparable, ISerialize, Runnable { final long millis = System.currentTimeMillis(); - for (Habbo habbo : this.roomUnitManager.getCurrentRoomHabbos().values()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { if (!foundRightHolder[0]) { foundRightHolder[0] = habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE; } - /* Habbo doesn't remove the handitem anymore, checked on February 25 2023 - if (habbo.getRoomUnit().getHandItem() > 0 && millis - habbo.getRoomUnit().getHandItemTimestamp() > (Room.HAND_ITEM_TIME * 1000L)) { - this.giveHandItem(habbo, 0); - } - - */ - if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) { habbo.getRoomUnit().giveEffect(0, -1); } @@ -798,8 +627,8 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.roomUnitManager.getCurrentRoomBots().isEmpty()) { - Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); + if (!this.roomUnitManager.getCurrentBots().isEmpty()) { + Iterator botIterator = this.roomUnitManager.getCurrentBots().values().iterator(); while(botIterator.hasNext()) { try { @@ -831,8 +660,8 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.roomUnitManager.getCurrentRoomPets().isEmpty() && this.allowBotsWalk) { - Iterator petIterator = this.roomUnitManager.getCurrentRoomPets().values().iterator(); + if (!this.roomUnitManager.getCurrentPets().isEmpty() && this.allowBotsWalk) { + Iterator petIterator = this.roomUnitManager.getCurrentPets().values().iterator(); while(petIterator.hasNext()) { final Pet pet; try { @@ -841,16 +670,12 @@ public class Room implements Comparable, ISerialize, Runnable { break; } - if (this.cycleRoomUnit(pet.getRoomUnit())) { - pet.getRoomUnit().setStatusUpdateNeeded(false); - updatedUnit.add(pet.getRoomUnit()); - } - + pet.getRoomUnit().cycle(this); pet.cycle(); - if (pet.isPacketUpdate()) { + if(pet.getRoomUnit().isStatusUpdateNeeded()) { + pet.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(pet.getRoomUnit()); - pet.setPacketUpdate(false); } if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { @@ -1136,60 +961,165 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private boolean cycleRoomUnit(RoomUnit unit) { - //Si esta caminando y su path no es nulo ni esta vacio - if (unit.isWalking() && unit.getPath() != null && !unit.getPath().isEmpty()) { - unit.cycle(this); - //Si no esta caminando o su path tiene errores + @Override + public void run() { + synchronized (this.loadLock) { + if (this.loaded) { + try { + Emulator.getThreading().run(Room.this::cycle); + } catch (Exception e) { + log.error(CAUGHT_EXCEPTION, e); + } + } + } + + this.save(); + } + + public void save() { + if (this.needsUpdate) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + this.roomInfo.update(connection); + this.needsUpdate = false; + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + } + + @Override + public void serialize(ServerMessage message) { + message.appendInt(this.roomInfo.getId()); + message.appendString(this.roomInfo.getName()); + + if (this.roomInfo.isPublicRoom()) { + message.appendInt(0); + message.appendString(""); } else { - //Y tiene el status de move, quitaselo y ocupa update - if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.isAnimateWalk()) { - unit.removeStatus(RoomUnitStatus.MOVE); + message.appendInt(this.roomInfo.getOwnerInfo().getId()); + message.appendString(this.roomInfo.getOwnerInfo().getUsername()); + } + + message.appendInt(this.roomInfo.getState().ordinal()); + message.appendInt(this.roomUnitManager.getRoomHabbosCount()); + message.appendInt(this.roomInfo.getMaxUsers()); + message.appendString(this.roomInfo.getDescription()); + message.appendInt(this.roomInfo.getTradeMode()); + message.appendInt(this.roomInfo.getScore()); + message.appendInt(0); + message.appendInt(this.roomInfo.getCategory().getId()); + + String[] tags = Arrays.stream(this.roomInfo.getTags().split(";")).filter(t -> !t.isEmpty()).toArray(String[]::new); + message.appendInt(tags.length); + for (String s : tags) { + message.appendString(s); + } + + int base = 0; + + if (this.roomInfo.hasGuild()) { + base = base | 2; + } + + if (this.roomInfo.isPromoted()) { + base = base | 4; + } + + if (!this.roomInfo.isPublicRoom()) { + base = base | 8; + } + + if (this.roomInfo.isAllowPets()) { + base = base | 16; + } + + message.appendInt(base); + + + if (this.roomInfo.hasGuild()) { + message.appendInt(this.roomInfo.getGuild().getId()); + message.appendString(this.roomInfo.getGuild().getName()); + message.appendString(this.roomInfo.getGuild().getBadge()); + } + + if (this.roomInfo.isPromoted()) { + message.appendString(this.promotion.getTitle()); + message.appendString(this.promotion.getDescription()); + message.appendInt((this.promotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); + } + } + + @Override + public int compareTo(Room room) { + return SORT_USERS_COUNT.compare(this, room); + } + + public synchronized void dispose() { + synchronized (this.loadLock) { + if (this.preventUnloading) + return; + + if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) + return; + + if (this.loaded) { + try { + + if (this.roomTraxManager != null && !this.roomTraxManager.disposed()) { + this.roomTraxManager.dispose(); + } + + this.roomCycleTask.cancel(false); + this.scheduledTasks.clear(); + this.scheduledComposers.clear(); + this.loaded = false; + + this.tileCache.clear(); + + synchronized (this.mutedHabbos) { + this.mutedHabbos.clear(); + } + + for (InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) { + timer.setRunning(false); + } + + for (Game game : this.games) { + game.dispose(); + } + this.games.clear(); + + this.roomUnitManager.removeAllPetsExceptRoomOwner(); + + this.roomItemManager.dispose(); + + if (this.roomSpecialTypes != null) { + this.roomSpecialTypes.dispose(); + } + + synchronized (this.habboQueue) { + this.habboQueue.clear(); + } + + this.roomUnitManager.dispose(); + } catch (Exception e) { + log.error(CAUGHT_EXCEPTION, e); + } } - if (!unit.isWalking() && !unit.isCmdSitEnabled()) { - RoomTile thisTile = this.layout.getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); - RoomItem topItem = this.roomItemManager.getTallestChair(thisTile); - - if (topItem == null || !topItem.getBaseItem().allowSit()) { - if (unit.hasStatus(RoomUnitStatus.SIT)) { - unit.removeStatus(RoomUnitStatus.SIT); - } - } else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) { - if(unit instanceof RoomAvatar roomAvatar) { - roomAvatar.setDance(DanceType.NONE); - } - unit.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); - unit.setCurrentZ(topItem.getZ()); - unit.setRotation(RoomRotation.values()[topItem.getRotation()]); - unit.setSitUpdate(false); - return true; - } + try { + this.wordQuiz = ""; + this.yesVotes = 0; + this.noVotes = 0; + this.updateDatabaseUserCount(); + this.preLoaded = true; + this.layout = null; + } catch (Exception e) { + log.error(CAUGHT_EXCEPTION, e); } } - if (!unit.isWalking() && !unit.isCmdLayEnabled()) { - RoomItem topItem = this.roomItemManager.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); - - if (topItem == null || !topItem.getBaseItem().allowLay()) { - if (unit.hasStatus(RoomUnitStatus.LAY)) { - unit.removeStatus(RoomUnitStatus.LAY); - } - } else { - if (!unit.hasStatus(RoomUnitStatus.LAY)) { - unit.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); - unit.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); - - if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { - unit.setLocation(this.layout.getTile(unit.getCurrentPosition().getX(), topItem.getY())); - } else { - unit.setLocation(this.layout.getTile(topItem.getX(), unit.getCurrentPosition().getY())); - } - } - } - } - - return unit.isStatusUpdateNeeded(); + Emulator.getPluginManager().fireEvent(new RoomUnloadedEvent(this)); } public void setDiagonalMoveEnabled(boolean moveDiagonally) { @@ -1444,11 +1374,11 @@ public class Room implements Comparable, ISerialize, Runnable { public void habboEntered(Habbo habbo) { habbo.getRoomUnit().setAnimateWalk(false); - synchronized (this.roomUnitManager.getCurrentRoomBots()) { + synchronized (this.roomUnitManager.getCurrentBots()) { if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) return; - Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); + Iterator botIterator = this.roomUnitManager.getCurrentBots().values().iterator(); while (botIterator.hasNext()) { try { @@ -1613,7 +1543,7 @@ public class Room implements Comparable, ISerialize, Runnable { final ServerMessage message = new WhisperMessageComposer(roomChatMessage).compose(); final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); - for (Habbo h : this.roomUnitManager.getRoomHabbos()) { + for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { if (h == roomChatMessage.getTargetHabbo() || h == habbo) { if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { if (prefixMessage != null) { @@ -1636,7 +1566,7 @@ public class Room implements Comparable, ISerialize, Runnable { ServerMessage message = new ChatMessageComposer(roomChatMessage).compose(); boolean noChatLimit = habbo.hasPermissionRight(Permission.ACC_CHAT_NO_LIMIT); - for (Habbo h : this.roomUnitManager.getRoomHabbos()) { + for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= this.roomInfo.getChatDistance() || h.equals(habbo) || this.roomRightsManager.hasRights(h) || @@ -1658,7 +1588,7 @@ public class Room implements Comparable, ISerialize, Runnable { } else if (chatType == RoomChatType.SHOUT) { ServerMessage message = new ShoutMessageComposer(roomChatMessage).compose(); - for (Habbo h : this.roomUnitManager.getRoomHabbos()) { + for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { // Show the message // If the receiving Habbo has not ignored the sending Habbo // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo @@ -1678,8 +1608,8 @@ public class Room implements Comparable, ISerialize, Runnable { } if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { - synchronized (this.roomUnitManager.getCurrentRoomBots()) { - Iterator botIterator = this.roomUnitManager.getCurrentRoomBots().values().iterator(); + synchronized (this.roomUnitManager.getCurrentBots()) { + Iterator botIterator = this.roomUnitManager.getCurrentBots().values().iterator(); while (botIterator.hasNext()) { try { @@ -1831,18 +1761,6 @@ public class Room implements Comparable, ISerialize, Runnable { return this.getStackHeight(x, y, calculateHeightmap, null); } - public boolean hasObjectTypeAt(Class type, int x, int y) { - THashSet items = this.roomItemManager.getItemsAt(x, y); - - for (RoomItem item : items) { - if (item.getClass() == type) { - return true; - } - } - - return false; - } - public boolean canSitOrLayAt(int x, int y) { RoomTile tile = this.layout.getTile((short) x, (short) y); @@ -1871,38 +1789,6 @@ public class Room implements Comparable, ISerialize, Runnable { return this.canSitAt(this.roomItemManager.getItemsAt(x, y)); } - boolean canWalkAt(RoomTile roomTile) { - if (roomTile == null) { - return false; - } - - if (roomTile.getState() == RoomTileState.INVALID) - return false; - - RoomItem topItem = null; - boolean canWalk = true; - THashSet items = this.roomItemManager.getItemsAt(roomTile); - if (items != null) { - for (RoomItem item : items) { - if (topItem == null) { - topItem = item; - } - - if (item.getZ() > topItem.getZ()) { - topItem = item; - canWalk = topItem.isWalkable() || topItem.getBaseItem().allowWalk(); - } else if (item.getZ() == topItem.getZ() && canWalk) { - if ((!topItem.isWalkable() && !topItem.getBaseItem().allowWalk()) - || (!item.getBaseItem().allowWalk() && !item.isWalkable())) { - canWalk = false; - } - } - } - } - - return canWalk; - } - boolean canSitAt(THashSet items) { if (items == null) return false; @@ -1957,7 +1843,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void sendComposer(ServerMessage message) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { if (habbo.getClient() == null) continue; habbo.getClient().sendResponse(message); @@ -1965,7 +1851,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void petChat(ServerMessage message) { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { if (!habbo.getHabboStats().isIgnorePets()) habbo.getClient().sendResponse(message); } @@ -1976,7 +1862,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { if (habbo == null) { return ; } if (!habbo.getHabboStats().isIgnoreBots()) habbo.getClient().sendResponse(message); @@ -2101,7 +1987,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (guild.getRoomId() == this.roomInfo.getId()) { THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { Optional member = members.stream().filter(m -> m.getUserId() == habbo.getHabboInfo().getId()).findAny(); if (member.isEmpty()) continue; @@ -2128,7 +2014,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void refreshGuildRightsInRoom() { - for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) { + for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) && (!(habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_MOVEROTATE)))) this.getRoomRightsManager().refreshRightsForHabbo(habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 1c346abc..9fb490ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -427,7 +427,7 @@ public class RoomManager { room.getRoomInfo().setScore(room.getRoomInfo().getScore() + 1); room.setNeedsUpdate(true); habbo.getHabboStats().getVotedRooms().push(room.getRoomInfo().getId()); - for (Habbo h : room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo h : room.getRoomUnitManager().getCurrentHabbos().values()) { h.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(h, room))); } @@ -523,7 +523,7 @@ public class RoomManager { boolean habbosWithRights = false; synchronized (room.getRoomUnitManager().roomUnitLock) { - for (Habbo current : room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo current : room.getRoomUnitManager().getCurrentHabbos().values()) { if (room.getRoomRightsManager().hasRights(current) || current.getHabboInfo().getId() == room.getRoomInfo().getOwnerInfo().getId() || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(current).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) { current.getClient().sendResponse(new DoorbellMessageComposer(habbo.getHabboInfo().getUsername())); habbosWithRights = true; @@ -681,9 +681,9 @@ public class RoomManager { List visibleHabbos = new ArrayList<>(); - if (!room.getRoomUnitManager().getCurrentRoomHabbos().isEmpty()) { - Collection habbosToSendEnter = room.getRoomUnitManager().getRoomHabbos(); - Collection allHabbos = room.getRoomUnitManager().getRoomHabbos(); + if (!room.getRoomUnitManager().getCurrentHabbos().values().isEmpty()) { + Collection habbosToSendEnter = room.getRoomUnitManager().getCurrentHabbos().values(); + Collection allHabbos = room.getRoomUnitManager().getCurrentHabbos().values(); if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, allHabbos)); @@ -716,14 +716,14 @@ public class RoomManager { } - habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentRoomBots().values(), true)); + habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentBots().values(), true)); - if (!room.getRoomUnitManager().getCurrentRoomBots().isEmpty()) { - room.getRoomUnitManager().getCurrentRoomBots().values().stream() + if (!room.getRoomUnitManager().getCurrentBots().isEmpty()) { + room.getRoomUnitManager().getCurrentBots().values().stream() .filter(b -> !b.getRoomUnit().getDanceType().equals(DanceType.NONE)) .forEach(b -> habbo.getClient().sendResponse(new DanceMessageComposer(b.getRoomUnit()))); - room.getRoomUnitManager().getCurrentRoomBots().values() + room.getRoomUnitManager().getCurrentBots().values() .forEach(b -> habbo.getClient().sendResponse(new UserUpdateComposer(b.getRoomUnit(), b.getRoomUnit().getCurrentZ()))); } @@ -760,9 +760,9 @@ public class RoomManager { habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); floorItems.clear(); - if (!room.getRoomUnitManager().getCurrentRoomPets().isEmpty()) { - habbo.getClient().sendResponse(new RoomPetComposer(room.getRoomUnitManager().getCurrentRoomPets())); - room.getRoomUnitManager().getCurrentRoomPets().values().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); + if (!room.getRoomUnitManager().getCurrentPets().isEmpty()) { + habbo.getClient().sendResponse(new RoomPetComposer(room.getRoomUnitManager().getCurrentPets())); + room.getRoomUnitManager().getCurrentPets().values().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); } if (!habbo.getHabboStats().allowTalk()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java index dfbb3c12..fdc97e94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -55,7 +55,7 @@ public class RoomRightsManager { } public boolean hasRights(Habbo habbo) { - return this.room.getRoomInfo().isRoomOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.room.getRoomUnitManager().getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())); + return this.room.getRoomInfo().isRoomOwner(habbo) || this.rights.contains(habbo.getHabboInfo().getId()) || (habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE && this.room.getRoomUnitManager().getCurrentHabbos().containsKey(habbo.getHabboInfo().getId())); } public HashMap getUsersWithRights() { @@ -167,7 +167,7 @@ public class RoomRightsManager { } private void refreshRightsInRoom() { - for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : this.room.getRoomUnitManager().getCurrentHabbos().values()) { if (habbo.getRoomUnit().getRoom() == room) { this.refreshRightsForHabbo(habbo); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java index 4c84821f..fff25fd9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java @@ -395,7 +395,7 @@ public class RoomTraxManager implements Disposable { } public void sendUpdatedSongList() { - this.room.getRoomUnitManager().getRoomHabbos().forEach(h -> { + this.room.getRoomUnitManager().getCurrentHabbos().values().forEach(h -> { GameClient client = h.getClient(); if (client != null) { 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 4a2c87f2..26b4bd39 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -38,18 +38,18 @@ import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; public class RoomUnitManager { private final Room room; private final ConcurrentHashMap currentRoomUnits; - private final ConcurrentHashMap currentRoomHabbos; - private final ConcurrentHashMap currentRoomBots; - private final ConcurrentHashMap currentRoomPets; + private final ConcurrentHashMap currentHabbos; + private final ConcurrentHashMap currentBots; + private final ConcurrentHashMap currentPets; private volatile int roomUnitCounter; public final Object roomUnitLock; public RoomUnitManager(Room room) { this.room = room; this.currentRoomUnits = new ConcurrentHashMap<>(); - this.currentRoomHabbos = new ConcurrentHashMap<>(); - this.currentRoomBots = new ConcurrentHashMap<>(); - this.currentRoomPets = new ConcurrentHashMap<>(); + this.currentHabbos = new ConcurrentHashMap<>(); + this.currentBots = new ConcurrentHashMap<>(); + this.currentPets = new ConcurrentHashMap<>(); this.roomUnitCounter = 0; this.roomUnitLock = new Object(); } @@ -60,7 +60,7 @@ public class RoomUnitManager { } private synchronized void loadBots(Connection connection) { - this.currentRoomBots.clear(); + this.currentBots.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.room.getRoomInfo().getId()); @@ -100,7 +100,7 @@ public class RoomUnitManager { } private synchronized void loadPets(Connection connection) { - this.currentRoomPets.clear(); + this.currentPets.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.room.getRoomInfo().getId()); @@ -141,12 +141,12 @@ public class RoomUnitManager { switch (unit.getRoomUnit().getRoomUnitType()) { case HABBO -> { - this.currentRoomHabbos.put(((Habbo) unit).getHabboInfo().getId(), (Habbo) unit); + this.currentHabbos.put(((Habbo) unit).getHabboInfo().getId(), (Habbo) unit); unit.getRoomUnit().getRoom().updateDatabaseUserCount(); } - case BOT -> this.currentRoomBots.put(((Bot) unit).getId(), (Bot) unit); + case BOT -> this.currentBots.put(((Bot) unit).getId(), (Bot) unit); case PET -> { - this.currentRoomPets.put(((Pet) unit).getId(), (Pet) unit); + this.currentPets.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()); @@ -164,66 +164,62 @@ public class RoomUnitManager { return this.currentRoomUnits.values().stream().anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); } - public Collection getAvatarsAt(RoomTile tile) { + public List getAvatarsAt(RoomTile tile) { return Stream.concat(this.getHabbosAt(tile).stream(), this.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList()); } - public Collection getRoomHabbos() { - return this.currentRoomHabbos.values(); - } - public int getRoomHabbosCount() { - return this.currentRoomHabbos.size(); + return this.currentHabbos.size(); } public boolean hasHabbosAt(RoomTile tile) { - return this.currentRoomHabbos.values().stream().anyMatch(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)); + return this.currentHabbos.values().stream().anyMatch(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)); } public Collection getHabbosAt(RoomTile tile) { - return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + return this.currentHabbos.values().stream().filter(habbo -> habbo.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } public Habbo getRoomHabboById(int habboId) { - return this.currentRoomHabbos.get(habboId); + return this.currentHabbos.get(habboId); } public Habbo getRoomHabboByUsername(String username) { - return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)).findFirst().orElse(null); + return this.currentHabbos.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); + return this.currentHabbos.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); + return this.currentHabbos.values().stream().filter(habbo -> habbo.getRoomUnit() == roomUnit).findFirst().orElse(null); } public Bot getRoomBotById(int botId) { - return this.currentRoomBots.get(botId); + return this.currentBots.get(botId); } public List getBotsByName(String name) { - synchronized (this.currentRoomBots) { - return currentRoomBots.values().stream().filter(bot -> bot.getName().equalsIgnoreCase(name)).toList(); + synchronized (this.currentBots) { + return currentBots.values().stream().filter(bot -> bot.getName().equalsIgnoreCase(name)).toList(); } } public Bot getBotByRoomUnit(RoomUnit roomUnit) { - return this.currentRoomBots.values().stream().filter(bot -> bot.getRoomUnit() == roomUnit).findFirst().orElse(null); + return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit() == roomUnit).findFirst().orElse(null); } public boolean hasBotsAt(RoomTile tile) { - return this.currentRoomBots.values().stream().anyMatch(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)); + return this.currentBots.values().stream().anyMatch(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)); } public Collection getBotsAt(RoomTile tile) { - return this.currentRoomBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } public void placePet(Pet pet, Room room, short x, short y, double z) { - synchronized (this.currentRoomPets) { + synchronized (this.currentPets) { RoomTile tile = room.getLayout().getTile(x, y); if (tile == null) { @@ -255,26 +251,26 @@ public class RoomUnitManager { } public boolean hasPetsAt(RoomTile tile) { - return this.currentRoomPets.values().stream().anyMatch(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)); + return this.currentPets.values().stream().anyMatch(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)); } public Collection getPetsAt(RoomTile tile) { - return this.currentRoomPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } public Pet getRoomPetById(int petId) { - return this.currentRoomPets.get(petId); + return this.currentPets.get(petId); } public Pet getPetByRoomUnit(RoomUnit roomUnit) { - return this.currentRoomPets.values().stream().filter(pet -> pet.getRoomUnit() == roomUnit).findFirst().orElse(null); + return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit() == roomUnit).findFirst().orElse(null); } public void pickUpMyPets(Habbo owner) { THashSet pets = new THashSet<>(); - synchronized (this.currentRoomPets) { - for (Pet pet : this.currentRoomPets.values()) { + synchronized (this.currentPets) { + for (Pet pet : this.currentPets.values()) { if (pet.getUserId() == owner.getHabboInfo().getId()) { pets.add(pet); } @@ -286,12 +282,12 @@ public class RoomUnitManager { Emulator.getThreading().run(pet); owner.getInventory().getPetsComponent().addPet(pet); owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - this.currentRoomPets.remove(pet.getId()); + this.currentPets.remove(pet.getId()); } } public void removeHabbo(Habbo habbo, boolean sendRemovePacket) { - if(!this.currentRoomHabbos.containsKey(habbo.getHabboInfo().getId())) { + if(!this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { return; } @@ -306,7 +302,7 @@ public class RoomUnitManager { } synchronized (this.roomUnitLock) { - this.currentRoomHabbos.remove(habbo.getHabboInfo().getId()); + this.currentHabbos.remove(habbo.getHabboInfo().getId()); this.currentRoomUnits.remove(roomHabbo.getVirtualId()); } @@ -342,13 +338,13 @@ public class RoomUnitManager { } public boolean removeBot(Bot bot) { - synchronized (this.currentRoomBots) { - if (this.currentRoomBots.containsKey(bot.getId())) { + synchronized (this.currentBots) { + if (this.currentBots.containsKey(bot.getId())) { if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentPosition() != null) { bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit()); } - this.currentRoomBots.remove(bot.getId()); + this.currentBots.remove(bot.getId()); this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId()); bot.getRoomUnit().setInRoom(false); @@ -363,16 +359,16 @@ public class RoomUnitManager { } public Pet removePet(int petId) { - Pet pet = this.currentRoomPets.get(petId); + Pet pet = this.currentPets.get(petId); this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId()); - return this.currentRoomPets.remove(petId); + return this.currentPets.remove(petId); } public void removeAllPetsExceptRoomOwner() { ArrayList toRemovePets = new ArrayList<>(); ArrayList removedPets = new ArrayList<>(); - synchronized (this.currentRoomPets) { - for (Pet pet : this.currentRoomPets.values()) { + synchronized (this.currentPets) { + for (Pet pet : this.currentPets.values()) { try { if (pet.getUserId() != pet.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId()) { toRemovePets.add(pet); @@ -401,7 +397,7 @@ public class RoomUnitManager { } for (Pet pet : removedPets) { - this.currentRoomPets.remove(pet.getId()); + this.currentPets.remove(pet.getId()); this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId()); } } @@ -409,23 +405,23 @@ public class RoomUnitManager { public void clear() { synchronized (this.roomUnitLock) { this.currentRoomUnits.clear(); - this.currentRoomHabbos.clear(); - this.currentRoomBots.clear(); - this.currentRoomPets.clear(); + this.currentHabbos.clear(); + this.currentBots.clear(); + this.currentPets.clear(); this.roomUnitCounter = 0; } } public void dispose() { - for(Habbo habbo : this.currentRoomHabbos.values()) { + for(Habbo habbo : this.currentHabbos.values()) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); } this.room.sendComposer(new CloseConnectionMessageComposer().compose()); - this.currentRoomHabbos.clear(); + this.currentHabbos.clear(); - Iterator botIterator = this.currentRoomBots.values().iterator(); + Iterator botIterator = this.currentBots.values().iterator(); while(botIterator.hasNext()) { try { @@ -438,8 +434,8 @@ public class RoomUnitManager { } } - this.currentRoomBots.clear(); - this.currentRoomPets.clear(); + this.currentBots.clear(); + this.currentPets.clear(); this.currentRoomUnits.clear(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index ef25ca41..9b076d29 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -2,12 +2,10 @@ package com.eu.habbo.habbohotel.rooms.entities.units; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWater; import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomRightLevels; -import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; @@ -188,6 +186,7 @@ public abstract class RoomUnit extends RoomEntity { } } + this.statusUpdateNeeded = true; return this; } @@ -449,6 +448,60 @@ public abstract class RoomUnit extends RoomEntity { ); } + public boolean handleSitStatus(RoomItem topItem) { + if(topItem == null || !topItem.getBaseItem().allowSit()) { + return false; + } + + if(!this.isCmdSitEnabled()) { + if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { + this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); + this.setCurrentZ(topItem.getZ()); + this.setRotation(RoomRotation.values()[topItem.getRotation()]); + return true; + } else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { + this.removeStatus(RoomUnitStatus.SIT); + this.instantUpdate(); + return true; + } + } + + return false; + } + + public boolean handleLayStatus(RoomItem topItem) { + if(topItem == null || !topItem.getBaseItem().allowLay()) { + return false; + } + + if(!this.isCmdLayEnabled()) { + if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { + this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); + this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); + + if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { + this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getY())); + } else { + this.setLocation(this.getRoom().getLayout().getTile(topItem.getX(), this.getCurrentPosition().getY())); + } + return true; + } else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { + this.removeStatus(RoomUnitStatus.LAY); + this.instantUpdate(); + return true; + } + } + + return false; + } + + public void instantUpdate() { + if(this.statusUpdateNeeded) { + this.statusUpdateNeeded = false; + this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + } + } + public void clear() { this.setRoom(null); this.canWalk = true; 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 4cbfe873..a985266e 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; +import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; @@ -25,9 +26,7 @@ import lombok.Setter; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; -import java.util.Deque; -import java.util.LinkedList; -import java.util.Map; +import java.util.*; @Slf4j @Getter @@ -35,6 +34,7 @@ import java.util.Map; @Accessors(chain = true) public class RoomAvatar extends RoomUnit { private RideablePet rideablePet; + private boolean rideLock; private DanceType danceType; private int handItem; private long handItemTimestamp; @@ -75,11 +75,12 @@ public class RoomAvatar extends RoomUnit { } } - Habbo habboT = room.getRoomUnitManager().getHabboByRoomUnit(this); + Habbo habbo = null; + boolean canFastWalk = false; - if (!this.isWalking() && !this.isKicked() && this.removeStatus(RoomUnitStatus.MOVE) == null && habboT != null) { - habboT.getHabboInfo().getRiding().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - return true; + if(this instanceof RoomHabbo roomHabbo) { + habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo); + canFastWalk = habbo == null || habbo.getHabboInfo().getRiding() == null; } for (Map.Entry set : this.getStatuses().entrySet()) { @@ -92,10 +93,7 @@ public class RoomAvatar extends RoomUnit { return true; } - boolean canFastWalk = habboT == null || habboT.getHabboInfo().getRiding() == null; - RoomTile next = this.getPath().poll(); - boolean overrideTile = next != null && this.canOverrideTile(next); if (this.getPath().isEmpty()) { @@ -139,19 +137,16 @@ public class RoomAvatar extends RoomUnit { return true; } - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(this); - this.removeStatus(RoomUnitStatus.DEAD); if (habbo != null) { - if(this instanceof RoomHabbo roomHabbo) { - if (roomHabbo.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); + RoomHabbo roomHabbo = (RoomHabbo) this; + if (roomHabbo.isIdle()) { + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled() && !event.isIdle()) { - roomHabbo.unIdle(); - } + if (!event.isCancelled() && !event.isIdle()) { + roomHabbo.unIdle(); } } @@ -180,7 +175,6 @@ public class RoomAvatar extends RoomUnit { return false; } next = this.getPath().pop(); - } boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); @@ -222,7 +216,7 @@ public class RoomAvatar extends RoomUnit { this.decrementTilesMoved(); this.setGoalLocation(this.getCurrentPosition()); this.removeStatus(RoomUnitStatus.MOVE); - room.sendComposer(new UserUpdateComposer(this).compose()); + this.instantUpdate(); if(this instanceof RoomHabbo) { conditionalGate.onRejected(this, this.getRoom(), new Object[]{}); @@ -243,7 +237,6 @@ public class RoomAvatar extends RoomUnit { zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); } - this.setPreviousLocation(this.getCurrentPosition()); this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); @@ -293,6 +286,41 @@ public class RoomAvatar extends RoomUnit { } } + public void dismountPet(boolean isRemoving) { + Habbo habbo = null; + + if(this instanceof RoomHabbo roomHabbo) { + habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomHabbo); + } + + if(habbo == null || habbo.getHabboInfo().getRiding() == null) { + return; + } + + RideablePet ridingPet = habbo.getHabboInfo().getRiding(); + + ridingPet.setRider(null); + ridingPet.setTask(PetTasks.FREE); + + habbo.getHabboInfo().setRiding(null); + + this.giveEffect(0, -1); + this.setCurrentZ(ridingPet.getRoomUnit().getCurrentZ()); + this.setPreviousLocationZ(ridingPet.getRoomUnit().getCurrentZ()); + this.stopWalking(); + + ridingPet.getRoomUnit().stopWalking(); + + this.instantUpdate(); + ridingPet.getRoomUnit().instantUpdate(); + + List availableTiles = isRemoving ? new ArrayList<>() : this.getRoom().getLayout().getWalkableTilesAround(this.getCurrentPosition()); + + RoomTile tile = availableTiles.isEmpty() ? this.getCurrentPosition() : availableTiles.get(0); + this.setGoalLocation(tile); + this.setStatusUpdateNeeded(true); + } + public void setDance(DanceType danceType) { if (this.danceType != danceType) { boolean isDancing = !this.danceType.equals(DanceType.NONE); @@ -336,57 +364,13 @@ public class RoomAvatar extends RoomUnit { } if ((this.getRoom().isAllowEffects() || forceEffect) && !this.isSwimming()) { - this.setEffectId(effectId); - this.setEffectEndTimestamp(duration); + this.effectId = effectId; + this.effectEndTimestamp = duration; + this.getRoom().sendComposer(new AvatarEffectMessageComposer(this).compose()); } } - private boolean handleSitStatus(RoomItem topItem) { - if(topItem == null || !topItem.getBaseItem().allowSit()) { - return false; - } - - if(!this.isCmdSitEnabled()) { - if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { - this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); - this.setCurrentZ(topItem.getZ()); - this.setRotation(RoomRotation.values()[topItem.getRotation()]); - return true; - } else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { - this.removeStatus(RoomUnitStatus.SIT); - return true; - } - } - - return false; - } - - private boolean handleLayStatus(RoomItem topItem) { - if(topItem == null || !topItem.getBaseItem().allowLay()) { - return false; - } - - if(!this.isCmdLayEnabled()) { - if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { - this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); - this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); - - if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { - this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getY())); - } else { - this.setLocation(this.getRoom().getLayout().getTile(topItem.getX(), this.getCurrentPosition().getY())); - } - return true; - } else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { - this.removeStatus(RoomUnitStatus.LAY); - return true; - } - } - - return false; - } - @Override public void clear() { super.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 53efc1a1..4a704659 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -10,7 +10,6 @@ import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.util.pathfinding.Rotation; import lombok.extern.slf4j.Slf4j; @@ -29,12 +28,23 @@ public class RoomPet extends RoomUnit { try { Pet pet = this.getRoom().getRoomUnitManager().getPetByRoomUnit(this); - if (this.handleRider(pet, room)) { - return this.isStatusUpdateNeeded(); + if(pet == null) { + return false; } - if (this.removeStatus(RoomUnitStatus.SIT) != null || this.removeStatus(RoomUnitStatus.MOVE) != null || this.removeStatus(RoomUnitStatus.LAY) != null) { - this.setStatusUpdateNeeded(true); + if (this.handleRider(pet, room)) { + return true; + } + + if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) { + if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) { + this.removeStatus(RoomUnitStatus.MOVE); + } + + if(!this.isWalking()) { + RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition()); + return this.handleSitStatus(topItem) || this.handleLayStatus(topItem); + } } for (Map.Entry set : this.getStatuses().entrySet()) { @@ -44,7 +54,6 @@ public class RoomPet extends RoomUnit { } if (this.getPath() == null || this.getPath().isEmpty()) { - this.setStatusUpdateNeeded(true); return true; } @@ -55,14 +64,15 @@ public class RoomPet extends RoomUnit { this.setSitUpdate(true); if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) { - this.setStatusUpdateNeeded(false); return false; } } Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); - if (peekPath == null) peekPath = new LinkedList<>(); + if (peekPath == null) { + peekPath = new LinkedList<>(); + } if (peekPath.size() >= 3) { if (this.getPath().isEmpty()) { @@ -93,13 +103,11 @@ public class RoomPet extends RoomUnit { double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.setRoom(room); this.getPath().clear(); this.findPath(); if (this.getPath().isEmpty()) { this.removeStatus(RoomUnitStatus.MOVE); - this.setStatusUpdateNeeded(false); return false; } next = this.getPath().pop(); @@ -117,7 +125,6 @@ public class RoomPet extends RoomUnit { if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.removeStatus(RoomUnitStatus.MOVE); - this.setStatusUpdateNeeded(false); return false; } @@ -141,9 +148,8 @@ public class RoomPet extends RoomUnit { this.decrementTilesMoved(); this.setGoalLocation(this.getCurrentPosition()); this.removeStatus(RoomUnitStatus.MOVE); - room.sendComposer(new UserUpdateComposer(this).compose()); + this.instantUpdate(); - this.setStatusUpdateNeeded(false); return false; } } else { @@ -167,7 +173,6 @@ public class RoomPet extends RoomUnit { this.setCurrentZ(zHeight); this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); - this.setStatusUpdateNeeded(false); return false; } catch (Exception e) { log.error("Caught exception", e); @@ -187,7 +192,7 @@ public class RoomPet extends RoomUnit { } // copy things from rider - if (this.hasStatus(RoomUnitStatus.MOVE) && !rider.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) { + if (this.hasStatus(RoomUnitStatus.MOVE) && !rider.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || !rider.getRoomUnit().isWalking()) { this.removeStatus(RoomUnitStatus.MOVE); } 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 3f64b505..fb3a8f01 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -8,12 +8,7 @@ import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.PermissionGroup; -import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.RideablePet; -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.messages.outgoing.rooms.users.UserUpdateComposer; import gnu.trove.map.hash.TIntIntHashMap; import lombok.Getter; import lombok.Setter; @@ -271,44 +266,6 @@ public class HabboInfo implements Runnable { this.run(); } - public void dismountPet(Room room) { - this.dismountPet(false, room); - } - - public void dismountPet(boolean isRemoving, Room room) { - if (this.getRiding() == null) - return; - - Habbo habbo = room.getRoomUnitManager().getRoomHabboById(this.getId()); - - if (habbo == null) - return; - - RideablePet riding = this.getRiding(); - - riding.setRider(null); - riding.setTask(PetTasks.FREE); - this.setRiding(null); - - habbo.getRoomUnit().giveEffect(0, -1); - - RoomUnit roomUnit = habbo.getRoomUnit(); - if (roomUnit == null) - return; - - roomUnit.setCurrentZ(riding.getRoomUnit().getCurrentZ()); - roomUnit.setPreviousLocationZ(riding.getRoomUnit().getCurrentZ()); - roomUnit.stopWalking(); - - room.sendComposer(new UserUpdateComposer(roomUnit).compose()); - - List availableTiles = isRemoving ? new ArrayList<>() : room.getLayout().getWalkableTilesAround(roomUnit.getCurrentPosition()); - - RoomTile tile = availableTiles.isEmpty() ? roomUnit.getCurrentPosition() : availableTiles.get(0); - roomUnit.setGoalLocation(tile); - roomUnit.setStatusUpdateNeeded(true); - } - public boolean isInGame() { return this.currentGame != null; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index df4c02b2..08df20b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -173,7 +173,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { room.getRoomInfo().setWallHeight(wallHeight); room.save(); Collection habbos = new ArrayList<>(room.getRoomUnitManager().getRoomHabbosCount()); - habbos.addAll(room.getRoomUnitManager().getRoomHabbos()); + habbos.addAll(room.getRoomUnitManager().getCurrentHabbos().values()); Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java index 998afd70..10209066 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java @@ -72,7 +72,7 @@ public class CreateGuildEvent extends GuildBadgeEvent { this.client.sendResponse(new PurchaseOKMessageComposer()); this.client.sendResponse(new GuildCreatedMessageComposer(guild)); - for (Habbo habbo : r.getRoomUnitManager().getRoomHabbos()) { + for (Habbo habbo : r.getRoomUnitManager().getCurrentHabbos().values()) { habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, null)); } r.refreshGuild(guild); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java index 324b9c44..a7d5f72f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildIdentityEvent.java @@ -36,7 +36,7 @@ public class UpdateGuildIdentityEvent extends MessageHandler { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId()); if (room != null) { - if (!room.getRoomUnitManager().getCurrentRoomHabbos().isEmpty()) { + if (!room.getRoomUnitManager().getCurrentHabbos().values().isEmpty()) { room.refreshGuild(guild); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index e65c8dff..b4a4d7c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -42,16 +42,16 @@ public class DeleteRoomEvent extends MessageHandler { room.getRoomItemManager().ejectAllFurni(); room.getRoomItemManager().ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); - List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomBots().values()); + List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentBots().values()); for (Bot bot : bots) { Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room); } - List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentRoomPets().values()); + List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentPets().values()); for (Pet pet : pets) { if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { - rideablePet.getRider().getHabboInfo().dismountPet(true, room); + rideablePet.getRider().getRoomUnit().dismountPet(true); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index 6459545e..298db957 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -50,7 +50,7 @@ public class UseFurnitureEvent extends MessageHandler { if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase())) { - if (room.getRoomUnitManager().getCurrentRoomPets().size() < Room.MAXIMUM_PETS) { + if (room.getRoomUnitManager().getCurrentPets().size() < Room.MAXIMUM_PETS) { this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index fce34f12..291983e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -30,31 +30,35 @@ public class MountPetEvent extends MessageHandler { //dismount if (habbo.getHabboInfo().getRiding() != null) { - boolean mountAgain = petId != habbo.getHabboInfo().getRiding().getId(); + boolean mountAnotherPet = petId != habbo.getHabboInfo().getRiding().getId(); - habbo.getHabboInfo().dismountPet(room); + habbo.getRoomUnit().dismountPet(false); - if(!mountAgain) { + if(!mountAnotherPet) { return; } } // someone is already on it - if (rideablePet.getRider() != null) + if (rideablePet.getRider() != null) { return; + } // check if able to ride - if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) + if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) { return; + } List availableTiles = room.getLayout().getWalkableTilesAround(pet.getRoomUnit().getCurrentPosition()); // if cant reach it then cancel - if (availableTiles.isEmpty()) + if (availableTiles.isEmpty()) { return; + } RoomTile goalTile = availableTiles.get(0); habbo.getRoomUnit().setGoalLocation(goalTile); + habbo.getRoomUnit().setRideLock(true); Emulator.getThreading().run(new RoomUnitRidePet(rideablePet, habbo, goalTile)); rideablePet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp()); rideablePet.getRoomUnit().stopWalking(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index 8cb46f19..6dab7341 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -36,7 +36,7 @@ public class PlacePetEvent extends MessageHandler { if (pet == null) { return; } - if (room.getRoomUnitManager().getCurrentRoomPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS)) { + if (room.getRoomUnitManager().getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS)) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_MAX_PETS)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java index 3975ab77..c0452168 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java @@ -31,7 +31,7 @@ public class RemovePetFromFlatEvent extends MessageHandler { if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { - rideablePet.getRider().getHabboInfo().dismountPet(true, room); + rideablePet.getRider().getRoomUnit().dismountPet(true); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java index 4eabeea3..368b837a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java @@ -23,7 +23,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { rideablePet.setNeedsUpdate(true); if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { - rideablePet.getRider().getHabboInfo().dismountPet(this.client.getHabbo().getRoomUnit().getRoom()); + rideablePet.getRider().getRoomUnit().dismountPet(false); } if (pet instanceof HorsePet) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 5ac62007..5c82f48b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -53,6 +53,11 @@ public class MoveAvatarEvent extends MessageHandler { return; } + //Is going to ride a pet, can't cancel + if(roomHabbo.isRideLock()) { + return; + } + // Get the room the habbo is in Room room = habbo.getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java index 44d93cdd..774320c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModeratorRoomInfoComposer.java @@ -14,7 +14,7 @@ public class ModeratorRoomInfoComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.moderatorRoomInfoComposer); this.response.appendInt(this.room.getRoomInfo().getId()); - this.response.appendInt(this.room.getRoomUnitManager().getCurrentRoomHabbos().size()); + this.response.appendInt(this.room.getRoomUnitManager().getCurrentHabbos().values().size()); this.response.appendBoolean(this.room.getRoomUnitManager().getRoomHabboById(this.room.getRoomInfo().getOwnerInfo().getId()) != null); this.response.appendInt(this.room.getRoomInfo().getOwnerInfo().getId()); this.response.appendString(this.room.getRoomInfo().getOwnerInfo().getUsername()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 78dfebf2..79743b4b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -30,7 +30,7 @@ public class RoomUnitRidePet implements Runnable { habbo.getRoomUnit().setCurrentZ(this.pet.getRoomUnit().getCurrentZ() + 1); habbo.getRoomUnit().setPreviousLocationZ(this.pet.getRoomUnit().getCurrentZ() + 1); habbo.getRoomUnit().setRotation(this.pet.getRoomUnit().getBodyRotation()); - habbo.getRoomUnit().setStatusUpdateNeeded(true); + habbo.getRoomUnit().setRideLock(false); pet.setRider(habbo); habbo.getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index dde2cf2a..67e59b84 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -64,7 +64,6 @@ class TeleportActionThree implements Runnable { } this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); - this.client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true); targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); From 81f45ba4b77e53d8047864bc6132f8b36e4b2ad5 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 29 Jul 2023 14:16:18 -0500 Subject: [PATCH 33/42] RoomItem refactor --- featurelist.md | 2 +- .../com/eu/habbo/habbohotel/bots/Bot.java | 36 +--- .../eu/habbo/habbohotel/bots/BotManager.java | 2 +- .../habbohotel/catalog/CatalogManager.java | 2 +- .../catalog/marketplace/MarketPlace.java | 4 +- .../commands/list/GiveRankCommand.java | 3 +- .../habbohotel/commands/list/LayCommand.java | 2 +- .../commands/list/RedeemCommand.java | 2 +- .../commands/list/ReloadRoomCommand.java | 2 +- .../commands/list/StandCommand.java | 4 +- .../commands/list/SubscriptionCommand.java | 3 +- .../commands/list/UserInfoCommand.java | 3 +- .../commands/list/badge/BadgeCommand.java | 3 +- .../commands/list/badge/TakeBadgeCommand.java | 3 +- .../commands/list/bans/BanCommand.java | 3 +- .../commands/list/bans/BaseBanCommand.java | 4 +- .../commands/list/credits/CreditsCommand.java | 3 +- .../commands/list/gift/GiftCommand.java | 5 +- .../games/battlebanzai/BattleBanzaiGame.java | 44 ++-- .../battlebanzai/BattleBanzaiGameTeam.java | 17 +- .../habbohotel/games/freeze/FreezeGame.java | 26 +-- .../games/freeze/FreezeGameTeam.java | 17 +- .../habbo/habbohotel/games/tag/TagGame.java | 17 +- .../habbohotel/games/wired/WiredGame.java | 16 +- .../com/eu/habbo/habbohotel/items/Item.java | 8 +- .../habbo/habbohotel/items/ItemManager.java | 10 +- .../InteractionBackgroundToner.java | 19 +- .../interactions/InteractionBadgeDisplay.java | 11 +- .../interactions/InteractionBlackHole.java | 11 +- .../interactions/InteractionBuildArea.java | 41 ++-- .../items/interactions/InteractionCannon.java | 17 +- .../interactions/InteractionClothing.java | 7 +- .../interactions/InteractionColorPlate.java | 13 +- .../interactions/InteractionColorWheel.java | 11 +- .../InteractionCostumeHopper.java | 5 +- .../interactions/InteractionCrackable.java | 31 +-- .../InteractionCrackableMaster.java | 5 +- .../interactions/InteractionCustomValues.java | 9 +- .../interactions/InteractionDefault.java | 128 +----------- .../items/interactions/InteractionDice.java | 15 +- .../interactions/InteractionEffectGate.java | 11 +- .../interactions/InteractionEffectGiver.java | 21 +- .../interactions/InteractionEffectTile.java | 5 +- .../interactions/InteractionEffectToggle.java | 11 +- .../InteractionEffectVendingMachine.java | 9 +- ...nteractionEffectVendingMachineNoSides.java | 11 +- .../InteractionExternalImage.java | 9 +- .../items/interactions/InteractionFXBox.java | 17 +- .../interactions/InteractionFireworks.java | 21 +- .../items/interactions/InteractionGate.java | 19 +- .../items/interactions/InteractionGift.java | 9 +- .../InteractionGroupEffectTile.java | 5 +- .../InteractionGroupPressurePlate.java | 5 +- .../interactions/InteractionGuildFurni.java | 9 +- .../interactions/InteractionGuildGate.java | 13 +- .../interactions/InteractionGymEquipment.java | 27 +-- .../interactions/InteractionHanditem.java | 17 +- .../interactions/InteractionHanditemTile.java | 7 +- .../items/interactions/InteractionHopper.java | 23 ++- .../InteractionInformationTerminal.java | 5 +- .../interactions/InteractionJukeBox.java | 11 +- .../interactions/InteractionLoveLock.java | 15 +- .../interactions/InteractionMannequin.java | 15 +- .../InteractionMonsterCrackable.java | 12 +- .../interactions/InteractionMoodLight.java | 9 +- .../interactions/InteractionMultiHeight.java | 71 ++----- .../interactions/InteractionMusicDisc.java | 11 +- .../interactions/InteractionMuteArea.java | 21 +- .../InteractionNoSidesVendingMachine.java | 7 +- .../interactions/InteractionObstacle.java | 19 +- .../interactions/InteractionOneWayGate.java | 27 +-- .../items/interactions/InteractionPostIt.java | 9 +- .../items/interactions/InteractionPoster.java | 9 +- .../InteractionPressurePlate.java | 15 +- .../interactions/InteractionPushable.java | 13 +- .../interactions/InteractionPuzzleBox.java | 28 +-- .../interactions/InteractionPyramid.java | 15 +- .../interactions/InteractionRandomState.java | 11 +- .../InteractionRedeemableSubscriptionBox.java | 5 +- .../InteractionRentableSpace.java | 19 +- .../items/interactions/InteractionRoller.java | 11 +- .../interactions/InteractionRoomAds.java | 5 +- .../interactions/InteractionRoomClubGate.java | 11 +- .../InteractionRoomClubHopper.java | 5 +- .../InteractionRoomClubTeleportTile.java | 5 +- .../interactions/InteractionRoomOMatic.java | 5 +- .../InteractionSnowboardSlope.java | 16 +- .../InteractionSpinningBottle.java | 15 +- .../interactions/InteractionStackHelper.java | 9 +- .../interactions/InteractionStickyPole.java | 5 +- .../items/interactions/InteractionSwitch.java | 9 +- .../InteractionSwitchRemoteControl.java | 17 +- .../InteractionTalkingFurniture.java | 5 +- .../interactions/InteractionTeleport.java | 23 ++- .../interactions/InteractionTeleportTile.java | 5 +- .../items/interactions/InteractionTent.java | 5 +- .../InteractionTileEffectProvider.java | 5 +- .../items/interactions/InteractionTrap.java | 7 +- .../items/interactions/InteractionTrophy.java | 5 +- .../InteractionVendingMachine.java | 21 +- .../interactions/InteractionVikingCotie.java | 15 +- .../interactions/InteractionVoteCounter.java | 13 +- .../items/interactions/InteractionWater.java | 59 +++--- .../interactions/InteractionWaterItem.java | 11 +- .../items/interactions/InteractionWired.java | 11 +- .../InteractionWiredCondition.java | 8 +- .../interactions/InteractionWiredEffect.java | 7 +- .../interactions/InteractionWiredExtra.java | 5 +- .../InteractionWiredHighscore.java | 15 +- .../interactions/InteractionWiredTrigger.java | 9 +- .../interactions/InteractionYoutubeTV.java | 11 +- .../games/InteractionGameGate.java | 15 +- .../games/InteractionGameScoreboard.java | 13 +- .../games/InteractionGameTeamItem.java | 5 +- .../games/InteractionGameTimer.java | 19 +- .../InteractionBattleBanzaiPuck.java | 23 ++- .../InteractionBattleBanzaiSphere.java | 13 +- .../InteractionBattleBanzaiTeleporter.java | 13 +- .../InteractionBattleBanzaiTile.java | 25 +-- .../gates/InteractionBattleBanzaiGate.java | 5 +- .../InteractionBattleBanzaiGateBlue.java | 5 +- .../InteractionBattleBanzaiGateGreen.java | 5 +- .../gates/InteractionBattleBanzaiGateRed.java | 5 +- .../InteractionBattleBanzaiGateYellow.java | 5 +- .../InteractionBattleBanzaiScoreboard.java | 5 +- ...InteractionBattleBanzaiScoreboardBlue.java | 5 +- ...nteractionBattleBanzaiScoreboardGreen.java | 5 +- .../InteractionBattleBanzaiScoreboardRed.java | 5 +- ...teractionBattleBanzaiScoreboardYellow.java | 5 +- .../games/football/InteractionFootball.java | 40 ++-- .../football/InteractionFootballGate.java | 9 +- .../goals/InteractionFootballGoal.java | 7 +- .../goals/InteractionFootballGoalBlue.java | 5 +- .../goals/InteractionFootballGoalGreen.java | 5 +- .../goals/InteractionFootballGoalRed.java | 5 +- .../goals/InteractionFootballGoalYellow.java | 5 +- .../InteractionFootballScoreboard.java | 11 +- .../InteractionFootballScoreboardBlue.java | 5 +- .../InteractionFootballScoreboardGreen.java | 5 +- .../InteractionFootballScoreboardRed.java | 5 +- .../InteractionFootballScoreboardYellow.java | 5 +- .../games/freeze/InteractionFreezeBlock.java | 29 +-- .../freeze/InteractionFreezeExitTile.java | 15 +- .../games/freeze/InteractionFreezeTile.java | 15 +- .../freeze/gates/InteractionFreezeGate.java | 5 +- .../gates/InteractionFreezeGateBlue.java | 5 +- .../gates/InteractionFreezeGateGreen.java | 5 +- .../gates/InteractionFreezeGateRed.java | 5 +- .../gates/InteractionFreezeGateYellow.java | 5 +- .../InteractionFreezeScoreboard.java | 5 +- .../InteractionFreezeScoreboardBlue.java | 5 +- .../InteractionFreezeScoreboardGreen.java | 5 +- .../InteractionFreezeScoreboardRed.java | 5 +- .../InteractionFreezeScoreboardYellow.java | 5 +- .../games/tag/InteractionTagField.java | 7 +- .../games/tag/InteractionTagPole.java | 11 +- .../bunnyrun/InteractionBunnyrunField.java | 7 +- .../tag/bunnyrun/InteractionBunnyrunPole.java | 5 +- .../tag/icetag/InteractionIceTagField.java | 7 +- .../tag/icetag/InteractionIceTagPole.java | 5 +- .../InteractionRollerskateField.java | 7 +- .../pets/InteractionMonsterPlantSeed.java | 17 +- .../interactions/pets/InteractionNest.java | 11 +- .../pets/InteractionPetBreedingNest.java | 18 +- .../pets/InteractionPetDrink.java | 25 +-- .../interactions/pets/InteractionPetFood.java | 13 +- .../interactions/pets/InteractionPetToy.java | 55 ++--- .../pets/InteractionPetTrampoline.java | 49 ++--- .../interactions/pets/InteractionPetTree.java | 69 ++++--- .../totems/InteractionTotemHead.java | 22 +- .../totems/InteractionTotemLegs.java | 16 +- .../totems/InteractionTotemPlanet.java | 21 +- .../WiredConditionDateRangeActive.java | 7 +- .../WiredConditionFurniHaveFurni.java | 23 ++- .../WiredConditionFurniHaveRoom.java | 7 +- .../WiredConditionFurniTypeMatch.java | 7 +- .../conditions/WiredConditionGroupMember.java | 5 +- .../WiredConditionLessTimeElapsed.java | 5 +- .../WiredConditionMatchStatePosition.java | 13 +- .../WiredConditionMoreTimeElapsed.java | 5 +- .../WiredConditionNotFurniHaveFurni.java | 23 ++- .../WiredConditionNotFurniHaveRoom.java | 7 +- .../WiredConditionNotFurniTypeMatch.java | 7 +- .../conditions/WiredConditionNotInGroup.java | 5 +- .../conditions/WiredConditionNotInTeam.java | 5 +- .../WiredConditionNotMatchStatePosition.java | 5 +- .../WiredConditionNotRoomCount.java | 5 +- .../WiredConditionNotRoomHasEffect.java | 5 +- .../WiredConditionNotRoomWearsBadge.java | 5 +- .../WiredConditionNotTriggerOnFurni.java | 5 +- .../conditions/WiredConditionRoomCount.java | 5 +- .../WiredConditionRoomHasEffect.java | 5 +- .../WiredConditionRoomHasHandItem.java | 7 +- .../WiredConditionRoomWearsBadge.java | 5 +- .../conditions/WiredConditionTeamMember.java | 5 +- .../WiredConditionTriggerOnFurni.java | 5 +- .../wired/effects/WiredEffectAlert.java | 5 +- .../wired/effects/WiredEffectBotClothes.java | 5 +- .../effects/WiredEffectBotFollowRoom.java | 12 +- .../effects/WiredEffectBotGiveHandItem.java | 5 +- .../wired/effects/WiredEffectBotTalk.java | 5 +- .../effects/WiredEffectBotTalkToRoom.java | 5 +- .../wired/effects/WiredEffectBotTeleport.java | 7 +- .../effects/WiredEffectBotWalkToFurni.java | 7 +- .../WiredEffectChangeFurniDirection.java | 17 +- .../wired/effects/WiredEffectGiveEffect.java | 5 +- .../effects/WiredEffectGiveHandItem.java | 5 +- ...redEffectGiveHotelviewBonusRarePoints.java | 5 +- .../WiredEffectGiveHotelviewHofPoints.java | 5 +- .../wired/effects/WiredEffectGiveRespect.java | 5 +- .../wired/effects/WiredEffectGiveReward.java | 5 +- .../wired/effects/WiredEffectGiveScore.java | 5 +- .../effects/WiredEffectGiveScoreToTeam.java | 5 +- .../wired/effects/WiredEffectJoinTeam.java | 5 +- .../wired/effects/WiredEffectKickRoom.java | 5 +- .../wired/effects/WiredEffectLeaveTeam.java | 5 +- .../wired/effects/WiredEffectMatchFurni.java | 17 +- .../effects/WiredEffectMoveFurniAway.java | 29 +-- .../wired/effects/WiredEffectMoveFurniTo.java | 15 +- .../effects/WiredEffectMoveFurniTowards.java | 31 +-- .../effects/WiredEffectMoveRotateFurni.java | 17 +- .../wired/effects/WiredEffectMuteRoom.java | 5 +- .../wired/effects/WiredEffectResetTimers.java | 5 +- .../wired/effects/WiredEffectTeleport.java | 7 +- .../wired/effects/WiredEffectToggleFurni.java | 9 +- .../effects/WiredEffectToggleRandom.java | 9 +- .../effects/WiredEffectTriggerStacks.java | 11 +- .../wired/effects/WiredEffectWhisper.java | 5 +- .../interactions/wired/extra/WiredBlob.java | 17 +- .../wired/extra/WiredExtraRandom.java | 5 +- .../wired/extra/WiredExtraUnseen.java | 5 +- .../wired/triggers/WiredTriggerAtSetTime.java | 5 +- .../triggers/WiredTriggerAtTimeLong.java | 5 +- .../triggers/WiredTriggerBotReachedFurni.java | 5 +- .../triggers/WiredTriggerBotReachedRoom.java | 5 +- .../wired/triggers/WiredTriggerCollision.java | 7 +- .../WiredTriggerFurniStateToggled.java | 5 +- .../wired/triggers/WiredTriggerGameEnds.java | 5 +- .../triggers/WiredTriggerGameStarts.java | 5 +- .../wired/triggers/WiredTriggerRepeater.java | 7 +- .../triggers/WiredTriggerRepeaterLong.java | 7 +- .../triggers/WiredTriggerRoomEntersRoom.java | 5 +- .../triggers/WiredTriggerRoomSaysKeyword.java | 5 +- .../WiredTriggerRoomWalkOffFurni.java | 7 +- .../triggers/WiredTriggerRoomWalkOnFurni.java | 7 +- .../triggers/WiredTriggerScoreAchieved.java | 5 +- .../wired/triggers/WiredTriggerTeamLoses.java | 5 +- .../wired/triggers/WiredTriggerTeamWins.java | 5 +- .../habbo/habbohotel/messenger/Messenger.java | 3 +- .../habbohotel/modtool/ModToolManager.java | 3 +- .../habbohotel/pets/MonsterplantPet.java | 8 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 50 ++--- .../eu/habbo/habbohotel/pets/PetCommand.java | 4 +- .../habbohotel/pets/actions/ActionBreed.java | 2 +- .../habbohotel/pets/actions/ActionCroak.java | 2 +- .../habbohotel/pets/actions/ActionDip.java | 2 +- .../habbohotel/pets/actions/ActionDown.java | 2 +- .../habbohotel/pets/actions/ActionHang.java | 2 +- .../pets/actions/ActionPlayDead.java | 2 +- .../pets/actions/ActionPlayFootball.java | 2 +- .../habbohotel/pets/actions/ActionRelax.java | 2 +- .../pets/actions/ActionRingOfFire.java | 2 +- .../habbohotel/pets/actions/ActionRoll.java | 2 +- .../habbohotel/pets/actions/ActionSit.java | 2 +- .../habbohotel/pets/actions/ActionSwing.java | 2 +- .../habbohotel/pets/actions/ActionWave.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 178 ++++++---------- .../habbohotel/rooms/RoomItemManager.java | 82 ++++---- .../habbo/habbohotel/rooms/RoomManager.java | 7 +- .../habbohotel/rooms/RoomRightsManager.java | 2 +- .../habbohotel/rooms/RoomSpecialTypes.java | 16 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 5 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 19 +- .../habbohotel/rooms/RoomTraxManager.java | 8 +- .../habbohotel/rooms/RoomUnitManager.java | 14 ++ .../rooms/RoomWordFilterManager.java | 81 ++++++++ .../habbohotel/rooms/entities/RoomEntity.java | 19 ++ .../rooms/entities/items/RoomItem.java | 195 +++++++++--------- .../rooms/entities/units/RoomUnit.java | 86 +++----- .../entities/units/types/RoomAvatar.java | 25 ++- .../rooms/entities/units/types/RoomPet.java | 18 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 2 + .../habbo/habbohotel/users/HabboManager.java | 31 ++- .../users/cache/HabboInfoCache.java | 36 +++- .../habbo/habbohotel/wired/WiredHandler.java | 18 +- .../incoming/camera/PurchasePhotoEvent.java | 2 +- .../PurchaseFromCatalogAsGiftEvent.java | 2 +- .../catalog/recycler/PresentOpenEvent.java | 12 +- .../UpdateFloorPropertiesEvent.java | 4 +- .../incoming/friends/AcceptFriendEvent.java | 4 +- .../guilds/ApproveMembershipRequestEvent.java | 3 +- .../modtool/CallForHelpFromIMEvent.java | 3 +- .../modtool/CallForHelpFromPhotoEvent.java | 2 +- .../incoming/modtool/GetUserChatlogEvent.java | 3 +- .../incoming/navigator/DeleteRoomEvent.java | 2 +- .../rooms/RequestRoomPropertySet.java | 8 +- .../SetRoomBackgroundColorDataEvent.java | 2 +- .../incoming/rooms/UpdateRoomFilterEvent.java | 4 +- .../rooms/items/AddSpamWallPostItEvent.java | 8 +- .../rooms/items/CreditFurniRedeemEvent.java | 8 +- .../items/CustomizeAvatarWithFurniEvent.java | 4 +- .../incoming/rooms/items/DiceOffEvent.java | 6 +- .../rooms/items/EnterOneWayDoorEvent.java | 2 +- .../rooms/items/PickupObjectEvent.java | 6 +- .../rooms/items/PlaceObjectEvent.java | 2 +- .../rooms/items/PlacePostItEvent.java | 4 +- .../incoming/rooms/items/RemoveItemEvent.java | 2 +- .../items/RoomDimmerChangeStateEvent.java | 4 +- .../items/RoomDimmerSavePresetEvent.java | 2 +- .../items/SetCustomStackingHeightEvent.java | 7 +- .../rooms/items/SetItemDataEvent.java | 4 +- .../rooms/items/SetMannequinFigureEvent.java | 6 +- .../rooms/items/SetMannequinNameEvent.java | 6 +- .../rooms/items/SetObjectDataEvent.java | 2 +- .../incoming/rooms/items/ThrowDiceEvent.java | 2 +- .../rooms/items/UseFurnitureEvent.java | 10 +- .../rooms/pets/CompostPlantEvent.java | 9 +- .../pets/CustomizePetWithFurniEvent.java | 14 +- .../rooms/pets/OpenPetPackageEvent.java | 14 +- .../incoming/rooms/pets/PlacePetEvent.java | 2 +- .../incoming/rooms/users/MoveAvatarEvent.java | 12 +- .../incoming/rooms/users/SignEvent.java | 2 +- .../incoming/users/ChangeUserNameEvent.java | 3 +- .../incoming/users/CheckUserNameEvent.java | 3 +- .../users/GetExtendedProfileEvent.java | 2 +- .../incoming/users/GetIgnoredUsersEvent.java | 3 +- .../incoming/wired/ApplySnapshotEvent.java | 10 +- .../FurniListAddOrUpdateComposer.java | 4 +- .../outgoing/inventory/FurniListComposer.java | 6 +- .../RoomFilterSettingsMessageComposer.java | 4 +- .../items/FloorItemOnRollerComposer.java | 22 +- .../items/ItemDataUpdateMessageComposer.java | 6 +- .../items/ItemRemoveMessageComposer.java | 2 +- .../items/ItemUpdateMessageComposer.java | 2 +- .../rooms/items/ObjectAddMessageComposer.java | 2 +- .../items/ObjectUpdateMessageComposer.java | 2 +- .../rooms/items/ObjectsMessageComposer.java | 2 +- .../OneWayDoorStatusMessageComposer.java | 2 +- .../rooms/items/RemoveFloorItemComposer.java | 2 +- .../rooms/users/SleepMessageComposer.java | 1 - .../rooms/users/UserUpdateComposer.java | 8 +- .../habbo/messages/rcon/ChangeRoomOwner.java | 2 +- .../eu/habbo/messages/rcon/FriendRequest.java | 3 +- .../habbo/messages/rcon/SendRoomBundle.java | 3 +- .../runnables/BackgroundAnimation.java | 2 +- .../runnables/BanzaiRandomTeleport.java | 14 +- .../runnables/BattleBanzaiTilesFlicker.java | 4 +- .../threading/runnables/CannonKickAction.java | 2 +- .../threading/runnables/ClearRentedSpace.java | 4 +- .../habbo/threading/runnables/CloseGate.java | 4 +- .../threading/runnables/CrackableExplode.java | 16 +- .../runnables/HabboItemNewState.java | 2 +- .../threading/runnables/KickBallAction.java | 12 +- .../runnables/OneWayGateActionOne.java | 8 +- .../habbo/threading/runnables/OpenGift.java | 4 +- .../threading/runnables/PetEatAction.java | 6 +- .../threading/runnables/RandomDiceNumber.java | 2 +- .../runnables/RandomSpinningBottleNumber.java | 2 +- .../runnables/RemoveFloorItemTask.java | 4 +- .../threading/runnables/RoomUnitRidePet.java | 2 +- .../RoomUnitTeleportWalkToAction.java | 2 +- .../RoomUnitVendingMachineAction.java | 2 +- .../runnables/RoomUnitWalkToLocation.java | 2 +- .../runnables/RoomUnitWalkToRoomUnit.java | 2 +- .../runnables/TeleportInteraction.java | 18 +- .../freeze/FreezeHandleSnowballExplosion.java | 16 +- .../freeze/FreezeResetExplosionTiles.java | 2 +- .../runnables/freeze/FreezeThrowSnowball.java | 2 +- .../runnables/hopper/HopperActionFive.java | 2 +- .../runnables/hopper/HopperActionFour.java | 2 +- .../runnables/hopper/HopperActionOne.java | 8 +- .../runnables/hopper/HopperActionThree.java | 8 +- .../runnables/hopper/HopperActionTwo.java | 4 +- .../teleport/TeleportActionFive.java | 4 +- .../teleport/TeleportActionFour.java | 2 +- .../runnables/teleport/TeleportActionOne.java | 8 +- .../teleport/TeleportActionThree.java | 4 +- .../runnables/teleport/TeleportActionTwo.java | 2 +- 378 files changed, 2212 insertions(+), 2036 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java diff --git a/featurelist.md b/featurelist.md index 7f494997..3a63b5ab 100644 --- a/featurelist.md +++ b/featurelist.md @@ -132,7 +132,7 @@ If you wish to contribute to this list, features are laid out in the following f > [`Habbo.getHabboStats()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L94) > [`Habbo.getRoomUnit()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L102) > [`HabboManager`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java) -> [`HabboManager.getOfflineHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L47) +> [`Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L47) > [`HabboManager.getCloneAccounts()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L203) > [`HabboManager.setRank()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L243) > [`HabboInfo`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index cff434d7..1bdaf554 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -17,7 +17,6 @@ import com.eu.habbo.plugin.events.bots.BotChatEvent; import com.eu.habbo.plugin.events.bots.BotShoutEvent; import com.eu.habbo.plugin.events.bots.BotTalkEvent; import com.eu.habbo.plugin.events.bots.BotWhisperEvent; -import com.eu.habbo.threading.runnables.BotFollowHabbo; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -64,13 +63,16 @@ public class Bot extends Unit implements Runnable { @Getter @Setter private short lastChatIndex; - private final int bubble; + @Getter + private final int bubbleId; @Getter private final String type; @Getter private int effect; private transient boolean canWalk = true; private boolean needsUpdate; + @Getter + @Setter private transient int followingHabboId; @Getter @Setter @@ -95,7 +97,7 @@ public class Bot extends Unit implements Runnable { this.chatLines = new ArrayList<>(); this.type = "generic_bot"; this.room = null; - this.bubble = RoomChatMessageBubbles.BOT_RENTABLE.getType(); + this.bubbleId = RoomChatMessageBubbles.BOT_RENTABLE.getType(); } public Bot(ResultSet set) throws SQLException { @@ -116,7 +118,7 @@ public class Bot extends Unit implements Runnable { this.room = null; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.needsUpdate = false; - this.bubble = set.getInt("bubble_id"); + this.bubbleId = set.getInt("bubble_id"); this.roomUnit = new RoomBot(); } @@ -135,7 +137,7 @@ public class Bot extends Unit implements Runnable { this.chatLines = new ArrayList<>(List.of("Default Message :D")); this.type = bot.getType(); this.effect = bot.getEffect(); - this.bubble = bot.getBubbleId(); + this.bubbleId = bot.getBubbleId(); this.needsUpdate = false; } @@ -177,7 +179,7 @@ public class Bot extends Unit implements Runnable { statement.setString(12, this.chatRandom ? "1" : "0"); statement.setInt(13, this.chatDelay); statement.setInt(14, this.effect); - statement.setInt(15, this.bubble); + statement.setInt(15, this.bubbleId); statement.setInt(16, this.id); statement.execute(); this.needsUpdate = false; @@ -287,12 +289,10 @@ public class Bot extends Unit implements Runnable { } - public void onUserSay(final RoomChatMessage message) { - - } + public void onUserSay(final RoomChatMessage message) {} public int getBubbleId() { - return bubble; + return bubbleId; } public void setName(String name) { @@ -396,20 +396,6 @@ public class Bot extends Unit implements Runnable { } } - public int getFollowingHabboId() { - return this.followingHabboId; - } - - public void startFollowingHabbo(Habbo habbo) { - this.followingHabboId = habbo.getHabboInfo().getId(); - - Emulator.getThreading().run(new BotFollowHabbo(this, habbo, habbo.getRoomUnit().getRoom())); - } - - public void stopFollowingHabbo() { - this.followingHabboId = 0; - } - public boolean canWalk() { return this.canWalk; } @@ -441,7 +427,7 @@ public class Bot extends Unit implements Runnable { statement.setString(15, this.chatRandom ? "1" : "0"); statement.setInt(16, this.chatDelay); statement.setInt(17, this.effect); - statement.setInt(18, this.bubble); + statement.setInt(18, this.bubbleId); statement.setInt(19, this.id); statement.execute(); } catch (SQLException e) { diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 4fed28b7..a8f6931c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -190,7 +190,7 @@ public class BotManager { bot.onPickUp(habbo, room); room.getRoomUnitManager().removeBot(bot); - bot.stopFollowingHabbo(); + bot.setFollowingHabboId(0); bot.setOwnerId(botOwnerInfo.getId()); bot.setOwnerName(botOwnerInfo.getUsername()); bot.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 2434c6c6..386753b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1005,7 +1005,7 @@ public class CatalogManager { if (guild != null && Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo) != null) { InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); - habboItem.setExtradata(""); + habboItem.setExtraData(""); habboItem.needsUpdate(true); Emulator.getThreading().run(habboItem); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index b852fd30..ce152637 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -281,7 +281,7 @@ public class MarketPlace { } event.price = calculateCommision(event.price); - item.setOwnerId(client.getHabbo().getHabboInfo().getId()); + item.setOwnerInfo(client.getHabbo().getHabboInfo()); item.needsUpdate(true); Emulator.getThreading().run(item); @@ -362,7 +362,7 @@ public class MarketPlace { MarketPlaceOffer offer = new MarketPlaceOffer(event.getItem(), event.getPrice(), client.getHabbo()); client.getHabbo().getInventory().addMarketplaceOffer(offer); client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.getItem()); - item.setOwnerId(-1); + item.setOwnerInfo(null); item.needsUpdate(true); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java index 3c832360..1e6dc93b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.PermissionGroup; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import org.apache.commons.lang3.StringUtils; public class GiveRankCommand extends Command { @@ -40,7 +39,7 @@ public class GiveRankCommand extends Command { return true; } - HabboInfo habbo = HabboManager.getOfflineHabboInfo(params[1]); + HabboInfo habbo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); if (habbo != null) { if (habbo.getPermissionGroup().getId() > gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java index 3f2b7d54..164b7fbb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java @@ -35,7 +35,7 @@ public class LayCommand extends Command { return false; } - gameClient.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.LAY, 0.5 + ""); + gameClient.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.LAY, 0.5 + ""); gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(gameClient.getHabbo().getRoomUnit()).compose()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java index 3f89bb8e..6a939ff7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java @@ -30,7 +30,7 @@ public class RedeemCommand extends Command { TIntIntMap points = new TIntIntHashMap(); for (RoomItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) { - if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getOwnerId() == gameClient.getHabbo().getHabboInfo().getId()) { + if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getOwnerInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) { items.add(item); if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { try { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java index a9a67383..63c0947e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java @@ -22,7 +22,7 @@ public class ReloadRoomCommand extends Command { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { Collection habbos = new ArrayList<>(room.getRoomUnitManager().getCurrentHabbos().values()); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room.dispose(); room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); habbos.forEach(habbo -> habbo.getClient().sendResponse(message)); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java index bb0eeb9f..8d2cf0d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java @@ -10,8 +10,10 @@ public class StandCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getRiding() == null) + if (gameClient.getHabbo().getHabboInfo().getRiding() == null) { gameClient.getHabbo().getRoomUnit().makeStand(); + } + return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java index 70618942..bd1e8f85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.HabboStats; import com.eu.habbo.habbohotel.users.subscriptions.Subscription; @@ -45,7 +44,7 @@ public class SubscriptionCommand extends Command { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_subscription.invalid_params", "Invalid command format"), RoomChatMessageBubbles.ALERT); return true; } - HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]); + HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); if (info == null) { gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_subscription.user_not_found", "%user% was not found"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java index 9637e77b..871be6ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import gnu.trove.iterator.TIntIntIterator; import java.text.SimpleDateFormat; @@ -30,7 +29,7 @@ public class UserInfoCommand extends Command { HabboInfo habbo = (onlineHabbo != null ? onlineHabbo.getHabboInfo() : null); if (habbo == null) { - habbo = HabboManager.getOfflineHabboInfo(params[1]); + habbo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); } if (habbo == null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java index 51a57aec..ae6e1f71 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; @@ -42,7 +41,7 @@ public class BadgeCommand extends BaseBadgeCommand { return true; } else { - HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(params[1]); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); if (habboInfo == null) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_badge.unknown_user"), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java index 923ca3e0..d27c0bbb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.messages.outgoing.inventory.BadgesComposer; import com.eu.habbo.messages.outgoing.users.UserBadgesComposer; @@ -51,7 +50,7 @@ public class TakeBadgeCommand extends BaseBadgeCommand { if (habbo != null) userId = habbo.getHabboInfo().getId(); else { - HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(username); if (habboInfo != null) userId = habboInfo.getId(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java index 3215fb19..4839d98e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.modtool.ModToolBanType; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -54,7 +53,7 @@ public class BanCommand extends Command { if (t != null) { target = t.getHabboInfo(); } else { - target = HabboManager.getOfflineHabboInfo(params[1]); + target = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); } if (target == null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java index a0073c31..4bd23179 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java @@ -1,10 +1,10 @@ package com.eu.habbo.habbohotel.commands.list.bans; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -43,7 +43,7 @@ public abstract class BaseBanCommand extends Command { if (h != null) { return h.getHabboInfo(); } else { - return HabboManager.getOfflineHabboInfo(params[1]); + return Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); } } return null; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java index 8b362593..ecff906c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; public class CreditsCommand extends BaseCreditsCommand { private static final String INVALID_AMOUNT = "commands.error.cmd_credits.invalid_amount"; @@ -17,7 +16,7 @@ public class CreditsCommand extends BaseCreditsCommand { @Override public boolean handle(GameClient gameClient, String[] params) { if (params.length == 3) { - HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]); + HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]); if (info != null) { Habbo habbo = getHabbo(params[1]); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java index 9ea0bad4..c72b46ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java @@ -4,10 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; @@ -46,7 +45,7 @@ public class GiftCommand extends BaseGiftCommand { return true; } - HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(username); if (habboInfo == null) { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_gift.user_not_found"), username), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index edb0fe5e..8968e945 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -70,7 +70,7 @@ public class BattleBanzaiGame extends Game { } for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata("1"); + item.setExtraData("1"); this.room.updateItemState(item); } @@ -105,12 +105,12 @@ public class BattleBanzaiGame extends Game { if (this.countDown == 0) { for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata("1"); + item.setExtraData("1"); this.room.updateItemState(item); if(this.countDown2 > 0) { this.countDown2--; if(this.countDown2 == 0) { - item.setExtradata("2"); + item.setExtraData("2"); this.room.updateItemState(item); } } @@ -147,7 +147,7 @@ public class BattleBanzaiGame extends Game { if (highestScore != null) { for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata((highestScore.teamColor.type + 2) + ""); + item.setExtraData((highestScore.teamColor.type + 2) + ""); this.room.updateItemState(item); } } @@ -195,7 +195,7 @@ public class BattleBanzaiGame extends Game { } for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata((6 + winningTeam.teamColor.type) + ""); + item.setExtraData((6 + winningTeam.teamColor.type) + ""); this.room.updateItemState(item); } synchronized (this.lockedTiles) { @@ -213,8 +213,8 @@ public class BattleBanzaiGame extends Game { this.refreshGates(); for (RoomItem tile : this.gameTiles.values()) { - if (tile.getExtradata().equals("1")) { - tile.setExtradata("0"); + if (tile.getExtraData().equals("1")) { + tile.setExtraData("0"); this.room.updateItem(tile); } } @@ -228,14 +228,14 @@ public class BattleBanzaiGame extends Game { this.tileCount = 0; for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionBattleBanzaiTile) { - item.setExtradata("1"); + item.setExtraData("1"); this.room.updateItemState(item); this.tileCount++; this.gameTiles.put(item.getId(), item); } if (item instanceof InteractionBattleBanzaiScoreboard) { - item.setExtradata("0"); + item.setExtraData("0"); this.room.updateItemState(item); } } @@ -262,8 +262,8 @@ public class BattleBanzaiGame extends Game { if (doNotCheckFill) return; - final int x = item.getX(); - final int y = item.getY(); + final int x = item.getCurrentPosition().getX(); + final int y = item.getCurrentPosition().getY(); final List> filledAreas = new ArrayList<>(); final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); @@ -278,12 +278,12 @@ public class BattleBanzaiGame extends Game { if (largestAreaOfAll.isPresent()) { for (RoomTile tile : largestAreaOfAll.get()) { - Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.getX() && i.getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny(); + Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getCurrentPosition().getX() == tile.getX() && i.getCurrentPosition().getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny(); tileItem.ifPresent(habboItem -> { this.tileLocked(teamColor, habboItem, habbo, true); - habboItem.setExtradata((2 + (teamColor.type * 3)) + ""); + habboItem.setExtraData((2 + (teamColor.type * 3)) + ""); this.room.updateItem(habboItem); }); } @@ -322,7 +322,7 @@ public class BattleBanzaiGame extends Game { private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) { for (RoomItem item : lockedTiles) { - if (item.getX() == x && item.getY() == y) return true; + if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return true; } return false; @@ -330,7 +330,7 @@ public class BattleBanzaiGame extends Game { private boolean isOutOfBounds(int x, int y) { for (RoomItem item : this.gameTiles.values()) { - if (item.getX() == x && item.getY() == y) return false; + if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return false; } return true; @@ -341,7 +341,7 @@ public class BattleBanzaiGame extends Game { if (lockedTilesForColor.getKey() == color) continue; for (RoomItem item : lockedTilesForColor.getValue()) { - if (item.getX() == x && item.getY() == y) return true; + if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return true; } } @@ -366,16 +366,16 @@ public class BattleBanzaiGame extends Game { THashMap scoreBoards = this.room.getRoomSpecialTypes().getBattleBanzaiScoreboards(teamColors); for (InteractionBattleBanzaiScoreboard scoreboard : scoreBoards.values()) { - if (scoreboard.getExtradata().isEmpty()) { - scoreboard.setExtradata("0"); + if (scoreboard.getExtraData().isEmpty()) { + scoreboard.setExtraData("0"); } - int oldScore = Integer.parseInt(scoreboard.getExtradata()); + int oldScore = Integer.parseInt(scoreboard.getExtraData()); if (oldScore == totalScore) continue; - scoreboard.setExtradata(totalScore + ""); + scoreboard.setExtraData(totalScore + ""); this.room.updateItemState(scoreboard); } } @@ -384,7 +384,7 @@ public class BattleBanzaiGame extends Game { Collection gates = this.room.getRoomSpecialTypes().getBattleBanzaiGates().values(); THashSet tilesToUpdate = new THashSet<>(gates.size()); for (RoomItem item : gates) { - tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); + tilesToUpdate.add(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } this.room.updateTiles(tilesToUpdate); @@ -410,7 +410,7 @@ public class BattleBanzaiGame extends Game { } this.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor()); - tile.setExtradata(state + ""); + tile.setExtraData(state + ""); this.room.updateItem(tile); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java index f4427915..50460edc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; 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.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -38,10 +37,10 @@ public class BattleBanzaiGameTeam extends GameTeam { Habbo habbo = gamePlayer.getHabbo(); Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class); - RoomUnit roomUnit = habbo.getRoomUnit(); - Room room = roomUnit.getRoom(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); + Room room = roomHabbo.getRoom(); if(room == null) return; - RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -49,10 +48,10 @@ public class BattleBanzaiGameTeam extends GameTeam { if (topItem != null) { nextEffectM = topItem.getBaseItem().getEffectM(); nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } else if (roomHabbo.getPreviousEffectId() > 0) { + nextEffectF = roomHabbo.getPreviousEffectId(); + nextEffectM = roomHabbo.getPreviousEffectId(); + nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp(); } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { @@ -64,7 +63,7 @@ public class BattleBanzaiGameTeam extends GameTeam { habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } - roomUnit.setCanWalk(true); + roomHabbo.setCanWalk(true); if (room.getRoomSpecialTypes() != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 2abe1ff4..f859c4f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -80,7 +80,7 @@ public class FreezeGame extends Game { synchronized void resetMap() { for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) { if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) { - item.setExtradata("0"); + item.setExtraData("0"); this.room.updateItemState(item); } } @@ -90,10 +90,10 @@ public class FreezeGame extends Game { if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass()) return; - if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty()) + if (!item.getExtraData().equalsIgnoreCase("0") && !item.getExtraData().isEmpty()) return; - if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentPosition(), this.room.getLayout().getTile(item.getX(), item.getY()))) { + if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentPosition(), this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()))) { if (((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) { Emulator.getThreading().run(new FreezeThrowSnowball(habbo, item, this.room)); } @@ -147,7 +147,7 @@ public class FreezeGame extends Game { powerUp += Emulator.getRandom().nextInt(6) + 1; } - block.setExtradata((powerUp + 1) + String.format("%3d", delay)); + block.setExtraData((powerUp + 1) + String.format("%3d", delay)); this.room.updateItemState(block); } @@ -173,7 +173,7 @@ public class FreezeGame extends Game { Emulator.getThreading().run(new FreezeClearEffects(player.getHabbo()), 1000); if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { InteractionFreezeExitTile tile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); - tile.setExtradata("1"); + tile.setExtraData("1"); this.room.updateItemState(tile); this.room.teleportHabboToItem(player.getHabbo(), tile); } @@ -194,7 +194,7 @@ public class FreezeGame extends Game { for (RoomItem item : this.room.getRoomItemManager().getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { if (item instanceof InteractionFreezeTile) { RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); - WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY())); + WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getCurrentPosition().getX(), exitTile.getCurrentPosition().getY())); } } } @@ -227,16 +227,16 @@ public class FreezeGame extends Game { THashMap scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor); for (InteractionFreezeScoreboard scoreboard : scoreBoards.values()) { - if (scoreboard.getExtradata().isEmpty()) { - scoreboard.setExtradata("0"); + if (scoreboard.getExtraData().isEmpty()) { + scoreboard.setExtraData("0"); } - int oldScore = Integer.parseInt(scoreboard.getExtradata()); + int oldScore = Integer.parseInt(scoreboard.getExtraData()); if (oldScore == totalScore) continue; - scoreboard.setExtradata(totalScore + ""); + scoreboard.setExtraData(totalScore + ""); this.room.updateItemState(scoreboard); } } @@ -282,7 +282,7 @@ public class FreezeGame extends Game { for (Map.Entry set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet()) { if (teamMemberCount.containsKey(set.getValue().teamColor)) { int amount = Math.min(teamMemberCount.get(set.getValue().teamColor), 5); - set.getValue().setExtradata(amount + ""); + set.getValue().setExtraData(amount + ""); teamMemberCount.put(set.getValue().teamColor, teamMemberCount.get(set.getValue().teamColor) - amount); this.room.updateItemState(set.getValue()); } @@ -295,7 +295,7 @@ public class FreezeGame extends Game { public void setFreezeTileState(String state) { this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(object -> { - object.setExtradata(state); + object.setExtraData(state); FreezeGame.this.room.updateItemState(object); return true; }); @@ -305,7 +305,7 @@ public class FreezeGame extends Game { private void refreshGates() { THashSet tilesToUpdate = new THashSet<>(); for (RoomItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) { - tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); + tilesToUpdate.add(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } this.room.updateTiles(tilesToUpdate); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index 9993c69f..a31f278d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; 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.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -25,11 +24,11 @@ public class FreezeGameTeam extends GameTeam { Habbo habbo = gamePlayer.getHabbo(); Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class); - RoomUnit roomUnit = habbo.getRoomUnit(); - Room room = roomUnit.getRoom(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); + Room room = roomHabbo.getRoom(); if(room == null) return; - RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -37,10 +36,10 @@ public class FreezeGameTeam extends GameTeam { if (topItem != null) { nextEffectM = topItem.getBaseItem().getEffectM(); nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } else if (roomHabbo.getPreviousEffectId() > 0) { + nextEffectF = roomHabbo.getPreviousEffectId(); + nextEffectM = roomHabbo.getPreviousEffectId(); + nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp(); } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { @@ -52,7 +51,7 @@ public class FreezeGameTeam extends GameTeam { habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); } - roomUnit.setCanWalk(true); + roomHabbo.setCanWalk(true); if (room.getRoomSpecialTypes() != null) { for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) { 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 8cdb6f11..743d9d56 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 @@ -10,7 +10,6 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; @@ -121,7 +120,7 @@ public abstract class TagGame extends Game { } if (pole != null) { - pole.setExtradata("1"); + pole.setExtraData("1"); room.updateItemState(pole); Emulator.getThreading().run(new HabboItemNewState(pole, room, "0"), 1000); } @@ -173,11 +172,11 @@ public abstract class TagGame extends Game { super.removeHabbo(habbo); this.taggers.remove(habbo); - RoomUnit roomUnit = habbo.getRoomUnit(); - Room room = roomUnit.getRoom(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); + Room room = roomHabbo.getRoom(); if (room == null) return; - RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -185,10 +184,10 @@ public abstract class TagGame extends Game { if (topItem != null) { nextEffectM = topItem.getBaseItem().getEffectM(); nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } else if (roomHabbo.getPreviousEffectId() > 0) { + nextEffectF = roomHabbo.getPreviousEffectId(); + nextEffectM = roomHabbo.getPreviousEffectId(); + nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp(); } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index f438461b..0bf1d1d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -41,11 +41,11 @@ public class WiredGame extends Game { @Override public void removeHabbo(Habbo habbo) { super.removeHabbo(habbo); - RoomHabbo roomUnit = habbo.getRoomUnit(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); Room room = this.room; if (room == null) return; - RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -53,19 +53,19 @@ public class WiredGame extends Game { if (topItem != null) { nextEffectM = topItem.getBaseItem().getEffectM(); nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } else if (roomHabbo.getPreviousEffectId() > 0) { + nextEffectF = roomHabbo.getPreviousEffectId(); + nextEffectM = roomHabbo.getPreviousEffectId(); + nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp(); } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - roomUnit.giveEffect(nextEffectM, nextEffectDuration, true); + roomHabbo.giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - roomUnit.giveEffect(nextEffectF, nextEffectDuration, true); + roomHabbo.giveEffect(nextEffectF, nextEffectDuration, true); } } 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 25e6ae8a..8827829d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -66,13 +66,13 @@ public class Item implements ISerialize { public static double getCurrentHeight(RoomItem item) { if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) { - if (item.getExtradata().isEmpty()) { - item.setExtradata("0"); + if (item.getExtraData().isEmpty()) { + item.setExtraData("0"); } try { - int index = Integer.parseInt(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length); - return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)]; + int index = Integer.parseInt(item.getExtraData()) % (item.getBaseItem().getMultiHeights().length); + return item.getBaseItem().getMultiHeights()[(item.getExtraData().isEmpty() ? 0 : index)]; } catch (NumberFormatException ignored) { } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 00240bbc..0532ab67 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -51,8 +51,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent; @@ -488,13 +489,14 @@ public class ItemManager { try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) { Class itemClass = item.getInteractionType().getType(); + HabboInfo userInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(habboId); if (itemClass != null) { try { - return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); + return itemClass.getDeclaredConstructor(int.class, HabboInfo.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), userInfo, item, extraData, limitedStack, limitedSells); } catch (Exception e) { log.error("Caught exception", e); - return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); + return new InteractionDefault(set.getInt(1), userInfo, item, extraData, limitedStack, limitedSells); } } } @@ -562,7 +564,7 @@ public class ItemManager { preparedStatement.setInt(1, set.getInt(1)); preparedStatement.setInt(2, Integer.parseInt(itemId)); preparedStatement.addBatch(); - item = new InteractionDefault(set.getInt(1), habbo.getHabboInfo().getId(), Emulator.getGameEnvironment().getCatalogManager().ecotronItem, extradata, 0, 0); + item = new InteractionDefault(set.getInt(1), habbo.getHabboInfo(), Emulator.getGameEnvironment().getCatalogManager().ecotronItem, extradata, 0, 0); } preparedStatement.executeBatch(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java index 6506c596..3c04a3e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.BackgroundAnimation; @@ -18,16 +19,16 @@ public class InteractionBackgroundToner extends RoomItem { super(set, baseItem); } - public InteractionBackgroundToner(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionBackgroundToner(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(5 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(4); - if (this.getExtradata().split(":").length == 4) { - String[] colorData = this.getExtradata().split(":"); + if (this.getExtraData().split(":").length == 4) { + String[] colorData = this.getExtraData().split(":"); serverMessage.appendInt(Integer.parseInt(colorData[0])); serverMessage.appendInt(Integer.parseInt(colorData[1])); serverMessage.appendInt(Integer.parseInt(colorData[2])); @@ -37,7 +38,7 @@ public class InteractionBackgroundToner extends RoomItem { serverMessage.appendInt(126); serverMessage.appendInt(126); serverMessage.appendInt(126); - this.setExtradata("0:126:126:126"); + this.setExtraData("0:126:126:126"); this.needsUpdate(true); Emulator.getThreading().run(this); } @@ -77,12 +78,12 @@ public class InteractionBackgroundToner extends RoomItem { } } - if (this.getExtradata().split(":").length == 4) { - String[] data = this.getExtradata().split(":"); - this.setExtradata((data[0].equals("0") ? "1" : "0") + ":" + data[1] + ":" + data[2] + ":" + data[3]); + if (this.getExtraData().split(":").length == 4) { + String[] data = this.getExtraData().split(":"); + this.setExtraData((data[0].equals("0") ? "1" : "0") + ":" + data[1] + ":" + data[2] + ":" + data[3]); room.updateItem(this); } else { - this.setExtradata("0:126:126:126"); + this.setExtraData("0:126:126:126"); room.updateItem(this); } this.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java index aa9d223a..d62cf21c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class InteractionBadgeDisplay extends RoomItem { super(set, baseItem); } - public InteractionBadgeDisplay(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionBadgeDisplay(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -24,13 +25,13 @@ public class InteractionBadgeDisplay extends RoomItem { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(4); serverMessage.appendString("0"); - String[] data = this.getExtradata().split((char) 9 + ""); + String[] data = this.getExtraData().split((char) 9 + ""); if (data.length == 3) { serverMessage.appendString(data[2]); serverMessage.appendString(data[1]); serverMessage.appendString(data[0]); } else { - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); serverMessage.appendString("Unknown User"); serverMessage.appendString("Unknown Date"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java index 672d77e8..c8a6493a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -15,8 +16,8 @@ public class InteractionBlackHole extends InteractionGate { super(set, baseItem); } - public InteractionBlackHole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionBlackHole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -24,10 +25,10 @@ public class InteractionBlackHole extends InteractionGate { Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount"); int holesCountProgress = 0; - Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerInfo().getId()); if (owner == null) { - holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), holeCountAchievement); + holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerInfo().getId(), holeCountAchievement); } else { holesCountProgress = owner.getHabboStats().getAchievementProgress(holeCountAchievement); } @@ -37,7 +38,7 @@ public class InteractionBlackHole extends InteractionGate { if (owner != null) { AchievementManager.progressAchievement(owner, holeCountAchievement, holeDifference); } else { - AchievementManager.progressAchievement(this.getOwnerId(), holeCountAchievement, holeDifference); + AchievementManager.progressAchievement(this.getOwnerInfo().getId(), holeCountAchievement, holeDifference); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index a8b5eff1..cde00f3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import gnu.trove.TCollections; @@ -39,8 +38,8 @@ public class InteractionBuildArea extends InteractionCustomValues { tiles = new THashSet<>(); } - public InteractionBuildArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + public InteractionBuildArea(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues); defaultValues.put("tilesLeft", "0"); defaultValues.put("tilesRight", "0"); defaultValues.put("tilesFront", "0"); @@ -69,7 +68,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (builder != null) { builderInfo = builder.getHabboInfo(); } else { - builderInfo = HabboManager.getOfflineHabboInfo(builderName); + builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName); } if (builderInfo != null) { canBuild.add(builderInfo.getId()); @@ -80,7 +79,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (RoomTile tile : this.tiles) { THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } @@ -103,7 +102,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (builder != null) { builderInfo = builder.getHabboInfo(); } else { - builderInfo = HabboManager.getOfflineHabboInfo(builderName); + builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName); } if (builderInfo != null) { canBuild.add(builderInfo.getId()); @@ -130,7 +129,7 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); if (newTiles.contains(tile)) continue; for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } @@ -151,10 +150,10 @@ public class InteractionBuildArea extends InteractionCustomValues { } private void regenAffectedTiles(Room room) { - int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack"))); - int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight"))); - int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront"))); - int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft"))); + int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(this.values.get("tilesBack"))); + int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(this.values.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(this.values.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(this.values.get("tilesLeft"))); this.tiles.clear(); @@ -179,7 +178,7 @@ public class InteractionBuildArea extends InteractionCustomValues { if (builder != null) { builderInfo = builder.getHabboInfo(); } else { - builderInfo = HabboManager.getOfflineHabboInfo(builderName); + builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName); } if (builderInfo != null) { canBuild.add(builderInfo.getId()); @@ -188,10 +187,10 @@ public class InteractionBuildArea extends InteractionCustomValues { THashSet oldTiles = new THashSet<>(); - int minX = Math.max(0, this.getX() - Integer.parseInt(oldValues.get("tilesBack"))); - int minY = Math.max(0, this.getY() - Integer.parseInt(oldValues.get("tilesRight"))); - int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(oldValues.get("tilesFront"))); - int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(oldValues.get("tilesLeft"))); + int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(oldValues.get("tilesBack"))); + int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(oldValues.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(oldValues.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(oldValues.get("tilesLeft"))); for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { @@ -204,7 +203,7 @@ public class InteractionBuildArea extends InteractionCustomValues { for (RoomTile tile : oldTiles) { THashSet tileItems = room.getRoomItemManager().getItemsAt(tile); for (RoomItem tileItem : tileItems) { - if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { + if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) { room.getRoomItemManager().pickUpItem(tileItem, null); } } @@ -222,10 +221,10 @@ public class InteractionBuildArea extends InteractionCustomValues { int id = 0; for (RoomTile tile : this.tiles) { id--; - RoomItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); - item.setX(tile.getX()); - item.setY(tile.getY()); - item.setZ(tile.relativeHeight()); + RoomItem item = new InteractionDefault(id, null, effectItem, "1", 0, 0); + + item.setCurrentPosition(tile); + item.setCurrentZ(tile.relativeHeight()); items.add(item); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java index a2f3a65e..ebf28fc5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java @@ -7,6 +7,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.CannonKickAction; import com.eu.habbo.threading.runnables.CannonResetCooldownAction; @@ -20,18 +21,18 @@ public class InteractionCannon extends RoomItem { public InteractionCannon(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionCannon(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionCannon(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -55,7 +56,7 @@ public class InteractionCannon extends RoomItem { if (room == null) return; - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomTile fuseTile = this.getRotation() >= 4 ? tile : room.getLayout().getTileInFront(tile, ((this.getRotation() % 2) + 2) % 8); List tiles = room.getLayout().getTilesAround(fuseTile); tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8)); @@ -70,7 +71,7 @@ public class InteractionCannon extends RoomItem { } this.cooldown = true; - this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); + this.setExtraData(this.getExtraData().equals("1") ? "0" : "1"); room.updateItemState(this); Emulator.getThreading().run(new CannonKickAction(this, room, client), 750); Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000); @@ -94,7 +95,7 @@ public class InteractionCannon extends RoomItem { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java index bfd245bd..d34bc24c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class InteractionClothing extends RoomItem { super(set, baseItem); } - public InteractionClothing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionClothing(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index d530ba7c..43d2ca82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class InteractionColorPlate extends InteractionDefault { super(set, baseItem); } - public InteractionColorPlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionColorPlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -36,12 +37,12 @@ public class InteractionColorPlate extends InteractionDefault { private void change(Room room, int amount) { int state = 0; - if (this.getExtradata() == null || this.getExtradata().isEmpty()) { - this.setExtradata("0"); + if (this.getExtraData() == null || this.getExtraData().isEmpty()) { + this.setExtraData("0"); } try { - state = Integer.parseInt(this.getExtradata()); + state = Integer.parseInt(this.getExtraData()); } catch (Exception e) { log.error("Caught exception", e); } @@ -55,7 +56,7 @@ public class InteractionColorPlate extends InteractionDefault { state = 0; } - this.setExtradata(state + ""); + this.setExtraData(state + ""); this.needsUpdate(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java index 1a7d9f06..f7c817ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java @@ -6,6 +6,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer; import com.eu.habbo.threading.runnables.RandomDiceNumber; @@ -20,14 +21,14 @@ public class InteractionColorWheel extends RoomItem { super(set, baseItem); } - public InteractionColorWheel(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionColorWheel(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -49,8 +50,8 @@ public class InteractionColorWheel extends RoomItem { if (!room.getRoomRightsManager().hasRights(client.getHabbo())) return; - if (this.rollTaks == null && !this.getExtradata().equalsIgnoreCase("-1")) { - this.setExtradata("-1"); + if (this.rollTaks == null && !this.getExtraData().equalsIgnoreCase("-1")) { + this.setExtraData("-1"); room.sendComposer(new ItemUpdateMessageComposer(this).compose()); Emulator.getThreading().run(this); Emulator.getThreading().run(new RandomDiceNumber(this, room, this.getBaseItem().getStateCount()), 3000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java index 96e83953..55ed6ed2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class InteractionCostumeHopper extends InteractionHopper { super(set, baseItem); } - public InteractionCostumeHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionCostumeHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index 3909c88f..2cf7524a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -10,6 +10,7 @@ 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.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.CrackableExplode; @@ -27,19 +28,19 @@ public class InteractionCrackable extends RoomItem { super(set, baseItem); } - public InteractionCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionCrackable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); serverMessage.appendInt(7 + (this.isLimited() ? 256 : 0)); - serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtradata()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + ""); - serverMessage.appendInt(Integer.parseInt(this.getExtradata())); + serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtraData()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + ""); + serverMessage.appendInt(Integer.parseInt(this.getExtraData())); serverMessage.appendInt(Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())); super.serializeExtradata(serverMessage); @@ -69,13 +70,13 @@ public class InteractionCrackable extends RoomItem { if (this.cracked) return; - if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) { - client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getX(), this.getY()))); + if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) > 1.5) { + client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))); return; } - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); if (this.getBaseItem().getEffectF() > 0) if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() == client.getHabbo().getRoomUnit().getEffectId()) @@ -92,7 +93,7 @@ public class InteractionCrackable extends RoomItem { public void onTick(Habbo habbo, Room room) { if (this.cracked) return; - if (this.allowAnyone() || this.getOwnerId() == habbo.getHabboInfo().getId()) { + if (this.allowAnyone() || this.getOwnerInfo().getId() == habbo.getHabboInfo().getId()) { CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId()); if (rewardData != null) { @@ -102,10 +103,10 @@ public class InteractionCrackable extends RoomItem { if(this.ticks < 1) { // If there are no ticks (for example because the room has been reloaded), check the current extradata of the item and update the ticks. - this.ticks = Integer.parseInt(this.getExtradata()); + this.ticks = Integer.parseInt(this.getExtraData()); } this.ticks++; - this.setExtradata("" + (this.ticks)); + this.setExtraData("" + (this.ticks)); this.needsUpdate(true); room.updateItem(this); @@ -114,7 +115,7 @@ public class InteractionCrackable extends RoomItem { } if (!this.cracked && this.ticks == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())) { this.cracked = true; - Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getX(), this.getY()), 1500); + Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getCurrentPosition()), 1500); if (!rewardData.getAchievementCracked().isEmpty()) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.getAchievementCracked())); @@ -168,7 +169,7 @@ public class InteractionCrackable extends RoomItem { public void reset(Room room) { this.cracked = false; this.ticks = 0; - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java index 60244939..af4de4b3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,8 +11,8 @@ public class InteractionCrackableMaster extends InteractionCrackable { super(set, baseItem); } - public InteractionCrackableMaster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionCrackableMaster(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java index ed124f97..bb996240 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.map.hash.THashMap; @@ -29,8 +30,8 @@ public abstract class InteractionCustomValues extends RoomItem { } } - public InteractionCustomValues(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionCustomValues(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.values.putAll(defaultValues); } @@ -52,7 +53,7 @@ public abstract class InteractionCustomValues extends RoomItem { @Override public void run() { - this.setExtradata(this.toExtraData()); + this.setExtraData(this.toExtraData()); super.run(); } 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 55cb7c7f..a198504d 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 @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; @@ -8,11 +7,8 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; 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.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; @@ -26,14 +22,14 @@ public class InteractionDefault extends RoomItem { super(set, baseItem); } - public InteractionDefault(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionDefault(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -79,19 +75,19 @@ public class InteractionDefault extends RoomItem { if (objects != null && objects.length > 0) { if (objects[0] instanceof Integer) { - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); if (this.getBaseItem().getStateCount() > 0) { int currentState = 0; try { - currentState = Integer.parseInt(this.getExtradata()); + currentState = Integer.parseInt(this.getExtraData()); } catch (NumberFormatException e) { - log.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); + log.error("Incorrect extradata (" + this.getExtraData() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); } - this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount()); + this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount()); this.needsUpdate(true); room.updateItemState(this); @@ -109,115 +105,11 @@ public class InteractionDefault extends RoomItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - - if (roomUnit == null || (this.getBaseItem().getEffectF() == 0 && this.getBaseItem().getEffectM() == 0)) { - return; - } - - if (roomUnit instanceof RoomHabbo roomHabbo) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo); - - if (habbo == null) return; - - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) { - if (roomHabbo.getEffectId() > 0) { - roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - } - - roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) { - if (roomHabbo.getEffectId() > 0) { - roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp()); - } - roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1); - } - } else if (roomUnit instanceof RoomBot roomBot) { - Bot bot = room.getRoomUnitManager().getBotByRoomUnit(roomBot); - - if (bot == null) return; - - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectM()) { - if (roomBot.getEffectId() > 0) { - roomBot.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp()); - } - - roomBot.giveEffect(this.getBaseItem().getEffectM(), -1); - return; - } - - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectF()) { - if (roomBot.getEffectId() > 0) { - roomUnit.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp()); - } - - roomBot.giveEffect(this.getBaseItem().getEffectF(), -1); - } - } } @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - - if (roomUnit != null) { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - int nextEffectM = 0; - int nextEffectF = 0; - int nextEffectDuration = -1; - - if (objects != null && objects.length == 2) { - if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) { - RoomItem exclude = (objects[0] != objects[1]) ? this : null; - RoomItem topItem = room.getRoomItemManager().getTopItemAt(goalTile.getX(), goalTile.getY(), exclude); - - if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { - return; - } - - if (topItem != null) { - nextEffectM = topItem.getBaseItem().getEffectM(); - nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); - } - } - } - - if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); - - if (habbo != null) { - - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration); - } - } - } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); - - if (bot != null) { - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - bot.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration); - return; - } - - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - bot.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration); - } - } - } - } - } } public boolean canToggle(Habbo habbo, Room room) { @@ -227,7 +119,7 @@ public class InteractionDefault extends RoomItem { RoomItem rentSpace = room.getRoomItemManager().getRoomItemById(habbo.getHabboStats().getRentedItemId()); - return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); + return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getCurrentPosition().getX(), rentSpace.getCurrentPosition().getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java index 6a9cdffe..8f983a3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent; import com.eu.habbo.threading.runnables.RandomDiceNumber; @@ -15,8 +16,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionDice extends RoomItem { - public InteractionDice(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionDice(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public InteractionDice(ResultSet set, Item baseItem) throws SQLException { @@ -26,7 +27,7 @@ public class InteractionDice extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -46,14 +47,14 @@ public class InteractionDice extends RoomItem { super.onClick(client, room, objects); if (client != null) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { - if (!this.getExtradata().equalsIgnoreCase("-1")) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { + if (!this.getExtraData().equalsIgnoreCase("-1")) { FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1)); if (event.isCancelled()) return; - this.setExtradata("-1"); + this.setExtraData("-1"); room.updateItemState(this); Emulator.getThreading().run(this); @@ -74,7 +75,7 @@ public class InteractionDice extends RoomItem { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java index d4138670..e88ff3fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; @@ -29,12 +30,12 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi public InteractionEffectGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionEffectGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionEffectGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -61,7 +62,7 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi super.onWalkOn(roomUnit, room, objects); if (this.canWalkOn(roomUnit, room, objects)) { - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java index 9e321918..75781047 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -15,28 +16,28 @@ import java.sql.SQLException; public class InteractionEffectGiver extends InteractionDefault { public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionEffectGiver(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY())) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) || + (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } protected void handle(Room room, RoomUnit roomUnit) { - if (this.getExtradata().isEmpty()) this.setExtradata("0"); + if (this.getExtraData().isEmpty()) this.setExtraData("0"); - if (!this.getExtradata().equals("0")) return; + if (!this.getExtraData().equals("0")) return; RoomItem instance = this; @@ -45,11 +46,11 @@ public class InteractionEffectGiver extends InteractionDefault { } if (this.getBaseItem().getStateCount() > 1) { - this.setExtradata("1"); + this.setExtraData("1"); room.updateItem(this); Emulator.getThreading().run(() -> { - InteractionEffectGiver.this.setExtradata("0"); + InteractionEffectGiver.this.setExtraData("0"); room.updateItem(instance); }, 500); } 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 3504ef38..a89643ef 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -20,8 +21,8 @@ public class InteractionEffectTile extends InteractionPressurePlate { super(set, baseItem); } - public InteractionEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionEffectTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java index d003bb94..50a30309 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java @@ -4,6 +4,7 @@ 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.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,19 +14,19 @@ public class InteractionEffectToggle extends InteractionDefault { super(set, baseItem); } - public InteractionEffectToggle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionEffectToggle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if (this.getExtradata().isEmpty()) { - this.setExtradata("0"); + if (this.getExtraData().isEmpty()) { + this.setExtraData("0"); } if (client != null) { if (room.getRoomRightsManager().hasRights(client.getHabbo())) { - if (Integer.parseInt(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) { + if (Integer.parseInt(this.getExtraData()) < this.getBaseItem().getStateCount() - 1) { if ((client.getHabbo().getHabboInfo().getGender() == HabboGender.M && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) || (client.getHabbo().getHabboInfo().getGender() == HabboGender.F && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectF())) { super.onClick(client, room, objects); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java index 91da5312..f579950b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,12 +11,12 @@ import java.sql.SQLException; public class InteractionEffectVendingMachine extends InteractionVendingMachine { public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionEffectVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionEffectVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java index ffd43e91..c7a77d10 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java @@ -4,6 +4,7 @@ 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.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -12,12 +13,12 @@ import java.sql.SQLException; public class InteractionEffectVendingMachineNoSides extends InteractionVendingMachine { public InteractionEffectVendingMachineNoSides(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionEffectVendingMachineNoSides(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionEffectVendingMachineNoSides(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -31,7 +32,7 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa THashSet tiles = new THashSet<>(); for(int x = -1; x <= 1; x++) { for(int y = -1; y <= 1; y++) { - RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y)); + RoomTile tile = room.getLayout().getTile((short)(this.getCurrentPosition().getX() + x), (short)(this.getCurrentPosition().getY() + y)); if(tile != null) { tiles.add(tile); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java index 7be45959..b5c5e429 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class InteractionExternalImage extends RoomItem { super(set, baseItem); } - public InteractionExternalImage(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionExternalImage(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -37,7 +38,7 @@ public class InteractionExternalImage extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index 89d7e53d..9ebe2cb2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -6,6 +6,7 @@ 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.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -18,15 +19,15 @@ public class InteractionFXBox extends InteractionDefault { // this.setExtradata("0"); } - public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionFXBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); // this.setExtradata("0"); } @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (client != null && this.getOwnerId() == client.getHabbo().getHabboInfo().getId()) { - if(this.getExtradata().equals("1")) + if (client != null && this.getOwnerInfo().getId() == client.getHabbo().getHabboInfo().getId()) { + if (this.getExtraData().equals("1")) return; int effectId = -1; @@ -43,23 +44,23 @@ public class InteractionFXBox extends InteractionDefault { } } - if(effectId < 0) + if (effectId < 0) return; - if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) + if (client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) return; client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0); client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); room.getRoomItemManager().removeRoomItem(this); RoomItem item = this; Emulator.getThreading().run(() -> { new QueryDeleteHabboItem(item.getId()).run(); room.sendComposer(new RemoveFloorItemComposer(item).compose()); - room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); + room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); }, 500); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 777811bd..482005ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import lombok.extern.slf4j.Slf4j; @@ -30,8 +31,8 @@ public class InteractionFireworks extends InteractionDefault { super(set, baseItem); } - public InteractionFireworks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionFireworks(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -53,10 +54,10 @@ public class InteractionFireworks extends InteractionDefault { // Wireds can always detonate fireworks if charged if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) { - if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + if (this.getExtraData().equalsIgnoreCase(STATE_CHARGED)) { super.onClick(client, room, objects); - if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) { + if (this.getExtraData().equalsIgnoreCase(STATE_EXPLOSION)) { this.reCharge(room); } } @@ -70,7 +71,7 @@ public class InteractionFireworks extends InteractionDefault { // Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; - for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) { if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } @@ -91,10 +92,10 @@ public class InteractionFireworks extends InteractionDefault { } } - if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) { + if (this.getExtraData().equalsIgnoreCase(STATE_CHARGED)) { super.onClick(client, room, objects); - if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) + if (this.getExtraData().equalsIgnoreCase(STATE_EXPLOSION)) { this.reCharge(room); AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger")); @@ -110,13 +111,13 @@ public class InteractionFireworks extends InteractionDefault { @Override public void onPlace(Room room) { super.onPlace(room); - this.setExtradata(STATE_CHARGED); + this.setExtraData(STATE_CHARGED); } @Override public boolean canToggle(Habbo habbo, Room room) { return room.getRoomRightsManager().hasRights(habbo) || RoomLayout.tilesAdjecent( - room.getLayout().getTile(this.getX(), this.getY()), + room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition() ); } @@ -133,7 +134,7 @@ public class InteractionFireworks extends InteractionDefault { } Emulator.getThreading().run(() -> { - this.setExtradata(STATE_CHARGED); + this.setExtraData(STATE_CHARGED); this.needsUpdate(true); room.updateItemState(this); }, explodeDuration); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index d22864bd..ec9eee39 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -6,6 +6,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; @@ -17,14 +18,14 @@ public class InteractionGate extends RoomItem { super(set, baseItem); } - public InteractionGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -34,7 +35,7 @@ public class InteractionGate extends RoomItem { } public boolean isWalkable() { - return this.getExtradata().equals("1"); + return this.getExtraData().equals("1"); } @Override @@ -44,16 +45,16 @@ public class InteractionGate extends RoomItem { if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !executedByWired) return; // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close - for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) + for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) if (room.getRoomUnitManager().hasHabbosAt(tile)) return; // Gate closed = 0, open = 1 - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); - this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + ""); - room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); + this.setExtraData((Integer.parseInt(this.getExtraData()) + 1) % 2 + ""); + room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); this.needsUpdate(true); room.updateItemState(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java index 991fbcd4..5498893e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java @@ -6,6 +6,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -37,8 +38,8 @@ public class InteractionGift extends RoomItem { } } - public InteractionGift(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGift(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); try { this.loadData(); @@ -91,8 +92,8 @@ public class InteractionGift extends RoomItem { private void loadData() throws NumberFormatException { String[] data = null; - if (this.getExtradata().contains("\t")) - data = this.getExtradata().split("\t"); + if (this.getExtraData().contains("\t")) + data = this.getExtraData().split("\t"); if (data != null && data.length >= 5) { int count = Integer.parseInt(data[0]); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java index 721f252f..9e74799c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,8 +11,8 @@ public class InteractionGroupEffectTile extends InteractionEffectTile { super(set, baseItem); } - public InteractionGroupEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGroupEffectTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java index 6aae5d31..7e1082b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,8 +11,8 @@ public class InteractionGroupPressurePlate extends InteractionPressurePlate { super(set, baseItem); } - public InteractionGroupPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGroupPressurePlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java index cc34a193..8646cead 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -23,8 +24,8 @@ public class InteractionGuildFurni extends InteractionDefault { this.guildId = set.getInt("guild_id"); } - public InteractionGuildFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGuildFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.guildId = 0; } @@ -43,14 +44,14 @@ public class InteractionGuildFurni extends InteractionDefault { if (guild != null) { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(5); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); serverMessage.appendString(guild.getId() + ""); serverMessage.appendString(guild.getBadge()); serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).getValueA()); serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).getValueA()); } else { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); } if (this.isLimited()) { 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 802049a1..048c837a 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 @@ -9,6 +9,7 @@ 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.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; @@ -17,12 +18,12 @@ import java.sql.SQLException; public class InteractionGuildGate extends InteractionGuildFurni implements ConditionalGate { public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionGuildGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionGuildGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -45,7 +46,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi super.onWalkOn(roomUnit, room, objects); if (this.canWalkOn(roomUnit, room, objects)) { - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); } } @@ -59,7 +60,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - this.setExtradata("0"); + this.setExtraData("0"); room.updateItemState(this); } 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 acf0813b..417cf5a0 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 @@ -13,6 +13,7 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,8 +26,8 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC super(set, baseItem); } - public InteractionGymEquipment(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGymEquipment(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -66,9 +67,9 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC this.reset(room); - if (roomUnit != null) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); - RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + if (roomUnit instanceof RoomAvatar roomAvatar) { + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY()); int nextEffectM = 0; int nextEffectF = 0; int nextEffectDuration = -1; @@ -76,23 +77,23 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC if (topItem != null) { nextEffectM = topItem.getBaseItem().getEffectM(); nextEffectF = topItem.getBaseItem().getEffectF(); - } else if (roomUnit.getPreviousEffectId() > 0) { - nextEffectF = roomUnit.getPreviousEffectId(); - nextEffectM = roomUnit.getPreviousEffectId(); - nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp(); + } else if (roomAvatar.getPreviousEffectId() > 0) { + nextEffectF = roomAvatar.getPreviousEffectId(); + nextEffectM = roomAvatar.getPreviousEffectId(); + nextEffectDuration = roomAvatar.getPreviousEffectEndTimestamp(); } if (this.forceRotation()) { - roomUnit.setCanRotate(true); + roomAvatar.setCanRotate(true); } if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) { - habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true); + roomAvatar.giveEffect(nextEffectM, nextEffectDuration, true); return; } if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) { - habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true); + roomAvatar.giveEffect(nextEffectF, nextEffectDuration, true); } } } @@ -175,7 +176,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC private void reset(Room room) { this.roomUnitId = -1; this.startTime = 0; - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java index 181698a7..77ec9e26 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import java.sql.ResultSet; @@ -18,24 +19,24 @@ public class InteractionHanditem extends InteractionDefault { super(set, baseItem); } - public InteractionHanditem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionHanditem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY())) || - (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY())) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) || + (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY())) { this.handle(room, client.getHabbo().getRoomUnit()); } } protected void handle(Room room, RoomUnit roomUnit) { - if (this.getExtradata().isEmpty()) this.setExtradata("0"); + if (this.getExtraData().isEmpty()) this.setExtraData("0"); - if (!this.getExtradata().equals("0")) return; + if (!this.getExtraData().equals("0")) return; if(!(roomUnit instanceof RoomAvatar roomAvatar)) { return; @@ -46,11 +47,11 @@ public class InteractionHanditem extends InteractionDefault { room.sendComposer(new CarryObjectMessageComposer(roomAvatar).compose()); if (this.getBaseItem().getStateCount() > 1) { - this.setExtradata("1"); + this.setExtraData("1"); room.updateItem(this); Emulator.getThreading().run(() -> { - InteractionHanditem.this.setExtradata("0"); + InteractionHanditem.this.setExtraData("0"); room.updateItem(instance); }, 500); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java index 13e5d5d6..bf8c2bd0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,15 +14,15 @@ public class InteractionHanditemTile extends InteractionHanditem { super(set, baseItem); } - public InteractionHanditemTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionHanditemTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { InteractionHanditemTile instance = this; Emulator.getThreading().run(() -> { - if (roomUnit.getCurrentPosition().getX() == instance.getX() && roomUnit.getCurrentPosition().getY() == instance.getY()) { + if (roomUnit.getCurrentPosition().getX() == instance.getCurrentPosition().getX() && roomUnit.getCurrentPosition().getY() == instance.getCurrentPosition().getY()) { instance.handle(room, roomUnit); } }, 3000); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java index 9e3ab63a..b4a939e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java @@ -7,6 +7,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.hopper.HopperActionOne; @@ -16,18 +17,18 @@ import java.sql.SQLException; public class InteractionHopper extends RoomItem { public InteractionHopper(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -56,7 +57,7 @@ public class InteractionHopper extends RoomItem { if (loc != null) { if (this.canUseTeleport(client, loc, room)) { client.getHabbo().getRoomUnit().setTeleporting(true); - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); Emulator.getThreading().run(new HopperActionOne(this, room, client), 500); @@ -69,13 +70,13 @@ public class InteractionHopper extends RoomItem { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override public void run() { - if (!this.getExtradata().equals("0")) { - this.setExtradata("0"); + if (!this.getExtraData().equals("0")) { + this.setExtraData("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { @@ -95,7 +96,7 @@ public class InteractionHopper extends RoomItem { if (client.getHabbo().getRoomUnit().isTeleporting()) return false; - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if(tile == null) { return false; @@ -104,6 +105,6 @@ public class InteractionHopper extends RoomItem { if (room.getRoomUnitManager().hasHabbosAt(tile)) return false; - return this.getExtradata().equals("0"); + return this.getExtraData().equals("0"); } } 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 b75412c2..2a508003 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 @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.habboway.nux.InClientLinkMessageComposer; import gnu.trove.map.hash.THashMap; @@ -22,8 +23,8 @@ public class InteractionInformationTerminal extends InteractionCustomValues { super(set, baseItem, defaultValues); } - public InteractionInformationTerminal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + public InteractionInformationTerminal(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index ccc4287c..f97e02cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -5,6 +5,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -15,14 +16,14 @@ public class InteractionJukeBox extends RoomItem { super(set, baseItem); } - public InteractionJukeBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionJukeBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -60,7 +61,7 @@ public class InteractionJukeBox extends RoomItem { @Override public void onPickUp(Room room) { super.onPickUp(room); - this.setExtradata("0"); + this.setExtraData("0"); room.getRoomTraxManager().removeTraxOnRoom(this); } @@ -69,7 +70,7 @@ public class InteractionJukeBox extends RoomItem { super.onPlace(room); room.getRoomTraxManager().addTraxOnRoom(this); if (room.getRoomTraxManager().isPlaying()) { - this.setExtradata("1"); + this.setExtraData("1"); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java index c676a9a4..630fad81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java @@ -9,6 +9,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.lovelock.FriendFurniStartConfirmationMessageComposer; @@ -24,8 +25,8 @@ public class InteractionLoveLock extends RoomItem { super(set, baseItem); } - public InteractionLoveLock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionLoveLock(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -33,7 +34,7 @@ public class InteractionLoveLock extends RoomItem { serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(6); - String[] data = this.getExtradata().split("\t"); + String[] data = this.getExtraData().split("\t"); if (data.length == 6) { serverMessage.appendString("1"); @@ -71,13 +72,13 @@ public class InteractionLoveLock extends RoomItem { @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (this.getExtradata().contains("\t")) + if (this.getExtraData().contains("\t")) return; if (client == null) return; - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY()))) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) { if (this.userOneId == 0) { this.userOneId = client.getHabbo().getHabboInfo().getId(); client.sendResponse(new FriendFurniStartConfirmationMessageComposer(this)); @@ -95,7 +96,7 @@ public class InteractionLoveLock extends RoomItem { } public boolean lock(Habbo userOne, Habbo userTwo, Room room) { - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentPosition(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentPosition(), tile)) { String data = "1"; data += "\t"; @@ -109,7 +110,7 @@ public class InteractionLoveLock extends RoomItem { data += "\t"; data += Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR); - this.setExtradata(data); + this.setExtraData(data); this.needsUpdate(true); Emulator.getThreading().run(this); room.updateItem(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java index 18a26b93..6d9d71db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java @@ -4,8 +4,9 @@ import com.eu.habbo.Emulator; 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.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.users.HabboInfo; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; @@ -19,8 +20,8 @@ public class InteractionMannequin extends RoomItem { super(set, baseItem); } - public InteractionMannequin(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMannequin(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -32,8 +33,8 @@ public class InteractionMannequin extends RoomItem { public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(3); - if (this.getExtradata().split(":").length >= 2) { - String[] data = this.getExtradata().split(":"); + if (this.getExtraData().split(":").length >= 2) { + String[] data = this.getExtraData().split(":"); serverMessage.appendString("GENDER"); serverMessage.appendString(data[0].toLowerCase()); serverMessage.appendString("FIGURE"); @@ -47,7 +48,7 @@ public class InteractionMannequin extends RoomItem { serverMessage.appendString(""); serverMessage.appendString("OUTFIT_NAME"); serverMessage.appendString("My Look"); - this.setExtradata("m: :My look"); + this.setExtraData("m: :My look"); this.needsUpdate(true); Emulator.getThreading().run(this); } @@ -66,7 +67,7 @@ public class InteractionMannequin extends RoomItem { @Override public void onClick(GameClient client, Room room, Object[] objects) { - String[] data = this.getExtradata().split(":"); + String[] data = this.getExtraData().split(":"); if(data.length < 2) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java index 9940030a..1d79a5e4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.ICycleable; 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.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -18,8 +19,8 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements super(set, baseItem); } - public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMonsterCrackable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -46,9 +47,10 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements @Override public void reset(Room room) { RoomTile tile = room.getRandomWalkableTile(); - this.setX(tile.getX()); - this.setY(tile.getY()); - this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); + + this.setCurrentPosition(tile); + this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false)); + super.reset(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java index bd2c79cd..42474010 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.map.TIntObjectMap; @@ -17,14 +18,14 @@ public class InteractionMoodLight extends RoomItem { super(set, baseItem); } - public InteractionMoodLight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMoodLight(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -49,7 +50,7 @@ public class InteractionMoodLight extends RoomItem { if (room != null) { for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) { if (data.isEnabled()) { - this.setExtradata(data.toString()); + this.setExtraData(data.toString()); this.needsUpdate(true); room.updateItem(this); Emulator.getThreading().run(this); 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 3095e6f0..2c6e09f2 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 @@ -7,9 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -19,8 +17,8 @@ import java.sql.SQLException; import java.util.Collection; public class InteractionMultiHeight extends RoomItem { - public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMultiHeight(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public InteractionMultiHeight(ResultSet set, Item baseItem) throws SQLException { @@ -30,7 +28,7 @@ public class InteractionMultiHeight extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -49,42 +47,47 @@ public class InteractionMultiHeight extends RoomItem { public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) + if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) { return; + } - if (objects.length <= 0) { + if (objects.length == 0) { return; } if (objects[0] instanceof Integer && room != null) { - RoomItem topItem = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY()); + RoomItem topItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top return; } this.needsUpdate(true); - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) { + this.setExtraData("0"); + } if (this.getBaseItem().getMultiHeights().length > 0) { - this.setExtradata("" + (Integer.parseInt(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length)); + this.setExtraData(String.valueOf((Integer.parseInt(this.getExtraData()) + 1) % (this.getBaseItem().getMultiHeights().length))); this.needsUpdate(true); - room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); + room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); room.updateItemState(this); } } } public void updateUnitsOnItem(Room room) { - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for(RoomTile tile : occupiedTiles) { Collection unitsOnItem = room.getRoomUnitManager().getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY())); for (RoomUnit unit : unitsOnItem) { - if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoalLocation() != tile) { - continue; + if (unit.hasStatus(RoomUnitStatus.MOVE)) { + if (unit.getTargetPosition() != tile) { + continue; + } } if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) { @@ -92,8 +95,6 @@ public class InteractionMultiHeight extends RoomItem { unit.setStatusUpdateNeeded(true); } else { unit.setCurrentZ(unit.getCurrentPosition().getStackHeight()); - unit.setPreviousLocationZ(unit.getCurrentZ()); - unit.setStatusUpdateNeeded(true); } } } @@ -107,45 +108,11 @@ public class InteractionMultiHeight extends RoomItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - - if (roomUnit != null - && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - 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()) { - habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1); - } - } - } } @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - - if (roomUnit != null - && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) - && roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); - - if (habbo != null) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - habbo.getRoomUnit().giveEffect(0, -1); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - habbo.getRoomUnit().giveEffect(0, -1); - } - } - } } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index d81205aa..3cb5277f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -4,6 +4,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import lombok.extern.slf4j.Slf4j; @@ -18,7 +19,7 @@ public class InteractionMusicDisc extends RoomItem { public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - String[] stuff = this.getExtradata().split("\n"); + String[] stuff = this.getExtraData().split("\n"); if (stuff.length >= 7 && !stuff[6].isEmpty()) { try { @@ -29,10 +30,10 @@ public class InteractionMusicDisc extends RoomItem { } } - public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMusicDisc(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); - String[] stuff = this.getExtradata().split("\n"); + String[] stuff = this.getExtraData().split("\n"); if (stuff.length >= 7 && !stuff[6].isEmpty()) { try { @@ -46,7 +47,7 @@ public class InteractionMusicDisc extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index 8ff653eb..f0824698 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -7,6 +7,7 @@ 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.items.RoomItem; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.ObjectDataUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; @@ -39,8 +40,8 @@ public class InteractionMuteArea extends InteractionCustomValues { tiles = new THashSet<>(); } - public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + public InteractionMuteArea(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues); tiles = new THashSet<>(); } @@ -96,10 +97,10 @@ public class InteractionMuteArea extends InteractionCustomValues { } private void regenAffectedTiles(Room room) { - int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack"))); - int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight"))); - int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront"))); - int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft"))); + int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(this.values.get("tilesBack"))); + int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(this.values.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(this.values.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(this.values.get("tilesLeft"))); this.tiles.clear(); @@ -129,10 +130,10 @@ public class InteractionMuteArea extends InteractionCustomValues { int id = 0; for(RoomTile tile : this.tiles) { id--; - RoomItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); - item.setX(tile.getX()); - item.setY(tile.getY()); - item.setZ(tile.relativeHeight()); + RoomItem item = new InteractionDefault(id, null, effectItem, "1", 0, 0); + + item.setCurrentPosition(tile); + item.setCurrentZ(tile.relativeHeight()); items.add(item); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java index f31560db..b8516dda 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; 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.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine super(set, baseItem); } - public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionNoSidesVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -23,7 +24,7 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine THashSet tiles = new THashSet<>(); for(int x = -1; x <= 1; x++) { for(int y = -1; y <= 1; y++) { - RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y)); + RoomTile tile = room.getLayout().getTile((short)(this.getCurrentPosition().getX() + x), (short)(this.getCurrentPosition().getY() + y)); if(tile != null) { tiles.add(tile); } 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 c6969081..16752dbd 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 @@ -13,6 +13,7 @@ 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -26,20 +27,20 @@ public class InteractionObstacle extends RoomItem implements ICycleable { public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); this.middleTiles = new THashSet<>(); } - public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionObstacle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); this.middleTiles = new THashSet<>(); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -155,12 +156,12 @@ public class InteractionObstacle extends RoomItem implements ICycleable { middleTiles.clear(); if(this.getRotation() == 2) { - middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), this.getY())); - middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1))); + middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), this.getCurrentPosition().getY())); + middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), (short)(this.getCurrentPosition().getY() + 1))); } else if(this.getRotation() == 4) { - middleTiles.add(room.getLayout().getTile(this.getX(), (short)(this.getY() + 1))); - middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1))); + middleTiles.add(room.getLayout().getTile(this.getCurrentPosition().getX(), (short)(this.getCurrentPosition().getY() + 1))); + middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), (short)(this.getCurrentPosition().getY() + 1))); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index 934f166e..f66f4939 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -7,6 +7,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; @@ -23,12 +24,12 @@ public class InteractionOneWayGate extends RoomItem { public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionOneWayGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionOneWayGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -48,13 +49,13 @@ public class InteractionOneWayGate extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { - if (this.getExtradata().length() == 0) { - this.setExtradata("0"); + if (this.getExtraData().length() == 0) { + this.setExtraData("0"); this.needsUpdate(true); } serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -64,11 +65,11 @@ public class InteractionOneWayGate extends RoomItem { super.onClick(client, room, objects); if (client != null) { - RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation()); + RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation()); if (tileInfront == null) return; - RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile currentLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (currentLocation == null) return; @@ -83,7 +84,7 @@ public class InteractionOneWayGate extends RoomItem { onSuccess.add(() -> { unit.setCanLeaveRoomByDoor(false); walkable = this.getBaseItem().allowWalk(); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation() + 4); unit.setGoalLocation(tile); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); @@ -122,14 +123,14 @@ public class InteractionOneWayGate extends RoomItem { } private void refresh(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose()); - room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); + room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); this.refresh(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java index 94e2dd3d..f9a31eb7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -16,8 +17,8 @@ public class InteractionPostIt extends RoomItem { super(set, baseItem); } - public InteractionPostIt(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPostIt(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -38,7 +39,7 @@ public class InteractionPostIt extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata().replace(((char) 9) + "", "")); + serverMessage.appendString(this.getExtraData().replace(((char) 9) + "", "")); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java index c58d0a40..2b5d2180 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java @@ -2,16 +2,17 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionPoster extends RoomItem { - public InteractionPoster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPoster(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public InteractionPoster(ResultSet set, Item baseItem) throws SQLException { @@ -36,7 +37,7 @@ public class InteractionPoster extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java index 137466af..6af9943d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java @@ -6,6 +6,7 @@ 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.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -15,12 +16,12 @@ import java.util.HashSet; public class InteractionPressurePlate extends InteractionDefault { public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionPressurePlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -66,7 +67,7 @@ public class InteractionPressurePlate extends InteractionDefault { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } public void updateState(Room room) { @@ -74,7 +75,7 @@ public class InteractionPressurePlate extends InteractionDefault { if (room == null || room.getLayout() == null || this.getBaseItem() == null) return; - RoomTile tileAtItem = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tileAtItem = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (tileAtItem == null) return; @@ -95,7 +96,7 @@ public class InteractionPressurePlate extends InteractionDefault { } } - this.setExtradata(occupied ? "1" : "0"); + this.setExtraData(occupied ? "1" : "0"); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java index 6e8a1d67..ab19efe7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.KickBallAction; import java.sql.ResultSet; @@ -21,12 +22,12 @@ public abstract class InteractionPushable extends InteractionDefault { public InteractionPushable(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionPushable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionPushable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -64,7 +65,7 @@ public abstract class InteractionPushable extends InteractionDefault { super.onClick(client, room, objects); if (client == null) return; - if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getX(), this.getY()))) { + if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) { int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room); RoomRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room); this.onTackle(room, client.getHabbo().getRoomUnit(), velocity, direction); @@ -87,7 +88,7 @@ public abstract class InteractionPushable extends InteractionDefault { boolean isDrag = false; RoomRotation direction; - if (this.getX() == roomUnit.getGoalLocation().getX() && this.getY() == roomUnit.getGoalLocation().getY()) //User clicked on the tile the ball is on, they want to kick it + if (this.getCurrentPosition().getX() == roomUnit.getTargetPosition().getX() && this.getCurrentPosition().getY() == roomUnit.getTargetPosition().getY()) //User clicked on the tile the ball is on, they want to kick it { velocity = this.getWalkOnVelocity(roomUnit, room); direction = this.getWalkOnDirection(roomUnit, room); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 77412e64..04679175 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -8,6 +8,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -19,35 +20,35 @@ public class InteractionPuzzleBox extends RoomItem { super(set, baseItem); } - public InteractionPuzzleBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPuzzleBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile boxLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomRotation rotation = null; - if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX()) { - if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() + 1) { + if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX()) { + if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() + 1) { rotation = RoomRotation.SOUTH; } else { - if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() - 1) { + if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() - 1) { rotation = RoomRotation.NORTH; } } } else { - if (this.getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY()) { - if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() + 1) { + if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY()) { + if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() + 1) { rotation = RoomRotation.EAST; - } else if (this.getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() - 1) { + } else if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() - 1) { rotation = RoomRotation.WEST; } } } if (rotation == null) { - RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), false); + RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false); if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile); return; @@ -55,7 +56,7 @@ public class InteractionPuzzleBox extends RoomItem { super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), rotation.getValue()); if (tile == null || tile.getState() == RoomTileState.INVALID || room.getRoomUnitManager().hasHabbosAt(tile)) { return; @@ -69,8 +70,9 @@ public class InteractionPuzzleBox extends RoomItem { if (item != null && !room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return; - this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); + this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false)); this.needsUpdate(true); + room.updateItem(this); room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); @@ -85,7 +87,7 @@ public class InteractionPuzzleBox extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java index d9998149..150c90ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java @@ -5,6 +5,7 @@ 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.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -16,26 +17,26 @@ public class InteractionPyramid extends InteractionGate { super(set, baseItem); } - public InteractionPyramid(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPyramid(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public void change(Room room) { - if (!(this.getExtradata().equals("0") || this.getExtradata().equals("1"))) - this.setExtradata("0"); + if (!(this.getExtraData().equals("0") || this.getExtraData().equals("1"))) + this.setExtraData("0"); if (room != null) { - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if(tile == null) { return; } if (!room.getRoomUnitManager().hasHabbosAt(tile)) { - int state = Integer.parseInt(this.getExtradata()); + int state = Integer.parseInt(this.getExtraData()); state = Math.abs(state - 1); - this.setExtradata(state + ""); + this.setExtraData(state + ""); room.updateItemState(this); this.nextChange = Emulator.getIntUnixTimestamp() + 1 + (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("pyramids.max.delay"))); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java index 2178ccef..7a4e42c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.RandomStateParams; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,28 +14,28 @@ public class InteractionRandomState extends InteractionDefault { super(set, baseItem); } - public InteractionRandomState(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRandomState(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onPlace(Room room) { super.onPlace(room); - this.setExtradata(""); + this.setExtraData(""); room.updateItemState(this); } public void onRandomStateClick(Room room) throws Exception { RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams()); - this.setExtradata(""); + this.setExtraData(""); room.updateItemState(this); int randomState = Emulator.getRandom().nextInt(params.getStates()) + 1; Emulator.getThreading().run(() -> { - this.setExtradata(randomState + ""); + this.setExtraData(randomState + ""); room.updateItemState(this); }, params.getDelay()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java index 250d7504..95c2f938 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,8 +11,8 @@ public class InteractionRedeemableSubscriptionBox extends InteractionCrackable { super(set, baseItem); } - public InteractionRedeemableSubscriptionBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRedeemableSubscriptionBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public boolean userRequiredToBeAdjacent() { 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 fa1ea0fa..a12142b9 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceStatusMessageComposer; import com.eu.habbo.threading.runnables.ClearRentedSpace; @@ -66,15 +67,15 @@ public class InteractionRentableSpace extends RoomItem { } } - public InteractionRentableSpace(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRentableSpace(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.renterName = ""; } @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - if (this.getExtradata().isEmpty()) + if (this.getExtraData().isEmpty()) return false; Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); @@ -109,8 +110,8 @@ public class InteractionRentableSpace extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { - if (this.getExtradata().isEmpty()) - this.setExtradata("0:0"); + if (this.getExtraData().isEmpty()) + this.setExtraData("0:0"); serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); @@ -156,17 +157,17 @@ public class InteractionRentableSpace extends RoomItem { if (room == null) return; - Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); + Rectangle rect = RoomLayout.getRectangle(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); THashSet items = new THashSet<>(); for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { - items.addAll(room.getRoomItemManager().getItemsAt(i, j, this.getZ())); + items.addAll(room.getRoomItemManager().getItemsAt(i, j, this.getCurrentZ())); } } for (RoomItem item : items) { - if (item.getOwnerId() == this.renterId) { + if (item.getOwnerInfo().getId() == this.renterId) { room.getRoomItemManager().pickUpItem(item, null); } } @@ -196,7 +197,7 @@ public class InteractionRentableSpace extends RoomItem { } @Override - public String getExtradata() { + public String getExtraData() { return this.renterId + ":" + this.endTimestamp; } 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 267cd835..d146d843 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 @@ -6,6 +6,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -20,18 +21,18 @@ public class InteractionRoller extends RoomItem { public InteractionRoller(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionRoller(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionRoller(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java index a09f2fd5..3b6329ea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; @@ -22,8 +23,8 @@ public class InteractionRoomAds extends InteractionCustomValues { super(set, baseItem, defaultValues); } - public InteractionRoomAds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + public InteractionRoomAds(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues); } @Override 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 834a8e8e..808f26a1 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer; import com.eu.habbo.threading.runnables.CloseGate; @@ -16,12 +17,12 @@ import java.sql.SQLException; public class InteractionRoomClubGate extends InteractionDefault implements ConditionalGate { public InteractionRoomClubGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionRoomClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionRoomClubGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -41,7 +42,7 @@ public class InteractionRoomClubGate extends InteractionDefault implements Condi super.onWalkOn(roomUnit, room, objects); if (this.canWalkOn(roomUnit, room, objects)) { - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java index 51936c4c..0ebcc7e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java @@ -4,6 +4,7 @@ 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.users.HabboInfo; import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class InteractionRoomClubHopper extends InteractionHopper { super(set, baseItem); } - public InteractionRoomClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRoomClubHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 12a228a0..e6e940b6 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,8 +15,8 @@ public class InteractionRoomClubTeleportTile extends InteractionTeleportTile { super(set, baseItem); } - public InteractionRoomClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRoomClubTeleportTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java index 8384d916..65f58760 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.navigator.NoOwnedRoomsAlertMessageComposer; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class InteractionRoomOMatic extends InteractionDefault { super(set, baseItem); } - public InteractionRoomOMatic(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionRoomOMatic(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java index 731b1483..fe64e06e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java @@ -9,8 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout; 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.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.awt.*; @@ -18,8 +18,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionSnowboardSlope extends InteractionMultiHeight { - public InteractionSnowboardSlope(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionSnowboardSlope(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public InteractionSnowboardSlope(ResultSet set, Item baseItem) throws SQLException { @@ -27,19 +27,13 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight { } @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - if(roomUnit instanceof RoomAvatar roomAvatar) { - roomAvatar.giveEffect(97, -1); - } + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); } @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - - if (roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.getEffectId() == 97) { - roomAvatar.giveEffect(0, -1); - } } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java index b47baa1b..e1e21051 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent; import com.eu.habbo.threading.runnables.RandomSpinningBottleNumber; @@ -15,8 +16,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionSpinningBottle extends RoomItem { - public InteractionSpinningBottle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionSpinningBottle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public InteractionSpinningBottle(ResultSet set, Item baseItem) throws SQLException { @@ -26,7 +27,7 @@ public class InteractionSpinningBottle extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -46,14 +47,14 @@ public class InteractionSpinningBottle extends RoomItem { super.onClick(client, room, objects); if (client != null) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { - if (!this.getExtradata().equalsIgnoreCase("-1")) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) { + if (!this.getExtraData().equalsIgnoreCase("-1")) { FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1)); if (event.isCancelled()) return; - this.setExtradata("-1"); + this.setExtraData("-1"); room.updateItemState(this); Emulator.getThreading().run(this); @@ -74,7 +75,7 @@ public class InteractionSpinningBottle extends RoomItem { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java index 7c6cd846..71557ba1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class InteractionStackHelper extends RoomItem { super(set, baseItem); } - public InteractionStackHelper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionStackHelper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -36,7 +37,7 @@ public class InteractionStackHelper extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java index cd434e5f..96024d2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,7 +11,7 @@ public class InteractionStickyPole extends InteractionDefault { super(set, baseItem); } - public InteractionStickyPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionStickyPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java index 5bac0dc9..d23b1791 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import java.sql.ResultSet; @@ -19,13 +20,13 @@ public class InteractionSwitch extends InteractionDefault { super(set, baseItem); } - public InteractionSwitch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionSwitch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override @@ -45,7 +46,7 @@ public class InteractionSwitch extends InteractionDefault { if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; - for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) { if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java index 2bc51667..c5da00e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; @@ -16,13 +17,13 @@ public class InteractionSwitchRemoteControl extends InteractionDefault { super(set, baseItem); } - public InteractionSwitchRemoteControl(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionSwitchRemoteControl(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override @@ -40,19 +41,19 @@ public class InteractionSwitchRemoteControl extends InteractionDefault { if (room != null) { super.onClick(client, room, objects); - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); if (this.getBaseItem().getStateCount() > 0) { int currentState = 0; try { - currentState = Integer.parseInt(this.getExtradata()); + currentState = Integer.parseInt(this.getExtraData()); } catch (NumberFormatException e) { - log.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); + log.error("Incorrect extradata (" + this.getExtraData() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); } - this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount()); + this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount()); this.needsUpdate(true); room.updateItemState(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java index c958a9d4..6d7be0ce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,7 +11,7 @@ public class InteractionTalkingFurniture extends InteractionDefault { super(set, baseItem); } - public InteractionTalkingFurniture(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTalkingFurniture(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 87fda1d2..9c209f90 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.threading.runnables.teleport.TeleportActionOne; @@ -27,19 +28,19 @@ public class InteractionTeleport extends RoomItem { public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); walkable = baseItem.allowWalk(); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTeleport(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); walkable = item.allowWalk(); - this.setExtradata("0"); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -73,7 +74,7 @@ public class InteractionTeleport extends RoomItem { return; } - RoomTile currentItemLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile currentItemLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (currentItemLocation == null) { return; @@ -97,7 +98,7 @@ public class InteractionTeleport extends RoomItem { } else if (roomHabbo.getCurrentPosition().equals(currentItemLocation) || roomHabbo.getCurrentPosition().equals(inFrontTile)) { // set state 1 and walk on item this.roomUnitID = roomHabbo.getVirtualId(); - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); roomHabbo.setGoalLocation(inFrontTile); @@ -115,7 +116,7 @@ public class InteractionTeleport extends RoomItem { onFail.add(() -> { this.walkable = this.getBaseItem().allowWalk(); room.updateTile(currentItemLocation); - this.setExtradata("0"); + this.setExtraData("0"); room.updateItemState(this); this.roomUnitID = -1; roomHabbo.removeOverrideTile(currentItemLocation); @@ -155,8 +156,8 @@ public class InteractionTeleport extends RoomItem { @Override public void run() { - if (!this.getExtradata().equals("0")) { - this.setExtradata("0"); + if (!this.getExtraData().equals("0")) { + this.setExtraData("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { @@ -171,7 +172,7 @@ public class InteractionTeleport extends RoomItem { this.targetId = 0; this.targetRoomId = 0; this.roomUnitID = -1; - this.setExtradata("0"); + this.setExtraData("0"); } public int getTargetId() { 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 9dff7a27..53aac853 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 @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,8 +14,8 @@ public class InteractionTeleportTile extends InteractionTeleport { super(set, baseItem); } - public InteractionTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTeleportTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java index e295e4b2..fb2653ba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -12,8 +13,8 @@ public class InteractionTent extends InteractionDefault { super(set, baseItem); } - public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTent(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java index 22ee08b2..f6cc49e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; @@ -20,8 +21,8 @@ public class InteractionTileEffectProvider extends InteractionCustomValues { super(set, baseItem, defaultValues); } - public InteractionTileEffectProvider(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + public InteractionTileEffectProvider(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues); } @Override 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 a02d58ff..66bac372 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -16,13 +17,13 @@ public class InteractionTrap extends InteractionDefault { super(set, baseItem); } - public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTrap(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - if (this.getExtradata().equals("0") || roomUnit == null || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) return; + if (this.getExtraData().equals("0") || roomUnit == null || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) return; Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java index 80f2c39c..6a9f93c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,8 +11,8 @@ public class InteractionTrophy extends InteractionDefault { super(set, baseItem); } - public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTrophy(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 1249d52a..c002bbcf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; @@ -26,12 +27,12 @@ import java.util.List; public class InteractionVendingMachine extends RoomItem { public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } public THashSet getActivatorTiles(Room room) { @@ -41,14 +42,14 @@ public class InteractionVendingMachine extends RoomItem { if (tileInFront != null) tiles.add(tileInFront); - tiles.add(room.getLayout().getTile(this.getX(), this.getY())); + tiles.add(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); return tiles; } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -77,7 +78,7 @@ public class InteractionVendingMachine extends RoomItem { return; } - this.setExtradata("1"); + this.setExtraData("1"); room.updateItem(this); try { @@ -159,8 +160,8 @@ public class InteractionVendingMachine extends RoomItem { @Override public void run() { super.run(); - if (this.getExtradata().equals("1")) { - this.setExtradata("0"); + if (this.getExtraData().equals("1")) { + this.setExtraData("0"); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { room.updateItem(this); @@ -184,7 +185,7 @@ public class InteractionVendingMachine extends RoomItem { } private void rotateToMachine(RoomUnit unit) { - RoomRotation rotation = RoomRotation.values()[Rotation.Calculate(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY(), this.getX(), this.getY())]; + RoomRotation rotation = RoomRotation.values()[Rotation.Calculate(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY())]; if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) { unit.setRotation(rotation); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java index 11f9d80c..43b095e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; 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.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,23 +15,23 @@ public class InteractionVikingCotie extends InteractionDefault { super(set, baseItem); } - public InteractionVikingCotie(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionVikingCotie(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onClick(GameClient client, Room room, Object[] objects) { - if (this.getExtradata().isEmpty()) { - this.setExtradata("0"); + if (this.getExtraData().isEmpty()) { + this.setExtraData("0"); } - if (client != null && client.getHabbo().getHabboInfo().getId() == this.getOwnerId()) { + if (client != null && client.getHabbo().getHabboInfo().getId() == this.getOwnerInfo().getId()) { if (client.getHabbo().getRoomUnit().getEffectId() == 172 || client.getHabbo().getRoomUnit().getEffectId() == 173) { - int state = Integer.parseInt(this.getExtradata()); + int state = Integer.parseInt(this.getExtraData()); if (state < 5) { state++; - this.setExtradata(state + ""); + this.setExtraData(state + ""); room.updateItem(this); if (state == 5) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java index d77c5307..6f4cfee2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -5,6 +5,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; @@ -21,18 +22,18 @@ public class InteractionVoteCounter extends RoomItem { public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - if(!this.getExtradata().contains(",")) { - this.setExtradata("1,0"); // frozen,votes + if(!this.getExtraData().contains(",")) { + this.setExtraData("1,0"); // frozen,votes } - String[] bits = this.getExtradata().split(","); + String[] bits = this.getExtraData().split(","); frozen = bits[0].equals("1"); votes = Integer.parseInt(bits[1]); votedUsers = new ArrayList<>(); } - public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionVoteCounter(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); if(!extradata.contains(",")) { extradata = "1,0"; @@ -63,7 +64,7 @@ public class InteractionVoteCounter extends RoomItem { } private void updateExtradata() { - this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes); + this.setExtraData((this.frozen ? "1" : "0") + "," + this.votes); } @Override 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 f032fd25..a91eb450 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 @@ -11,6 +11,7 @@ import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -32,8 +33,8 @@ public class InteractionWater extends InteractionDefault { this.isInRoom = this.getRoomId() != 0; } - public InteractionWater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionWater(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.isDeepWater = false; this.isInRoom = this.getRoomId() != 0; } @@ -89,7 +90,7 @@ public class InteractionWater extends InteractionDefault { return; if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().isCanSwim()) { - pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.SWIM, ""); } } @@ -206,55 +207,63 @@ public class InteractionWater extends InteractionDefault { byte _12 = 0; // Check if we are touching a water tile. - if (this.isValidForMask(room, this.getX() - 1, this.getY() - 1, this.getZ(), true)) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() - 1, this.getCurrentZ(), true)) { _1 = 1; } - if (this.isValidForMask(room, this.getX(), this.getY() - 1, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX(), this.getCurrentPosition().getY() - 1, this.getCurrentZ())) { _2 = 1; } - if (this.isValidForMask(room, this.getX() + 1, this.getY() - 1, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 1, this.getCurrentPosition().getY() - 1, this.getCurrentZ())) { _3 = 1; } - if (this.isValidForMask(room, this.getX() + 2, this.getY() - 1, this.getZ(), true)) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() - 1, this.getCurrentZ(), true)) { _4 = 1; } - if (this.isValidForMask(room, this.getX() - 1, this.getY(), this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY(), this.getCurrentZ())) { _5 = 1; } - if (this.isValidForMask(room, this.getX() + 2, this.getY(), this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY(), this.getCurrentZ())) { _6 = 1; } - if (this.isValidForMask(room, this.getX() - 1, this.getY() + 1, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() + 1, this.getCurrentZ())) { _7 = 1; } - if (this.isValidForMask(room, this.getX() + 2, this.getY() + 1, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() + 1, this.getCurrentZ())) { _8 = 1; } - if (this.isValidForMask(room, this.getX() - 1, this.getY() + 2, this.getZ(), true)) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() + 2, this.getCurrentZ(), true)) { _9 = 1; } - if (this.isValidForMask(room, this.getX(), this.getY() + 2, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX(), this.getCurrentPosition().getY() + 2, this.getCurrentZ())) { _10 = 1; } - if (this.isValidForMask(room, this.getX() + 1, this.getY() + 2, this.getZ())) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 1, this.getCurrentPosition().getY() + 2, this.getCurrentZ())) { _11 = 1; } - if (this.isValidForMask(room, this.getX() + 2, this.getY() + 2, this.getZ(), true)) { + if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() + 2, this.getCurrentZ(), true)) { _12 = 1; } // Check if we are touching invalid tiles. // if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1; - if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1; - if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1; + if (_2 == 0 && room.getLayout().isVoidTile(this.getCurrentPosition().getX(), (short) (this.getCurrentPosition().getY() - 1))) + _2 = 1; + if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 1), (short) (this.getCurrentPosition().getY() - 1))) + _3 = 1; // if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1; - if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1; - if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1; - if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1; - if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1; + if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() - 1), this.getCurrentPosition().getY())) + _5 = 1; + if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 2), this.getCurrentPosition().getY())) + _6 = 1; + if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() - 1), (short) (this.getCurrentPosition().getY() + 1))) + _7 = 1; + if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 2), (short) (this.getCurrentPosition().getY() + 1))) + _8 = 1; // if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1; - if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1; - if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1; + if (_10 == 0 && room.getLayout().isVoidTile(this.getCurrentPosition().getX(), (short) (this.getCurrentPosition().getY() + 2))) + _10 = 1; + if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 1), (short) (this.getCurrentPosition().getY() + 2))) + _11 = 1; // if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1; // Update water. @@ -273,8 +282,8 @@ public class InteractionWater extends InteractionDefault { String updatedData = String.valueOf(result); - if (!this.getExtradata().equals(updatedData)) { - this.setExtradata(updatedData); + if (!this.getExtraData().equals(updatedData)) { + this.setExtraData(updatedData); this.needsUpdate(true); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java index 6573f64b..0be5c28b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java @@ -6,6 +6,7 @@ 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.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.awt.*; @@ -17,8 +18,8 @@ public class InteractionWaterItem extends InteractionMultiHeight { super(set, baseItem); } - public InteractionWaterItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionWaterItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -30,7 +31,7 @@ public class InteractionWaterItem extends InteractionMultiHeight { @Override public void onPickUp(Room room) { super.onPickUp(room); - this.setExtradata("0"); + this.setExtraData("0"); this.needsUpdate(true); } @@ -79,8 +80,8 @@ public class InteractionWaterItem extends InteractionMultiHeight { // Update data if changed. String updatedData = foundWater ? "1" : "0"; - if (!this.getExtradata().equals(updatedData)) { - this.setExtradata(updatedData); + if (!this.getExtraData().equals(updatedData)) { + this.setExtraData(updatedData); this.needsUpdate(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 78af151f..176fc794 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -38,13 +39,13 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.wiredSettings = new WiredSettings(); - this.setExtradata("0"); + this.setExtraData("0"); } - InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + InteractionWired(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.wiredSettings = new WiredSettings(); - this.setExtradata("0"); + this.setExtraData("0"); } public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff); @@ -190,7 +191,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi } public void activateBox(Room room, RoomUnit roomUnit, long millis) { - this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); + this.setExtraData(this.getExtraData().equals("1") ? "0" : "1"); room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose()); if (roomUnit != null) { this.addUserExecutionCache(roomUnit.getVirtualId(), millis); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index a9b85cce..fe6bef8f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -1,11 +1,9 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import java.sql.ResultSet; import java.sql.SQLException; @@ -15,8 +13,8 @@ public abstract class InteractionWiredCondition extends InteractionWired { super(set, baseItem); } - public InteractionWiredCondition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionWiredCondition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public abstract WiredConditionType getType(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index 5b027410..68981e6c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredEffectInteraction; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -26,13 +27,13 @@ public abstract class InteractionWiredEffect extends InteractionWired implements super(set, baseItem); } - public InteractionWiredEffect(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { - super(id, userId, item, extraData, limitedStack, limitedSells); + public InteractionWiredEffect(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extraData, limitedStack, limitedSells); } public List getBlockedTriggers(Room room) { List blockedTriggers = new ArrayList<>(); - THashSet triggers = room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()); + THashSet triggers = room.getRoomSpecialTypes().getTriggers(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); for(InteractionWiredTrigger trigger : triggers) { if(!trigger.isTriggeredByRoomUnit()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java index d89937c3..c0bae61a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java @@ -4,6 +4,7 @@ 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.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,8 +14,8 @@ public abstract class InteractionWiredExtra extends InteractionWired { super(set, baseItem); } - protected InteractionWiredExtra(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + protected InteractionWiredExtra(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 6836e782..f75c8e58 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -6,6 +6,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -46,8 +47,8 @@ public class InteractionWiredHighscore extends RoomItem { this.reloadData(); } - public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionWiredHighscore(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.scoreType = WiredHighscoreScoreType.CLASSIC; this.clearType = WiredHighscoreClearType.ALLTIME; @@ -84,13 +85,13 @@ public class InteractionWiredHighscore extends RoomItem { if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; - if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) { - this.setExtradata("0"); + if (this.getExtraData() == null || this.getExtraData().isEmpty() || this.getExtraData().length() == 0) { + this.setExtraData("0"); } try { - int state = Integer.parseInt(this.getExtradata()); - this.setExtradata(Math.abs(state - 1) + ""); + int state = Integer.parseInt(this.getExtraData()); + this.setExtraData(Math.abs(state - 1) + ""); room.updateItem(this); } catch (Exception e) { log.error("Caught exception", e); @@ -105,7 +106,7 @@ public class InteractionWiredHighscore extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(6); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); serverMessage.appendInt(this.scoreType.getType()); serverMessage.appendInt(this.clearType.getType()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index be6fc806..86e1108f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -1,11 +1,10 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredTriggerInteraction; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; @@ -28,13 +27,13 @@ public abstract class InteractionWiredTrigger extends InteractionWired implement super(set, baseItem); } - protected InteractionWiredTrigger(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + protected InteractionWiredTrigger(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public List getBlockedEffects(Room room) { List blockedEffects = new ArrayList<>(); - THashSet effects = room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()); + THashSet effects = room.getRoomSpecialTypes().getEffects(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); for(InteractionWiredEffect effect : effects) { if (!effect.requiresTriggeringUser()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java index d3555cb0..e341d276 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java @@ -5,8 +5,9 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.YoutubeManager; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer; @@ -26,8 +27,8 @@ public class InteractionYoutubeTV extends RoomItem { super(set, baseItem); } - public InteractionYoutubeTV(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionYoutubeTV(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -47,8 +48,8 @@ public class InteractionYoutubeTV extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { - if (this.getExtradata().length() == 0) - this.setExtradata(""); + if (this.getExtraData().length() == 0) + this.setExtraData(""); serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(1); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java index 10615da4..47d768bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -13,17 +14,17 @@ import java.sql.SQLException; public abstract class InteractionGameGate extends InteractionGameTeamItem { public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); - this.setExtradata("0"); + public InteractionGameGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); + this.setExtraData("0"); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override @@ -34,7 +35,7 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -49,7 +50,7 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem { if (memberCount > maxPlayers) { memberCount = maxPlayers; } - this.setExtradata(memberCount + ""); + this.setExtraData(memberCount + ""); game.getRoom().updateItem(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java index eb416b80..cf81f3fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.games; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -11,24 +12,24 @@ import java.sql.SQLException; public abstract class InteractionGameScoreboard extends InteractionGameTeamItem { protected InteractionGameScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException { super(set, baseItem, teamColor); - this.setExtradata("0"); + this.setExtraData("0"); } - protected InteractionGameScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); - this.setExtradata("0"); + protected InteractionGameScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java index adf89c03..583040bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.games; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -16,8 +17,8 @@ public abstract class InteractionGameTeamItem extends RoomItem { this.teamColor = teamColor; } - protected InteractionGameTeamItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells); + protected InteractionGameTeamItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.teamColor = teamColor; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 4be41c87..3f1b02b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.permissions.Permission; 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -76,7 +77,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { } if (data.length >= 1) { - this.setExtradata(data[0] + "\t0"); + this.setExtraData(data[0] + "\t0"); } } catch (Exception e) { @@ -85,8 +86,8 @@ public class InteractionGameTimer extends RoomItem implements Runnable { } } - public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionGameTimer(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); parseCustomParams(item); } @@ -163,7 +164,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { public void onPickUp(Room room) { this.endGame(room); - this.setExtradata(this.baseTime + "\t" + this.baseTime); + this.setExtraData(this.baseTime + "\t" + this.baseTime); this.needsUpdate(true); } @@ -175,7 +176,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { this.timeNow = this.baseTime; - this.setExtradata(this.timeNow + "\t" + this.baseTime); + this.setExtraData(this.timeNow + "\t" + this.baseTime); room.updateItem(this); this.needsUpdate(true); @@ -202,8 +203,8 @@ public class InteractionGameTimer extends RoomItem implements Runnable { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if (this.getExtradata().isEmpty()) { - this.setExtradata("0\t" + this.TIMER_INTERVAL_STEPS[0]); + if (this.getExtraData().isEmpty()) { + this.setExtraData("0\t" + this.TIMER_INTERVAL_STEPS[0]); } // if wired triggered it @@ -313,7 +314,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { } this.baseTime = baseTime; - this.setExtradata(this.timeNow + "\t" + this.baseTime); + this.setExtraData(this.timeNow + "\t" + this.baseTime); this.timeNow = this.baseTime; room.updateItem(this); @@ -322,7 +323,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { @Override public String getDatabaseExtraData() { - return this.getExtradata(); + return this.getExtraData(); } @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 b30ecadc..b0002330 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 @@ -12,6 +12,7 @@ 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.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -21,8 +22,8 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { super(set, baseItem); } - public InteractionBattleBanzaiPuck(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionBattleBanzaiPuck(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -78,9 +79,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { return RoomRotation.SOUTH; case NORTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue()))) return RoomRotation.NORTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue()))) return RoomRotation.SOUTH_EAST; else return RoomRotation.SOUTH_WEST; @@ -89,9 +90,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { return RoomRotation.WEST; case SOUTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue()))) return RoomRotation.SOUTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue()))) return RoomRotation.NORTH_EAST; else return RoomRotation.NORTH_WEST; @@ -100,9 +101,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { return RoomRotation.NORTH; case SOUTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue()))) return RoomRotation.SOUTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue()))) return RoomRotation.NORTH_WEST; else return RoomRotation.NORTH_EAST; @@ -111,9 +112,9 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { return RoomRotation.EAST; case NORTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue()))) return RoomRotation.NORTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue()))) return RoomRotation.SOUTH_WEST; else return RoomRotation.SOUTH_EAST; @@ -167,7 +168,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { } catch (Exception e) { return; } - this.setExtradata(team.teamColor.type + ""); + this.setExtraData(team.teamColor.type + ""); room.updateItemState(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java index 0009d8b1..a518ca52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -12,18 +13,18 @@ import java.sql.SQLException; public class InteractionBattleBanzaiSphere extends RoomItem { public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionBattleBanzaiSphere(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionBattleBanzaiSphere(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index 11109f6e..3e8744a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.BanzaiRandomTeleport; @@ -16,18 +17,18 @@ import java.sql.SQLException; public class InteractionBattleBanzaiTeleporter extends RoomItem { public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionBattleBanzaiTeleporter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionBattleBanzaiTeleporter(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -60,7 +61,7 @@ public class InteractionBattleBanzaiTeleporter extends RoomItem { RoomItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this); if (target == null) return; - this.setExtradata("1"); + this.setExtraData("1"); room.updateItemState(this); roomUnit.removeStatus(RoomUnitStatus.MOVE); roomUnit.setGoalLocation(roomUnit.getCurrentPosition()); 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 9667d347..b336d2aa 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 @@ -8,6 +8,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -19,18 +20,18 @@ import java.util.List; public class InteractionBattleBanzaiTile extends RoomItem { public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionBattleBanzaiTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionBattleBanzaiTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -54,10 +55,10 @@ public class InteractionBattleBanzaiTile extends RoomItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata().isEmpty()) - this.setExtradata("0"); + if (this.getExtraData().isEmpty()) + this.setExtraData("0"); - int state = Integer.parseInt(this.getExtradata()); + int state = Integer.parseInt(this.getExtraData()); if (state % 3 == 2) return; @@ -85,10 +86,10 @@ public class InteractionBattleBanzaiTile extends RoomItem { } public boolean isLocked() { - if (this.getExtradata().isEmpty()) + if (this.getExtraData().isEmpty()) return false; - return Integer.parseInt(this.getExtradata()) % 3 == 2; + return Integer.parseInt(this.getExtraData()) % 3 == 2; } @Override @@ -104,7 +105,7 @@ public class InteractionBattleBanzaiTile extends RoomItem { public void onPickUp(Room room) { super.onPickUp(room); - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); } @@ -115,7 +116,7 @@ public class InteractionBattleBanzaiTile extends RoomItem { BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); if (game != null && game.getState() != GameState.IDLE) { - this.setExtradata("1"); + this.setExtraData("1"); } } } 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 58e6f2f6..04c1b7d9 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 @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -19,8 +20,8 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { super(set, baseItem, teamColor); } - public InteractionBattleBanzaiGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + public InteractionBattleBanzaiGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java index 206bd98b..6596d2e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateBlue extends InteractionBattleBanzaiGate super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiGateBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java index ee488fba..54052d44 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateGreen extends InteractionBattleBanzaiGat super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiGateGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java index ceeca701..6b6f1c24 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateRed extends InteractionBattleBanzaiGate super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiGateRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java index ec6609e4..770a1fe8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateYellow extends InteractionBattleBanzaiGa super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiGateYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java index ffb02954..2198418b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,8 +15,8 @@ public class InteractionBattleBanzaiScoreboard extends InteractionGameScoreboard super(set, baseItem, teamColor); } - public InteractionBattleBanzaiScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + public InteractionBattleBanzaiScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java index a5452738..af47fe4e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardBlue extends InteractionBattleBanz super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java index a42332f9..1f57ffac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardGreen extends InteractionBattleBan super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java index 9abf0aad..431c6290 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardRed extends InteractionBattleBanza super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java index 6b4b8950..36d80166 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardYellow extends InteractionBattleBa super(set, baseItem, TEAM_COLOR); } - public InteractionBattleBanzaiScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionBattleBanzaiScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java index 9ba08b4b..bb205a17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java @@ -12,6 +12,7 @@ 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.HabboInfo; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; import com.eu.habbo.util.pathfinding.Rotation; @@ -26,14 +27,14 @@ public class InteractionFootball extends InteractionPushable { super(set, baseItem); } - public InteractionFootball(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionFootball(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public int getWalkOnVelocity(RoomUnit roomUnit, Room room) { - if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2 && this.getExtradata().equals("1")) + if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2 && this.getExtraData().equals("1")) return 0; if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 1) @@ -72,7 +73,12 @@ public class InteractionFootball extends InteractionPushable { @Override public RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room) { RoomTile peek = roomUnit.getPath().peek(); - RoomTile nextWalkTile = peek != null ? room.getLayout().getTile(peek.getX(), peek.getY()) : roomUnit.getGoalLocation(); + RoomTile nextWalkTile; + if (peek != null) { + nextWalkTile = room.getLayout().getTile(peek.getX(), peek.getY()); + } else { + nextWalkTile = roomUnit.getTargetPosition(); + } return RoomRotation.values()[(RoomRotation.values().length + Rotation.Calculate(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8]; } @@ -103,9 +109,9 @@ public class InteractionFootball extends InteractionPushable { return RoomRotation.SOUTH; case NORTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue()))) return RoomRotation.NORTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue()))) return RoomRotation.SOUTH_EAST; else return RoomRotation.SOUTH_WEST; @@ -114,9 +120,9 @@ public class InteractionFootball extends InteractionPushable { return RoomRotation.WEST; case SOUTH_EAST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue()))) return RoomRotation.SOUTH_WEST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue()))) return RoomRotation.NORTH_EAST; else return RoomRotation.NORTH_WEST; @@ -125,9 +131,9 @@ public class InteractionFootball extends InteractionPushable { return RoomRotation.NORTH; case SOUTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue()))) return RoomRotation.SOUTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue()))) return RoomRotation.NORTH_WEST; else return RoomRotation.NORTH_EAST; @@ -136,9 +142,9 @@ public class InteractionFootball extends InteractionPushable { return RoomRotation.EAST; case NORTH_WEST: - if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.NORTH_EAST.getValue()))) + if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue()))) return RoomRotation.NORTH_EAST; - else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomRotation.SOUTH_WEST.getValue()))) + else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue()))) return RoomRotation.SOUTH_WEST; else return RoomRotation.SOUTH_EAST; @@ -162,8 +168,8 @@ public class InteractionFootball extends InteractionPushable { } // Ball can only go up by 1.65 according to Habbo (tested using stack tile on 22-03-2022) - BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight()); - BigDecimal ballHeight = BigDecimal.valueOf(this.getZ()); + BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getCurrentZ() + topItem.getBaseItem().getHeight()); + BigDecimal ballHeight = BigDecimal.valueOf(this.getCurrentZ()); if (topItemHeight.subtract(ballHeight).compareTo(BigDecimal.valueOf(1.65)) > 0) { return false; @@ -222,7 +228,7 @@ public class InteractionFootball extends InteractionPushable { game.onScore(kicker, color); } - this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + ""); + this.setExtraData(Math.abs(currentStep - (totalSteps + 1)) + ""); room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose()); } @@ -233,7 +239,7 @@ public class InteractionFootball extends InteractionPushable { @Override public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) { - this.setExtradata("0"); + this.setExtraData("0"); room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose()); } @@ -245,7 +251,7 @@ public class InteractionFootball extends InteractionPushable { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } } \ No newline at end of file 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 45cb0b6d..cbe737e2 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 @@ -7,6 +7,7 @@ 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.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer; @@ -33,8 +34,8 @@ public class InteractionFootballGate extends RoomItem { this.figureF = bits.length > 1 ? bits[1] : ""; } - public InteractionFootballGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionFootballGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); String[] bits = extradata.split(";"); this.figureM = bits.length > 0 ? bits[0] : ""; @@ -76,7 +77,7 @@ public class InteractionFootballGate extends RoomItem { public void setFigureM(String look) { this.figureM = look; - this.setExtradata(this.figureM + ";" + this.figureF); + this.setExtraData(this.figureM + ";" + this.figureF); this.needsUpdate(true); Emulator.getThreading().run(this); } @@ -84,7 +85,7 @@ public class InteractionFootballGate extends RoomItem { public void setFigureF(String look) { this.figureF = look; - this.setExtradata(this.figureM + ";" + this.figureF); + this.setExtraData(this.figureM + ";" + this.figureF); this.needsUpdate(true); Emulator.getThreading().run(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java index e50163c7..a87c770c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class InteractionFootballGoal extends InteractionGameTeamItem { super(set, baseItem, teamColor); } - public InteractionFootballGoal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + public InteractionFootballGoal(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); } @Override @@ -37,7 +38,7 @@ public class InteractionFootballGoal extends InteractionGameTeamItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java index 34d2b52f..1e600210 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballGoalBlue extends InteractionFootballGoal { super(set, baseItem, GameTeamColors.BLUE); } - public InteractionFootballGoalBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); + public InteractionFootballGoalBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java index 42276c9e..da40f7be 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballGoalGreen extends InteractionFootballGoal { super(set, baseItem, GameTeamColors.GREEN); } - public InteractionFootballGoalGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); + public InteractionFootballGoalGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java index b4d9b5d4..945a0227 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballGoalRed extends InteractionFootballGoal { super(set, baseItem, GameTeamColors.RED); } - public InteractionFootballGoalRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); + public InteractionFootballGoalRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java index ba725033..252cc98a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballGoalYellow extends InteractionFootballGoal { super(set, baseItem, GameTeamColors.YELLOW); } - public InteractionFootballGoalYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); + public InteractionFootballGoalYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java index ed3862e7..2305665a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -20,14 +21,14 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { super(set, baseItem, teamColor); try { - this.score = Integer.parseInt(this.getExtradata()); + this.score = Integer.parseInt(this.getExtraData()); } catch (Exception e) { this.score = 0; } } - public InteractionFootballScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + public InteractionFootballScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); try { this.score = Integer.parseInt(extradata); @@ -58,7 +59,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { this.score = 99; } - this.setExtradata(this.score + ""); + this.setExtraData(this.score + ""); this.needsUpdate(true); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); @@ -84,7 +85,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { this.score = 99; } - this.setExtradata(this.score + ""); + this.setExtraData(this.score + ""); this.needsUpdate(true); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java index 1a4cd219..912e0f22 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballScoreboardBlue extends InteractionFootballScoreb super(set, baseItem, GameTeamColors.BLUE); } - public InteractionFootballScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); + public InteractionFootballScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java index 1f785c0c..f9522567 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballScoreboardGreen extends InteractionFootballScore super(set, baseItem, GameTeamColors.GREEN); } - public InteractionFootballScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); + public InteractionFootballScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java index 6d65b7ea..bf40c6a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballScoreboardRed extends InteractionFootballScorebo super(set, baseItem, GameTeamColors.RED); } - public InteractionFootballScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); + public InteractionFootballScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.RED); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java index 731a9e82..93d4498b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionFootballScoreboardYellow extends InteractionFootballScor super(set, baseItem, GameTeamColors.YELLOW); } - public InteractionFootballScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); + public InteractionFootballScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW); } } \ No newline at end of file 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 3dc26e13..2df02776 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 @@ -12,6 +12,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; @@ -21,12 +22,12 @@ import java.sql.SQLException; public class InteractionFreezeBlock extends RoomItem { public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionFreezeBlock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionFreezeBlock(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -35,12 +36,12 @@ public class InteractionFreezeBlock extends RoomItem { return; RoomItem item = null; - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); THashSet items = room.getRoomItemManager().getItemsAt(tile); for (RoomItem i : items) { if (i instanceof InteractionFreezeTile) { - if (item == null || i.getZ() <= item.getZ()) { + if (item == null || i.getCurrentZ() <= item.getCurrentZ()) { item = i; } } @@ -58,11 +59,11 @@ public class InteractionFreezeBlock extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { - if (this.getExtradata().length() == 0) { - this.setExtradata("0"); + if (this.getExtraData().length() == 0) { + this.setExtraData("0"); } serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -74,7 +75,7 @@ public class InteractionFreezeBlock extends RoomItem { @Override public boolean isWalkable() { - return !this.getExtradata().isEmpty() && !this.getExtradata().equals("0"); + return !this.getExtraData().isEmpty() && !this.getExtraData().equals("0"); } @Override @@ -86,7 +87,7 @@ public class InteractionFreezeBlock extends RoomItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata().isEmpty() || this.getExtradata().equalsIgnoreCase("0")) + if (this.getExtraData().isEmpty() || this.getExtraData().equalsIgnoreCase("0")) return; FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); @@ -105,7 +106,7 @@ public class InteractionFreezeBlock extends RoomItem { int powerUp; try { - powerUp = Integer.parseInt(this.getExtradata()) / 1000; + powerUp = Integer.parseInt(this.getExtraData()) / 1000; } catch (NumberFormatException e) { powerUp = 0; } @@ -114,7 +115,7 @@ public class InteractionFreezeBlock extends RoomItem { if (powerUp == 6 && !player.canPickupLife()) return; - this.setExtradata((powerUp + 10) * 1000 + ""); + this.setExtraData((powerUp + 10) * 1000 + ""); room.updateItem(this); @@ -126,6 +127,6 @@ public class InteractionFreezeBlock extends RoomItem { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java index 52337257..62652f27 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -12,17 +13,17 @@ import java.sql.SQLException; public class InteractionFreezeExitTile extends RoomItem { public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionFreezeExitTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionFreezeExitTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override @@ -43,7 +44,7 @@ public class InteractionFreezeExitTile extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } 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 1f685c00..1df899dd 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 @@ -7,6 +7,7 @@ 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.HabboInfo; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.util.Pair; @@ -18,12 +19,12 @@ import java.util.List; public class InteractionFreezeTile extends RoomItem { public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionFreezeTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionFreezeTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -41,7 +42,7 @@ public class InteractionFreezeTile extends RoomItem { if (client == null) return; - if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getY()) { + if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY()) { FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class); if (game != null) @@ -57,14 +58,14 @@ public class InteractionFreezeTile extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } @Override 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 dc044e26..1bf54566 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 @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -19,8 +20,8 @@ public class InteractionFreezeGate extends InteractionGameGate { super(set, baseItem, teamColor); } - public InteractionFreezeGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + public InteractionFreezeGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java index 90040250..22d10c07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeGateBlue extends InteractionFreezeGate { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeGateBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java index dd62a2eb..f99c02ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeGateGreen extends InteractionFreezeGate { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeGateGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java index 7f502050..0d28f833 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeGateRed extends InteractionFreezeGate { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeGateRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java index 418ce0ed..8b5c3add 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeGateYellow extends InteractionFreezeGate { super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeGateYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java index 66cab607..d90ca07c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,8 +15,8 @@ public class InteractionFreezeScoreboard extends InteractionGameScoreboard { super(set, baseItem, teamColor); } - InteractionFreezeScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { - super(id, userId, item, extradata, limitedStack, limitedSells, teamColor); + InteractionFreezeScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java index 9c005626..b9fda992 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardBlue extends InteractionFreezeScoreboard super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java index 3ce66539..9aa9ebca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardGreen extends InteractionFreezeScoreboar super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java index 9846fa55..719299bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardRed extends InteractionFreezeScoreboard super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java index 1c9d94e0..59b2d384 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardYellow extends InteractionFreezeScoreboa super(set, baseItem, TEAM_COLOR); } - public InteractionFreezeScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR); + public InteractionFreezeScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR); } } 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 8020fdfe..dce84c97 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 @@ -7,6 +7,7 @@ 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -21,8 +22,8 @@ public abstract class InteractionTagField extends RoomItem { this.gameClazz = gameClazz; } - public InteractionTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, Class gameClazz) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTagField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, Class gameClazz) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.gameClazz = gameClazz; } @@ -75,7 +76,7 @@ public abstract class InteractionTagField extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java index e1f04890..e07f0388 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java @@ -2,8 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag; import com.eu.habbo.habbohotel.items.Item; 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class InteractionTagPole extends RoomItem { super(set, baseItem); } - public InteractionTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTagPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -36,13 +37,13 @@ public class InteractionTagPole extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java index 6c2f5bca..bd902eb8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -16,15 +17,15 @@ public class InteractionBunnyrunField extends InteractionTagField { super(set, baseItem, BunnyrunGame.class); } - public InteractionBunnyrunField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, BunnyrunGame.class); + public InteractionBunnyrunField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, BunnyrunGame.class); } @Override public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbBunnyTag")); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java index 9c0ae732..1573f4e5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionBunnyrunPole extends InteractionTagPole { super(set, baseItem); } - public InteractionBunnyrunPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionBunnyrunPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } } \ No newline at end of file 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 0e24397f..34901520 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -20,8 +21,8 @@ public class InteractionIceTagField extends InteractionTagField { super(set, baseItem, IceTagGame.class); } - public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, IceTagGame.class); + public InteractionIceTagField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, IceTagGame.class); } @Override @@ -48,7 +49,7 @@ public class InteractionIceTagField extends InteractionTagField { public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagA")); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java index b2fe44c0..78a1c4f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.icetag; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -11,7 +12,7 @@ public class InteractionIceTagPole extends InteractionTagPole { super(set, baseItem); } - public InteractionIceTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionIceTagPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } } \ No newline at end of file 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 34bd18a3..0511e567 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -20,8 +21,8 @@ public class InteractionRollerskateField extends InteractionTagField { super(set, baseItem, RollerskateGame.class); } - public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells, RollerskateGame.class); + public InteractionRollerskateField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells, RollerskateGame.class); } @Override @@ -48,7 +49,7 @@ public class InteractionRollerskateField extends InteractionTagField { public void onPlace(Room room) { super.onPlace(room); - Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerId()); + Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId()); if (itemOwner != null) { AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagA")); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java index b3304ea5..f4349444 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java @@ -4,8 +4,9 @@ import com.eu.habbo.Emulator; 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.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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; @@ -15,17 +16,17 @@ public class InteractionMonsterPlantSeed extends RoomItem { public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - if (this.getExtradata().isEmpty()) { - this.setExtradata("" + randomRarityLevel()); + if (this.getExtraData().isEmpty()) { + this.setExtraData("" + randomRarityLevel()); this.needsUpdate(true); } } - public InteractionMonsterPlantSeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionMonsterPlantSeed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); - if (this.getExtradata().isEmpty()) { - this.setExtradata("" + randomRarityLevel()); + if (this.getExtraData().isEmpty()) { + this.setExtraData("" + randomRarityLevel()); this.needsUpdate(true); } } @@ -78,7 +79,7 @@ public class InteractionMonsterPlantSeed extends RoomItem { serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0)); serverMessage.appendInt(1); serverMessage.appendString("rarity"); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java index dcd7e9a7..253535ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; @@ -20,14 +21,14 @@ public class InteractionNest extends RoomItem { super(set, baseItem); } - public InteractionNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionNest(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -71,10 +72,10 @@ public class InteractionNest extends RoomItem { return; pet.setTask(PetTasks.NEST); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getX(), this.getY(), false) + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false) + ""); room.sendComposer(new UserUpdateComposer(roomUnit).compose()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index 75ec69b4..f2e18be4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -10,6 +10,7 @@ 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.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.pets.PerkAllowancesComposer; import com.eu.habbo.messages.outgoing.rooms.pets.breeding.ConfirmBreedingRequestComposer; @@ -27,8 +28,8 @@ public class InteractionPetBreedingNest extends RoomItem { super(set, baseItem); } - public InteractionPetBreedingNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPetBreedingNest(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -45,7 +46,7 @@ public class InteractionPetBreedingNest extends RoomItem { @Override public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); + serverMessage.appendString(this.getExtraData()); super.serializeExtradata(serverMessage); } @@ -68,7 +69,7 @@ public class InteractionPetBreedingNest extends RoomItem { if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) { ownerPetTwo.getClient().sendResponse(new ConfirmBreedingRequestComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername())); - this.setExtradata("1"); + this.setExtraData("1"); room.updateItem(this); } } @@ -98,7 +99,7 @@ public class InteractionPetBreedingNest extends RoomItem { if (this.petOne != null && this.petOne.getRoomUnit() == roomUnit) this.petOne = null; if (this.petTwo != null && this.petTwo.getRoomUnit() == roomUnit) this.petTwo = null; - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); } @@ -108,7 +109,7 @@ public class InteractionPetBreedingNest extends RoomItem { } public void stopBreeding(Habbo habbo) { - this.setExtradata("0"); + this.setExtraData("0"); habbo.getRoomUnit().getRoom().updateItem(this); if (this.petOne != null) { @@ -142,7 +143,7 @@ public class InteractionPetBreedingNest extends RoomItem { public void breed(Habbo habbo, String name) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId())); - this.setExtradata("2"); + this.setExtraData("2"); habbo.getRoomUnit().getRoom().updateItem(this); RoomItem box = this; @@ -151,8 +152,7 @@ public class InteractionPetBreedingNest extends RoomItem { Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient()); - - habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getX(), box.getY(), box.getZ()); + habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ()); offspring.setNeedsUpdate(true); offspring.run(); InteractionPetBreedingNest.this.freePets(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index e5762342..1b6a04a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -13,6 +13,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.PetClearPosture; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import org.slf4j.Logger; @@ -31,13 +32,13 @@ public class InteractionPetDrink extends InteractionDefault { super(set, baseItem); } - public InteractionPetDrink(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPetDrink(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public boolean canToggle(Habbo habbo, Room room) { - return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentPosition()); + return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition()); } @Override @@ -47,7 +48,7 @@ public class InteractionPetDrink extends InteractionDefault { if (!this.canToggle(client.getHabbo(), room)) { RoomTile closestTile = null; - for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { + for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) { if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) { closestTile = tile; } @@ -68,17 +69,17 @@ public class InteractionPetDrink extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata() == null || this.getExtradata().isEmpty()) - this.setExtradata("0"); + if (this.getExtraData() == null || this.getExtraData().isEmpty()) + this.setExtraData("0"); Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) { pet.clearPosture(); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); Emulator.getThreading().run(() -> { @@ -102,12 +103,12 @@ public class InteractionPetDrink extends InteractionDefault { private void change(Room room, int amount) { int state = 0; - if (this.getExtradata() == null || this.getExtradata().isEmpty()) { - this.setExtradata("0"); + if (this.getExtraData() == null || this.getExtraData().isEmpty()) { + this.setExtraData("0"); } try { - state = Integer.parseInt(this.getExtradata()); + state = Integer.parseInt(this.getExtraData()); } catch (Exception e) { LOGGER.error("Caught exception", e); } @@ -121,7 +122,7 @@ public class InteractionPetDrink extends InteractionDefault { state = 0; } - this.setExtradata(state + ""); + this.setExtraData(state + ""); this.needsUpdate(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java index 8b9e5388..8bdf3757 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.threading.runnables.PetEatAction; @@ -20,16 +21,16 @@ public class InteractionPetFood extends InteractionDefault { super(set, baseItem); } - public InteractionPetFood(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPetFood(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata().length() == 0) - this.setExtradata("0"); + if (this.getExtraData().length() == 0) + this.setExtraData("0"); Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); @@ -37,11 +38,11 @@ public class InteractionPetFood extends InteractionDefault { if (pet.getPetData().haveFoodItem(this)) { if (pet.levelHunger >= 35) { pet.setTask(PetTasks.EAT); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, "0"); + pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, "0"); room.sendComposer(new UserUpdateComposer(roomUnit).compose()); Emulator.getThreading().run(new PetEatAction(pet, this)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index a3af6600..b53a95ce 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -13,6 +13,7 @@ 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.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -21,19 +22,19 @@ import java.sql.SQLException; public class InteractionPetToy extends InteractionDefault { public InteractionPetToy(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionPetToy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionPetToy(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override public void onClick(GameClient client, Room room, Object[] objects) {} @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { @@ -43,7 +44,7 @@ public class InteractionPetToy extends InteractionDefault { } @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); for (Pet pet : room.getPetsOnItem(this)) { pet.getRoomUnit().clearStatuses(); @@ -57,28 +58,30 @@ public class InteractionPetToy extends InteractionDefault { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); - if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { - if (pet.getEnergy() <= 35) { - return; - } + if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { + if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { + if (pet.getEnergy() <= 35) { + return; + } - pet.setTask(PetTasks.PLAY); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY())); - pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); - pet.setPacketUpdate(true); - RoomItem item = this; - Emulator.getThreading().run(() -> { - pet.addHappiness(25); - item.setExtradata("0"); - room.updateItem(item); + pet.setTask(PetTasks.PLAY); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); - new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run(); + pet.getRoomUnit().addStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); pet.setPacketUpdate(true); - }, ((long)(Emulator.getRandom().nextInt(20) * 500) + 2500)); - this.setExtradata("1"); - room.updateItemState(this); + RoomItem item = this; + Emulator.getThreading().run(() -> { + pet.addHappiness(25); + item.setExtraData("0"); + room.updateItem(item); + pet.getRoomUnit().clearStatuses(); + new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run(); + pet.setPacketUpdate(true); + }, ((long) (Emulator.getRandom().nextInt(20) * 500) + 2500)); + this.setExtraData("1"); + room.updateItemState(this); + } } } @@ -89,7 +92,7 @@ public class InteractionPetToy extends InteractionDefault { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java index cadb17a2..4361f4d6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -11,6 +11,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -19,12 +20,12 @@ import java.sql.SQLException; public class InteractionPetTrampoline extends InteractionDefault { public InteractionPetTrampoline(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + this.setExtraData("0"); } - public InteractionPetTrampoline(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + public InteractionPetTrampoline(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); + this.setExtraData("0"); } @Override @@ -32,7 +33,7 @@ public class InteractionPetTrampoline extends InteractionDefault { @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { @@ -43,7 +44,7 @@ public class InteractionPetTrampoline extends InteractionDefault { @Override public void onPickUp(Room room) { - this.setExtradata("0"); + this.setExtraData("0"); for (Pet pet : room.getPetsOnItem(this)) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); @@ -57,24 +58,26 @@ public class InteractionPetTrampoline extends InteractionDefault { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); - if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { - if (pet.getEnergy() <= 35) { - return; - } + if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { + if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { + if (pet.getEnergy() <= 35) { + return; + } - pet.clearPosture(); - pet.setTask(PetTasks.JUMP); - pet.getRoomUnit().setStatus(RoomUnitStatus.JUMP, ""); - Emulator.getThreading().run(() -> { - new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false); - pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile()); - this.setExtradata("0"); + pet.clearPosture(); + pet.setTask(PetTasks.JUMP); + pet.getRoomUnit().addStatus(RoomUnitStatus.JUMP, ""); + Emulator.getThreading().run(() -> { + new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false); + pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile()); + this.setExtraData("0"); + room.updateItemState(this); + }, 4000); + pet.addHappiness(25); + + this.setExtraData("1"); room.updateItemState(this); - }, 4000); - pet.addHappiness(25); - - this.setExtradata("1"); - room.updateItemState(this); + } } } @@ -85,7 +88,7 @@ public class InteractionPetTrampoline extends InteractionDefault { Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); if (pet != null) { - this.setExtradata("0"); + this.setExtraData("0"); room.updateItem(this); pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); pet.setPacketUpdate(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index 2be0541d..1b381e01 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.threading.runnables.PetClearPosture; import java.sql.ResultSet; @@ -20,8 +21,8 @@ public class InteractionPetTree extends InteractionDefault { super(set, baseItem); } - public InteractionPetTree(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionPetTree(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -44,38 +45,40 @@ public class InteractionPetTree extends InteractionDefault { super.onWalkOn(roomUnit, room, objects); Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); - if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) { - RoomUnitStatus task = switch (pet.getTask()) { - case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE; - case SWING -> RoomUnitStatus.SWING; - case ROLL -> RoomUnitStatus.ROLL; - default -> RoomUnitStatus.HANG; - }; - if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) { + if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { + if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { + RoomUnitStatus task = switch (pet.getTask()) { + case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE; + case SWING -> RoomUnitStatus.SWING; + case ROLL -> RoomUnitStatus.ROLL; + default -> RoomUnitStatus.HANG; + }; + if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) { - pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); - pet.setPacketUpdate(true); - RoomUnitStatus finalTask = task; - Emulator.getThreading().run(() -> { - pet.addHappiness(25); - pet.getRoomUnit().clearStatuses(); - new PetClearPosture(pet, finalTask, null, true); - if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentPosition())) { - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); - } else { - pet.clearPosture(); - } - pet.getRoomUnit().setCanWalk(true); - pet.setPacketUpdate(true); - }, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500)); - } else { - pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); - pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); - pet.setPacketUpdate(true); + pet.getRoomUnit().setCanWalk(false); + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().addStatus(task, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.setPacketUpdate(true); + RoomUnitStatus finalTask = task; + Emulator.getThreading().run(() -> { + pet.addHappiness(25); + pet.getRoomUnit().clearStatuses(); + new PetClearPosture(pet, finalTask, null, true); + if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentPosition())) { + pet.getRoomUnit().addStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + } else { + pet.clearPosture(); + } + pet.getRoomUnit().setCanWalk(true); + pet.setPacketUpdate(true); + }, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500)); + } else { + pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); + pet.getRoomUnit().clearStatuses(); + pet.getRoomUnit().addStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.setPacketUpdate(true); + } } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index f71e82b4..938a940f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -17,14 +18,14 @@ public class InteractionTotemHead extends InteractionDefault { super(set, baseItem); } - public InteractionTotemHead(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTotemHead(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public TotemType getTotemType() { int extraData; try { - extraData = Integer.parseInt(this.getExtradata()); + extraData = Integer.parseInt(this.getExtraData()); } catch(NumberFormatException ex) { extraData = 0; } @@ -37,7 +38,7 @@ public class InteractionTotemHead extends InteractionDefault { public TotemColor getTotemColor() { int extraData; try { - extraData = Integer.parseInt(this.getExtradata()); + extraData = Integer.parseInt(this.getExtraData()); }catch(NumberFormatException ex) { extraData = 0; } @@ -51,22 +52,23 @@ public class InteractionTotemHead extends InteractionDefault { InteractionTotemLegs legs = null; for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) { - if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) - legs = (InteractionTotemLegs)item; + if(item instanceof InteractionTotemLegs) { + if (item.getCurrentZ() < this.getCurrentZ()) legs = (InteractionTotemLegs) item; + } } if(legs == null) return; - this.setExtradata(((4 * this.getTotemType().getType()) + legs.getTotemColor().getColor()) - 1 + ""); + this.setExtraData(((4 * this.getTotemType().getType()) + legs.getTotemColor().getColor()) - 1 + ""); } public void updateTotemState(Room room) { - updateTotemState(room, room.getLayout().getTile(this.getX(), this.getY())); + updateTotemState(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); } public void updateTotemState(Room room, RoomTile tile) { - this.setExtradata(getTotemType().getType() - 1 + ""); + this.setExtraData(getTotemType().getType() - 1 + ""); update(room, tile); this.needsUpdate(true); room.updateItem(this); @@ -82,7 +84,7 @@ public class InteractionTotemHead extends InteractionDefault { newType = TotemType.TROLL; } - this.setExtradata(newType.getType() - 1 + ""); + this.setExtraData(newType.getType() - 1 + ""); updateTotemState(room); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index 6648d9d3..db588c04 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -16,14 +17,14 @@ public class InteractionTotemLegs extends InteractionDefault { super(set, baseItem); } - public InteractionTotemLegs(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTotemLegs(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public TotemType getTotemType() { int extraData; try { - extraData = Integer.parseInt(this.getExtradata()); + extraData = Integer.parseInt(this.getExtraData()); } catch(NumberFormatException ex) { extraData = 0; } @@ -33,7 +34,7 @@ public class InteractionTotemLegs extends InteractionDefault { public TotemColor getTotemColor() { int extraData; try { - extraData = Integer.parseInt(this.getExtradata()); + extraData = Integer.parseInt(this.getExtraData()); } catch(NumberFormatException ex) { extraData = 0; } @@ -42,8 +43,9 @@ public class InteractionTotemLegs extends InteractionDefault { private void updateHead(Room room, RoomTile tile) { for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) { - if(item instanceof InteractionTotemHead && item.getZ() > this.getZ()) - ((InteractionTotemHead)item).updateTotemState(room); + if(item instanceof InteractionTotemHead) { + if (item.getCurrentZ() > this.getCurrentZ()) ((InteractionTotemHead) item).updateTotemState(room); + } } } @@ -54,7 +56,7 @@ public class InteractionTotemLegs extends InteractionDefault { if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) return; - updateHead(room, room.getLayout().getTile(this.getX(), this.getY())); + updateHead(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index 45bd77df..fae2bab2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; 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.users.HabboInfo; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -16,14 +17,14 @@ public class InteractionTotemPlanet extends InteractionDefault { super(set, baseItem); } - public InteractionTotemPlanet(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public InteractionTotemPlanet(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public TotemPlanetType getPlanetType() { int extraData; try { - extraData = Integer.parseInt(this.getExtradata()); + extraData = Integer.parseInt(this.getExtraData()); } catch(NumberFormatException ex) { extraData = 0; } @@ -32,7 +33,7 @@ public class InteractionTotemPlanet extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if(client.getHabbo().getHabboInfo().getId() != this.getOwnerId()) { + if(client.getHabbo().getHabboInfo().getId() != this.getOwnerInfo().getId()) { super.onClick(client, room, objects); return; } @@ -40,12 +41,13 @@ public class InteractionTotemPlanet extends InteractionDefault { InteractionTotemLegs legs = null; InteractionTotemHead head = null; - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); THashSet items = room.getRoomItemManager().getItemsAt(tile); for(RoomItem item : items) { - if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) - legs = (InteractionTotemLegs)item; + if(item instanceof InteractionTotemLegs) { + if (item.getCurrentZ() < this.getCurrentZ()) legs = (InteractionTotemLegs) item; + } } if(legs == null) { @@ -54,8 +56,9 @@ public class InteractionTotemPlanet extends InteractionDefault { } for(RoomItem item : items) { - if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ()) - head = (InteractionTotemHead)item; + if(item instanceof InteractionTotemHead) { + if (item.getCurrentZ() > legs.getCurrentZ()) head = (InteractionTotemHead) item; + } } if(head == null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index ceb229a5..ab5860ef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -31,14 +32,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { /** * Creates a new instance of this class. * @param id The ID of this item. - * @param userId The ID of the user that owns this item. + * @param ownerInfo The info of the user that owns this item. * @param item The item this instance is associated with. * @param extradata Additional data associated with this item. * @param limitedStack The amount of items in this stack (if this item is stackable). * @param limitedSells The amount of items that can be sold from this stack (if this item is sellable). */ - public WiredConditionDateRangeActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionDateRangeActive(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } /** diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index b64aa729..cd6e7266 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -18,8 +19,8 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionFurniHaveFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -32,15 +33,21 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { if (allFurni) { return this.getWiredSettings().getItems(room).stream().allMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + double minZ = item.getCurrentZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> { + if (matchedItem == item) return false; + return matchedItem.getCurrentZ() >= minZ; + })); }); } else { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + double minZ = item.getCurrentZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> { + if (matchedItem == item) return false; + return matchedItem.getCurrentZ() >= minZ; + })); }); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java index be439213..498f74ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java @@ -8,6 +8,7 @@ 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.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -20,8 +21,8 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionFurniHaveRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionFurniHaveRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -35,7 +36,7 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition { Collection pets = room.getRoomUnitManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().allMatch(item -> { - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index cf5f08b3..7e32cc42 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionFurniTypeMatch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 27551a22..243bc2f6 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionGroupMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionGroupMember(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index f3de4bfe..439d7842 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionLessTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionLessTimeElapsed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index d5d4c95a..148fe15e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -4,8 +4,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import lombok.Getter; @@ -26,8 +27,8 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition super(set, baseItem); } - public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionMatchStatePosition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -49,13 +50,13 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } if(state) { - if(!item.getExtradata().equals(furniSettings.getState())) { + if(!item.getExtraData().equals(furniSettings.getState())) { return false; } } if(position) { - if (!(furniSettings.getX() == item.getX() && furniSettings.getY() == item.getY())) { + if (!(furniSettings.getX() == item.getCurrentPosition().getX() && furniSettings.getY() == item.getCurrentPosition().getY())) { return false; } } @@ -84,7 +85,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition List matchSettings = new ArrayList<>(); for (RoomItem item : this.getWiredSettings().getItems(room)) { - WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()); + WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), item.getExtraData(), item.getRotation(), item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); matchSettings.add(settings); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index e22a6d4e..4b968654 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionMoreTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionMoreTimeElapsed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 38441142..7d6c9d76 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -19,8 +20,8 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionNotFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotFurniHaveFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -33,16 +34,22 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { if(allFurni) { return this.getWiredSettings().getItems(room).stream().allMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + double minZ = item.getCurrentZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> { + if (matchedItem == item) return false; + return matchedItem.getCurrentZ() >= minZ; + })); }); } else { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { - double minZ = item.getZ() + Item.getCurrentHeight(item); - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); - return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); + double minZ = item.getCurrentZ() + Item.getCurrentHeight(item); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> { + if (matchedItem == item) return false; + return matchedItem.getCurrentZ() >= minZ; + })); }); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java index 60d9c148..bd60b14a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java @@ -8,6 +8,7 @@ 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.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -20,8 +21,8 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionNotFurniHaveRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotFurniHaveRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -35,7 +36,7 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition { Collection pets = room.getRoomUnitManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().noneMatch(item -> { - THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) || pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index 41a5c697..932842aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java @@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -19,8 +20,8 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionNotFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotFurniTypeMatch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 28ea52a1..1b4450a1 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionNotInGroup(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotInGroup(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 98654167..e8ada995 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -19,8 +20,8 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionNotInTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotInTeam(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java index 9f0378d0..b708916e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStat super(set, baseItem); } - public WiredConditionNotMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotMatchStatePosition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java index 0573a042..6c9260c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class WiredConditionNotRoomCount extends WiredConditionRoomCount { super(set, baseItem); } - public WiredConditionNotRoomCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotRoomCount(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java index 68b0983d..185eff52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -13,8 +14,8 @@ public class WiredConditionNotRoomHasEffect extends WiredConditionRoomHasEffect super(set, baseItem); } - public WiredConditionNotRoomHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotRoomHasEffect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java index f95791d6..c58c97c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredConditionNotRoomWearsBadge extends WiredConditionRoomWearsBadg super(set, baseItem); } - public WiredConditionNotRoomWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotRoomWearsBadge(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java index 54fd82c7..322a82d9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurn super(set, baseItem); } - public WiredConditionNotTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionNotTriggerOnFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java index 227e5ff0..bd80c4a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredConditionRoomCount extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionRoomCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionRoomCount(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java index a9dcf93d..63d97b87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredConditionRoomHasEffect extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionRoomHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionRoomHasEffect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java index 63a4f242..7cbcd262 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import lombok.extern.slf4j.Slf4j; @@ -19,13 +20,13 @@ public class WiredConditionRoomHasHandItem extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionRoomHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionRoomHasHandItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - if (roomUnit == null || !(roomUnit instanceof RoomAvatar roomAvatar)) { + if (!(roomUnit instanceof RoomAvatar roomAvatar)) { return false; } 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 24919fde..415a4c3e 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room; 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -16,8 +17,8 @@ public class WiredConditionRoomWearsBadge extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionRoomWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionRoomWearsBadge(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 c88d9631..fe4763a2 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionType; import java.sql.ResultSet; @@ -19,8 +20,8 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionTeamMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionTeamMember(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index e1601d17..92a564a3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; import gnu.trove.set.hash.THashSet; @@ -17,8 +18,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { super(set, baseItem); } - public WiredConditionTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredConditionTriggerOnFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 058b5e42..7455518f 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,8 +15,8 @@ public class WiredEffectAlert extends WiredEffectWhisper { super(set, baseItem); } - public WiredEffectAlert(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectAlert(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index 37718273..cef31e8d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotClothes(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotClothes(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 8954d19f..f7f29026 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 @@ -1,12 +1,15 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.threading.runnables.BotFollowHabbo; import java.sql.ResultSet; import java.sql.SQLException; @@ -19,8 +22,8 @@ public class WiredEffectBotFollowRoom extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotFollowRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotFollowRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -32,9 +35,10 @@ public class WiredEffectBotFollowRoom extends InteractionWiredEffect { Bot bot = bots.get(0); if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) { - bot.startFollowingHabbo(habbo); + bot.setFollowingHabboId(habbo.getHabboInfo().getId()); + Emulator.getThreading().run(new BotFollowHabbo(bot, habbo, habbo.getRoomUnit().getRoom())); } else { - bot.stopFollowingHabbo(); + bot.setFollowingHabboId(0); } return true; 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 cc037fbc..1bd29b60 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -26,8 +27,8 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotGiveHandItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 f81f59b9..8377b39c 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -22,8 +23,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotTalk(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotTalk(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 29cc3fad..a74dd952 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -22,8 +23,8 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotTalkToRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotTalkToRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 a45622a4..930c2c09 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 @@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; @@ -26,8 +27,8 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotTeleport(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -53,7 +54,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { Room room1 = bot.getRoom(); if (item.getRoomId() == room1.getRoomInfo().getId()) { if (i == j) { - teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY())); + teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); return true; } else { j++; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index 52d798df..cafd087c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -19,8 +20,8 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectBotWalkToFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -55,7 +56,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { if (item.getRoomId() != 0) { Room room1 = bot.getRoom(); if (item.getRoomId() == room1.getRoomInfo().getId()) { - bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY())); + bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 38da5f61..91e4b76a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -10,6 +10,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -44,8 +45,8 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { this.itemsSettings = new HashMap<>(); } - public WiredEffectChangeFurniDirection(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectChangeFurniDirection(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.itemsSettings = new HashMap<>(); } @@ -85,12 +86,12 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection) ); - RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); + RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), setting.getDirection().getValue()); int count = 1; while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.getLayout().tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) { setting.setDirection(this.nextDirection(setting.getDirection())); - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), setting.getDirection().getValue()); if (tile != null && tile.getState() != RoomTileState.INVALID) { targetTile = tile; } @@ -100,7 +101,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { int newDirectionValue = setting.getDirection().getValue(); - RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirectionValue); + RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), newDirectionValue); if(item.getRotation() != setting.getRotation()) { if(room.getRoomItemManager().furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE) @@ -124,10 +125,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) { if (!hasRoomUnits) { - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + double oldZ = item.getCurrentZ(); if (room.getRoomItemManager().moveItemTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getCurrentZ(), 0, room).compose()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java index 947444e6..bbf01674 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveEffect.java @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,8 +14,8 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper { super(set, baseItem); } - public WiredEffectGiveEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveEffect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 bcdf33c9..52992a2d 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 @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper { super(set, baseItem); } - public WiredEffectGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveHandItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 500c6bfb..89052f26 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.hotelview.BonusRareInfoMessageComposer; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends WiredEffectWhisper super(set, baseItem); } - public WiredEffectGiveHotelviewBonusRarePoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveHotelviewBonusRarePoints(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 041c99f7..8e7db2a9 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -16,8 +17,8 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectGiveHotelviewHofPoints(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveHotelviewHofPoints(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 e26332f6..28d42cfe 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectGiveRespect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveRespect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public WiredEffectType getType() { 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 67d46f1d..96b552bc 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -31,8 +32,8 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectGiveReward(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveReward(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 8be92006..47f4b591 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import gnu.trove.iterator.TObjectIntIterator; import gnu.trove.map.TObjectIntMap; @@ -25,8 +26,8 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectGiveScore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveScore(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 6df99b14..7507c887 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import gnu.trove.map.hash.TIntIntHashMap; @@ -22,8 +23,8 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; - public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectGiveScoreToTeam(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } public WiredEffectGiveScoreToTeam(ResultSet set, Item baseItem) throws SQLException { 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 7d9fd773..3b0c7695 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -21,8 +22,8 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectJoinTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectJoinTeam(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 12523f21..fd258d8e 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; import com.eu.habbo.threading.runnables.RoomUnitKick; @@ -21,8 +22,8 @@ public class WiredEffectKickRoom extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectKickRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectKickRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 c85bb9b5..40d38583 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 @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectLeaveTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectLeaveTeam(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index b7e72b6a..2d6b44d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -33,8 +34,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int super(set, baseItem); } - public WiredEffectMatchFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMatchFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -56,14 +57,14 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } if (state && (this.checkForWiredResetPermission && item.allowWiredResetState())) { - if (!furniSettings.getState().equals(" ") && !item.getExtradata().equals(furniSettings.getState())) { - item.setExtradata(furniSettings.getState()); + if (!furniSettings.getState().equals(" ") && !item.getExtraData().equals(furniSettings.getState())) { + item.setExtraData(furniSettings.getState()); room.updateItemState(item); } } - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + double oldZ = item.getCurrentZ(); if(rotation && !position) { if (item.getRotation() != furniSettings.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) { @@ -79,7 +80,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int boolean sendUpdates = !slideAnimation; if (room.getRoomItemManager().moveItemTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { if (slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getCurrentZ(), 0, room).compose()); } } } @@ -103,7 +104,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int List matchSettings = new ArrayList<>(); for (RoomItem item : this.getWiredSettings().getItems(room)) { - WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY()); + WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtraData() : " ", item.getRotation(), item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); matchSettings.add(settings); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index fea4a33f..0863a048 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -23,14 +24,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectMoveFurniAway(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMoveFurniAway(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { for (RoomItem item : this.getWiredSettings().getItems(room)) { - RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); + RoomTile t = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); RoomUnit target = room.getRoomUnitManager().getCurrentRoomUnits().values().stream().min(Comparator.comparingDouble(a -> a.getCurrentPosition().distance(t))).orElse(null); @@ -43,25 +44,25 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { int x = 0; int y = 0; - if (target.getCurrentPosition().getX() == item.getX()) { - if (item.getY() < target.getCurrentPosition().getY()) + if (target.getCurrentPosition().getX() == item.getCurrentPosition().getX()) { + if (item.getCurrentPosition().getY() < target.getCurrentPosition().getY()) y--; else y++; } else { - if (target.getCurrentPosition().getY() == item.getY()) { - if (item.getX() < target.getCurrentPosition().getX()) + if (target.getCurrentPosition().getY() == item.getCurrentPosition().getY()) { + if (item.getCurrentPosition().getX() < target.getCurrentPosition().getX()) x--; else x++; } else { - if (target.getCurrentPosition().getX() - item.getX() > target.getCurrentPosition().getY() - item.getY()) { - if (target.getCurrentPosition().getX() - item.getX() > 0) + if (target.getCurrentPosition().getX() - item.getCurrentPosition().getX() > target.getCurrentPosition().getY() - item.getCurrentPosition().getY()) { + if (target.getCurrentPosition().getX() - item.getCurrentPosition().getX() > 0) x--; else x++; } else { - if (target.getCurrentPosition().getY() - item.getY() > 0) + if (target.getCurrentPosition().getY() - item.getCurrentPosition().getY() > 0) y--; else y++; @@ -69,13 +70,13 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { } } - RoomTile newLocation = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y)); - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile newLocation = room.getLayout().getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); + RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + double oldZ = item.getCurrentZ(); if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.getRoomItemManager().furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) { if (room.getRoomItemManager().moveItemTo(item, newLocation, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getCurrentZ(), 0, room).compose()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index a6bb37ee..f1a2126a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -5,8 +5,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; 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.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -22,8 +23,8 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectMoveFurniTo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMoveFurniTo(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -50,10 +51,10 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { if (randomItem != null) { int indexOffset = 0; - RoomTile objectTile = room.getLayout().getTile(randomItem.getX(), randomItem.getY()); + RoomTile objectTile = room.getLayout().getTile(randomItem.getCurrentPosition().getX(), randomItem.getCurrentPosition().getY()); if (objectTile != null) { - THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getX(), ((RoomItem) object).getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation()); + THashSet refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getCurrentPosition().getX(), ((RoomItem) object).getCurrentPosition().getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation()); RoomTile tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); if (tile == null || !tile.getAllowStack()) { @@ -61,8 +62,8 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { tile = room.getLayout().getTileInFront(objectTile, direction, indexOffset); } - room.sendComposer(new FloorItemOnRollerComposer((RoomItem) object, null, tile, tile.getStackHeight() - ((RoomItem) object).getZ(), room).compose()); - refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getX(), ((RoomItem) object).getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation())); + room.sendComposer(new FloorItemOnRollerComposer((RoomItem) object, null, tile, tile.getStackHeight() - ((RoomItem) object).getCurrentZ(), room).compose()); + refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((RoomItem) object).getCurrentPosition().getX(), ((RoomItem) object).getCurrentPosition().getY()), ((RoomItem) object).getBaseItem().getWidth(), ((RoomItem) object).getBaseItem().getLength(), ((RoomItem) object).getRotation())); room.updateTiles(refreshTiles); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index b6041ae0..dba15814 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -7,6 +7,7 @@ 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.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.threading.runnables.WiredCollissionRunnable; @@ -32,8 +33,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { this.lastDirections = new THashMap<>(); } - public WiredEffectMoveFurniTowards(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMoveFurniTowards(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.lastDirections = new THashMap<>(); } @@ -41,7 +42,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { List availableDirections = new ArrayList<>(); RoomLayout layout = room.getLayout(); - RoomTile currentTile = layout.getTile(item.getX(), item.getY()); + RoomTile currentTile = layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); RoomRotation[] rotations = new RoomRotation[]{RoomRotation.NORTH, RoomRotation.EAST, RoomRotation.SOUTH, RoomRotation.WEST}; @@ -96,7 +97,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { RoomRotation[] rotations = new RoomRotation[]{RoomRotation.NORTH, RoomRotation.EAST, RoomRotation.SOUTH, RoomRotation.WEST}; for (RoomRotation rot : rotations) { - RoomTile startTile = layout.getTile(item.getX(), item.getY()); + RoomTile startTile = layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); for (int ii = 0; ii <= i; ii++) { if (startTile == null) @@ -123,25 +124,25 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { continue; if (target != null) { - if (target.getCurrentPosition().getX() == item.getX()) { - if (item.getY() < target.getCurrentPosition().getY()) + if (target.getCurrentPosition().getX() == item.getCurrentPosition().getX()) { + if (item.getCurrentPosition().getY() < target.getCurrentPosition().getY()) moveDirection = RoomRotation.SOUTH; else moveDirection = RoomRotation.NORTH; } else { - if (target.getCurrentPosition().getY() == item.getY()) { - if (item.getX() < target.getCurrentPosition().getX()) + if (target.getCurrentPosition().getY() == item.getCurrentPosition().getY()) { + if (item.getCurrentPosition().getX() < target.getCurrentPosition().getX()) moveDirection = RoomRotation.EAST; else moveDirection = RoomRotation.WEST; } else { - if (target.getCurrentPosition().getX() - item.getX() > target.getCurrentPosition().getY() - item.getY()) { - if (target.getCurrentPosition().getX() - item.getX() > 0) + if (target.getCurrentPosition().getX() - item.getCurrentPosition().getX() > target.getCurrentPosition().getY() - item.getCurrentPosition().getY()) { + if (target.getCurrentPosition().getX() - item.getCurrentPosition().getX() > 0) moveDirection = RoomRotation.EAST; else moveDirection = RoomRotation.WEST; } else { - if (target.getCurrentPosition().getY() - item.getY() > 0) + if (target.getCurrentPosition().getY() - item.getCurrentPosition().getY() > 0) moveDirection = RoomRotation.SOUTH; else moveDirection = RoomRotation.NORTH; @@ -193,16 +194,16 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } } - RoomTile newTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), moveDirection.getValue()); + RoomTile newTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), moveDirection.getValue()); - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + double oldZ = item.getCurrentZ(); if(newTile != null) { lastDirections.put(item.getId(), moveDirection); if (newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.getRoomItemManager().furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) { if (room.getRoomItemManager().moveItemTo(item, newTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getCurrentZ(), 0, room).compose()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 24346c91..d18fe1e1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -11,6 +11,7 @@ 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -29,8 +30,8 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement super(set, baseItem); } - public WiredEffectMoveRotateFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMoveRotateFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -52,15 +53,15 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement for (RoomItem item : this.getWiredSettings().getItems(room)) { int newRotation = rotation > 0 ? this.getNewRotation(item, rotation) : item.getRotation(); - RoomTile newLocation = room.getLayout().getTile(item.getX(), item.getY()); - RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY()); - double oldZ = item.getZ(); + RoomTile newLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + double oldZ = item.getCurrentZ(); if(direction > 0) { RoomRotation moveDirection = this.getMovementDirection(direction); newLocation = room.getLayout().getTile( - (short) (item.getX() + ((moveDirection == RoomRotation.WEST || moveDirection == RoomRotation.NORTH_WEST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomRotation.EAST || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.NORTH_EAST) ? 1 : 0)))), - (short) (item.getY() + ((moveDirection == RoomRotation.NORTH || moveDirection == RoomRotation.NORTH_EAST || moveDirection == RoomRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomRotation.SOUTH || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : 0))) + (short) (item.getCurrentPosition().getX() + ((moveDirection == RoomRotation.WEST || moveDirection == RoomRotation.NORTH_WEST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomRotation.EAST || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.NORTH_EAST) ? 1 : 0)))), + (short) (item.getCurrentPosition().getY() + ((moveDirection == RoomRotation.NORTH || moveDirection == RoomRotation.NORTH_EAST || moveDirection == RoomRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomRotation.SOUTH || moveDirection == RoomRotation.SOUTH_EAST || moveDirection == RoomRotation.SOUTH_WEST) ? -1 : 0))) ); } @@ -72,7 +73,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement boolean sendUpdates = !slideAnimation; if (room.getRoomItemManager().moveItemTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) { if (slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getCurrentZ(), 0, room).compose()); } } } 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 a7917d16..53c1b449 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; @@ -21,8 +22,8 @@ public class WiredEffectMuteRoom extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectMuteRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectMuteRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 85d12667..3c49cab4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.threading.runnables.WiredResetTimers; @@ -16,8 +17,8 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectResetTimers(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectResetTimers(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 7f75979d..5172ea41 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; @@ -31,8 +32,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect { this.items = new ArrayList<>(); } - public WiredEffectTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectTeleport(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.items = new ArrayList<>(); } @@ -48,7 +49,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { RoomItem randomItem = items[randomItemIndex]; - teleportUnitToTile(roomUnit, room.getLayout().getTile(randomItem.getX(), randomItem.getY())); + teleportUnitToTile(roomUnit, room.getLayout().getTile(randomItem.getCurrentPosition().getX(), randomItem.getCurrentPosition().getY())); return true; } 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 151120d4..11ce95c7 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 @@ -17,6 +17,7 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import lombok.extern.slf4j.Slf4j; @@ -73,8 +74,8 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectToggleFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { - super(id, userId, item, extraData, limitedStack, limitedSells); + public WiredEffectToggleFurni(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extraData, limitedStack, limitedSells); } @Override @@ -98,9 +99,9 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer) { int state = 0; - if (!item.getExtradata().isEmpty()) { + if (!item.getExtraData().isEmpty()) { try { - state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc. + state = Integer.parseInt(item.getExtraData()); // assumes that extradata is state, could be something else for trophies etc. } catch (NumberFormatException ignored) { } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index d5e0394a..b91a3327 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -14,8 +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.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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import lombok.extern.slf4j.Slf4j; @@ -70,8 +71,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectToggleRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectToggleRandom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -82,7 +83,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { } try { - item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); + item.setExtraData(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); room.updateItem(item); } catch (Exception e) { log.error("Caught exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java index db60860e..30923e0f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java @@ -4,8 +4,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; 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.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import gnu.trove.set.hash.THashSet; @@ -18,8 +19,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectTriggerStacks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectTriggerStacks(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -41,14 +42,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { { found = false; for (RoomTile tile : usedTiles) { - if (tile.getX() == item.getX() && tile.getY() == item.getY()) { + if (tile.getX() == item.getCurrentPosition().getX() && tile.getY() == item.getCurrentPosition().getY()) { found = true; break; } } if (!found) { - usedTiles.add(room.getLayout().getTile(item.getX(), item.getY())); + usedTiles.add(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } } 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 c810d135..4afa7d97 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 @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -21,8 +22,8 @@ public class WiredEffectWhisper extends InteractionWiredEffect { super(set, baseItem); } - public WiredEffectWhisper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredEffectWhisper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 80c8ad87..3f3f1396 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import lombok.AllArgsConstructor; import lombok.Getter; @@ -39,8 +40,8 @@ public class WiredBlob extends InteractionDefault { this.parseCustomParams(); } - public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredBlob(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); this.parseCustomParams(); } @@ -49,7 +50,7 @@ public class WiredBlob extends InteractionDefault { public void onPlace(Room room) { super.onPlace(room); - this.setExtradata(WiredBlobState.USED.getState()); + this.setExtraData(WiredBlobState.USED.getState()); room.updateItem(this); } @@ -57,7 +58,7 @@ public class WiredBlob extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return; + if (!this.getExtraData().equals(WiredBlobState.ACTIVE.getState())) return; Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); @@ -73,7 +74,7 @@ public class WiredBlob extends InteractionDefault { battleBanzaiGame.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor()); } - this.setExtradata(WiredBlobState.USED.getState()); + this.setExtraData(WiredBlobState.USED.getState()); room.updateItem(this); } } @@ -82,20 +83,20 @@ public class WiredBlob extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) { if (!this.RESETS_WITH_GAME && objects != null && objects.length == 2 && objects[1].equals(WiredEffectType.TOGGLE_STATE) && room.getGames().stream().anyMatch(game -> game.getState().equals(GameState.RUNNING) || game.getState().equals(GameState.PAUSED))) { - this.setExtradata(this.getExtradata().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState()); + this.setExtraData(this.getExtraData().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState()); room.updateItem(this); } } public void onGameStart(Room room) { if (this.RESETS_WITH_GAME) { - this.setExtradata(WiredBlobState.ACTIVE.getState()); + this.setExtraData(WiredBlobState.ACTIVE.getState()); room.updateItem(this); } } public void onGameEnd(Room room) { - this.setExtradata(WiredBlobState.USED.getState()); + this.setExtraData(WiredBlobState.USED.getState()); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java index 9bf933fd..edd2321d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraRandom.java @@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,8 +14,8 @@ public class WiredExtraRandom extends InteractionWiredExtra { super(set, baseItem); } - public WiredExtraRandom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredExtraRandom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java index d986d04f..73b05345 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredExtraUnseen.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra; 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.users.HabboInfo; import lombok.Getter; import java.sql.ResultSet; @@ -21,8 +22,8 @@ public class WiredExtraUnseen extends InteractionWiredExtra { super(set, baseItem); } - public WiredExtraUnseen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredExtraUnseen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index 67369e34..6b7aade0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.threading.runnables.WiredExecuteTask; @@ -21,8 +22,8 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi super(set, baseItem); } - public WiredTriggerAtSetTime(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerAtSetTime(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 270e9f98..56ad9c57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.threading.runnables.WiredExecuteTask; @@ -20,8 +21,8 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W super(set, baseItem); } - public WiredTriggerAtTimeLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerAtTimeLong(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index 1ff5b7ea..1776fa03 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.extern.slf4j.Slf4j; @@ -17,8 +18,8 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerBotReachedFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerBotReachedFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java index 2d469a3a..93758c00 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedRoom.java @@ -4,6 +4,7 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class WiredTriggerBotReachedRoom extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerBotReachedRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerBotReachedRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index bd6233b6..da95fec8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -3,8 +3,9 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerCollision(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerCollision(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 aa086241..7d8257e8 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; 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.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -16,8 +17,8 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerFurniStateToggled(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerFurniStateToggled(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index 875cece9..3dca0c5f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -4,6 +4,7 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerGameEnds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerGameEnds(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 8f199f99..d563cd1c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -4,6 +4,7 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -14,8 +15,8 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerGameStarts(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerGameStarts(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 183a13b7..a194425c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerR 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.Setter; @@ -25,8 +26,8 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWi super(set, baseItem); } - public WiredTriggerRepeater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerRepeater(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -54,7 +55,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWi @Override public void onPickUp(Room room) { - RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile oldLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if(room.getTriggersOnRoom().containsKey(oldLocation)) { if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index f4691557..41d05b1d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerR 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.Setter; @@ -24,8 +25,8 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements super(set, baseItem); } - public WiredTriggerRepeaterLong(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerRepeaterLong(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override @@ -53,7 +54,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override public void onPickUp(Room room) { - RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile oldLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if(room.getTriggersOnRoom().containsKey(oldLocation)) { if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) { 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 5cefe33e..9fc0b6d2 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 @@ -5,6 +5,7 @@ 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.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredTriggerRoomEntersRoom extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerRoomEntersRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerRoomEntersRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override 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 f7d76934..1c19b48a 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 @@ -5,6 +5,7 @@ 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.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -17,8 +18,8 @@ public class WiredTriggerRoomSaysKeyword extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerRoomSaysKeyword(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { - super(id, userId, item, extraData, limitedStack, limitedSells); + public WiredTriggerRoomSaysKeyword(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extraData, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java index 8c944f28..42af4a53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOffFurni.java @@ -3,8 +3,9 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredTriggerRoomWalkOffFurni extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerRoomWalkOffFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerRoomWalkOffFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java index b17b3179..da3b0c56 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRoomWalkOnFurni.java @@ -3,8 +3,9 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -15,8 +16,8 @@ public class WiredTriggerRoomWalkOnFurni extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerRoomWalkOnFurni(int id, int userId, Item item, String extraData, int limitedStack, int limitedSells) { - super(id, userId, item, extraData, limitedStack, limitedSells); + public WiredTriggerRoomWalkOnFurni(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extraData, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index a580c991..5e189abe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -4,6 +4,7 @@ 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.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -16,8 +17,8 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { super(set, baseItem); } - public WiredTriggerScoreAchieved(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerScoreAchieved(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java index feee2674..8b5521a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamLoses.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -11,8 +12,8 @@ public class WiredTriggerTeamLoses extends WiredTriggerGameStarts { super(set, baseItem); } - public WiredTriggerTeamLoses(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerTeamLoses(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java index afe8124c..ce03c230 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerTeamWins.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import java.sql.ResultSet; @@ -11,8 +12,8 @@ public class WiredTriggerTeamWins extends WiredTriggerGameStarts { super(set, baseItem); } - public WiredTriggerTeamWins(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { - super(id, userId, item, extradata, limitedStack, limitedSells); + public WiredTriggerTeamWins(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, ownerInfo, item, extradata, limitedStack, limitedSells); } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index 5f142514..ffbf0673 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.friends.UpdateFriendComposer; import com.eu.habbo.plugin.events.users.friends.UserAcceptFriendRequestEvent; import gnu.trove.map.hash.THashMap; @@ -77,7 +76,7 @@ public class Messenger { if (user != null) { habboInfo = user.getHabboInfo(); } else { - habboInfo = HabboManager.getOfflineHabboInfo(friend); + habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(friend); } if (habboInfo == null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index d298f236..7eaa80ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomState; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.modtool.IssueCloseNotificationMessageComposer; import com.eu.habbo.messages.outgoing.modtool.IssueInfoMessageComposer; @@ -415,7 +414,7 @@ public class ModToolManager { List bans = new ArrayList<>(); Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(targetUserId); - HabboInfo offlineInfo = target != null ? target.getHabboInfo() : HabboManager.getOfflineHabboInfo(targetUserId); + HabboInfo offlineInfo = target != null ? target.getHabboInfo() : Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(targetUserId); if (moderator.getHabboInfo().getPermissionGroup().getId() < offlineInfo.getPermissionGroup().getId()) { return bans; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index 2b378fa4..74079858 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -157,7 +157,7 @@ public class MonsterplantPet extends Pet implements IPetLook { } this.getRoomUnit().clearStatuses(); - this.getRoomUnit().setStatus(RoomUnitStatus.RIP, ""); + this.getRoomUnit().addStatus(RoomUnitStatus.RIP, ""); this.setPacketUpdate(true); } else { int difference = Emulator.getIntUnixTimestamp() - this.created + 1; @@ -181,7 +181,7 @@ public class MonsterplantPet extends Pet implements IPetLook { if (g > this.growthStage) { this.growthStage = g; this.getRoomUnit().clearStatuses(); - this.getRoomUnit().setStatus(RoomUnitStatus.fromString("grw" + this.growthStage), ""); + this.getRoomUnit().addStatus(RoomUnitStatus.fromString("grw" + this.growthStage), ""); this.setPacketUpdate(true); } } @@ -305,8 +305,8 @@ public class MonsterplantPet extends Pet implements IPetLook { this.room.sendComposer(new PetStatusUpdateComposer(pet).compose()); this.room.sendComposer(new PetStatusUpdateComposer(this).compose()); - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "reb"); - pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "reb"); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "reb"); + pet.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "reb"); this.room.sendComposer(new UserUpdateComposer(this.getRoomUnit()).compose()); this.room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 4b09df66..2425d5e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -378,7 +378,7 @@ public class Pet extends Unit implements ISerialize, Runnable { this.getRoomUnit().setCanWalk(true); this.getRoomUnit().setGoalLocation(this.room.getRandomWalkableTile()); this.task = null; - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); this.gestureTickTimeout = currentTime; } } /* this is regeneration, add back if needed @@ -509,9 +509,9 @@ public class Pet extends Unit implements ISerialize, Runnable { this.getRoomUnit().clearStatuses(); - if (isDead) this.getRoomUnit().setStatus(RoomUnitStatus.RIP, ""); + if (isDead) this.getRoomUnit().addStatus(RoomUnitStatus.RIP, ""); for (Map.Entry entry : keys.entrySet()) { - this.getRoomUnit().setStatus(entry.getKey(), entry.getValue()); + this.getRoomUnit().addStatus(entry.getKey(), entry.getValue()); } if (!keys.isEmpty()) this.setPacketUpdate(true); @@ -526,26 +526,26 @@ public class Pet extends Unit implements ISerialize, Runnable { public void updateGesture(int time) { this.gestureTickTimeout = time; if (this.energy < 30) { - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.TIRED.getKey()); this.findNest(); } else if (this.happiness == 100) { - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.LOVE.getKey()); } else if (this.happiness >= 90) { this.randomHappyAction(); - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.HAPPY.getKey()); } else if (this.happiness <= 5) { this.randomSadAction(); - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.SAD.getKey()); } else if (this.levelHunger > 80) { - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.HUNGRY.getKey()); this.eat(); } else if (this.levelThirst > 80) { - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.THIRSTY.getKey()); this.drink(); } else if (this.idleCommandTicks > 240) { this.idleCommandTicks = 0; - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey()); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.QUESTION.getKey()); } } @@ -578,9 +578,13 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests()); this.getRoomUnit().setCanWalk(true); if (item != null) { - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } else { - this.getRoomUnit().setStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.getRoomUnit().getCurrentPosition().getX(), this.getRoomUnit().getCurrentPosition().getY(), false) + ""); + if(this instanceof HorsePet horsePet && horsePet.hasSaddle()) { + return; + } + + this.getRoomUnit().addStatus(RoomUnitStatus.LAY, this.room.getStackHeight(this.getRoomUnit().getCurrentPosition().getX(), this.getRoomUnit().getCurrentPosition().getY(), false) + ""); this.say(this.petData.randomVocal(PetVocalsType.SLEEPING)); this.task = PetTasks.DOWN; } @@ -593,13 +597,13 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks()); if (item != null) { this.getRoomUnit().setCanWalk(true); - if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } } else { - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } return item != null; @@ -612,7 +616,7 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods()); if (item != null) { this.getRoomUnit().setCanWalk(true); - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } @@ -625,14 +629,14 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys()); if (item != null) { this.getRoomUnit().setCanWalk(true); - if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } return true; } - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); return true; } @@ -652,14 +656,14 @@ public class Pet extends Unit implements ISerialize, Runnable { if (item != null) { this.getRoomUnit().setCanWalk(true); this.setTask(task); - if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) { + if (this.getRoomUnit().getCurrentPosition().distance(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())) == 0) { try { item.onWalkOn(this.getRoomUnit(), this.getRoom(), null); } catch (Exception ignored) { } return true; } - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY())); + this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); return true; } return false; @@ -670,7 +674,7 @@ public class Pet extends Unit implements ISerialize, Runnable { */ public void randomHappyAction() { if (this.petData.getActionsHappy().length > 0) { - this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsHappy()[Emulator.getRandom().nextInt(this.petData.getActionsHappy().length)]), ""); + this.getRoomUnit().addStatus(RoomUnitStatus.fromString(this.petData.getActionsHappy()[Emulator.getRandom().nextInt(this.petData.getActionsHappy().length)]), ""); } } @@ -679,7 +683,7 @@ public class Pet extends Unit implements ISerialize, Runnable { */ public void randomSadAction() { if (this.petData.getActionsTired().length > 0) { - this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsTired()[Emulator.getRandom().nextInt(this.petData.getActionsTired().length)]), ""); + this.getRoomUnit().addStatus(RoomUnitStatus.fromString(this.petData.getActionsTired()[Emulator.getRandom().nextInt(this.petData.getActionsTired().length)]), ""); } } @@ -688,7 +692,7 @@ public class Pet extends Unit implements ISerialize, Runnable { */ public void randomAction() { if (this.petData.getActionsRandom().length > 0) { - this.getRoomUnit().setStatus(RoomUnitStatus.fromString(this.petData.getActionsRandom()[Emulator.getRandom().nextInt(this.petData.getActionsRandom().length)]), ""); + this.getRoomUnit().addStatus(RoomUnitStatus.fromString(this.petData.getActionsRandom()[Emulator.getRandom().nextInt(this.petData.getActionsRandom().length)]), ""); } } @@ -723,7 +727,7 @@ public class Pet extends Unit implements ISerialize, Runnable { this.level++; this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); this.addHappiness(100); - this.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "exp"); + this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "exp"); this.gestureTickTimeout = Emulator.getIntUnixTimestamp(); AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp")); this.room.sendComposer(new PetLevelUpdatedComposer(this).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index b09f2bf3..0639ab46 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -67,10 +67,10 @@ public class PetCommand implements Comparable { } for (RoomUnitStatus status : this.action.statusToSet) { - pet.getRoomUnit().setStatus(status, "0"); + pet.getRoomUnit().addStatus(status, "0"); } - pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet); + pet.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, this.action.gestureToSet); pet.getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); pet.addEnergy(-this.energyCost); pet.addHappiness(-this.happinessCost); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java index 1dc07ba1..38527995 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java @@ -25,7 +25,7 @@ public class ActionBreed extends PetAction { } if (nest != null) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(nest.getX(), nest.getY())); + pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(nest.getCurrentPosition().getX(), nest.getCurrentPosition().getY())); return true; } else { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java index 8ae9d0d3..2f8b1f31 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java @@ -15,7 +15,7 @@ public class ActionCroak extends ActionVocals { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.CROAK, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java index be7df55a..eec7e92d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java @@ -24,7 +24,7 @@ public class ActionDip extends PetAction { RoomItem waterPatch = (RoomItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())]; - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getX(), waterPatch.getY())); + pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getCurrentPosition().getX(), waterPatch.getCurrentPosition().getY())); if (pet.getHappiness() > 70) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java index e3cc23c2..b1edf2fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDown.java @@ -21,7 +21,7 @@ public class ActionDown extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getTask() != PetTasks.DOWN && !pet.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { pet.getRoomUnit().setCmdLayEnabled(true); - pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCmdLayEnabled(false); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java index 44fcd2f1..38c17c1f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHang.java @@ -21,7 +21,7 @@ public class ActionHang extends PetAction { boolean findTree = pet.findPetItem(PetTasks.HANG, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java index 0a41fea3..31f6a0d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayDead.java @@ -18,7 +18,7 @@ public class ActionPlayDead extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { pet.clearPosture(); - pet.getRoomUnit().setStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.DEAD, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); if (pet.getHappiness() > 50) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java index b77523c9..2503865a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java @@ -32,7 +32,7 @@ public class ActionPlayFootball extends PetAction { if(foundBall == null) return false; - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getX(), foundBall.getY())); + pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getCurrentPosition().getX(), foundBall.getCurrentPosition().getY())); if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java index c9eab174..8b472609 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRelax.java @@ -21,7 +21,7 @@ public class ActionRelax extends PetAction { else pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); - pet.getRoomUnit().setStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.RELAX, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java index 54278617..963b1e73 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRingOfFire.java @@ -21,7 +21,7 @@ public class ActionRingOfFire extends PetAction { boolean findTree = pet.findPetItem(PetTasks.RING_OF_FIRE, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.RINGOFFIRE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java index e2cc9c71..31777d91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionRoll.java @@ -21,7 +21,7 @@ public class ActionRoll extends PetAction { boolean findTree = pet.findPetItem(PetTasks.ROLL, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.ROLL, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java index 905a033a..6d40cea4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSit.java @@ -22,7 +22,7 @@ public class ActionSit extends PetAction { public boolean apply(Pet pet, Habbo habbo, String[] data) { if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { pet.getRoomUnit().setCmdSitEnabled(true); - pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCmdSitEnabled(false); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java index 52c8706b..c802ce9d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSwing.java @@ -21,7 +21,7 @@ public class ActionSwing extends PetAction { boolean findTree = pet.findPetItem(PetTasks.SWING, InteractionPetTree.class); if (!findTree && pet.getPetData().getToyItems().stream().noneMatch(item -> item.getInteractionType().getType() == InteractionPetTree.class)) { pet.getRoomUnit().setCanWalk(false); - pet.getRoomUnit().setStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.SWING, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(() -> { pet.getRoomUnit().setCanWalk(true); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java index f761f6f7..3d4652a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionWave.java @@ -19,7 +19,7 @@ public class ActionWave extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.WAVE, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.WAVE, null, false), this.minimumActionDuration); if (pet.getHappiness() > 40) { 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 b27bd14e..d227cbf9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -89,6 +89,8 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter private final RoomRightsManager roomRightsManager; @Getter + private final RoomWordFilterManager roomWordFilterManager; + @Getter private RoomTraxManager roomTraxManager; private static final String CAUGHT_EXCEPTION = "Caught exception"; public static final Comparator SORT_SCORE = Comparator.comparingInt(room -> room.roomInfo.getScore()); @@ -120,8 +122,6 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter private final TIntObjectMap furniOwnerNames; private final TIntIntMap furniOwnerCount; - @Getter - private final THashSet wordFilterWords; private final Object loadLock = new Object(); //Use appropriately. Could potentially cause memory leaks when used incorrectly. public volatile boolean preventUnloading = false; @@ -177,6 +177,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomUnitManager = new RoomUnitManager(this); this.roomItemManager = new RoomItemManager(this); this.roomRightsManager = new RoomRightsManager(this); + this.roomWordFilterManager = new RoomWordFilterManager(this); this.layoutName = set.getString("model"); this.bannedHabbos = new TIntObjectHashMap<>(); @@ -205,7 +206,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.allowEffects = true; this.furniOwnerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); this.furniOwnerCount = TCollections.synchronizedMap(new TIntIntHashMap(0)); - this.wordFilterWords = new THashSet<>(0); this.mutedHabbos = new TIntIntHashMap(); this.games = new ConcurrentSet<>(); @@ -233,7 +233,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomItemManager.load(connection); this.loadHeightmap(); this.roomUnitManager.load(connection); - this.loadWordFilter(connection); + this.roomWordFilterManager.load(connection); this.roomIdleCycles = 0; this.loaded = true; @@ -248,12 +248,12 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.roomInfo.isJukeboxEnabled()) { this.roomTraxManager.play(0); for (RoomItem item : this.roomSpecialTypes.getItemsOfType(InteractionJukeBox.class)) { - this.updateItem(item.setExtradata("1")); + this.updateItem(item.setExtraData("1")); } } for (RoomItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) { - this.updateItem(item.setExtradata("1")); + this.updateItem(item.setExtraData("1")); } } @@ -293,23 +293,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private synchronized void loadWordFilter(Connection connection) { - this.wordFilterWords.clear(); - - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) { - statement.setInt(1, this.roomInfo.getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - this.wordFilterWords.add(set.getString("word")); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - public void updateTile(RoomTile tile) { if (tile != null) { tile.setStackHeight(this.getStackHeight(tile.getX(), tile.getY(), false)); @@ -349,8 +332,10 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomTileState.LAY; } - if (tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; + if (tallestItem != null) { + if (tallestItem.getCurrentZ() + Item.getCurrentHeight(tallestItem) > item.getCurrentZ() + Item.getCurrentHeight(item)) + continue; + } result = this.checkStateForItem(item, tile); tallestItem = item; @@ -388,9 +373,9 @@ public class Room implements Comparable, ISerialize, Runnable { if (item != null) { if (item.getBaseItem().allowSit()) { - roomUnit.setCurrentZ(item.getZ()); + roomUnit.setCurrentZ(item.getCurrentZ()); } else { - roomUnit.setCurrentZ(item.getZ() + Item.getCurrentHeight(item)); + roomUnit.setCurrentZ(item.getCurrentZ() + Item.getCurrentHeight(item)); } if (oldZ != roomUnit.getCurrentZ()) { @@ -408,41 +393,33 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateHabbosAt(RoomTile tile) { - this.updateHabbosAt(tile.getX(), tile.getY(), new ArrayList<>(this.roomUnitManager.getHabbosAt(tile))); - } + RoomItem item = this.roomItemManager.getTopItemAt(tile.getX(), tile.getY()); - public void updateHabbosAt(short x, short y, List habbos) { - RoomItem item = this.roomItemManager.getTopItemAt(x, y); + Collection habbos = this.roomUnitManager.getHabbosAt(tile); + + if(habbos == null || habbos.isEmpty()) { + return; + } for (Habbo habbo : habbos) { - - double oldZ = habbo.getRoomUnit().getCurrentZ(); - RoomRotation oldRotation = habbo.getRoomUnit().getBodyRotation(); double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight(); - boolean updated = false; if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) { habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); - updated = true; } if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) { habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); - updated = true; } if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { - habbo.getRoomUnit().setCurrentZ(item.getZ()); - habbo.getRoomUnit().setPreviousLocationZ(item.getZ()); + habbo.getRoomUnit().setCurrentZ(item.getCurrentZ()); + habbo.getRoomUnit().setPreviousLocationZ(item.getCurrentZ()); habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); } else { habbo.getRoomUnit().setCurrentZ(z); habbo.getRoomUnit().setPreviousLocationZ(z); } - - if (habbo.getRoomUnit().getCurrentPosition().is(x, y) && (oldZ != z || updated || oldRotation != habbo.getRoomUnit().getBodyRotation())) { - habbo.getRoomUnit().setStatusUpdateNeeded(true); - } } } @@ -459,14 +436,14 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomUnitManager.getBotsAt(tile).forEach(bot -> { if (topItem != null) { if (topItem.getBaseItem().allowSit()) { - bot.getRoomUnit().setCurrentZ(topItem.getZ()); - bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); + bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ()); + bot.getRoomUnit().setPreviousLocationZ(topItem.getCurrentZ()); bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation())); } else { - bot.getRoomUnit().setCurrentZ(topItem.getZ() + Item.getCurrentHeight(topItem)); + bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ() + Item.getCurrentHeight(topItem)); if (topItem.getBaseItem().allowLay()) { - bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, String.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight())); + bot.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(topItem.getCurrentZ() + topItem.getBaseItem().getHeight())); } } } else { @@ -701,7 +678,7 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem newRoller = null; - RoomTile rollerTile = this.layout.getTile(roller.getX(), roller.getY()); + RoomTile rollerTile = this.layout.getTile(roller.getCurrentPosition().getX(), roller.getCurrentPosition().getY()); if (rollerTile == null) return true; @@ -709,7 +686,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet itemsOnRoller = new THashSet<>(); for (RoomItem item : this.roomItemManager.getItemsAt(rollerTile)) { - if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { + if (item.getCurrentZ() >= roller.getCurrentZ() + Item.getCurrentHeight(roller)) { itemsOnRoller.add(item); } } @@ -719,7 +696,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (!this.roomUnitManager.areRoomUnitsAt(rollerTile) && itemsOnRoller.isEmpty()) return true; - RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getX(), roller.getY()), roller.getRotation()); + RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getCurrentPosition().getX(), roller.getCurrentPosition().getY()), roller.getRotation()); if (tileInFront == null) return true; @@ -740,7 +717,7 @@ public class Room implements Comparable, ISerialize, Runnable { itemsNewTile.addAll(this.roomItemManager.getItemsAt(tileInFront)); itemsNewTile.removeAll(itemsOnRoller); - itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); + itemsOnRoller.removeIf(item -> item.getCurrentPosition().getX() != roller.getCurrentPosition().getX() || item.getCurrentPosition().getY() != roller.getCurrentPosition().getY() || rollerFurniIds.contains(item.getId())); RoomItem topItem = this.roomItemManager.getTopItemAt(tileInFront.getX(), tileInFront.getY()); @@ -749,14 +726,14 @@ public class Room implements Comparable, ISerialize, Runnable { boolean stackContainsRoller = false; for (RoomItem item : itemsNewTile) { - if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1"))) { + if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtraData().equals("1"))) { allowUsers = false; } if (item instanceof InteractionRoller) { newRoller = item; stackContainsRoller = true; - if ((item.getZ() != roller.getZ() || (itemsNewTile.size() > 1 && item != topItem)) && !InteractionRoller.NO_RULES) { + if ((item.getCurrentZ() != roller.getCurrentZ() || (itemsNewTile.size() > 1 && item != topItem)) && !InteractionRoller.NO_RULES) { allowUsers = false; allowFurniture = false; continue; @@ -849,7 +826,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) { Emulator.getThreading().run(() -> { - if (roomUnit.getGoalLocation() == rollerTile) { + if (roomUnit.getTargetPosition() == rollerTile) { try { item.onWalkOn(roomUnit, this, new Object[]{rollerTile, tileInFront}); } catch (Exception e) { @@ -882,10 +859,12 @@ public class Room implements Comparable, ISerialize, Runnable { if (newRoller == null || topItem == newRoller) { List sortedItems = new ArrayList<>(itemsOnRoller); - sortedItems.sort((o1, o2) -> Double.compare(o2.getZ(), o1.getZ())); + sortedItems.sort((o1, o2) -> { + return Double.compare(o2.getCurrentZ(), o1.getCurrentZ()); + }); for (RoomItem item : sortedItems) { - if ((item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) && (item != roller)) { + if ((item.getCurrentPosition().getX() == roller.getCurrentPosition().getX() && item.getCurrentPosition().getY() == roller.getCurrentPosition().getY() && zOffset <= 0) && (item != roller)) { if (furnitureRolledEvent != null) { furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront); Emulator.getPluginManager().fireEvent(furnitureRolledEvent); @@ -1137,7 +1116,7 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem object = iterator.next(); if (object instanceof InteractionBackgroundToner) { - String[] extraData = object.getExtradata().split(":"); + String[] extraData = object.getExtraData().split(":"); if (extraData.length == 4 && extraData[0].equalsIgnoreCase("1")) { return Color.getHSBColor(Integer.parseInt(extraData[1]), Integer.parseInt(extraData[2]), Integer.parseInt(extraData[3])); @@ -1292,8 +1271,8 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getHabbosOnItem(RoomItem item) { THashSet habbos = new THashSet<>(); - for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { - for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { + for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) { RoomTile tile = this.layout.getTile(x, y); habbos.addAll(this.roomUnitManager.getHabbosAt(tile)); } @@ -1304,8 +1283,8 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getBotsOnItem(RoomItem item) { THashSet bots = new THashSet<>(); - for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { - for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { + for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) { RoomTile tile = this.layout.getTile(x, y); bots.addAll(this.roomUnitManager.getBotsAt(tile)); } @@ -1316,8 +1295,8 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getPetsOnItem(RoomItem item) { THashSet pets = new THashSet<>(); - for (short x = item.getX(); x < item.getX() + item.getBaseItem().getLength(); x++) { - for (short y = item.getY(); y < item.getY() + item.getBaseItem().getWidth(); y++) { + for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) { + for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) { RoomTile tile = this.layout.getTile(x, y); pets.addAll(this.roomUnitManager.getPetsAt(tile)); } @@ -1327,7 +1306,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void teleportHabboToItem(Habbo habbo, RoomItem item) { - this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item)); + this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ() + Item.getCurrentHeight(item)); } public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) { @@ -1462,8 +1441,8 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.wordFilterWords.isEmpty() && !habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { - for (String string : this.wordFilterWords) { + if (!this.roomWordFilterManager.getFilteredWords().isEmpty() && !habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { + for (String string : this.roomWordFilterManager.getFilteredWords()) { roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); } } @@ -1627,7 +1606,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet items = this.roomSpecialTypes.getItemsOfType(InteractionTalkingFurniture.class); for (RoomItem item : items) { - if (this.layout.getTile(item.getX(), item.getY()).distance(habbo.getRoomUnit().getCurrentPosition()) <= Emulator.getConfig().getInt("furniture.talking.range")) { + if (this.layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()).distance(habbo.getRoomUnit().getCurrentPosition()) <= Emulator.getConfig().getInt("furniture.talking.range")) { int count = Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.count", 0); if (count > 0) { @@ -1639,11 +1618,11 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onClick(habbo.getClient(), this, new Object[0]); - item.setExtradata("1"); + item.setExtraData("1"); updateItemState(item); Emulator.getThreading().run(() -> { - item.setExtradata("0"); + item.setExtraData("0"); updateItemState(item); }, 2000); @@ -1691,13 +1670,13 @@ public class Room implements Comparable, ISerialize, Runnable { if (item.getBaseItem().getType() != FurnitureType.FLOOR) continue; - boolean found = lockedTiles.stream().anyMatch(tile -> tile.getX() == item.getX() && tile.getY() == item.getY()); + boolean found = lockedTiles.stream().anyMatch(tile -> tile.getX() == item.getCurrentPosition().getX() && tile.getY() == item.getCurrentPosition().getY()); if (!found) { if (item.getRotation() == 0 || item.getRotation() == 4) { for (short y = 0; y < item.getBaseItem().getLength(); y++) { for (short x = 0; x < item.getBaseItem().getWidth(); x++) { - RoomTile tile = this.layout.getTile((short) (item.getX() + x), (short) (item.getY() + y)); + RoomTile tile = this.layout.getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); if (tile != null) { lockedTiles.add(tile); @@ -1707,7 +1686,7 @@ public class Room implements Comparable, ISerialize, Runnable { } else { for (short y = 0; y < item.getBaseItem().getWidth(); y++) { for (short x = 0; x < item.getBaseItem().getLength(); x++) { - RoomTile tile = this.layout.getTile((short) (item.getX() + x), (short) (item.getY() + y)); + RoomTile tile = this.layout.getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); if (tile != null) { lockedTiles.add(tile); @@ -1740,14 +1719,18 @@ public class Room implements Comparable, ISerialize, Runnable { for (RoomItem item : stackHelpers) { if (item == exclude) continue; - return calculateHeightmap ? item.getZ() * 256.0D : item.getZ(); + if (calculateHeightmap) { + return item.getCurrentZ() * 256.0D; + } else { + return item.getCurrentZ(); + } } RoomItem item = this.roomItemManager.getTopItemAt(x, y, exclude); if (item != null) { canStack = item.getBaseItem().allowStack(); - height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); + height = item.getCurrentZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); } if (calculateHeightmap) { @@ -1796,8 +1779,10 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem tallestItem = null; for (RoomItem item : items) { - if (tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; + if (tallestItem != null) { + if (tallestItem.getCurrentZ() + Item.getCurrentHeight(tallestItem) > item.getCurrentZ() + Item.getCurrentHeight(item)) + continue; + } tallestItem = item; } @@ -1819,7 +1804,7 @@ public class Room implements Comparable, ISerialize, Runnable { RoomItem topItem = null; for (RoomItem item : items) { - if ((topItem == null || item.getZ() > topItem.getZ())) { + if ((topItem == null || item.getCurrentZ() > topItem.getCurrentZ())) { topItem = item; } } @@ -1943,7 +1928,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (item != null && item.getRoomId() == this.roomInfo.getId() && item.getBaseItem() != null) { if (item.getBaseItem().getType() == FurnitureType.FLOOR) { this.sendComposer(new ObjectUpdateMessageComposer(item).compose()); - this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new ItemUpdateMessageComposer(item).compose()); } @@ -1961,7 +1946,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (item.getBaseItem().getType() == FurnitureType.FLOOR) { if (this.layout == null) return; - this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.updateTiles(this.layout.getTilesAt(this.layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); if (item instanceof InteractionMultiHeight interactionMultiHeight) { interactionMultiHeight.updateUnitsOnItem(this); @@ -1977,7 +1962,7 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet items = new THashSet<>(); for (RoomItem item : this.roomItemManager.getCurrentItems().values()) { - if (!items.contains(item.getBaseItem()) && item.getOwnerId() == userId) items.add(item.getBaseItem()); + if (!items.contains(item.getBaseItem()) && item.getOwnerInfo().getId() == userId) items.add(item.getBaseItem()); } return items.size(); @@ -2021,39 +2006,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public void addToWordFilter(String word) { - synchronized (this.wordFilterWords) { - if (this.wordFilterWords.contains(word)) - return; - - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO room_wordfilter VALUES (?, ?)")) { - statement.setInt(1, this.roomInfo.getId()); - statement.setString(2, word); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - return; - } - - this.wordFilterWords.add(word); - } - } - - public void removeFromWordFilter(String word) { - synchronized (this.wordFilterWords) { - this.wordFilterWords.remove(word); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ? AND word = ?")) { - statement.setInt(1, this.roomInfo.getId()); - statement.setString(2, word); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } - } - public void handleWordQuiz(Habbo habbo, String answer) { synchronized (this.userVotes) { if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { 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 67c88d87..7c9a530f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -242,7 +242,7 @@ public class RoomItemManager { 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))) { + if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getCurrentPosition().getX(), rentSpace.getCurrentPosition().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; @@ -303,9 +303,8 @@ public class RoomItemManager { } } - item.setZ(height); - item.setX(tile.getX()); - item.setY(tile.getY()); + item.setCurrentPosition(tile); + item.setCurrentZ(height); item.setRotation(rotation); item.needsUpdate(true); @@ -314,7 +313,7 @@ public class RoomItemManager { item.onPlace(this.room); this.room.updateTiles(occupiedTiles); - this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerId())).compose()); + this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose()); for (RoomTile t : occupiedTiles) { this.room.updateHabbosAt(t); @@ -339,10 +338,10 @@ public class RoomItemManager { } item.setWallPosition(wallPosition); - if (!this.room.getFurniOwnerNames().containsKey(item.getOwnerId()) && owner != null) { - this.room.getFurniOwnerNames().put(item.getOwnerId(), owner.getHabboInfo().getUsername()); + if (!this.room.getFurniOwnerNames().containsKey(item.getOwnerInfo().getId()) && owner != null) { + this.room.getFurniOwnerNames().put(item.getOwnerInfo().getId(), owner.getHabboInfo().getUsername()); } - this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerId())).compose()); + this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose()); item.needsUpdate(true); this.addRoomItem(item); item.setRoomId(this.room.getRoomInfo().getId()); @@ -362,7 +361,7 @@ public class RoomItemManager { return error; } - RoomTile oldLocation = this.room.getLayout().getTile(item.getX(), item.getY()); + RoomTile oldLocation = this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); boolean pluginHelper = false; if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) { @@ -416,7 +415,7 @@ public class RoomItemManager { } } - THashSet oldOccupiedTiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + THashSet oldOccupiedTiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); int oldRotation = item.getRotation(); @@ -433,7 +432,7 @@ public class RoomItemManager { } } - if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > Room.MAXIMUM_FURNI_HEIGHT)) { + if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getCurrentZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > Room.MAXIMUM_FURNI_HEIGHT)) { item.setRotation(oldRotation); return FurnitureMovementError.CANT_STACK; } @@ -445,9 +444,9 @@ public class RoomItemManager { double height; if (stackHelper.isPresent()) { - height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100); + height = stackHelper.get().getExtraData().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtraData()) / 100); } else if (item == topItem) { - height = item.getZ(); + height = item.getCurrentZ(); } else { height = this.room.getStackHeight(targetTile.getX(), targetTile.getY(), false, item); for (RoomTile til : occupiedTiles) { @@ -481,17 +480,16 @@ public class RoomItemManager { return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor } - item.setX(targetTile.getX()); - item.setY(targetTile.getY()); - item.setZ(height); + item.setCurrentPosition(targetTile); + item.setCurrentZ(height); if (magicTile) { - item.setZ(targetTile.getZ()); - item.setExtradata("" + item.getZ() * 100); + item.setCurrentZ(targetTile.getZ()); + item.setExtraData(String.valueOf(item.getCurrentZ() * 100)); } - if (item.getZ() > Room.MAXIMUM_FURNI_HEIGHT) { - item.setZ(Room.MAXIMUM_FURNI_HEIGHT); + if (item.getCurrentZ() > Room.MAXIMUM_FURNI_HEIGHT) { + item.setCurrentZ(Room.MAXIMUM_FURNI_HEIGHT); } //Update Furniture @@ -512,8 +510,8 @@ public class RoomItemManager { //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.room.updateHabbosAt(t.getX(), t.getY(), new ArrayList<>(this.room.getRoomUnitManager().getHabbosAt(t))); - this.room.updateBotsAt(t.getX(), t.getY()); + this.room.updateHabbosAt(t); + this.room.updateBotsAt(t); } if (Emulator.getConfig().getBoolean("wired.place.under", false)) { @@ -552,7 +550,7 @@ public class RoomItemManager { 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()); + Rectangle rectangle = RoomLayout.getRectangle(item.getCurrentPosition().getX(), item.getCurrentPosition().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++) { @@ -575,7 +573,8 @@ public class RoomItemManager { this.room.sendComposer(new ItemRemoveMessageComposer(item).compose()); } - Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getOwnerId())); + Habbo habbo; + habbo = picker != null && picker.getHabboInfo().getId() == item.getId() ? (picker) : (Emulator.getGameServer().getGameClientManager().getHabbo(item.getOwnerInfo().getId())); if (habbo != null) { habbo.getInventory().getItemsComponent().addItem(item); habbo.getClient().sendResponse(new UnseenItemsComposer(item)); @@ -590,7 +589,7 @@ public class RoomItemManager { public void ejectUserFurni(int userId) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - HashSet userItems = this.currentItems.values().stream().filter(item -> item.getOwnerId() == userId).collect(Collectors.toCollection(HashSet::new)); + HashSet userItems = this.currentItems.values().stream().filter(item -> item.getOwnerInfo().getId() == userId).collect(Collectors.toCollection(HashSet::new)); if (habbo != null) { habbo.getInventory().getItemsComponent().addItems(userItems); @@ -610,11 +609,11 @@ public class RoomItemManager { ConcurrentHashMap> userItemsMap = new ConcurrentHashMap<>(); for (RoomItem item : this.currentItems.values()) { - if ((habbo != null && item.getOwnerId() == habbo.getHabboInfo().getId()) || item instanceof InteractionPostIt) { + if ((habbo != null && item.getOwnerInfo().getId() == habbo.getHabboInfo().getId()) || item instanceof InteractionPostIt) { continue; } - userItemsMap.computeIfAbsent(item.getOwnerId(), k -> new HashSet<>()).add(item); + userItemsMap.computeIfAbsent(item.getOwnerInfo().getId(), k -> new HashSet<>()).add(item); } for (Map.Entry> entrySet : userItemsMap.entrySet()) { @@ -734,7 +733,7 @@ public class RoomItemManager { length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1; } - if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1)) + if (!(tile.getX() >= item.getCurrentPosition().getX() && tile.getX() <= item.getCurrentPosition().getX() + width - 1 && tile.getY() >= item.getCurrentPosition().getY() && tile.getY() <= item.getCurrentPosition().getY() + length - 1)) continue; items.add(item); @@ -755,7 +754,7 @@ public class RoomItemManager { THashSet items = new THashSet<>(); for (RoomItem item : this.getItemsAt(x, y)) { - if (item.getZ() < minZ) + if (item.getCurrentZ() < minZ) continue; items.add(item); @@ -808,8 +807,10 @@ public class RoomItemManager { if (exclude != null && exclude == item) continue; - if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; + if (highestItem != null) { + if (highestItem.getCurrentZ() + Item.getCurrentHeight(highestItem) > item.getCurrentZ() + Item.getCurrentHeight(item)) + continue; + } highestItem = item; } @@ -828,8 +829,10 @@ public class RoomItemManager { if (exclude != null && exclude == item) continue; - if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) - continue; + if (highestItem != null) { + if (highestItem.getCurrentZ() + Item.getCurrentHeight(highestItem) > item.getCurrentZ() + Item.getCurrentHeight(item)) + continue; + } highestItem = item; } @@ -841,7 +844,7 @@ public class RoomItemManager { public double getTopHeightAt(int x, int y) { RoomItem item = this.getTopItemAt(x, y); if (item != null) { - return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); + return (item.getCurrentZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); } else { return this.room.getLayout().getHeightAtSquare(x, y); } @@ -857,8 +860,9 @@ public class RoomItemManager { if (!item.getBaseItem().allowSit()) continue; - if (lowestChair != null && lowestChair.getZ() < item.getZ()) - continue; + if (lowestChair != null) { + if (lowestChair.getCurrentZ() < item.getCurrentZ()) continue; + } lowestChair = item; } @@ -877,8 +881,10 @@ public class RoomItemManager { if (!item.getBaseItem().allowSit()) continue; - if (lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) > item.getZ() + Item.getCurrentHeight(item)) - continue; + if (lowestChair != null) { + if (lowestChair.getCurrentZ() + Item.getCurrentHeight(lowestChair) > item.getCurrentZ() + Item.getCurrentHeight(item)) + continue; + } lowestChair = item; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 9fb490ef..fc8156ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -29,7 +29,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.incoming.users.NewUserExperienceScriptProceedEvent; @@ -408,10 +407,6 @@ public class RoomManager { return layout; } - public void unloadRoom(Room room) { - room.dispose(); - } - public void uncacheRoom(Room room) { this.activeRooms.remove(room.getRoomInfo().getId()); } @@ -1374,7 +1369,7 @@ public class RoomManager { name = habbo.getHabboInfo().getUsername(); } else { - HabboInfo info = HabboManager.getOfflineHabboInfo(userId); + HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId); if (info != null) { if (info.getPermissionGroup().hasPermissionRight(Permission.ACC_UNKICKABLE, false)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java index fdc97e94..2f88a241 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -197,7 +197,7 @@ public class RoomRightsManager { habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl)); - habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel())); + habbo.getRoomUnit().addStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel())); habbo.getRoomUnit().setRightsLevel(flatCtrl); if (flatCtrl.equals(RoomRightLevels.MODERATOR)) { 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 c0c8c64b..8a84944a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -260,8 +260,7 @@ public class RoomSpecialTypes { for (Map.Entry> map : this.wiredTriggers.entrySet()) { for (InteractionWiredTrigger trigger : map.getValue()) { - if (trigger.getX() == x && trigger.getY() == y) - triggers.add(trigger); + if (trigger.getCurrentPosition().getX() == x && trigger.getCurrentPosition().getY() == y) triggers.add(trigger); } } @@ -324,8 +323,7 @@ public class RoomSpecialTypes { for (Map.Entry> map : this.wiredEffects.entrySet()) { for (InteractionWiredEffect effect : map.getValue()) { - if (effect.getX() == x && effect.getY() == y) - effects.add(effect); + if (effect.getCurrentPosition().getX() == x && effect.getCurrentPosition().getY() == y) effects.add(effect); } } @@ -389,7 +387,7 @@ public class RoomSpecialTypes { for (Map.Entry> map : this.wiredConditions.entrySet()) { for (InteractionWiredCondition condition : map.getValue()) { - if (condition.getX() == x && condition.getY() == y) + if (condition.getCurrentPosition().getX() == x && condition.getCurrentPosition().getY() == y) conditions.add(condition); } } @@ -435,7 +433,7 @@ public class RoomSpecialTypes { THashSet extras = new THashSet<>(); for (Map.Entry map : this.wiredExtras.entrySet()) { - if (map.getValue().getX() == x && map.getValue().getY() == y) { + if (map.getValue().getCurrentPosition().getX() == x && map.getValue().getCurrentPosition().getY() == y) { extras.add(map.getValue()); } } @@ -459,7 +457,7 @@ public class RoomSpecialTypes { public boolean hasExtraType(short x, short y, Class type) { synchronized (this.wiredExtras) { for (Map.Entry map : this.wiredExtras.entrySet()) { - if (map.getValue().getX() == x && map.getValue().getY() == y && map.getValue().getClass().isAssignableFrom(type)) { + if (map.getValue().getCurrentPosition().getX() == x && map.getValue().getCurrentPosition().getY() == y && map.getValue().getClass().isAssignableFrom(type)) { return true; } } @@ -680,7 +678,7 @@ public class RoomSpecialTypes { RoomItem i = null; synchronized (this.undefined) { for (RoomItem item : this.undefined.values()) { - if (i == null || item.getZ() < i.getZ()) { + if (i == null || item.getCurrentZ() < i.getCurrentZ()) { if (item.getClass().isAssignableFrom(type)) { i = item; } @@ -725,7 +723,7 @@ public class RoomSpecialTypes { public Rectangle tentAt(RoomTile location) { for (RoomItem item : this.getItemsOfType(InteractionTent.class)) { - Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + Rectangle rectangle = RoomLayout.getRectangle(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); if (RoomLayout.tileInSquare(rectangle, location)) { return rectangle; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 121e1a74..26182f8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -20,6 +20,7 @@ public class RoomTile { @Setter @Getter private RoomTileState state; + @Getter private double stackHeight; private boolean allowStack = true; @Getter @@ -60,10 +61,6 @@ public class RoomTile { this.roomItems = tile.roomItems; } - public double getStackHeight() { - return this.stackHeight; - } - public void setStackHeight(double stackHeight) { if (this.state == RoomTileState.INVALID) { this.stackHeight = Short.MAX_VALUE; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 6033a796..1e29ff96 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer; @@ -44,7 +45,7 @@ public class RoomTrade { protected void initializeTradeStatus() { for (RoomTradeUser roomTradeUser : this.users) { if (!roomTradeUser.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.TRADING)) { - roomTradeUser.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.TRADING, ""); + roomTradeUser.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.TRADING, ""); if (!roomTradeUser.getHabbo().getRoomUnit().isWalking()) this.room.sendComposer(new UserUpdateComposer(roomTradeUser.getHabbo().getRoomUnit()).compose()); } @@ -178,35 +179,35 @@ public class RoomTrade { } } - int userOneId = userOne.getHabbo().getHabboInfo().getId(); - int userTwoId = userTwo.getHabbo().getHabboInfo().getId(); + HabboInfo userOneInfo = userOne.getHabbo().getHabboInfo(); + HabboInfo userTwoInfo = userTwo.getHabbo().getHabboInfo(); try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ? WHERE id = ? LIMIT 1")) { try (PreparedStatement stmt = connection.prepareStatement("INSERT INTO room_trade_log_items (id, item_id, user_id) VALUES (?, ?, ?)")) { for (RoomItem item : userOne.getItems()) { - item.setOwnerId(userTwoId); - statement.setInt(1, userTwoId); + item.setOwnerInfo(userTwoInfo); + statement.setInt(1, userTwoInfo.getId()); statement.setInt(2, item.getId()); statement.addBatch(); if (logTrades) { stmt.setInt(1, tradeId); stmt.setInt(2, item.getId()); - stmt.setInt(3, userOneId); + stmt.setInt(3, userOneInfo.getId()); stmt.addBatch(); } } for (RoomItem item : userTwo.getItems()) { - item.setOwnerId(userOneId); - statement.setInt(1, userOneId); + item.setOwnerInfo(userOneInfo); + statement.setInt(1, userOneInfo.getId()); statement.setInt(2, item.getId()); statement.addBatch(); if (logTrades) { stmt.setInt(1, tradeId); stmt.setInt(2, item.getId()); - stmt.setInt(3, userTwoId); + stmt.setInt(3, userTwoInfo.getId()); stmt.addBatch(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java index fff25fd9..b7f373fe 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java @@ -185,7 +185,7 @@ public class RoomTraxManager implements Disposable { public void play(int index, Habbo starter) { if (this.currentlyPlaying == null) { - this.jukeBox.setExtradata("1"); + this.jukeBox.setExtraData("1"); this.room.updateItem(this.jukeBox); } @@ -226,7 +226,7 @@ public class RoomTraxManager implements Disposable { this.starter = null; this.playingIndex = 0; - this.jukeBox.setExtradata("0"); + this.jukeBox.setExtraData("0"); this.room.updateItem(this.jukeBox); this.room.sendComposer(new NowPlayingMessageComposer(null, -1, 0).compose()); @@ -298,7 +298,7 @@ public class RoomTraxManager implements Disposable { musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerId()); + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().getId()); if (owner != null) { owner.getInventory().getItemsComponent().addItem(musicDisc); @@ -328,7 +328,7 @@ public class RoomTraxManager implements Disposable { musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerId()); + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().getId()); if (owner != null) { owner.getInventory().getItemsComponent().addItem(musicDisc); 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 26b4bd39..23ff5231 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -435,6 +435,20 @@ public class RoomUnitManager { } this.currentBots.clear(); + + Iterator petIterator = this.currentPets.values().iterator(); + + while(petIterator.hasNext()) { + try { + Pet pet = petIterator.next(); + pet.setNeedsUpdate(true); + Emulator.getThreading().run(pet); + } catch (NoSuchElementException e) { + log.error("Caught Exception", e); + break; + } + } + this.currentPets.clear(); this.currentRoomUnits.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java new file mode 100644 index 00000000..698a9790 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java @@ -0,0 +1,81 @@ +package com.eu.habbo.habbohotel.rooms; + +import com.eu.habbo.Emulator; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +@Getter +@Setter +@Accessors(chain = true) +public class RoomWordFilterManager { + private final Room room; + + private final List filteredWords; + + public RoomWordFilterManager(Room room) { + this.room = room; + this.filteredWords = new ArrayList<>(); + } + + public synchronized void load(Connection connection) { + this.filteredWords.clear(); + + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.filteredWords.add(set.getString("word")); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + public void addWord(String word) { + synchronized (this.filteredWords) { + if (this.filteredWords.contains(word)) + return; + + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT IGNORE INTO room_wordfilter VALUES (?, ?)")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setString(2, word); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + return; + } + + this.filteredWords.add(word); + } + } + + public void removeWord(String word) { + synchronized (this.filteredWords) { + this.filteredWords.remove(word); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ? AND word = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setString(2, word); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java index c4665a0b..bfa82b32 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java @@ -23,6 +23,25 @@ public abstract class RoomEntity implements IRoomEntity { private Deque path = new LinkedList<>(); private int tilesMoved; + public boolean isAtGoal() { + if(this.currentPosition == null) { + return false; + } + + return this.currentPosition.equals(this.targetPosition); + } + + public void setPreviousLocation(RoomTile previousLocation) { + this.previousPosition = previousLocation; + this.previousZ = this.getCurrentZ(); + } + + public RoomEntity setCurrentZ(double currentZ) { + this.previousZ = this.currentZ; + this.currentZ = Math.max(-9999, Math.min(currentZ, 9999)); + return this; + } + public synchronized void incrementTilesMoved() { this.tilesMoved++; } 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 b84f73b5..66ced663 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 @@ -15,11 +15,13 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -45,41 +47,23 @@ import java.util.Arrays; import java.util.List; @Slf4j -public abstract class RoomItem implements Runnable, IEventTriggers { - @Getter +@Getter +@Setter +@Accessors(chain = true) +public abstract class RoomItem extends RoomEntity implements Runnable, IEventTriggers { private final int id; - @Getter - @Setter - private int ownerId; - @Getter - @Setter + private HabboInfo ownerInfo; private int roomId; - @Getter private final Item baseItem; - @Getter - @Setter private String wallPosition; - @Setter - @Getter - private short x; - @Setter - @Getter - private short y; - @Getter - private double z; - @Getter private int rotation; - @Setter - @Getter - @Accessors(chain = true) - private String extradata; - @Getter + private String extraData; private int limitedStack; - @Getter private int limitedSells; private boolean needsUpdate = false; private boolean needsDelete = false; private boolean isFromGift = false; + @SuppressWarnings("rawtypes") private static final Class[] TOGGLING_INTERACTIONS = new Class[]{ InteractionGameTimer.class, @@ -90,54 +74,66 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public RoomItem(ResultSet set, Item baseItem) throws SQLException { this.id = set.getInt("id"); - this.ownerId = set.getInt(DatabaseConstants.USER_ID); + this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt(DatabaseConstants.USER_ID)); this.roomId = set.getInt("room_id"); + + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id")); + this.setRoom(room); + this.baseItem = baseItem; this.wallPosition = set.getString("wall_pos"); - this.x = set.getShort("x"); - this.y = set.getShort("y"); - this.z = set.getDouble("z"); + + if(room != null) { + this.setCurrentPosition(room.getLayout().getTile(set.getShort("x"), set.getShort("y"))); + this.setCurrentZ(set.getDouble("z")); + } + this.rotation = set.getInt("rot"); - this.extradata = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data"); + this.extraData = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data"); String ltdData = set.getString("limited_data"); if (!ltdData.isEmpty()) { this.limitedStack = Integer.parseInt(set.getString("limited_data").split(":")[0]); this.limitedSells = Integer.parseInt(set.getString("limited_data").split(":")[1]); } + + this.setRoom(Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id"))); } - public RoomItem(int id, int ownerId, Item item, String extradata, int limitedStack, int limitedSells) { + public RoomItem(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { this.id = id; - this.ownerId = ownerId; + this.ownerInfo = ownerInfo; + + //@Deprecated RoomItem this.roomId = 0; + this.baseItem = item; this.wallPosition = ""; - this.x = 0; - this.y = 0; - this.z = 0; + this.rotation = 0; - this.extradata = extradata.isEmpty() ? "0" : extradata; + this.extraData = extraData.isEmpty() ? "0" : extraData; this.limitedSells = limitedSells; this.limitedStack = limitedStack; + + this.setRoom(null); + this.setCurrentPosition(null); + this.setCurrentZ(0); } public static RoomTile getSquareInFront(RoomLayout roomLayout, RoomItem item) { - return roomLayout.getTileInFront(roomLayout.getTile(item.getX(), item.getY()), item.getRotation()); + return roomLayout.getTileInFront(roomLayout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getRotation()); } public void serializeFloorData(ServerMessage serverMessage) { try { serverMessage.appendInt(this.getId()); serverMessage.appendInt(this.baseItem.getSpriteId()); - serverMessage.appendInt(this.x); - serverMessage.appendInt(this.y); + serverMessage.appendInt(this.getCurrentPosition().getX()); + serverMessage.appendInt(this.getCurrentPosition().getY()); serverMessage.appendInt(this.getRotation()); - serverMessage.appendString(Double.toString(this.z)); - - serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().equalsIgnoreCase("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) + "" : "")); - //serverMessage.appendString( ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) : "")); + serverMessage.appendString(Double.toString(this.getCurrentZ())); + serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().equalsIgnoreCase("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? String.valueOf(Item.getCurrentHeight(this)) : "")); } catch (Exception e) { log.error("Caught exception", e); } @@ -151,17 +147,17 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } public void serializeWallData(ServerMessage serverMessage) { - serverMessage.appendString(this.getId() + ""); + serverMessage.appendString(String.valueOf(this.getId())); serverMessage.appendInt(this.baseItem.getSpriteId()); serverMessage.appendString(this.wallPosition); if (this instanceof InteractionPostIt) - serverMessage.appendString(this.extradata.split(" ")[0]); + serverMessage.appendString(this.extraData.split(" ")[0]); else - serverMessage.appendString(this.extradata); + serverMessage.appendString(this.extraData); serverMessage.appendInt(-1); serverMessage.appendInt(this.isUsable()); - serverMessage.appendInt(this.getOwnerId()); + serverMessage.appendInt(this.ownerInfo.getId()); } public int getGiftAdjustedId() { @@ -170,11 +166,6 @@ public abstract class RoomItem implements Runnable, IEventTriggers { return this.id; } - public void setZ(double z) { - if (z > 9999 || z < -9999) return; - this.z = z; - } - public void setRotation(int rotation) { this.rotation = (byte) (rotation % 8); } @@ -214,12 +205,12 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } } else if (this.needsUpdate) { try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) { - statement.setInt(1, this.ownerId); + statement.setInt(1, this.ownerInfo.getId()); statement.setInt(2, this.roomId); statement.setString(3, this.wallPosition); - statement.setInt(4, this.x); - statement.setInt(5, this.y); - statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.z * Math.pow(10, 6)) / Math.pow(10, 6)))); + statement.setInt(4, this.getCurrentPosition().getX()); + statement.setInt(5, this.getCurrentPosition().getY()); + statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.getCurrentZ() * Math.pow(10, 6)) / Math.pow(10, 6)))); statement.setInt(7, this.rotation); statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); statement.setString(9, this.limitedStack + ":" + this.limitedSells); @@ -257,9 +248,6 @@ public abstract class RoomItem implements Runnable, IEventTriggers { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - /*if (objects != null && objects.length >= 1 && objects[0] instanceof InteractionWired) - return;*/ - WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, roomUnit, room, new Object[]{this}); if(roomUnit instanceof RoomAvatar roomAvatar) { @@ -267,18 +255,35 @@ public abstract class RoomItem implements Runnable, IEventTriggers { roomAvatar.setDanceType(DanceType.NONE); room.sendComposer(new DanceMessageComposer(roomAvatar).compose()); } + + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); + + if (habbo != null && habbo.getHabboInfo().getRiding() == null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { + roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1); + return; + } + + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { + roomAvatar.giveEffect(this.getBaseItem().getEffectF(), -1); + } + } + } } - if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoalLocation() && roomUnit.getGoalLocation() == room.getLayout().getTile(this.x, this.y)) { - Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); + if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousPosition() != roomUnit.getTargetPosition()) { + if (this.getCurrentPosition().equals(roomUnit.getTargetPosition())) { + 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); - habbo.getHabboInfo().setLook(String.join(".", Arrays.stream(habbo.getHabboInfo().getLook().split("\\.")).filter(k -> !ArrayUtils.contains(clothingKeys, k.split("-")[0])).toArray(String[]::new)) + "." + this.getBaseItem().getClothingOnWalk()); + if (habbo != null && habbo.getClient() != null) { + String[] clothingKeys = Arrays.stream(this.getBaseItem().getClothingOnWalk().split("\\.")).map(k -> k.split("-")[0]).toArray(String[]::new); + habbo.getHabboInfo().setLook(String.join(".", Arrays.stream(habbo.getHabboInfo().getLook().split("\\.")).filter(k -> !ArrayUtils.contains(clothingKeys, k.split("-")[0])).toArray(String[]::new)) + "." + this.getBaseItem().getClothingOnWalk()); - habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); - if (habbo.getRoomUnit().getRoom() != null) { - habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + habbo.getClient().sendResponse(new FigureUpdateComposer(habbo)); + if (habbo.getRoomUnit().getRoom() != null) { + habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose()); + } } } } @@ -289,29 +294,43 @@ public abstract class RoomItem implements Runnable, IEventTriggers { if(objects != null && objects.length > 0) { WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this}); } + + if (roomUnit instanceof RoomAvatar roomAvatar) { + + Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); + + if (habbo != null && habbo.getHabboInfo().getRiding() == null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { + roomAvatar.giveEffect(0, -1); + } + + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { + roomAvatar.giveEffect(0, -1); + } + } + } } public abstract void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception; - public void onPlace(Room room) { //TODO: IMPORTANT: MAKE THIS GENERIC. (HOLES, ICE SKATE PATCHES, BLACK HOLE, BUNNY RUN FIELD, FOOTBALL FIELD) Achievement roomDecoAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFurniCount"); - Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerId()); + Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.ownerInfo.getId()); int furniCollecterProgress; if (owner == null) { - furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), roomDecoAchievement); + furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.ownerInfo.getId(), roomDecoAchievement); } else { furniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoAchievement); } - int difference = room.getUserFurniCount(this.getOwnerId()) - furniCollecterProgress; + int difference = room.getUserFurniCount(this.ownerInfo.getId()) - furniCollecterProgress; if (difference > 0) { if (owner != null) { AchievementManager.progressAchievement(owner, roomDecoAchievement, difference); } else { - AchievementManager.progressAchievement(this.getOwnerId(), roomDecoAchievement, difference); + AchievementManager.progressAchievement(this.ownerInfo.getId(), roomDecoAchievement, difference); } } @@ -319,24 +338,24 @@ public abstract class RoomItem implements Runnable, IEventTriggers { int uniqueFurniCollecterProgress; if (owner == null) { - uniqueFurniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerId(), roomDecoUniqueAchievement); + uniqueFurniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.ownerInfo.getId(), roomDecoUniqueAchievement); } else { uniqueFurniCollecterProgress = owner.getHabboStats().getAchievementProgress(roomDecoUniqueAchievement); } - int uniqueDifference = room.getUserUniqueFurniCount(this.getOwnerId()) - uniqueFurniCollecterProgress; + int uniqueDifference = room.getUserUniqueFurniCount(this.ownerInfo.getId()) - uniqueFurniCollecterProgress; if (uniqueDifference > 0) { if (owner != null) { AchievementManager.progressAchievement(owner, roomDecoUniqueAchievement, uniqueDifference); } else { - AchievementManager.progressAchievement(this.getOwnerId(), roomDecoUniqueAchievement, uniqueDifference); + AchievementManager.progressAchievement(this.ownerInfo.getId(), roomDecoUniqueAchievement, uniqueDifference); } } } public void onPickUp(Room room) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY(), this); + RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this); int nextEffectM = 0; int nextEffectF = 0; @@ -355,7 +374,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } } - RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); + RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); for (Bot bot : room.getRoomUnitManager().getBotsAt(tile)) { if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) { bot.getRoomUnit().giveEffect(nextEffectM, -1); @@ -441,12 +460,12 @@ public abstract class RoomItem implements Runnable, IEventTriggers { } public String getDatabaseExtraData() { - return this.getExtradata(); + return this.getExtraData(); } @Override public String toString() { - return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.x + ", Y: " + this.y + ", Z: " + this.z + ", Extradata: " + this.extradata; + return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.getCurrentPosition().getX() + ", Y: " + this.getCurrentPosition().getY() + ", Z: " + this.getCurrentZ() + ", Extradata: " + this.extraData; } public boolean allowWiredResetState() { @@ -461,20 +480,12 @@ public abstract class RoomItem implements Runnable, IEventTriggers { return true; } - public boolean isFromGift() { - return isFromGift; - } - - public void setFromGift(boolean fromGift) { - isFromGift = fromGift; - } - public boolean invalidatesToRoomKick() { return false; } public List getOccupyingTiles(RoomLayout layout) { List tiles = new ArrayList<>(); - Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); + Rectangle rect = RoomLayout.getRectangle(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { @@ -499,8 +510,8 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public Rectangle getRectangle() { return RoomLayout.getRectangle( - this.getX(), - this.getY(), + this.getCurrentPosition().getX(), + this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); @@ -508,8 +519,8 @@ public abstract class RoomItem implements Runnable, IEventTriggers { public Rectangle getRectangle(int marginX, int marginY) { return RoomLayout.getRectangle( - this.getX() - marginX, - this.getY() - marginY, + this.getCurrentPosition().getX() - marginX, + this.getCurrentPosition().getY() - marginY, this.getBaseItem().getWidth() + (marginX * 2), this.getBaseItem().getLength() + (marginY * 2), this.getRotation()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 9b076d29..2ff43d7e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -86,14 +86,10 @@ public abstract class RoomUnit extends RoomEntity { @Setter private RoomTile botStartLocation; @Getter - private RoomTile previousLocation; - @Getter @Setter @Accessors(chain = true) private double previousLocationZ; @Getter - private RoomTile goalLocation; - @Getter @Setter private boolean inRoom; @Getter @@ -160,8 +156,7 @@ public abstract class RoomUnit extends RoomEntity { } public void clearWalking() { - this.goalLocation = null; - this.setCurrentPosition(null); + this.setTargetPosition(null); this.startLocation = this.getCurrentPosition(); this.statuses.clear(); this.cacheable.clear(); @@ -211,13 +206,14 @@ public abstract class RoomUnit extends RoomEntity { if (goalLocation != null && !noReset) { boolean isWalking = this.hasStatus(RoomUnitStatus.MOVE); - this.goalLocation = goalLocation; + this.setTargetPosition(goalLocation); + this.findPath(); ///< Quadral: this is where we start formulating a path if (!this.getPath().isEmpty()) { this.setTilesMoved(isWalking ? this.getTilesMoved() : 0); this.setCmdSitEnabled(false); } else { - this.goalLocation = this.getCurrentPosition(); + this.setTargetPosition(this.getCurrentPosition()); } } } @@ -227,40 +223,38 @@ public abstract class RoomUnit extends RoomEntity { this.startLocation = location; this.setPreviousLocation(location); this.setCurrentPosition(location); - this.goalLocation = location; + this.setTargetPosition(location); this.botStartLocation = location; } return this; } - public void setPreviousLocation(RoomTile previousLocation) { - this.previousLocation = previousLocation; - this.previousLocationZ = this.getCurrentZ(); - } - public void findPath() { - if (this.getRoom() != null && this.getRoom().getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.getRoom().canSitOrLayAt(this.goalLocation.getX(), this.goalLocation.getY()) || this.canOverrideTile(this.goalLocation))) { - Deque newPath = this.getRoom().getLayout().findPath(this.getCurrentPosition(), this.goalLocation, this.goalLocation, this); + if (this.getRoom() != null && this.getRoom().getLayout() != null && this.getTargetPosition() != null && (this.getTargetPosition().isWalkable() || this.getRoom().canSitOrLayAt(this.getTargetPosition().getX(), this.getTargetPosition().getY()) || this.canOverrideTile(this.getTargetPosition()))) { + Deque newPath = this.getRoom().getLayout().findPath(this.getCurrentPosition(), this.getTargetPosition(), this.getTargetPosition(), this); if (newPath != null) this.setPath(newPath); } } - public boolean isAtGoal() { - if(this.getCurrentPosition() == null) { - return false; - } - - return this.getCurrentPosition().equals(this.goalLocation); - } - public boolean isWalking() { return !this.isAtGoal() && this.canWalk; } + public boolean hasStatus(RoomUnitStatus key) { + return this.statuses.containsKey(key); + } + public String getStatus(RoomUnitStatus key) { return this.statuses.get(key); } + public void addStatus(RoomUnitStatus key, String value) { + if (key != null && value != null) { + this.statuses.put(key, value); + this.statusUpdateNeeded = true; + } + } + public RoomUnit removeStatus(RoomUnitStatus key) { String statusRemoved = this.statuses.remove(key); @@ -271,11 +265,8 @@ public abstract class RoomUnit extends RoomEntity { return this; } - public void setStatus(RoomUnitStatus key, String value) { - if (key != null && value != null) { - this.statuses.put(key, value); - this.statusUpdateNeeded = true; - } + public void clearStatuses() { + this.statuses.clear(); } public void setRightsLevel(RoomRightLevels rightsLevel) { @@ -283,17 +274,13 @@ public abstract class RoomUnit extends RoomEntity { this.statusUpdateNeeded = true; } - public boolean hasStatus(RoomUnitStatus key) { - return this.statuses.containsKey(key); - } - public void makeStand() { RoomItem item = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { this.setCmdStandEnabled(true); this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); this.removeStatus(RoomUnitStatus.SIT); - this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + this.instantUpdate(); } } @@ -304,36 +291,19 @@ public abstract class RoomUnit extends RoomEntity { this.setCmdSitEnabled(true); this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); - this.setStatus(RoomUnitStatus.SIT, 0.5 + ""); + this.addStatus(RoomUnitStatus.SIT, 0.5 + ""); if(this instanceof RoomAvatar roomAvatar) { roomAvatar.setDance(DanceType.NONE); } - this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); - } - - public void clearStatuses() { - this.statuses.clear(); + this.instantUpdate(); } public TMap getCacheable() { return this.cacheable; } - public int getPreviousEffectId() { - return this.previousEffectId; - } - - public void setPreviousEffectId(int effectId, int endTimestamp) { - this.previousEffectId = effectId; - this.previousEffectEndTimestamp = endTimestamp; - } - - public int getPreviousEffectEndTimestamp() { - return this.previousEffectEndTimestamp; - } - public int getWalkTimeOut() { return this.walkTimeOut; } @@ -455,8 +425,8 @@ public abstract class RoomUnit extends RoomEntity { if(!this.isCmdSitEnabled()) { if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { - this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); - this.setCurrentZ(topItem.getZ()); + this.addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); + this.setCurrentZ(topItem.getCurrentZ()); this.setRotation(RoomRotation.values()[topItem.getRotation()]); return true; } else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { @@ -476,13 +446,13 @@ public abstract class RoomUnit extends RoomEntity { if(!this.isCmdLayEnabled()) { if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { - this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); + this.addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { - this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getY())); + this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getCurrentPosition().getY())); } else { - this.setLocation(this.getRoom().getLayout().getTile(topItem.getX(), this.getCurrentPosition().getY())); + this.setLocation(this.getRoom().getLayout().getTile(topItem.getCurrentPosition().getX(), this.getCurrentPosition().getY())); } return true; } else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { 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 a985266e..c7fbd1c7 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 @@ -104,7 +104,7 @@ public class RoomAvatar extends RoomUnit { } } - Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); + Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this); if (peekPath == null) { peekPath = new LinkedList<>(); @@ -186,7 +186,7 @@ public class RoomAvatar extends RoomUnit { item = tallestChair; } - if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideTile && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideTile && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.removeStatus(RoomUnitStatus.MOVE); return false; } @@ -198,7 +198,7 @@ public class RoomAvatar extends RoomUnit { } RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); - if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) + if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); @@ -208,7 +208,7 @@ public class RoomAvatar extends RoomUnit { this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); if (item != null) { - if (item != roomItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { + if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { if (item.canWalkOn(this, room, null)) { item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); } else if (item instanceof ConditionalGate conditionalGate) { @@ -228,7 +228,7 @@ public class RoomAvatar extends RoomUnit { item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); } - zHeight += item.getZ(); + zHeight += item.getCurrentZ(); if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { zHeight += Item.getCurrentHeight(item); @@ -239,7 +239,7 @@ public class RoomAvatar extends RoomUnit { this.setPreviousLocation(this.getCurrentPosition()); - this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); + this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); if(habbo != null) { RideablePet rideablePet = habbo.getHabboInfo().getRiding(); @@ -252,8 +252,8 @@ public class RoomAvatar extends RoomUnit { this.setCurrentZ(zHeight - 1.0); ridingUnit.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); ridingUnit.setPreviousLocation(this.getCurrentPosition()); - ridingUnit.setGoalLocation(this.getGoalLocation()); - ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); + ridingUnit.setGoalLocation(this.getTargetPosition()); + ridingUnit.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); room.sendComposer(new UserUpdateComposer(ridingUnit).compose()); } } @@ -350,6 +350,10 @@ public class RoomAvatar extends RoomUnit { return; } + if(this.getEffectId() == effectId) { + return; + } + if(this instanceof RoomHabbo) { Habbo habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(this); if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) { @@ -371,6 +375,11 @@ public class RoomAvatar extends RoomUnit { } } + public void setPreviousEffectId(int effectId, int endTimestamp) { + this.previousEffectId = effectId; + this.previousEffectEndTimestamp = endTimestamp; + } + @Override public void clear() { super.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 4a704659..9607678a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -68,7 +68,7 @@ public class RoomPet extends RoomUnit { } } - Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getGoalLocation(), this); + Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this); if (peekPath == null) { peekPath = new LinkedList<>(); @@ -123,7 +123,7 @@ public class RoomPet extends RoomUnit { item = tallestChair; } - if (next.equals(this.getGoalLocation()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { + if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { this.removeStatus(RoomUnitStatus.MOVE); return false; } @@ -131,7 +131,7 @@ public class RoomPet extends RoomUnit { double zHeight = 0.0D; RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); - if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) + if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); @@ -140,7 +140,7 @@ public class RoomPet extends RoomUnit { RoomRotation oldRotation = this.getBodyRotation(); this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); if (item != null) { - if (item != roomItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { + if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { if (item.canWalkOn(this, room, null)) { item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); } else if (item instanceof ConditionalGate conditionalGate) { @@ -156,7 +156,7 @@ public class RoomPet extends RoomUnit { item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); } - zHeight += item.getZ(); + zHeight += item.getCurrentZ(); if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { zHeight += Item.getCurrentHeight(item); @@ -168,7 +168,7 @@ public class RoomPet extends RoomUnit { this.setPreviousLocation(this.getCurrentPosition()); - this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); + this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); this.setCurrentZ(zHeight); this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); @@ -197,9 +197,9 @@ public class RoomPet extends RoomUnit { } if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) { - this.setStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); - this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation()); - this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight()); + this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); + this.setPreviousLocation(rider.getRoomUnit().getPreviousPosition()); + this.setPreviousLocationZ(rider.getRoomUnit().getPreviousPosition().getStackHeight()); this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition()); this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight()); } 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 fb3a8f01..f72e7a18 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -82,6 +82,8 @@ public class HabboInfo implements Runnable { this.loadCurrencies(); this.loadSavedSearches(); this.loadMessengerCategories(); + + Emulator.getGameEnvironment().getHabboManager().getHabboInfoCache().getData().remove(this.id); } private void loadCurrencies() { 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 ef88b747..9a786399 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.PermissionGroup; +import com.eu.habbo.habbohotel.users.cache.HabboInfoCache; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigurationComposer; @@ -25,6 +26,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; @Slf4j public class HabboManager { @@ -34,16 +37,30 @@ public class HabboManager { @Getter private final ConcurrentHashMap onlineHabbos; + @Getter + private final HabboInfoCache habboInfoCache; + + public ScheduledFuture infoCacheTask; + public HabboManager() { long millis = System.currentTimeMillis(); this.onlineHabbos = new ConcurrentHashMap<>(); + this.habboInfoCache = new HabboInfoCache(); + log.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + + this.infoCacheTask = Emulator.getThreading().getService().scheduleAtFixedRate(this.habboInfoCache, 500, 5, TimeUnit.MINUTES); } - public static HabboInfo getOfflineHabboInfo(int id) { + public HabboInfo getOfflineHabboInfo(int id) { + if(this.habboInfoCache.getData().containsKey(id)) { + return this.habboInfoCache.getData().get(id).getValue(); + } + HabboInfo info = null; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) { statement.setInt(1, id); try (ResultSet set = statement.executeQuery()) { @@ -55,10 +72,14 @@ public class HabboManager { log.error("Caught SQL exception", e); } + if(info != null) { + this.habboInfoCache.add(info); + } + return info; } - public static HabboInfo getOfflineHabboInfo(String username) { + public HabboInfo getOfflineHabboInfo(String username) { HabboInfo info = null; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username = ? LIMIT 1")) { @@ -185,11 +206,7 @@ public class HabboManager { } public synchronized void dispose() { - - -// - - + this.infoCacheTask.cancel(false); log.info("Habbo Manager -> Disposed!"); } 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 index 8eb8f3ca..9d4353fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboInfoCache.java @@ -1,22 +1,48 @@ package com.eu.habbo.habbohotel.users.cache; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboInfo; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.math3.util.Pair; import java.util.LinkedHashMap; import java.util.Map; @Slf4j @Getter -public class HabboInfoCache { - private final LinkedHashMap habboInfoCache; +public class HabboInfoCache implements Runnable { + private static final long CACHE_DURATION = 10 * 60 * 1000; + private final LinkedHashMap> data; public HabboInfoCache() { - this.habboInfoCache = new LinkedHashMap(16, 0.75f, true) { - protected boolean removeEldestEntry(Map.Entry eldest) { - return false; + this.data = new LinkedHashMap>(16, 0.75f) { + @Override + protected boolean removeEldestEntry(Map.Entry> eldest) { + return cleanEntry(eldest); } }; } + + public void add(HabboInfo habboInfo) { + long currentMillis = Emulator.getIntUnixTimestamp(); + this.data.put(habboInfo.getId(), new Pair<>(currentMillis, habboInfo)); + } + + private boolean cleanEntry(Map.Entry> entry) { + long currentMillis = Emulator.getIntUnixTimestamp(); + long entryTimestamp = entry.getValue().getKey(); + return entryTimestamp < currentMillis - CACHE_DURATION; + } + + public void verifyInfo(int userId) { + this.data.remove(userId); + } + + @Override + public void run() { + synchronized (this.data) { + this.data.entrySet().removeIf(this::cleanEntry); + } + } } 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 c3ce78f5..22d0aed4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -62,7 +62,7 @@ public class WiredHandler { List triggeredTiles = new ArrayList<>(); for (InteractionWiredTrigger trigger : triggers) { - RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY()); + RoomTile tile = room.getLayout().getTile(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY()); if (triggeredTiles.contains(tile)) { continue; @@ -113,7 +113,7 @@ public class WiredHandler { for (InteractionWiredTrigger trigger : triggers) { if (trigger.getClass() != triggerType) continue; - RoomTile tile = room.getLayout().getTile(trigger.getX(), trigger.getY()); + RoomTile tile = room.getLayout().getTile(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY()); if (triggeredTiles.contains(tile)) continue; @@ -157,8 +157,8 @@ public class WiredHandler { //DUNNO IF YOU HAVE TO SET EXTRADATA TO 1 IN HERE (In case of Repeaters) trigger.activateBox(room, roomUnit, millis); - THashSet conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY()); - THashSet effects = room.getRoomSpecialTypes().getEffects(trigger.getX(), trigger.getY()); + THashSet conditions = room.getRoomSpecialTypes().getConditions(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY()); + THashSet effects = room.getRoomSpecialTypes().getEffects(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY()); if (Emulator.getPluginManager().fireEvent(new WiredStackTriggeredEvent(room, roomUnit, trigger, effects, conditions)).isCancelled()) return false; @@ -182,9 +182,9 @@ public class WiredHandler { trigger.setCooldown(millis); - boolean hasExtraRandom = room.getRoomSpecialTypes().hasExtraType(trigger.getX(), trigger.getY(), WiredExtraRandom.class); - boolean hasExtraUnseen = room.getRoomSpecialTypes().hasExtraType(trigger.getX(), trigger.getY(), WiredExtraUnseen.class); - THashSet extras = room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY()); + boolean hasExtraRandom = room.getRoomSpecialTypes().hasExtraType(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY(), WiredExtraRandom.class); + boolean hasExtraUnseen = room.getRoomSpecialTypes().hasExtraType(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY(), WiredExtraUnseen.class); + THashSet extras = room.getRoomSpecialTypes().getExtras(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY()); for (InteractionWiredExtra extra : extras) { extra.activateBox(room, roomUnit, millis); @@ -198,9 +198,9 @@ public class WiredHandler { if (hasExtraUnseen) { - for (InteractionWiredExtra extra : room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY())) { + for (InteractionWiredExtra extra : room.getRoomSpecialTypes().getExtras(trigger.getCurrentPosition().getX(), trigger.getCurrentPosition().getY())) { if (extra instanceof WiredExtraUnseen) { - extra.setExtradata(extra.getExtradata().equals("1") ? "0" : "1"); + extra.setExtraData(extra.getExtraData().equals("1") ? "0" : "1"); InteractionWiredEffect effect = ((WiredExtraUnseen) extra).getUnseenEffect(effectList); effectsToExecute.add(effect); // triggerEffect(effect, roomUnit, room, stuff, millis); break; diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java index 91336f57..211c170a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java @@ -39,7 +39,7 @@ public class PurchasePhotoEvent extends MessageHandler { RoomItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); if (photoItem != null) { - photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + "")); + photoItem.setExtraData(photoItem.getExtraData().replace("%id%", photoItem.getId() + "")); photoItem.needsUpdate(true); this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java index c3c0995a..bc714081 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java @@ -284,7 +284,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { itemsList.add(hopper); } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) { InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - habboItem.setExtradata(""); + habboItem.setExtraData(""); habboItem.needsUpdate(true); int guildId; try { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index 14d0c0c4..e609b5bd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -37,7 +37,7 @@ public class PresentOpenEvent extends MessageHandler { Emulator.getThreading().run(new OpenGift(item, this.client.getHabbo(), room), item.getBaseItem().getName().contains("present_wrap") ? 1000 : 0); } else { - if (item.getExtradata().length() == 0) { + if (item.getExtraData().length() == 0) { this.client.sendResponse(new WhisperMessageComposer(new RoomChatMessage(Emulator.getTexts().getValue("error.recycler.box.empty"), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.BOT))); } else { RoomItem reward = Emulator.getGameEnvironment().getItemManager().handleOpenRecycleBox(this.client.getHabbo(), item); @@ -47,7 +47,7 @@ public class PresentOpenEvent extends MessageHandler { this.client.sendResponse(new UnseenItemsComposer(reward)); this.client.sendResponse(new FurniListInvalidateComposer()); - this.client.sendResponse(new PresentOpenedMessageComposer(reward, item.getExtradata(), true)); + this.client.sendResponse(new PresentOpenedMessageComposer(reward, item.getExtraData(), true)); } } room.sendComposer(new RemoveFloorItemComposer(item).compose()); @@ -56,16 +56,16 @@ public class PresentOpenEvent extends MessageHandler { } if (item.getRoomId() == 0) { - room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); + room.updateTile(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); RoomLayout roomLayout = room.getLayout(); - short z = (short)room.getStackHeight(item.getX(), item.getY(), true); + short z = (short)room.getStackHeight(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), true); if(roomLayout != null) { - RoomTile roomTile = roomLayout.getTile(item.getX(), item.getY()); + RoomTile roomTile = roomLayout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); if(roomTile != null) { z = roomTile.getZ(); } } - room.sendComposer(new HeightMapUpdateMessageComposer(item.getX(), item.getY(), z, room.getStackHeight(item.getX(), item.getY(), true)).compose()); + room.sendComposer(new HeightMapUpdateMessageComposer(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), z, room.getStackHeight(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), true)).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java index 08df20b8..b75b5ebf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/UpdateFloorPropertiesEvent.java @@ -155,7 +155,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { if (layout.getDoorTile() == null) { this.client.getHabbo().alert("Error"); ((CustomRoomLayout) layout).needsUpdate(false); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room.dispose(); return; } ((CustomRoomLayout) layout).needsUpdate(true); @@ -174,7 +174,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler { room.save(); Collection habbos = new ArrayList<>(room.getRoomUnitManager().getRoomHabbosCount()); habbos.addAll(room.getRoomUnitManager().getCurrentHabbos().values()); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room.dispose(); room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId()); ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose(); for (Habbo habbo : habbos) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java index 8f55d0e3..74c32cc7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendEvent.java @@ -14,8 +14,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import static com.eu.habbo.habbohotel.users.HabboManager.getOfflineHabboInfo; - @Slf4j public class AcceptFriendEvent extends MessageHandler { @@ -38,7 +36,7 @@ public class AcceptFriendEvent extends MessageHandler { Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if(target == null) { - HabboInfo habboInfo = getOfflineHabboInfo(userId); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId); if(habboInfo == null) { this.client.sendResponse(new MessengerErrorComposer(MessengerErrorComposer.TARGET_NOT_FOUND)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java index 7d87c024..e1052a0f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/ApproveMembershipRequestEvent.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.GuildMemberMgmtFailedMessageComposer; import com.eu.habbo.messages.outgoing.guilds.GuildMembershipRejectedMessageComposer; @@ -26,7 +25,7 @@ public class ApproveMembershipRequestEvent extends MessageHandler { GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo == null) userInfo = HabboManager.getOfflineHabboInfo(userId); + if (habbo == null) userInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId); else userInfo = habbo.getHabboInfo(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromIMEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromIMEvent.java index 895d49f8..533299ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromIMEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromIMEvent.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.modtool.ModToolIssue; import com.eu.habbo.habbohotel.modtool.ModToolTicketType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.CallForHelpDisabledNotifyMessageComposer; import com.eu.habbo.threading.runnables.InsertModToolIssue; @@ -32,7 +31,7 @@ public class CallForHelpFromIMEvent extends MessageHandler { if (target != null) { info = target.getHabboInfo(); } else { - info = HabboManager.getOfflineHabboInfo(userId); + info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId); } if (info == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java index 71c0de71..c0bf448c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromPhotoEvent.java @@ -40,7 +40,7 @@ public class CallForHelpFromPhotoEvent extends MessageHandler { if (!(item instanceof InteractionExternalImage)) return; - HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getOwnerId()); + HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getOwnerInfo().getId()); if (photoOwner == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java index c7cf5143..dd684925 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetUserChatlogEvent.java @@ -3,7 +3,6 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.UserChatlogComposer; @@ -12,7 +11,7 @@ public class GetUserChatlogEvent extends MessageHandler { public void handle() { if (this.client.getHabbo().hasPermissionRight(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); - String username = HabboManager.getOfflineHabboInfo(userId).getUsername(); + String username = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId).getUsername(); this.client.sendResponse(new UserChatlogComposer(Emulator.getGameEnvironment().getModToolManager().getUserRoomVisitsAndChatlogs(userId), userId, username)); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index b4a4d7c0..7c790233 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -91,7 +91,7 @@ public class DeleteRoomEvent extends MessageHandler { } } - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room.dispose(); try (PreparedStatement rights = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { rights.setInt(1, roomId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 2f771bfd..4ad3455d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -28,17 +28,17 @@ public class RequestRoomPropertySet extends MessageHandler { switch (item.getBaseItem().getName()) { case "floor": - room.getRoomInfo().setFloorPaint(item.getExtradata()); + room.getRoomInfo().setFloorPaint(item.getExtraData()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoFloor")); break; case "wallpaper": - room.getRoomInfo().setWallPaint(item.getExtradata()); + room.getRoomInfo().setWallPaint(item.getExtraData()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoWallpaper")); break; case "landscape": - room.getRoomInfo().setLandscapePaint(item.getExtradata()); + room.getRoomInfo().setLandscapePaint(item.getExtraData()); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoLandscape")); break; @@ -48,7 +48,7 @@ public class RequestRoomPropertySet extends MessageHandler { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); room.setNeedsUpdate(true); - room.sendComposer(new RoomPropertyMessageComposer(item.getBaseItem().getName(), item.getExtradata()).compose()); + room.sendComposer(new RoomPropertyMessageComposer(item.getBaseItem().getName(), item.getExtraData()).compose()); item.needsDelete(true); Emulator.getThreading().run(item); this.client.sendResponse(new FurniListRemoveComposer(itemId)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index cd81a0e0..b820bffc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -35,7 +35,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { saturation = event.getSaturation() % 256; brightness = event.getBrightness() % 256; - item.setExtradata(item.getExtradata().split(":")[0] + ":" + hue + ":" + saturation + ":" + brightness); + item.setExtraData(item.getExtraData().split(":")[0] + ":" + hue + ":" + saturation + ":" + brightness); item.needsUpdate(true); Emulator.getThreading().run(item); room.updateItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java index e3b6aaf5..f9eb118e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/UpdateRoomFilterEvent.java @@ -29,9 +29,9 @@ public class UpdateRoomFilterEvent extends MessageHandler { // Modify word filter. if (add) { - room.addToWordFilter(word); + room.getRoomWordFilterManager().addWord(word); } else { - room.removeFromWordFilter(word); + room.getRoomWordFilterManager().removeWord(word); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index 583ddae5..f8f35f1b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -37,8 +37,8 @@ public class AddSpamWallPostItEvent extends MessageHandler { Room room = this.client.getHabbo().getRoomUnit().getRoom(); RoomItem sticky = room.getRoomItemManager().getRoomItemById(itemId); - if (sticky != null && sticky.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { - sticky.setOwnerId(room.getRoomInfo().getOwnerInfo().getId()); + if (sticky != null && sticky.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { + sticky.setOwnerInfo(room.getRoomInfo().getOwnerInfo()); if (color.equalsIgnoreCase(PostItColor.YELLOW.hexColor)) { color = PostItColor.randomColorNotYellow().hexColor; @@ -47,8 +47,8 @@ public class AddSpamWallPostItEvent extends MessageHandler { text = InteractionPostIt.STICKYPOLE_PREFIX_TEXT.replace("\\r", "\r").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%timestamp%", LocalDate.now().toString()) + text; } - sticky.setOwnerId(room.getRoomInfo().getOwnerInfo().getId()); - sticky.setExtradata(color + " " + text); + sticky.setOwnerInfo(room.getRoomInfo().getOwnerInfo()); + sticky.setExtraData(color + " " + text); sticky.needsUpdate(true); room.updateItem(sticky); Emulator.getThreading().run(sticky); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java index 42183db6..2ee0e584 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CreditFurniRedeemEvent.java @@ -25,7 +25,7 @@ public class CreditFurniRedeemEvent extends MessageHandler { if (room != null) { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); - if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getOwnerId()) { + if (item != null && this.client.getHabbo().getHabboInfo().getId() == item.getOwnerInfo().getId()) { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); FurnitureRedeemedEvent furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), 0, FurnitureRedeemedEvent.CREDITS); @@ -98,10 +98,10 @@ public class CreditFurniRedeemEvent extends MessageHandler { room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item).compose()); - RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); - t.setStackHeight(room.getStackHeight(item.getX(), item.getY(), false)); + RoomTile t = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + t.setStackHeight(room.getStackHeight(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), false)); room.updateTile(t); - room.sendComposer(new HeightMapUpdateMessageComposer(item.getX(), item.getY(), t.getZ(), t.relativeHeight()).compose()); + room.sendComposer(new HeightMapUpdateMessageComposer(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), t.getZ(), t.relativeHeight()).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); switch (furniRedeemEvent.currencyID) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index 87ce4df9..a5d0a21f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -29,14 +29,14 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getRoom() != null && this.client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(this.client.getHabbo())) { RoomItem item = this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getRoomItemById(itemId); - if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item != null && item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { if (item instanceof InteractionClothing) { ClothItem clothing = Emulator.getGameEnvironment().getCatalogManager().getClothing(item.getBaseItem().getName()); if (clothing != null) { if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) { item.setRoomId(0); - RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getX(), item.getY()); + RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java index 71379105..ed5d896b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java @@ -22,9 +22,9 @@ public class DiceOffEvent extends MessageHandler { if (item != null) { if (item instanceof InteractionDice) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { - if (!item.getExtradata().equals("-1")) { - item.setExtradata("0"); + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { + if (!item.getExtraData().equals("-1")) { + item.setExtraData("0"); item.needsUpdate(true); Emulator.getThreading().run(item); room.updateItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java index ebab2d5a..ba4452ba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/EnterOneWayDoorEvent.java @@ -17,7 +17,7 @@ public class EnterOneWayDoorEvent extends MessageHandler { return; if (item instanceof InteractionOneWayGate) { - if (!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting()) + if (!item.getExtraData().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting()) return; item.onClick(this.client, this.client.getHabbo().getRoomUnit().getRoom(), null); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java index 87ec232e..4f6da343 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PickupObjectEvent.java @@ -24,15 +24,15 @@ public class PickupObjectEvent extends MessageHandler { return; } - if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { room.getRoomItemManager().pickUpItem(item, this.client.getHabbo()); } else { if (room.getRoomRightsManager().hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { - item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); + item.setOwnerInfo(this.client.getHabbo().getHabboInfo()); } else { if (!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { - if (item.getOwnerId() == room.getRoomInfo().getOwnerInfo().getId()) { + if (item.getOwnerInfo().getId() == room.getRoomInfo().getOwnerInfo().getId()) { return; } } 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 988fa148..776acf3e 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 @@ -87,7 +87,7 @@ public class PlaceObjectEvent extends MessageHandler { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } - if (rentSpace != null && !RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(x, y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { + if (rentSpace != null && !RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getCurrentPosition().getX(), rentSpace.getCurrentPosition().getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(x, y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index b2c5a382..e5bc4c86 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -28,10 +28,10 @@ public class PlacePostItEvent extends MessageHandler { if (item instanceof InteractionPostIt) { if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) { room.getRoomItemManager().addRoomItem(item); - item.setExtradata("FFFF33"); + item.setExtraData("FFFF33"); item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); item.setWallPosition(location); - item.setOwnerId(this.client.getHabbo().getHabboInfo().getId()); + item.setOwnerInfo(this.client.getHabbo().getHabboInfo()); item.needsUpdate(true); room.sendComposer(new ItemAddMessageComposer(item, this.client.getHabbo().getHabboInfo().getUsername()).compose()); this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index 9ba6aa6c..6841f9fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -23,7 +23,7 @@ public class RemoveItemEvent extends MessageHandler { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { - if (item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { + if (item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { item.setRoomId(0); room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new ItemRemoveMessageComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java index b50d4b55..f8130a7f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java @@ -29,8 +29,8 @@ public class RoomDimmerChangeStateEvent extends MessageHandler { } RoomMoodlightData adjusted = RoomMoodlightData.fromString(extradata); - if (RoomMoodlightData.fromString(moodLight.getExtradata()).isEnabled()) adjusted.disable(); - moodLight.setExtradata(adjusted.toString()); + if (RoomMoodlightData.fromString(moodLight.getExtraData()).isEnabled()) adjusted.disable(); + moodLight.setExtraData(adjusted.toString()); moodLight.needsUpdate(true); room.updateItem(moodLight); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java index 98fc6e7d..2d75a54b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java @@ -49,7 +49,7 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { if (apply) data.enable(); for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { - item.setExtradata(data.toString()); + item.setExtraData(data.toString()); item.needsUpdate(true); room.updateItem(item); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 48f1b97c..6d570d08 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -22,7 +22,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { if (item instanceof InteractionStackHelper) { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY()); + RoomTile itemTile = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); double stackerHeight = this.packet.readInt(); THashSet tiles = room.getLayout().getTilesAt(itemTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); @@ -46,9 +46,10 @@ public class SetCustomStackingHeightEvent extends MessageHandler { tile.setStackHeight(height); } - item.setZ(height); - item.setExtradata((int) (height * 100) + ""); + item.setCurrentZ(height); + item.setExtraData(String.valueOf((int) (height * 100))); item.needsUpdate(true); + this.client.getHabbo().getRoomUnit().getRoom().updateItem(item); this.client.getHabbo().getRoomUnit().getRoom().updateTiles(tiles); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new HeightMapUpdateMessageComposer (room, tiles).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index 8739eb13..03d731f4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -40,7 +40,7 @@ public class SetItemDataEvent extends MessageHandler { return; if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.getRoomRightsManager().hasRights(this.client.getHabbo())) { - if (!text.startsWith(item.getExtradata().replace(item.getExtradata().split(" ")[0], ""))) { + if (!text.startsWith(item.getExtraData().replace(item.getExtraData().split(" ")[0], ""))) { return; } } else { @@ -51,7 +51,7 @@ public class SetItemDataEvent extends MessageHandler { if (color.isEmpty()) color = PostItColor.YELLOW.hexColor; - item.setExtradata(color + " " + text); + item.setExtraData(color + " " + text); item.needsUpdate(true); room.updateItem(item); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java index 5270f139..3f785e48 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java @@ -20,7 +20,7 @@ public class SetMannequinFigureEvent extends MessageHandler { if (item == null) return; - String[] data = item.getExtradata().split(":"); + String[] data = item.getExtraData().split(":"); //TODO: Only clothing not whole body part. StringBuilder look = new StringBuilder(); @@ -36,9 +36,9 @@ public class SetMannequinFigureEvent extends MessageHandler { } if (data.length == 3) { - item.setExtradata(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + data[2]); + item.setExtraData(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + data[2]); } else { - item.setExtradata(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + habbo.getHabboInfo().getUsername() + "'s look."); + item.setExtraData(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + habbo.getHabboInfo().getUsername() + "'s look."); } item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java index 77d17e51..3be84b84 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java @@ -17,7 +17,7 @@ public class SetMannequinNameEvent extends MessageHandler { if (item == null) return; - String[] data = item.getExtradata().split(":"); + String[] data = item.getExtraData().split(":"); String name = this.packet.readString(); if (name.length() < 3 || name.length() > 15) { @@ -25,9 +25,9 @@ public class SetMannequinNameEvent extends MessageHandler { } if (data.length == 3) { - item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + data[1] + ":" + name); + item.setExtraData(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + data[1] + ":" + name); } else { - item.setExtradata(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + this.client.getHabbo().getHabboInfo().getLook() + ":" + name); + item.setExtraData(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + this.client.getHabbo().getHabboInfo().getLook() + ":" + name); } item.needsUpdate(true); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index e15581c7..fd5873f2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -42,7 +42,7 @@ public class SetObjectDataEvent extends MessageHandler { ((InteractionCustomValues) item).values.put(key, value); } - item.setExtradata(((InteractionCustomValues) item).toExtraData()); + item.setExtraData(((InteractionCustomValues) item).toExtraData()); item.needsUpdate(true); Emulator.getThreading().run(item); room.updateItem(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java index da54a9e8..ea6ef3fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ThrowDiceEvent.java @@ -22,7 +22,7 @@ public class ThrowDiceEvent extends MessageHandler { if (item != null) { if (item instanceof InteractionDice || item instanceof InteractionSpinningBottle) { - if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getX(), item.getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { + if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { item.onClick(this.client, room, new Object[]{}); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index 298db957..67f4e111 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -69,11 +69,11 @@ public class UseFurnitureEvent extends MessageHandler { boolean isRare = item.getBaseItem().getName().contains("rare"); int rarity = getRarity(item, isRare); - MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity); + MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), rarity); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); room.getRoomItemManager().removeRoomItem(item); - room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); - room.getRoomUnitManager().placePet(pet, room, item.getX(), item.getY(), item.getZ()); + room.updateTile(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); pet.cycle(); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); return true; @@ -82,11 +82,11 @@ public class UseFurnitureEvent extends MessageHandler { } private int getRarity(RoomItem item, boolean isRare) { - if (item.getExtradata().isEmpty() || Integer.parseInt(item.getExtradata()) - 1 < 0) { + if (item.getExtraData().isEmpty() || Integer.parseInt(item.getExtraData()) - 1 < 0) { return isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel(); } else { try { - return Integer.parseInt(item.getExtradata()) - 1; + return Integer.parseInt(item.getExtraData()) - 1; } catch (Exception ignored) { return 0; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java index 6682fa31..db1054fe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java @@ -32,11 +32,12 @@ public class CompostPlantEvent extends MessageHandler { Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem("mnstr_compost"); if (baseItem != null) { - RoomItem compost = Emulator.getGameEnvironment().getItemManager().createItem(pet.getUserId(), baseItem, 0, 0, ""); - compost.setX(pet.getRoomUnit().getCurrentPosition().getX()); - compost.setY(pet.getRoomUnit().getCurrentPosition().getY()); - compost.setZ(pet.getRoomUnit().getCurrentZ()); + RoomItem compost = Emulator.getGameEnvironment().getItemManager().createItem(pet.getUserId(), baseItem, 0, 0, "");; + + compost.setCurrentPosition(pet.getRoomUnit().getCurrentPosition()); + compost.setCurrentZ(pet.getRoomUnit().getCurrentZ()); compost.setRotation(pet.getRoomUnit().getBodyRotation().getValue()); + room.getRoomItemManager().addRoomItem(compost); room.sendComposer(new ObjectAddMessageComposer(compost, this.client.getHabbo().getHabboInfo().getUsername()).compose()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 6ee20822..46737ae3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -93,14 +93,14 @@ public class CustomizePetWithFurniEvent extends MessageHandler { if (((MonsterplantPet) pet).isDead()) { ((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.TIME_TO_LIVE); pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev"); + pet.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "rev"); pet.setPacketUpdate(true); this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantHealer")); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -110,13 +110,13 @@ public class CustomizePetWithFurniEvent extends MessageHandler { pet.setCreated(pet.getCreated() - MonsterplantPet.GROW_TIME); pet.getRoomUnit().clearStatuses(); pet.cycle(); - pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "spd"); - pet.getRoomUnit().setStatus(RoomUnitStatus.fromString("grw" + ((MonsterplantPet) pet).getGrowthStage()), ""); + pet.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "spd"); + pet.getRoomUnit().addStatus(RoomUnitStatus.fromString("grw" + ((MonsterplantPet) pet).getGrowthStage()), ""); this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); pet.cycle(); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); @@ -132,13 +132,13 @@ public class CustomizePetWithFurniEvent extends MessageHandler { { ((MonsterplantPet) pet).setCanBreed(true); pet.getRoomUnit().clearStatuses(); - pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "reb"); + pet.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, "reb"); this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new RemoveFloorItemComposer(item).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetStatusUpdateComposer(pet).compose()); - this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + this.client.getHabbo().getRoomUnit().getRoom().updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index 4dfb082d..26a43454 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -22,7 +22,7 @@ public class OpenPetPackageEvent extends MessageHandler { if (room != null) { RoomItem item = room.getRoomItemManager().getRoomItemById(itemId); - if (item != null && item.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) { + if (item != null && item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { if (!name.matches("^[a-zA-Z0-9]*$")) { this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", ""))); return; @@ -55,18 +55,18 @@ public class OpenPetPackageEvent extends MessageHandler { } if (pet != null) { - room.getRoomUnitManager().placePet(pet, room, item.getX(), item.getY(), item.getZ()); + room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); pet.setUserId(this.client.getHabbo().getHabboInfo().getId()); pet.setNeedsUpdate(true); - pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getX(), item.getY())); - pet.getRoomUnit().setCurrentZ(item.getZ()); + pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + pet.getRoomUnit().setCurrentZ(item.getCurrentZ()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item).compose()); - RoomTile tile = room.getLayout().getTile(item.getX(), item.getY()); - room.updateTile(room.getLayout().getTile(item.getX(), item.getY())); + RoomTile tile = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); + room.updateTile(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); room.sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose()); - item.setOwnerId(0); + item.setOwnerInfo(null); } else { this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index 6dab7341..8bad80f6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -84,7 +84,7 @@ public class PlacePetEvent extends MessageHandler { roomUnit.setLocation(tile); roomUnit.setCurrentZ(tile.getStackHeight()); - roomUnit.setStatus(RoomUnitStatus.SIT, "0"); + roomUnit.addStatus(RoomUnitStatus.SIT, "0"); roomUnit.setRoomUnitType(RoomUnitType.PET); if (playerTile != null) { roomUnit.lookAtPoint(playerTile); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 5c82f48b..9cca3aa2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -102,8 +102,9 @@ public class MoveAvatarEvent extends MessageHandler { } // Don't calculate a new path if we are on a horse - if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) + if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) { return; + } // Reset idle status if (roomHabbo.isIdle()) { @@ -137,11 +138,12 @@ public class MoveAvatarEvent extends MessageHandler { RoomItem bed = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); if (bed != null && bed.getBaseItem().allowLay()) { - room.getLayout().getTile(bed.getX(), bed.getY()); + room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); RoomTile pillow = switch (bed.getRotation()) { - case 0, 4 -> room.getLayout().getTile((short) x, bed.getY()); - case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y); - default -> room.getLayout().getTile(bed.getX(), bed.getY()); + case 0, 4 -> room.getLayout().getTile((short) x, bed.getCurrentPosition().getY()); + case 2, 8 -> room.getLayout().getTile(bed.getCurrentPosition().getX(), (short) y); + default -> + room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); }; if (pillow != null && room.canLayAt(pillow)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java index 11885a68..55119bf7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/SignEvent.java @@ -22,7 +22,7 @@ public class SignEvent extends MessageHandler { UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { - this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, String.valueOf(event.getSign())); + this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.SIGN, String.valueOf(event.getSign())); this.client.getHabbo().getRoomUnit().unIdle(); if(signId <= 10) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java index af63c7c2..0d24bd23 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeUserNameEvent.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.ChangeUserNameResultMessageEvent; import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer; @@ -41,7 +40,7 @@ public class ChangeUserNameEvent extends MessageHandler { } if (name.equals(this.client.getHabbo().getHabboStats().getChangeNameChecked())) { - HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(name); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(name); if (habboInfo == null) { synchronized (changingUsernames) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java index ca79760b..61d5e9d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/CheckUserNameEvent.java @@ -1,7 +1,6 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.CheckUserNameResultMessageComposer; @@ -25,7 +24,7 @@ public class CheckUserNameEvent extends MessageHandler { errorCode = CheckUserNameResultMessageComposer.TOO_SHORT; } else if (name.length() > 15) { errorCode = CheckUserNameResultMessageComposer.TOO_LONG; - } else if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername()) || HabboManager.getOfflineHabboInfo(name) != null || ChangeUserNameEvent.changingUsernames.contains(name.toLowerCase())) { + } else if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername()) || Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(name) != null || ChangeUserNameEvent.changingUsernames.contains(name.toLowerCase())) { errorCode = CheckUserNameResultMessageComposer.TAKEN_WITH_SUGGESTIONS; suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/GetExtendedProfileEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/GetExtendedProfileEvent.java index 9203d35c..369c6167 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/GetExtendedProfileEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/GetExtendedProfileEvent.java @@ -15,6 +15,6 @@ public class GetExtendedProfileEvent extends MessageHandler { if (habbo != null) this.client.sendResponse(new ExtendedProfileMessageComposer(habbo, this.client)); else - this.client.sendResponse(new ExtendedProfileMessageComposer(HabboManager.getOfflineHabboInfo(habboId), this.client)); + this.client.sendResponse(new ExtendedProfileMessageComposer(Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(habboId), this.client)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/GetIgnoredUsersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/GetIgnoredUsersEvent.java index a3bc41b3..653a7848 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/GetIgnoredUsersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/GetIgnoredUsersEvent.java @@ -3,7 +3,6 @@ package com.eu.habbo.messages.incoming.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.unknown.IgnoredUsersMessageComposer; import gnu.trove.list.array.TIntArrayList; @@ -26,7 +25,7 @@ public class GetIgnoredUsersEvent extends MessageHandler { int userId = ignoredUsersId.iterator().next(); HabboInfo user = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId); - if(user == null) user = HabboManager.getOfflineHabboInfo(userId); + if(user == null) user = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(userId); if(user != null) ignoredUsernames.add(user.getUsername()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java index 4daf1e0e..1d5534f5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/ApplySnapshotEvent.java @@ -65,13 +65,13 @@ public class ApplySnapshotEvent extends MessageHandler { RoomItem matchItem = room.getRoomItemManager().getRoomItemById(setting.getItem_id()); // Match state - if (wired.shouldMatchState() && matchItem.allowWiredResetState() && !setting.getState().equals(" ") && !matchItem.getExtradata().equals(setting.getState())) { - matchItem.setExtradata(setting.getState()); + if (wired.shouldMatchState() && matchItem.allowWiredResetState() && !setting.getState().equals(" ") && !matchItem.getExtraData().equals(setting.getState())) { + matchItem.setExtraData(setting.getState()); room.updateItemState(matchItem); } - RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY()); - double oldZ = matchItem.getZ(); + RoomTile oldLocation = room.getLayout().getTile(matchItem.getCurrentPosition().getX(), matchItem.getCurrentPosition().getY()); + double oldZ = matchItem.getCurrentZ(); // Match Position & Rotation if (wired.shouldMatchRotation() && !wired.shouldMatchPosition()) { @@ -86,7 +86,7 @@ public class ApplySnapshotEvent extends MessageHandler { if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) { boolean sendUpdates = !slideAnimation; if (room.getRoomItemManager().moveItemTo(matchItem, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE && slideAnimation) { - room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose()); + room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getCurrentZ(), 0, room).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java index fc797a33..4ba9cb7f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListAddOrUpdateComposer.java @@ -29,13 +29,13 @@ public class FurniListAddOrUpdateComposer extends MessageComposer { if (this.roomItem.isLimited()) { this.response.appendInt(1); this.response.appendInt(256); - this.response.appendString(this.roomItem.getExtradata()); + this.response.appendString(this.roomItem.getExtraData()); this.response.appendInt(this.roomItem.getLimitedSells()); this.response.appendInt(this.roomItem.getLimitedStack()); } else { this.response.appendInt(1); this.response.appendInt(0); - this.response.appendString(this.roomItem.getExtradata()); + this.response.appendString(this.roomItem.getExtraData()); } this.response.appendBoolean(this.roomItem.getBaseItem().allowRecyle()); this.response.appendBoolean(this.roomItem.getBaseItem().allowTrade()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java index 71f01bec..0b9e9301 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/FurniListComposer.java @@ -57,7 +57,7 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc } this.response.appendInt(0); - this.response.appendString(roomItem.getExtradata()); + this.response.appendString(roomItem.getExtraData()); } else { if (roomItem.getBaseItem().getName().equals("gnome_box")) this.response.appendInt(13); @@ -77,7 +77,7 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc if (roomItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.response.appendString(""); if(roomItem.getBaseItem().getName().equals("song_disk")) { - List extraDataAsList = Arrays.asList(roomItem.getExtradata().split("\n")); + List extraDataAsList = Arrays.asList(roomItem.getExtraData().split("\n")); this.response.appendInt(Integer.valueOf(extraDataAsList.get(extraDataAsList.size() - 1))); return true; } @@ -89,7 +89,7 @@ public class FurniListComposer extends MessageComposer implements TIntObjectProc public void addExtraDataToResponse(RoomItem roomItem) { this.response.appendInt(0); - this.response.appendString(roomItem.getExtradata()); + this.response.appendString(roomItem.getExtraData()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java index 96d0ad1c..0c808f8b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomFilterSettingsMessageComposer.java @@ -14,9 +14,9 @@ public class RoomFilterSettingsMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.roomFilterSettingsMessageComposer); - this.response.appendInt(this.room.getWordFilterWords().size()); + this.response.appendInt(this.room.getRoomWordFilterManager().getFilteredWords().size()); - for (String string : this.room.getWordFilterWords()) { + for (String string : this.room.getRoomWordFilterManager().getFilteredWords()) { this.response.appendString(string); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java index 092a2e9c..f23c8fa7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java @@ -35,31 +35,31 @@ public class FloorItemOnRollerComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { - short oldX = this.item.getX(); - short oldY = this.item.getY(); + short oldX = this.item.getCurrentPosition().getX(); + short oldY = this.item.getCurrentPosition().getY(); this.response.init(Outgoing.slideObjectBundleMessageComposer); - this.response.appendInt(this.oldLocation != null ? this.oldLocation.getX() : this.item.getX()); - this.response.appendInt(this.oldLocation != null ? this.oldLocation.getY() : this.item.getY()); + this.response.appendInt(this.oldLocation != null ? this.oldLocation.getX() : this.item.getCurrentPosition().getX()); + this.response.appendInt(this.oldLocation != null ? this.oldLocation.getY() : this.item.getCurrentPosition().getY()); this.response.appendInt(this.newLocation.getX()); this.response.appendInt(this.newLocation.getY()); this.response.appendInt(1); this.response.appendInt(this.item.getId()); - this.response.appendString(Double.toString(this.oldLocation != null ? this.oldZ : this.item.getZ())); - this.response.appendString(Double.toString(this.oldLocation != null ? this.newZ : (this.item.getZ() + this.heightOffset))); + this.response.appendString(Double.toString(this.oldLocation != null ? this.oldZ : this.item.getCurrentZ())); + this.response.appendString(Double.toString(this.oldLocation != null ? this.newZ : (this.item.getCurrentZ() + this.heightOffset))); this.response.appendInt(this.roller != null ? this.roller.getId() : -1); if(this.oldLocation == null) { - this.item.onMove(this.room, this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.newLocation); - this.item.setX(this.newLocation.getX()); - this.item.setY(this.newLocation.getY()); - this.item.setZ(this.item.getZ() + this.heightOffset); + this.item.onMove(this.room, this.room.getLayout().getTile(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY()), this.newLocation); + + this.item.setCurrentPosition(this.newLocation); + this.item.setCurrentZ(this.item.getCurrentZ() + this.heightOffset); this.item.needsUpdate(true); //TODO This is bad // THashSet tiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(oldX, oldY), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation()); - tiles.addAll(this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())); + tiles.addAll(this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())); this.room.updateTiles(tiles); //this.room.sendComposer(new UpdateStackHeightComposer(oldX, oldY, this.room.getStackHeight(oldX, oldY, true)).compose()); // diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java index 54962305..674093b7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemDataUpdateMessageComposer.java @@ -13,13 +13,13 @@ public class ItemDataUpdateMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { - if (this.postIt.getExtradata().isEmpty() || this.postIt.getExtradata().length() < 6) { - this.postIt.setExtradata("FFFF33"); + if (this.postIt.getExtraData().isEmpty() || this.postIt.getExtraData().length() < 6) { + this.postIt.setExtraData("FFFF33"); } this.response.init(Outgoing.itemDataUpdateMessageComposer); this.response.appendString(this.postIt.getId() + ""); - this.response.appendString(this.postIt.getExtradata()); + this.response.appendString(this.postIt.getExtraData()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java index 128e1ffe..dadb1f62 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemRemoveMessageComposer.java @@ -14,7 +14,7 @@ public class ItemRemoveMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.itemRemoveMessageComposer); this.response.appendString(this.item.getId() + ""); - this.response.appendInt(this.item.getOwnerId()); + this.response.appendInt(this.item.getOwnerInfo().getId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java index 2a45013a..daedf355 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemUpdateMessageComposer.java @@ -15,7 +15,7 @@ public class ItemUpdateMessageComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.itemUpdateMessageComposer); this.item.serializeWallData(this.response); - this.response.appendString(this.item.getOwnerId() + ""); + this.response.appendString(String.valueOf(this.item.getOwnerInfo().getId())); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java index 527e88f1..246cd2cf 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectAddMessageComposer.java @@ -21,7 +21,7 @@ public class ObjectAddMessageComposer extends MessageComposer { this.item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(this.item instanceof InteractionTeleport || this.item instanceof InteractionSwitch || this.item instanceof InteractionSwitchRemoteControl || this.item instanceof InteractionVendingMachine || this.item instanceof InteractionInformationTerminal || this.item instanceof InteractionPostIt || this.item instanceof InteractionSpinningBottle || this.item instanceof InteractionPuzzleBox ? 2 : this.item.isUsable() ? 1 : 0); - this.response.appendInt(this.item.getOwnerId()); + this.response.appendInt(this.item.getOwnerInfo().getId()); this.response.appendString(this.itemOwnerName); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java index 54c35d29..419717bb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectUpdateMessageComposer.java @@ -21,7 +21,7 @@ public class ObjectUpdateMessageComposer extends MessageComposer { this.item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(0); - this.response.appendInt(this.item.getOwnerId()); + this.response.appendInt(this.item.getOwnerInfo().getId()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java index f8cd51b1..901e289c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ObjectsMessageComposer.java @@ -43,7 +43,7 @@ public class ObjectsMessageComposer extends MessageComposer { item.serializeExtradata(this.response); this.response.appendInt(-1); this.response.appendInt(item instanceof InteractionTeleport || item instanceof InteractionSwitch || item instanceof InteractionSwitchRemoteControl || item instanceof InteractionVendingMachine || item instanceof InteractionInformationTerminal || item instanceof InteractionPostIt || item instanceof InteractionSpinningBottle || item instanceof InteractionPuzzleBox ? 2 : item.isUsable() ? 1 : 0); - this.response.appendInt(item.getOwnerId()); + this.response.appendInt(item.getOwnerInfo().getId()); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java index 9ee6f7af..8f02ff06 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/OneWayDoorStatusMessageComposer.java @@ -15,7 +15,7 @@ public class OneWayDoorStatusMessageComposer extends MessageComposer { this.response.init(Outgoing.oneWayDoorStatusMessageComposer); this.response.appendInt(this.item.getId()); try { - int state = Integer.parseInt(this.item.getExtradata()); + int state = Integer.parseInt(this.item.getExtraData()); this.response.appendInt(state); } catch (Exception e) { this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java index b5674944..c9e90cdc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/RemoveFloorItemComposer.java @@ -23,7 +23,7 @@ public class RemoveFloorItemComposer extends MessageComposer { this.response.appendString(this.item.getId() + ""); this.response.appendBoolean(false); - this.response.appendInt(this.noUser ? 0 : this.item.getOwnerId()); + this.response.appendInt(this.noUser ? 0 : this.item.getOwnerInfo().getId()); this.response.appendInt(0); return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java index 9f09e379..ef7e00d6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/SleepMessageComposer.java @@ -10,7 +10,6 @@ import lombok.AllArgsConstructor; public class SleepMessageComposer extends MessageComposer { private final RoomHabbo roomHabbo; - @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.sleepMessageComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java index 6df02fa0..39239c4c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java @@ -41,8 +41,8 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(this.roomUnits.size()); for (RoomUnit roomUnit : this.roomUnits) { this.response.appendInt(roomUnit.getVirtualId()); - this.response.appendInt(roomUnit.getPreviousLocation().getX()); - this.response.appendInt(roomUnit.getPreviousLocation().getY()); + this.response.appendInt(roomUnit.getPreviousPosition().getX()); + this.response.appendInt(roomUnit.getPreviousPosition().getY()); this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); @@ -62,8 +62,8 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(this.habbos.size()); for (Habbo habbo : this.habbos) { this.response.appendInt(habbo.getRoomUnit().getVirtualId()); - this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getX()); - this.response.appendInt(habbo.getRoomUnit().getPreviousLocation().getY()); + this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getX()); + this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getY()); this.response.appendString(habbo.getRoomUnit().getPreviousLocationZ() + ""); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java index b5348e2f..d5bf751e 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java @@ -27,7 +27,7 @@ public class ChangeRoomOwner extends RCONMessage { room.getRoomInfo().setOwnerInfo(newOwner.getHabboInfo()); room.setNeedsUpdate(true); room.save(); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room.dispose(); } static class JSON { diff --git a/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java b/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java index aac25f42..e8b0dece 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java +++ b/src/main/java/com/eu/habbo/messages/rcon/FriendRequest.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.messages.outgoing.friends.NewFriendRequestComposer; import com.google.gson.Gson; @@ -25,7 +24,7 @@ public class FriendRequest extends RCONMessage { if (from != null) { target.getClient().sendResponse(new NewFriendRequestComposer(from.getHabboInfo())); } else { - final HabboInfo info = HabboManager.getOfflineHabboInfo(json.user_id); + final HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(json.user_id); if (info != null) { target.getClient().sendResponse(new NewFriendRequestComposer(info)); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java b/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java index 25b276ac..074133db 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendRoomBundle.java @@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.catalog.CatalogPage; import com.eu.habbo.habbohotel.catalog.layouts.RoomBundleLayout; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.habbohotel.users.HabboManager; import com.google.gson.Gson; public class SendRoomBundle extends RCONMessage { @@ -23,7 +22,7 @@ public class SendRoomBundle extends RCONMessage { if (habbo != null) { ((RoomBundleLayout) page).buyRoom(habbo); } else { - HabboInfo info = HabboManager.getOfflineHabboInfo(json.user_id); + HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(json.user_id); if (info != null) { ((RoomBundleLayout) page).buyRoom(null, json.user_id, info.getUsername()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java index 7ac9c258..200044e7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BackgroundAnimation.java @@ -16,7 +16,7 @@ public class BackgroundAnimation implements Runnable { @Override public void run() { if (this.room.isLoaded() && !this.room.isPreLoaded()) { - this.toner.setExtradata("1:" + this.state + ":126:126"); + this.toner.setExtraData("1:" + this.state + ":126:126"); this.state = (this.state + 1) % 256; this.room.updateItem(this.toner); diff --git a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java index 6e66017c..8527cdb1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -21,7 +21,7 @@ public class BanzaiRandomTeleport implements Runnable { public void run() { RoomItem topItemNow = this.room.getRoomItemManager().getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); RoomTile lastLocation = this.habbo.getCurrentPosition(); - RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY()); + RoomTile newLocation = this.room.getLayout().getTile(toItem.getCurrentPosition().getX(), toItem.getCurrentPosition().getY()); if(topItemNow != null) { try { @@ -32,14 +32,14 @@ public class BanzaiRandomTeleport implements Runnable { } Emulator.getThreading().run(() -> { - if (this.item.getExtradata().equals("1")) { - this.item.setExtradata("0"); + if (this.item.getExtraData().equals("1")) { + this.item.setExtraData("0"); this.room.updateItemState(this.item); } }, 500); - if(!this.toItem.getExtradata().equals("1")) { - this.toItem.setExtradata("1"); + if(!this.toItem.getExtraData().equals("1")) { + this.toItem.setExtraData("1"); this.room.updateItemState(this.toItem); } @@ -55,8 +55,8 @@ public class BanzaiRandomTeleport implements Runnable { } } - if (this.toItem.getExtradata().equals("1")) { - this.toItem.setExtradata("0"); + if (this.toItem.getExtraData().equals("1")) { + this.toItem.setExtraData("0"); this.room.updateItemState(this.toItem); } }, 750); diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java index 0e4670f3..a1ebe1a2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -33,14 +33,14 @@ public class BattleBanzaiTilesFlicker implements Runnable { } for (RoomItem item : this.items) { - item.setExtradata(state + ""); + item.setExtraData(state + ""); } this.room.sendComposer(new ItemsDataUpdateComposer(this.items).compose()); if (this.count == 9) { for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { - item.setExtradata("0"); + item.setExtraData("0"); this.room.updateItemState(item); } return; diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java index cb2b4365..878246d7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -32,7 +32,7 @@ public class CannonKickAction implements Runnable { dater.put("message", "${notification.room.kick.cannonball.message}"); int rotation = this.cannon.getRotation(); - List tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3); + List tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getCurrentPosition().getX(), this.cannon.getCurrentPosition().getY()), rotation + 6, 3); ServerMessage message = new NotificationDialogMessageComposer("cannon.png", dater).compose(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index a79a48da..068122d9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -20,9 +20,9 @@ public class ClearRentedSpace implements Runnable { public void run() { HashSet items = new HashSet<>(); - for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { + for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) { - if (i.getOwnerId() == this.item.getRenterId()) { + if (i.getOwnerInfo().getId() == this.item.getRenterId()) { items.add(i); i.setRoomId(0); i.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java index 22033b4a..775d0536 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java @@ -14,14 +14,14 @@ public class CloseGate implements Runnable { public void run() { if (this.gate.getRoomId() == this.room.getRoomInfo().getId()) { if (this.room.isLoaded()) { - RoomTile tile = this.room.getLayout().getTile(this.gate.getX(), this.gate.getY()); + RoomTile tile = this.room.getLayout().getTile(this.gate.getCurrentPosition().getX(), this.gate.getCurrentPosition().getY()); if(tile == null) { return; } if (!this.room.getRoomUnitManager().hasHabbosAt(tile)) { - this.gate.setExtradata("0"); + this.gate.setExtraData("0"); this.room.updateItem(this.gate); this.gate.needsUpdate(true); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index 237d4eea..614df84a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable; 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.users.Habbo; import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer; @@ -19,8 +20,7 @@ public class CrackableExplode implements Runnable { private final InteractionCrackable habboItem; private final Habbo habbo; private final boolean toInventory; - private final short x; - private final short y; + private final RoomTile tile; @Override public void run() { @@ -40,7 +40,7 @@ public class CrackableExplode implements Runnable { Item rewardItem = Emulator.getGameEnvironment().getItemManager().getCrackableReward(this.habboItem.getBaseItem().getId()); if (rewardItem != null) { - RoomItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getOwnerId(), rewardItem, 0, 0, ""); + RoomItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getOwnerInfo().getId(), rewardItem, 0, 0, ""); if (newItem != null) { //Add to inventory in case if isn't possible place the item or in case is wall item @@ -49,18 +49,18 @@ public class CrackableExplode implements Runnable { this.habbo.getClient().sendResponse(new UnseenItemsComposer(newItem)); this.habbo.getClient().sendResponse(new FurniListInvalidateComposer()); } else { - newItem.setX(this.x); - newItem.setY(this.y); - newItem.setZ(this.room.getStackHeight(this.x, this.y, false)); + newItem.setCurrentPosition(this.tile); + newItem.setCurrentZ(this.room.getStackHeight(this.tile.getX(), this.tile.getY(), false)); + newItem.setRoomId(this.room.getRoomInfo().getId()); newItem.needsUpdate(true); this.room.getRoomItemManager().addRoomItem(newItem); this.room.updateItem(newItem); - this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerId())).compose()); + this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerInfo().getId())).compose()); } } } - this.room.updateTile(this.room.getLayout().getTile(this.x, this.y)); + this.room.updateTile(this.tile); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java index a2e8ed07..639d9248 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboItemNewState.java @@ -12,7 +12,7 @@ public class HabboItemNewState implements Runnable { @Override public void run() { - this.item.setExtradata(this.state); + this.item.setExtraData(this.state); if (this.item.getRoomId() == this.room.getRoomInfo().getId()) { this.room.updateItemState(this.item); diff --git a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java index 7afad767..eb8c6e11 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/KickBallAction.java @@ -4,8 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionPushable; 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.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; @@ -36,10 +36,10 @@ public class KickBallAction implements Runnable { return; if (this.currentStep < this.totalSteps) { - RoomTile currentTile = this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()); + RoomTile currentTile = this.room.getLayout().getTile(this.ball.getCurrentPosition().getX(), this.ball.getCurrentPosition().getY()); RoomTile next = this.room.getLayout().getTileInFront(currentTile, this.currentDirection.getValue()); - if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next)) { + if (next == null || !this.ball.validMove(this.room, this.room.getLayout().getTile(this.ball.getCurrentPosition().getX(), this.ball.getCurrentPosition().getY()), next)) { RoomRotation oldDirection = this.currentDirection; if(!this.isDrag) { @@ -58,10 +58,10 @@ public class KickBallAction implements Runnable { int delay = this.ball.getNextRollDelay(this.currentStep, this.totalSteps); //Algorithm to work out the delay till next run - if (this.ball.canStillMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps)) { - this.ball.onMove(this.room, this.room.getLayout().getTile(this.ball.getX(), this.ball.getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps); + if (this.ball.canStillMove(this.room, this.room.getLayout().getTile(this.ball.getCurrentPosition().getX(), this.ball.getCurrentPosition().getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps)) { + this.ball.onMove(this.room, this.room.getLayout().getTile(this.ball.getCurrentPosition().getX(), this.ball.getCurrentPosition().getY()), next, this.currentDirection, this.kicker, delay, this.currentStep, this.totalSteps); - this.room.sendComposer(new FloorItemOnRollerComposer(this.ball, null, next, next.getStackHeight() - this.ball.getZ(), this.room).compose()); + this.room.sendComposer(new FloorItemOnRollerComposer(this.ball, null, next, next.getStackHeight() - this.ball.getCurrentZ(), this.room).compose()); Emulator.getThreading().run(this, delay); } else { diff --git a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java index 59e0251c..0f074672 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -19,17 +19,17 @@ public class OneWayGateActionOne implements Runnable { public void run() { this.room.sendComposer(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); - RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getX(), this.oneWayGate.getY()), (this.oneWayGate.getRotation() + 4) % 8); + RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getCurrentPosition().getX(), this.oneWayGate.getCurrentPosition().getY()), (this.oneWayGate.getRotation() + 4) % 8); if (this.client.getHabbo().getRoomUnit().isAnimateWalk()) { this.client.getHabbo().getRoomUnit().setAnimateWalk(false); } if (t.isWalkable()) { - if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getY()) { + if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getCurrentPosition().getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getCurrentPosition().getY()) { this.client.getHabbo().getRoomUnit().setGoalLocation(t); - if (!this.oneWayGate.getExtradata().equals("0")) { + if (!this.oneWayGate.getExtraData().equals("0")) { Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000); } } @@ -38,7 +38,7 @@ public class OneWayGateActionOne implements Runnable { //} else { - if (!this.oneWayGate.getExtradata().equals("0")) { + if (!this.oneWayGate.getExtraData().equals("0")) { Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 710c954f..702f3e0a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -33,7 +33,7 @@ public class OpenGift implements Runnable { if (inside == null) inside = i; - i.setOwnerId(this.habbo.getHabboInfo().getId()); + i.setOwnerInfo(this.habbo.getHabboInfo()); i.needsUpdate(true); i.run(); } @@ -42,7 +42,7 @@ public class OpenGift implements Runnable { this.habbo.getInventory().getItemsComponent().addItems(items); - RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY()); + RoomTile tile = this.room.getLayout().getTile(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY()); if (tile != null) { this.room.updateTile(tile); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java index 85e8fe8d..d068b126 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java @@ -20,12 +20,12 @@ public class PetEatAction implements Runnable { @Override public void run() { if (this.pet.getRoomUnit() != null && this.pet.getRoom() != null) { - if (this.pet.levelHunger >= 20 && this.food != null && Integer.parseInt(this.food.getExtradata()) < this.food.getBaseItem().getStateCount()) { + if (this.pet.levelHunger >= 20 && this.food != null && Integer.parseInt(this.food.getExtraData()) < this.food.getBaseItem().getStateCount()) { this.pet.addHunger(-20); this.pet.setTask(PetTasks.EAT); this.pet.getRoomUnit().setCanWalk(false); - this.food.setExtradata(Integer.parseInt(this.food.getExtradata()) + 1 + ""); + this.food.setExtraData(Integer.parseInt(this.food.getExtraData()) + 1 + ""); this.pet.getRoom().updateItem(this.food); if (this.pet instanceof GnomePet) { @@ -40,7 +40,7 @@ public class PetEatAction implements Runnable { Emulator.getThreading().run(this, 1000); } else { - if (this.food != null && Integer.parseInt(this.food.getExtradata()) == this.food.getBaseItem().getStateCount()) { + if (this.food != null && Integer.parseInt(this.food.getExtraData()) == this.food.getBaseItem().getStateCount()) { Emulator.getThreading().run(new QueryDeleteHabboItem(this.food.getId()), 500); if (this.pet.getRoom() != null) { this.pet.getRoom().getRoomItemManager().removeRoomItem(this.food); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java index 0aa18560..2e41d251 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java @@ -30,7 +30,7 @@ public class RandomDiceNumber implements Runnable { if (this.result <= 0) this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1); - this.item.setExtradata(this.result + ""); + this.item.setExtraData(this.result + ""); this.item.needsUpdate(true); Emulator.getThreading().run(this.item); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java index b699cda0..1a76da07 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java @@ -29,7 +29,7 @@ public class RandomSpinningBottleNumber implements Runnable { if (this.result <= 0) this.result = Emulator.getRandom().nextInt(this.maxNumber); - this.item.setExtradata(this.result + ""); + this.item.setExtraData(this.result + ""); this.item.needsUpdate(true); Emulator.getThreading().run(this.item); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java index d7eb4e2b..26f68060 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RemoveFloorItemTask.java @@ -18,10 +18,10 @@ class RemoveFloorItemTask implements Runnable { if (this.item == null || this.room == null) return; - RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY()); + RoomTile tile = this.room.getLayout().getTile(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY()); this.room.getRoomItemManager().removeRoomItem(this.item); this.room.updateTile(tile); this.room.sendComposer(new RemoveFloorItemComposer(this.item, true).compose()); - this.room.sendComposer(new HeightMapUpdateMessageComposer(this.item.getX(), this.item.getY(), tile.getZ(), tile.relativeHeight()).compose()); + this.room.sendComposer(new HeightMapUpdateMessageComposer(this.item.getCurrentPosition().getX(), this.item.getCurrentPosition().getY(), tile.getZ(), tile.relativeHeight()).compose()); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 79743b4b..0d7d2e59 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -18,7 +18,7 @@ public class RoomUnitRidePet implements Runnable { @Override public void run() { - if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getRoomUnit().getRoom() || this.goalTile == null || this.habbo.getRoomUnit().getGoalLocation() != this.goalTile) + if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getRoomUnit().getRoom() || this.goalTile == null || this.habbo.getRoomUnit().getTargetPosition() != this.goalTile) return; if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 2422f360..208f773e 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -24,7 +24,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { } RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.roomItem); - if (!this.habbo.getRoomUnit().getGoalLocation().equals(tile)) { + if (!this.habbo.getRoomUnit().getTargetPosition().equals(tile)) { return; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 7a333ae9..999b0b1d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -27,7 +27,7 @@ public class RoomUnitVendingMachineAction implements Runnable { return; } - if (this.habbo.getRoomUnit().getGoalLocation().equals(tile)) { + if (this.habbo.getRoomUnit().getTargetPosition().equals(tile)) { if (this.habbo.getRoomUnit().getCurrentPosition().equals(tile)) { try { this.roomItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index ed9f3467..61256ee0 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -43,7 +43,7 @@ public class RoomUnitWalkToLocation implements Runnable { return; } - if (!this.walker.getGoalLocation().equals(this.goalTile) || (this.walker.getPath().isEmpty() && !this.walker.hasStatus(RoomUnitStatus.MOVE))) { + if (!this.walker.getTargetPosition().equals(this.goalTile) || (this.walker.getPath().isEmpty() && !this.walker.hasStatus(RoomUnitStatus.MOVE))) { onFail(); return; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index 193e6d1b..118f2a98 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -38,7 +38,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { return; } - if (this.walker.getGoalLocation().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal + if (this.walker.getTargetPosition().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal if (this.walker.getCurrentPosition().distance(this.goalTile) <= this.minDistance) { for (Runnable r : this.targetReached) { Emulator.getThreading().run(r); diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index 2752003b..dbb92645 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -37,7 +37,7 @@ class TeleportInteraction extends Thread { public void run() { try { if (this.state == 5) { - this.teleportTwo.setExtradata("1"); + this.teleportTwo.setExtraData("1"); this.targetRoom.updateItem(this.teleportTwo); this.room.updateItem(this.teleportOne); RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportTwo); @@ -65,8 +65,8 @@ class TeleportInteraction extends Thread { this.teleportTwo = this.teleportOne; } - this.teleportOne.setExtradata("2"); - this.teleportTwo.setExtradata("2"); + this.teleportOne.setExtraData("2"); + this.teleportTwo.setExtraData("2"); if (this.room != this.targetRoom) { Emulator.getGameEnvironment().getRoomManager().logExit(this.client.getHabbo()); @@ -75,8 +75,8 @@ class TeleportInteraction extends Thread { } this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.teleportTwo.getRotation()]); - this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportTwo.getX(), this.teleportTwo.getY())); - this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportTwo.getZ()); + this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportTwo.getCurrentPosition().getX(), this.teleportTwo.getCurrentPosition().getY())); + this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportTwo.getCurrentZ()); this.room.sendComposer(new UserRemoveMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); this.targetRoom.sendComposer(new UserRemoveMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); @@ -90,14 +90,14 @@ class TeleportInteraction extends Thread { Emulator.getThreading().run(this, 500); } else if (this.state == 3) { - this.teleportOne.setExtradata("0"); + this.teleportOne.setExtraData("0"); this.room.updateItem(this.teleportOne); this.state = 4; Emulator.getThreading().run(this, 500); } else if (this.state == 2) { - this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getX(), this.teleportOne.getY())); + this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY())); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.newRotation(this.teleportOne.getRotation())]); - this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); + this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.teleportOne.getCurrentPosition().getX() + "," + this.teleportOne.getCurrentPosition().getY() + "," + this.teleportOne.getCurrentZ()); //room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit())); this.state = 3; @@ -108,7 +108,7 @@ class TeleportInteraction extends Thread { if (this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == loc.getX()) { if (this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == loc.getY()) { - this.teleportOne.setExtradata("1"); + this.teleportOne.setExtraData("1"); this.room.updateItem(this.teleportOne); this.state = 2; diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index 2e19b25e..1c607a74 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -41,11 +41,11 @@ class FreezeHandleSnowballExplosion implements Runnable { return; if (player.nextHorizontal) { - tiles.addAll(game.affectedTilesByExplosion(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY(), this.thrownData.radius + 1)); + tiles.addAll(game.affectedTilesByExplosion(this.thrownData.targetTile.getCurrentPosition().getX(), this.thrownData.targetTile.getCurrentPosition().getY(), this.thrownData.radius + 1)); } if (player.nextDiagonal) { - tiles.addAll(game.affectedTilesByExplosionDiagonal(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY(), this.thrownData.radius + 1)); + tiles.addAll(game.affectedTilesByExplosionDiagonal(this.thrownData.targetTile.getCurrentPosition().getX(), this.thrownData.targetTile.getCurrentPosition().getY(), this.thrownData.radius + 1)); player.nextDiagonal = false; } @@ -57,20 +57,20 @@ class FreezeHandleSnowballExplosion implements Runnable { for (RoomItem freezeTile : items) { if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) { int distance = 0; - if (freezeTile.getX() != this.thrownData.targetTile.getX() && freezeTile.getY() != this.thrownData.targetTile.getY()) { - distance = Math.abs(freezeTile.getX() - this.thrownData.targetTile.getX()); + if (freezeTile.getCurrentPosition().getX() != this.thrownData.targetTile.getCurrentPosition().getX() && freezeTile.getCurrentPosition().getY() != this.thrownData.targetTile.getCurrentPosition().getY()) { + distance = Math.abs(freezeTile.getCurrentPosition().getX() - this.thrownData.targetTile.getCurrentPosition().getX()); } else { - distance = (int) Math.ceil(this.thrownData.room.getLayout().getTile(this.thrownData.targetTile.getX(), this.thrownData.targetTile.getY()).distance(roomTile)); + distance = (int) Math.ceil(this.thrownData.room.getLayout().getTile(this.thrownData.targetTile.getCurrentPosition().getX(), this.thrownData.targetTile.getCurrentPosition().getY()).distance(roomTile)); } if (freezeTile instanceof InteractionFreezeTile) { - freezeTile.setExtradata("11" + String.format("%03d", distance * 100)); //TODO Investigate this further. Probably height dependent or something. + freezeTile.setExtraData("11" + String.format("%03d", distance * 100)); //TODO Investigate this further. Probably height dependent or something. freezeTiles.add((InteractionFreezeTile) freezeTile); this.thrownData.room.updateItem(freezeTile); THashSet habbos = new THashSet<>(); - RoomTile tile = this.thrownData.room.getLayout().getTile(freezeTile.getX(), freezeTile.getY()); + RoomTile tile = this.thrownData.room.getLayout().getTile(freezeTile.getCurrentPosition().getX(), freezeTile.getCurrentPosition().getY()); habbos.addAll(this.thrownData.room.getRoomUnitManager().getHabbosAt(tile)); for (Habbo habbo : habbos) { @@ -91,7 +91,7 @@ class FreezeHandleSnowballExplosion implements Runnable { } } } else { - if (freezeTile.getExtradata().equalsIgnoreCase("0")) { + if (freezeTile.getExtraData().equalsIgnoreCase("0")) { game.explodeBox((InteractionFreezeBlock) freezeTile, distance * 100); player.addScore(FreezeGame.DESTROY_BLOCK_POINTS); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java index 329543d1..da8426d9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeResetExplosionTiles.java @@ -15,7 +15,7 @@ class FreezeResetExplosionTiles implements Runnable { @Override public void run() { for (RoomItem item : this.tiles) { - item.setExtradata("0"); + item.setExtraData("0"); this.room.updateItem(item); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java index 2c86bff4..0ed63f60 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeThrowSnowball.java @@ -24,7 +24,7 @@ public class FreezeThrowSnowball implements Runnable { @Override public void run() { ((FreezeGamePlayer) this.habbo.getHabboInfo().getGamePlayer()).takeSnowball(); - this.targetTile.setExtradata((this.radius + 1) * 1000 + ""); + this.targetTile.setExtraData((this.radius + 1) * 1000 + ""); this.room.updateItem(this.targetTile); Emulator.getThreading().run(new FreezeHandleSnowballExplosion(this), 2000); Emulator.getThreading().run(new HabboItemNewState(this.targetTile, this.room, "11000"), 2000); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java index 8f1602fe..408e82a9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java @@ -17,7 +17,7 @@ class HopperActionFive implements Runnable { @Override public void run() { this.client.getHabbo().getRoomUnit().setTeleporting(false); - RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()), this.currentTeleport.getRotation()); + RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY()), this.currentTeleport.getRotation()); if (tile != null) { this.client.getHabbo().getRoomUnit().setGoalLocation(tile); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java index 9c9c7823..a7b0f75b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFour.java @@ -14,7 +14,7 @@ class HopperActionFour implements Runnable { @Override public void run() { - this.currentTeleport.setExtradata("1"); + this.currentTeleport.setExtraData("1"); this.room.updateItem(this.currentTeleport); Emulator.getThreading().run(new HopperActionFive(this.currentTeleport, this.room, this.client), 500); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java index ec1c8c4e..1b97cbd9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java @@ -19,11 +19,11 @@ public class HopperActionOne implements Runnable { public void run() { //this.client.getHabbo().getRoomUnit().setGoalLocation(this.teleportOne.getX(), this.teleportOne.getY()); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[(this.teleportOne.getRotation() + 4) % 8]); - this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.teleportOne.getX() + "," + this.teleportOne.getY() + "," + this.teleportOne.getZ()); + this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.teleportOne.getCurrentPosition().getX() + "," + this.teleportOne.getCurrentPosition().getY() + "," + this.teleportOne.getCurrentZ()); this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); - this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getX(), this.teleportOne.getY())); - this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getZ()); - this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getZ()); + this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY())); + this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getCurrentZ()); + this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getCurrentZ()); Emulator.getThreading().run(() -> { HopperActionOne.this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java index 84335194..2cd4aa22 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java @@ -40,11 +40,11 @@ class HopperActionThree implements Runnable { return; } - targetTeleport.setExtradata("2"); + targetTeleport.setExtraData("2"); targetRoom.updateItem(targetTeleport); - this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getX(), targetTeleport.getY())); - this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getZ()); - this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getZ()); + this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getCurrentPosition().getX(), targetTeleport.getCurrentPosition().getY())); + this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getCurrentZ()); + this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getCurrentZ()); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); targetRoom.sendComposer(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index 3a7c7831..545ffd68 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -22,7 +22,7 @@ class HopperActionTwo implements Runnable { @Override public void run() { - this.teleportOne.setExtradata("2"); + this.teleportOne.setExtraData("2"); int targetRoomId = 0; int targetItemId = 0; @@ -44,7 +44,7 @@ class HopperActionTwo implements Runnable { if (targetRoomId != 0 && targetItemId != 0) { Emulator.getThreading().run(new HopperActionThree(this.teleportOne, this.room, this.client, targetRoomId, targetItemId), 500); } else { - this.teleportOne.setExtradata("0"); + this.teleportOne.setExtraData("0"); this.client.getHabbo().getRoomUnit().setCanWalk(true); this.client.getHabbo().getRoomUnit().setTeleporting(false); Emulator.getThreading().run(new HopperActionFour(this.teleportOne, this.room, this.client), 500); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index e60b022a..df1826e9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -37,7 +37,7 @@ class TeleportActionFive implements Runnable { if (this.room.getLayout() == null || this.currentTeleport == null) return; - RoomTile currentLocation = this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()); + RoomTile currentLocation = this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY()); RoomTile tile = this.room.getLayout().getTileInFront(currentLocation, this.currentTeleport.getRotation()); if (tile != null) { @@ -55,7 +55,7 @@ class TeleportActionFive implements Runnable { Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess)); } - this.currentTeleport.setExtradata("1"); + this.currentTeleport.setExtraData("1"); this.room.updateItem(this.currentTeleport); Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java index 6ed4fef4..8b360570 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFour.java @@ -17,7 +17,7 @@ class TeleportActionFour implements Runnable { public void run() { if (this.client.getHabbo().getRoomUnit().getRoom() != this.room) { this.client.getHabbo().getRoomUnit().setCanWalk(true); - this.currentTeleport.setExtradata("0"); + this.currentTeleport.setExtraData("0"); this.room.updateItem(this.currentTeleport); return; } diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java index 652b2bb1..2ab481b9 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionOne.java @@ -27,12 +27,12 @@ public class TeleportActionOne implements Runnable { delay = 0; } - if (this.client.getHabbo().getRoomUnit().getCurrentPosition() != this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())) { - this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())); + if (this.client.getHabbo().getRoomUnit().getCurrentPosition() != this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY())) { + this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY())); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[(this.currentTeleport.getRotation() + 4) % 8]); - this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.MOVE, this.currentTeleport.getX() + "," + this.currentTeleport.getY() + "," + this.currentTeleport.getZ()); + this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.currentTeleport.getCurrentPosition().getX() + "," + this.currentTeleport.getCurrentPosition().getY() + "," + this.currentTeleport.getCurrentZ()); this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); - this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY())); + this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY())); } Emulator.getThreading().run(new TeleportActionTwo(this.currentTeleport, this.room, this.client), delay); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 67e59b84..16400f3c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -46,7 +46,7 @@ class TeleportActionThree implements Runnable { return; } - RoomTile teleportLocation = targetRoom.getLayout().getTile(targetTeleport.getX(), targetTeleport.getY()); + RoomTile teleportLocation = targetRoom.getLayout().getTile(targetTeleport.getCurrentPosition().getX(), targetTeleport.getCurrentPosition().getY()); if (teleportLocation == null) { Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 0); @@ -65,7 +65,7 @@ class TeleportActionThree implements Runnable { this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); - targetTeleport.setExtradata("2"); + targetTeleport.setExtraData("2"); targetRoom.updateItem(targetTeleport); //targetRoom.updateHabbo(this.client.getHabbo()); //LOGGER.info((targetTeleport.getX() + " | " + targetTeleport.getY()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index fbdc1c36..f089d215 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -77,7 +77,7 @@ class TeleportActionTwo implements Runnable { } } - this.currentTeleport.setExtradata("0"); + this.currentTeleport.setExtraData("0"); this.room.updateItem(this.currentTeleport); if (((InteractionTeleport) this.currentTeleport).getTargetRoomId() == 0) { From 13a05d1c071618f8f07d127dbf77561547ef0c10 Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 2 Aug 2023 15:44:28 -0500 Subject: [PATCH 34/42] RoomUnit walking behaviour refactor --- .../com/eu/habbo/habbohotel/bots/Bot.java | 43 +- .../eu/habbo/habbohotel/bots/BotManager.java | 3 - .../commands/list/EnableCommand.java | 2 +- .../commands/list/FastwalkCommand.java | 7 +- .../habbohotel/commands/list/PullCommand.java | 2 +- .../habbohotel/commands/list/PushCommand.java | 2 +- .../habbohotel/commands/list/SitCommand.java | 2 +- .../commands/list/StandCommand.java | 2 +- .../commands/list/SummonCommand.java | 2 + .../commands/list/SuperPullCommand.java | 2 +- .../commands/list/TeleportCommand.java | 2 +- .../habbo/habbohotel/items/ItemManager.java | 2 +- .../interactions/InteractionBuildArea.java | 2 +- .../items/interactions/InteractionCannon.java | 2 +- .../interactions/InteractionCrackable.java | 4 +- .../interactions/InteractionFireworks.java | 2 +- .../interactions/InteractionGymEquipment.java | 2 +- .../items/interactions/InteractionHopper.java | 4 +- .../interactions/InteractionMultiHeight.java | 1 - .../interactions/InteractionMuteArea.java | 2 +- .../interactions/InteractionObstacle.java | 12 +- .../interactions/InteractionOneWayGate.java | 4 +- .../interactions/InteractionPuzzleBox.java | 6 +- .../InteractionRentableSpace.java | 4 +- .../items/interactions/InteractionSwitch.java | 2 +- .../interactions/InteractionTeleport.java | 12 +- .../interactions/InteractionTeleportTile.java | 2 +- .../InteractionVendingMachine.java | 2 +- .../games/InteractionGameTimer.java | 5 - .../InteractionBattleBanzaiTeleporter.java | 2 +- .../interactions/pets/InteractionNest.java | 2 +- .../pets/InteractionPetDrink.java | 4 +- .../interactions/pets/InteractionPetFood.java | 2 +- .../interactions/pets/InteractionPetToy.java | 2 +- .../pets/InteractionPetTrampoline.java | 2 +- .../effects/WiredEffectBotGiveHandItem.java | 2 +- .../effects/WiredEffectBotWalkToFurni.java | 2 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 21 +- .../eu/habbo/habbohotel/pets/PetCommand.java | 2 +- .../eu/habbo/habbohotel/pets/PetManager.java | 3 + .../habbohotel/pets/actions/ActionBreed.java | 2 +- .../habbohotel/pets/actions/ActionDip.java | 2 +- .../habbohotel/pets/actions/ActionHere.java | 2 +- .../pets/actions/ActionMoveForward.java | 2 +- .../pets/actions/ActionPlayFootball.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 38 +- .../habbohotel/rooms/RoomItemManager.java | 6 + .../eu/habbo/habbohotel/rooms/RoomLayout.java | 2 +- .../habbo/habbohotel/rooms/RoomManager.java | 21 +- .../eu/habbo/habbohotel/rooms/RoomTile.java | 9 +- .../habbohotel/rooms/RoomTraxManager.java | 7 +- .../habbohotel/rooms/RoomUnitManager.java | 29 +- .../rooms/entities/IRoomEntity.java | 6 + .../habbohotel/rooms/entities/RoomEntity.java | 55 ++- .../rooms/entities/items/RoomItem.java | 52 ++- .../rooms/entities/units/RoomUnit.java | 397 +++++++++++------- .../entities/units/types/RoomAvatar.java | 337 +++------------ .../rooms/entities/units/types/RoomBot.java | 59 +-- .../rooms/entities/units/types/RoomHabbo.java | 61 ++- .../rooms/entities/units/types/RoomPet.java | 172 +------- .../com/eu/habbo/habbohotel/units/Unit.java | 2 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 2 + .../eu/habbo/habbohotel/users/HabboInfo.java | 2 - .../incoming/hotelview/QuitEvent.java | 6 +- .../items/CustomizeAvatarWithFurniEvent.java | 2 + .../rooms/items/PlacePostItEvent.java | 2 + .../incoming/rooms/items/RemoveItemEvent.java | 2 + .../pets/CustomizePetWithFurniEvent.java | 2 + .../incoming/rooms/pets/MountPetEvent.java | 8 +- .../incoming/rooms/pets/MovePetEvent.java | 2 - .../incoming/rooms/pets/PlacePetEvent.java | 23 +- .../incoming/rooms/pets/RespectPetEvent.java | 2 +- .../incoming/rooms/users/MoveAvatarEvent.java | 195 ++------- .../rooms/users/RoomUnitOnRollerComposer.java | 1 - .../rooms/users/UserUpdateComposer.java | 31 +- .../events/roomunit/RoomUnitSetGoalEvent.java | 2 +- .../threading/runnables/BotFollowHabbo.java | 2 +- .../threading/runnables/ClearRentedSpace.java | 2 + .../threading/runnables/CrackableExplode.java | 5 +- .../runnables/OneWayGateActionOne.java | 6 +- .../threading/runnables/PetFollowHabbo.java | 2 +- .../threading/runnables/RoomUnitRidePet.java | 8 +- .../threading/runnables/RoomUnitTeleport.java | 2 - .../RoomUnitTeleportWalkToAction.java | 2 +- .../RoomUnitVendingMachineAction.java | 2 +- .../runnables/RoomUnitWalkToRoomUnit.java | 2 +- .../runnables/TeleportInteraction.java | 4 +- .../runnables/hopper/HopperActionFive.java | 2 +- .../runnables/hopper/HopperActionOne.java | 1 - .../runnables/hopper/HopperActionThree.java | 1 - .../teleport/TeleportActionFive.java | 2 +- .../teleport/TeleportActionThree.java | 4 - 92 files changed, 695 insertions(+), 1080 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 1bdaf554..1fd17654 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -121,6 +121,7 @@ public class Bot extends Unit implements Runnable { this.bubbleId = set.getInt("bubble_id"); this.roomUnit = new RoomBot(); + this.roomUnit.setUnit(this); } public Bot(Bot bot) { @@ -189,48 +190,6 @@ public class Bot extends Unit implements Runnable { } } - public void cycle(boolean allowBotsWalk) { - if (this.getRoomUnit() != null) { - if (allowBotsWalk && this.canWalk) { - if (!this.getRoomUnit().isWalking()) { - if (this.getRoomUnit().getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) { - this.getRoomUnit().setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.room.getLayout().getRandomWalkableTilesAround(this.getRoomUnit(), this.room.getLayout().getTile(this.getRoomUnit().getBotStartLocation().getX(), this.getRoomUnit().getBotStartLocation().getY()), this.room, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.room.getRandomWalkableTile()); - - int timeOut = Emulator.getRandom().nextInt(20) * 2; - this.getRoomUnit().setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); - } - }/* else { - for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) { - WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.getRoomUnit(), this.room, this.room.getItemsAt(t).toArray()); - } - }*/ - } - - if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) { - if (this.room != null) { - this.lastChatIndex = (this.chatRandom ? (short) Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++)); - - if (this.lastChatIndex >= this.chatLines.size()) { - this.lastChatIndex = 0; - } - - String message = this.chatLines.get(this.lastChatIndex) - .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getRoomInfo().getOwnerInfo().getUsername()) - .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.getRoomItemManager().getCurrentItems().size() + "") - .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name) - .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getRoomInfo().getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getRoomUnitManager().getRoomHabbosCount() + ""); - - if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) { - this.talk(message); - } - - this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; - } - } - } - } - public void talk(String message) { if (this.room != null) { BotChatEvent event = new BotTalkEvent(this, message); diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index a8f6931c..c0914662 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -126,13 +126,10 @@ public class BotManager { return; } - bot.setRoomUnit(new RoomBot()); - RoomBot roomBot = bot.getRoomUnit(); roomBot.setRotation(RoomRotation.SOUTH); roomBot.setLocation(location); double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY()); - roomBot.setPreviousLocationZ(stackHeight); roomBot.setCurrentZ(stackHeight); roomBot.setRoom(room); roomBot.setRoomUnitType(RoomUnitType.BOT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java index bfe37b2a..e1860133 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java @@ -33,7 +33,7 @@ public class EnableCommand extends Command { } if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ENABLE_OTHERS)) { try { - if (target.getRoomUnit().getRoom() != null && target.getHabboInfo().getRiding() == null) { + if (target.getRoomUnit().getRoom() != null && !target.getRoomUnit().isRiding()) { if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) { gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java index 65c9e5f5..cc5dfd75 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java @@ -12,9 +12,11 @@ public class FastwalkCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { if (gameClient.getHabbo().getRoomUnit().getRoom() != null) { + //TODO Make this an event plugin which fires that can be cancelled - if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getHabboInfo().getRiding() != null) + if (gameClient.getHabbo().getRoomUnit().isRiding()) { return true; + } Habbo habbo = gameClient.getHabbo(); @@ -26,7 +28,8 @@ public class FastwalkCommand extends Command { if (habbo == null) return false; } - habbo.getRoomUnit().setFastWalkEnabled(!habbo.getRoomUnit().isFastWalkEnabled()); + + habbo.getRoomUnit().setCmdFastWalkEnabled(!habbo.getRoomUnit().isCmdFastWalkEnabled()); return true; } 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 8fee7982..da1c4285 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 @@ -41,7 +41,7 @@ public class PullCommand extends Command { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1])); return true; } - habbo.getRoomUnit().setGoalLocation(tile); + habbo.getRoomUnit().walkTo(tile); gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); } 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 dea7b678..a14768b6 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 @@ -40,7 +40,7 @@ public class PushCommand extends Command { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_push.invalid"), params[1])); return true; } - habbo.getRoomUnit().setGoalLocation(tFrontTarget); + habbo.getRoomUnit().walkTo(tFrontTarget); gameClient.getHabbo().getRoomUnit().getRoom().sendComposer( new ChatMessageComposer( new RoomChatMessage( diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java index 7ef27f24..66667785 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java @@ -10,7 +10,7 @@ public class SitCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled + if (!gameClient.getHabbo().getRoomUnit().isRiding()) //TODO Make this an event plugin which fires that can be cancelled gameClient.getHabbo().getRoomUnit().makeSit(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java index 8d2cf0d6..9f65e5a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java @@ -10,7 +10,7 @@ public class StandCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getRiding() == null) { + if (!gameClient.getHabbo().getRoomUnit().isRiding()) { gameClient.getHabbo().getRoomUnit().makeStand(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java index 83c9c42c..1c679c37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java @@ -41,6 +41,8 @@ public class SummonCommand extends Command { } Room room = habbo.getRoomUnit().getRoom(); + + //WHY? Why not just roomManager -> leaveRoom() if (room != null) { Emulator.getGameEnvironment().getRoomManager().logExit(habbo); 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 d1e3b2cd..852230a9 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 @@ -36,7 +36,7 @@ public class SuperPullCommand extends Command { gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]), RoomChatMessageBubbles.ALERT); return true; } - habbo.getRoomUnit().setGoalLocation(tile); + habbo.getRoomUnit().walkTo(tile); gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java index d1f67b33..518b44fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java @@ -12,7 +12,7 @@ public class TeleportCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getHabboInfo().getRiding() != null){ //TODO Make this an event plugin which fires that can be cancelled + if (gameClient.getHabbo().getRoomUnit().isRiding()){ //TODO Make this an event plugin which fires that can be cancelled return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 0532ab67..125a12d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -687,7 +687,7 @@ public class ItemManager { Constructor c = itemClass.getConstructor(ResultSet.class, Item.class); c.setAccessible(true); - RoomItem item = (RoomItem) c.newInstance(set, baseItem); + RoomItem item = c.newInstance(set, baseItem); if (item instanceof InteractionWired interactionWired) { interactionWired.loadWiredSettings(set); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java index cde00f3b..dff6cbd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -139,7 +139,7 @@ public class InteractionBuildArea extends InteractionCustomValues { } public boolean inSquare(RoomTile location) { - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + Room room = this.getRoom(); if (room != null && this.tiles.size() == 0) { regenAffectedTiles(room); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java index ebf28fc5..114871a0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java @@ -65,7 +65,7 @@ public class InteractionCannon extends RoomItem { if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentPosition())) && client.getHabbo().getRoomUnit().isCanWalk()) && !this.cooldown) { if (client != null) { client.getHabbo().getRoomUnit().setCanWalk(false); - client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentPosition()); + client.getHabbo().getRoomUnit().walkTo(client.getHabbo().getRoomUnit().getCurrentPosition()); client.getHabbo().getRoomUnit().lookAtPoint(fuseTile); client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index 2cf7524a..fcfc9515 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -64,14 +64,14 @@ public class InteractionCrackable extends RoomItem { super.onClick(client, room, objects); synchronized (this.lock) { - if (this.getRoomId() == 0) + if (this.getRoom() == null) return; if (this.cracked) return; if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) > 1.5) { - client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))); + client.getHabbo().getRoomUnit().walkTo(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 482005ae..50a3bff1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -87,7 +87,7 @@ public class InteractionFireworks extends InteractionDefault { } }); - client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + client.getHabbo().getRoomUnit().walkTo(closestTile); Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); } } 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 417cf5a0..d6a51125 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 @@ -131,7 +131,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC super.setRotation(rotation); if (this.forceRotation() && this.roomUnitId != -1) { - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + Room room = this.getRoom(); if (room != null) { RoomUnit roomUnit = this.getCurrentRoomUnit(room); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java index b4a939e0..717cbc3c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java @@ -62,7 +62,7 @@ public class InteractionHopper extends RoomItem { Emulator.getThreading().run(new HopperActionOne(this, room, client), 500); } else { - client.getHabbo().getRoomUnit().setGoalLocation(loc); + client.getHabbo().getRoomUnit().walkTo(loc); } } } @@ -78,7 +78,7 @@ public class InteractionHopper extends RoomItem { if (!this.getExtraData().equals("0")) { this.setExtraData("0"); - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + Room room = this.getRoom(); if (room != null) { room.updateItemState(this); } 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 2c6e09f2..5b19d9bd 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 @@ -91,7 +91,6 @@ public class InteractionMultiHeight extends RoomItem { } if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) { - unit.setSitUpdate(true); unit.setStatusUpdateNeeded(true); } else { unit.setCurrentZ(unit.getCurrentPosition().getStackHeight()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index f0824698..9ff89f85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -74,7 +74,7 @@ public class InteractionMuteArea extends InteractionCustomValues { } public boolean inSquare(RoomTile location) { - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + Room room = this.getRoom(); if(!this.values.get("state").equals("1")) return false; 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 16752dbd..d3546bc1 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 @@ -103,15 +103,15 @@ public class InteractionObstacle extends RoomItem implements ICycleable { if (roomUnit.getBodyRotation().getValue() % 2 == 0) { if (this.getRotation() == 2) { if (roomUnit.getBodyRotation().equals(RoomRotation.WEST)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY())); + ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY())); } else if (roomUnit.getBodyRotation().equals(RoomRotation.EAST)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY())); + ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY())); } } else if (this.getRotation() == 4) { if (roomUnit.getBodyRotation().equals(RoomRotation.NORTH)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3))); + ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3))); } else if (roomUnit.getBodyRotation().equals(RoomRotation.SOUTH)) { - ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3))); + ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3))); } } } @@ -191,12 +191,12 @@ public class InteractionObstacle extends RoomItem implements ICycleable { RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue()); if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) { - roomUnit.setGoalLocation(tileInfront); + roomUnit.walkTo(tileInfront); } else { RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue()); if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) { - roomUnit.setGoalLocation(tileBehind); + roomUnit.walkTo(tileBehind); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index f66f4939..9d8185a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -85,7 +85,7 @@ public class InteractionOneWayGate extends RoomItem { unit.setCanLeaveRoomByDoor(false); walkable = this.getBaseItem().allowWalk(); RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation() + 4); - unit.setGoalLocation(tile); + unit.walkTo(tile); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail)); Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500); @@ -102,7 +102,7 @@ public class InteractionOneWayGate extends RoomItem { walkable = true; room.updateTile(currentLocation); unit.addOverrideTile(currentLocation); - unit.setGoalLocation(currentLocation); + unit.walkTo(currentLocation); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail)); room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 04679175..aafe8fa3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -50,7 +50,7 @@ public class InteractionPuzzleBox extends RoomItem { if (rotation == null) { RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false); - if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile); + if (nearestTile != null) client.getHabbo().getRoomUnit().walkTo(nearestTile); return; } @@ -77,9 +77,9 @@ public class InteractionPuzzleBox extends RoomItem { room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); room.scheduledTasks.add(() -> { - client.getHabbo().getRoomUnit().setGoalLocation(boxLocation); + client.getHabbo().getRoomUnit().walkTo(boxLocation); - room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); + room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().walkTo(boxLocation)); }); this.needsUpdate(true); } 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 a12142b9..ca66792d 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 @@ -58,7 +58,7 @@ public class InteractionRentableSpace extends RoomItem { } } } else { - if (this.getRoomId() > 0) { + if (this.getRoom() != null) { Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()))); this.renterId = 0; } @@ -152,7 +152,7 @@ public class InteractionRentableSpace extends RoomItem { public void endRent() { this.setEndTimestamp(0); - Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); + Room room = this.getRoom(); if (room == null) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java index d23b1791..8fb08d3d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java @@ -62,7 +62,7 @@ public class InteractionSwitch extends InteractionDefault { } }); - client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + client.getHabbo().getRoomUnit().walkTo(closestTile); Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 9c209f90..78671ede 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -100,7 +100,7 @@ public class InteractionTeleport extends RoomItem { this.roomUnitID = roomHabbo.getVirtualId(); this.setExtraData("1"); room.updateItemState(this); - roomHabbo.setGoalLocation(inFrontTile); + roomHabbo.walkTo(inFrontTile); List onSuccess = new ArrayList<>(); List onFail = new ArrayList<>(); @@ -127,7 +127,7 @@ public class InteractionTeleport extends RoomItem { room.updateTile(currentItemLocation); roomHabbo.addOverrideTile(currentItemLocation); - roomHabbo.setGoalLocation(currentItemLocation); + roomHabbo.walkTo(currentItemLocation); roomHabbo.setCanLeaveRoomByDoor(false); Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, currentItemLocation, room, onSuccess, onFail)); @@ -138,7 +138,7 @@ public class InteractionTeleport extends RoomItem { onSuccess.add(() -> tryTeleport(client, room)); - roomHabbo.setGoalLocation(inFrontTile); + roomHabbo.walkTo(inFrontTile); Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, inFrontTile, room, onSuccess, onFail)); } } @@ -204,13 +204,13 @@ public class InteractionTeleport extends RoomItem { return false; } - RoomUnit unit = habbo.getRoomUnit(); + RoomHabbo roomHabbo = habbo.getRoomUnit(); - if (unit == null) { + if (roomHabbo == null) { return false; } - return habbo.getHabboInfo().getRiding() == null; + return !roomHabbo.isRiding(); } public void startTeleport(Room room, Habbo habbo) { 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 53aac853..74aaed4f 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 @@ -38,7 +38,7 @@ public class InteractionTeleportTile extends InteractionTeleport { return; if (!habbo.getRoomUnit().isTeleporting()) { - habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentPosition()); + habbo.getRoomUnit().walkTo(habbo.getRoomUnit().getCurrentPosition()); this.startTeleport(room, habbo, 1000); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index c002bbcf..72c7d8f9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -143,7 +143,7 @@ public class InteractionVendingMachine extends RoomItem { onSuccess.add(() -> tryInteract(client, room, unit)); - unit.setGoalLocation(tileToWalkTo); + unit.walkTo(tileToWalkTo); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail)); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 3f1b02b9..c9bd0cad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -321,11 +321,6 @@ public class InteractionGameTimer extends RoomItem implements Runnable { this.needsUpdate(true); } - @Override - public String getDatabaseExtraData() { - return this.getExtraData(); - } - @Override public boolean allowWiredResetState() { return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index 3e8744a2..859593de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -64,7 +64,7 @@ public class InteractionBattleBanzaiTeleporter extends RoomItem { this.setExtraData("1"); room.updateItemState(this); roomUnit.removeStatus(RoomUnitStatus.MOVE); - roomUnit.setGoalLocation(roomUnit.getCurrentPosition()); + roomUnit.walkTo(roomUnit.getCurrentPosition()); roomUnit.setCanWalk(false); Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java index 253535ee..d4fea6d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java @@ -72,7 +72,7 @@ public class InteractionNest extends RoomItem { return; pet.setTask(PetTasks.NEST); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false) + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index 1b6a04a2..ae9951db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -58,7 +58,7 @@ public class InteractionPetDrink extends InteractionDefault { List onSuccess = new ArrayList<>(); onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1)); - client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + client.getHabbo().getRoomUnit().walkTo(closestTile); Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); } } @@ -76,7 +76,7 @@ public class InteractionPetDrink extends InteractionDefault { if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) { pet.clearPosture(); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java index 8bdf3757..5e606bcf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java @@ -38,7 +38,7 @@ public class InteractionPetFood extends InteractionDefault { if (pet.getPetData().haveFoodItem(this)) { if (pet.levelHunger >= 35) { pet.setTask(PetTasks.EAT); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index b53a95ce..4a13ee51 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -65,7 +65,7 @@ public class InteractionPetToy extends InteractionDefault { } pet.setTask(PetTasks.PLAY); - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]); pet.getRoomUnit().clearStatuses(); pet.getRoomUnit().addStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + ""); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java index 4361f4d6..acc70222 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -69,7 +69,7 @@ public class InteractionPetTrampoline extends InteractionDefault { pet.getRoomUnit().addStatus(RoomUnitStatus.JUMP, ""); Emulator.getThreading().run(() -> { new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false); - pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile()); + pet.getRoomUnit().walkTo(room.getRandomWalkableTile()); this.setExtraData("0"); room.updateItemState(this); }, 4000); 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 1bd29b60..9fd302a5 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 @@ -58,7 +58,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY(), true); if(tile != null) { - bot.getRoomUnit().setGoalLocation(tile); + bot.getRoomUnit().walkTo(tile); } Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, itemId)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index cafd087c..4a845ae0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -56,7 +56,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { if (item.getRoomId() != 0) { Room room1 = bot.getRoom(); if (item.getRoomId() == room1.getRoomInfo().getId()) { - bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + bot.getRoomUnit().walkTo(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 2425d5e0..1132de60 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -5,6 +5,7 @@ import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ISerialize; @@ -127,6 +128,10 @@ public class Pet extends Unit implements ISerialize, Runnable { @Getter private boolean muted = false; + @Getter + @Setter + private RoomPet roomUnit; + /** * Creates a new pet using the given result set, which should contain data retrieved from a * database. @@ -359,7 +364,7 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomTile tile = this.room.getRandomWalkableTile(); if (tile != null) { - this.getRoomUnit().setGoalLocation(tile); + this.getRoomUnit().walkTo(tile); } } @@ -376,7 +381,7 @@ public class Pet extends Unit implements ISerialize, Runnable { if (this.energy == PetManager.maxEnergy(this.level)) { this.getRoomUnit().removeStatus(RoomUnitStatus.LAY); this.getRoomUnit().setCanWalk(true); - this.getRoomUnit().setGoalLocation(this.room.getRandomWalkableTile()); + this.getRoomUnit().walkTo(this.room.getRandomWalkableTile()); this.task = null; this.getRoomUnit().addStatus(RoomUnitStatus.GESTURE, PetGestures.ENERGY.getKey()); this.gestureTickTimeout = currentTime; @@ -578,7 +583,7 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests()); this.getRoomUnit().setCanWalk(true); if (item != null) { - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } else { if(this instanceof HorsePet horsePet && horsePet.hasSaddle()) { return; @@ -603,7 +608,7 @@ public class Pet extends Unit implements ISerialize, Runnable { } catch (Exception ignored) { } } else { - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } return item != null; @@ -616,7 +621,7 @@ public class Pet extends Unit implements ISerialize, Runnable { RoomItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods()); if (item != null) { this.getRoomUnit().setCanWalk(true); - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } } @@ -636,7 +641,7 @@ public class Pet extends Unit implements ISerialize, Runnable { } return true; } - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); return true; } @@ -663,7 +668,7 @@ public class Pet extends Unit implements ISerialize, Runnable { } return true; } - this.getRoomUnit().setGoalLocation(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); + this.getRoomUnit().walkTo(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); return true; } return false; @@ -768,7 +773,7 @@ public class Pet extends Unit implements ISerialize, Runnable { */ public void freeCommand() { this.task = null; - this.getRoomUnit().setGoalLocation(this.getRoomUnit().getCurrentPosition()); + this.getRoomUnit().walkTo(this.getRoomUnit().getCurrentPosition()); this.getRoomUnit().clearStatuses(); this.getRoomUnit().setCanWalk(true); this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java index 0639ab46..b9d03275 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java @@ -59,7 +59,7 @@ public class PetCommand implements Comparable { if (this.action != null && pet.energy > this.energyCost && pet.happiness > this.happinessCost && Emulator.getRandom().nextInt((pet.level - this.level <= 0 ? 2 : pet.level - this.level) + 2) == 0) { if (this.action.petTask != pet.getTask()) { if (this.action.stopsPetWalking) { - pet.getRoomUnit().setGoalLocation(pet.getRoomUnit().getCurrentPosition()); + pet.getRoomUnit().walkTo(pet.getRoomUnit().getCurrentPosition()); } if (this.action.apply(pet, habbo, data)) { for (RoomUnitStatus status : this.action.statusToRemove) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index dbaf0664..354d4f5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -444,6 +444,7 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); @@ -463,6 +464,7 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); @@ -483,6 +485,7 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); pet.setNeedsUpdate(true); pet.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java index 38527995..3dfa32e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java @@ -25,7 +25,7 @@ public class ActionBreed extends PetAction { } if (nest != null) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(nest.getCurrentPosition().getX(), nest.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTile(nest.getCurrentPosition().getX(), nest.getCurrentPosition().getY())); return true; } else { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java index eec7e92d..3b1a11ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionDip.java @@ -24,7 +24,7 @@ public class ActionDip extends PetAction { RoomItem waterPatch = (RoomItem) waterItems.toArray()[Emulator.getRandom().nextInt(waterItems.size())]; - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTile(waterPatch.getCurrentPosition().getX(), waterPatch.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTile(waterPatch.getCurrentPosition().getX(), waterPatch.getCurrentPosition().getY())); if (pet.getHappiness() > 70) { pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java index df982829..9c97ab2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionHere.java @@ -16,7 +16,7 @@ public class ActionHere extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue())); + pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); if (pet.getHappiness() > 50) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java index 98083d2b..e00b3914 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionMoveForward.java @@ -13,7 +13,7 @@ public class ActionMoveForward extends PetAction { @Override public boolean apply(Pet pet, Habbo habbo, String[] data) { - pet.getRoomUnit().setGoalLocation(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentPosition(), pet.getRoomUnit().getBodyRotation().getValue())); + pet.getRoomUnit().walkTo(pet.getRoom().getLayout().getTileInFront(pet.getRoomUnit().getCurrentPosition(), pet.getRoomUnit().getBodyRotation().getValue())); pet.getRoomUnit().setCanWalk(true); pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_NEUTRAL)); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java index 2503865a..c34c7eab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionPlayFootball.java @@ -32,7 +32,7 @@ public class ActionPlayFootball extends PetAction { if(foundBall == null) return false; - pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(foundBall.getCurrentPosition().getX(), foundBall.getCurrentPosition().getY())); + pet.getRoomUnit().walkTo(room.getLayout().getTile(foundBall.getCurrentPosition().getX(), foundBall.getCurrentPosition().getY())); if (pet.getHappiness() > 75) pet.say(pet.getPetData().randomVocal(PetVocalsType.PLAYFUL)); 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 d227cbf9..24946e74 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -401,6 +401,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; } + //Improve this for (Habbo habbo : habbos) { double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight(); @@ -413,12 +414,16 @@ public class Room implements Comparable, ISerialize, Runnable { } if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { + if(item.getBaseItem().allowSit()) { + habbo.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item))); + } else if(item.getBaseItem().allowLay()) { + habbo.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item))); + } + habbo.getRoomUnit().setCurrentZ(item.getCurrentZ()); - habbo.getRoomUnit().setPreviousLocationZ(item.getCurrentZ()); habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); } else { habbo.getRoomUnit().setCurrentZ(z); - habbo.getRoomUnit().setPreviousLocationZ(z); } } } @@ -437,7 +442,6 @@ public class Room implements Comparable, ISerialize, Runnable { if (topItem != null) { if (topItem.getBaseItem().allowSit()) { bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ()); - bot.getRoomUnit().setPreviousLocationZ(topItem.getCurrentZ()); bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation())); } else { bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ() + Item.getCurrentHeight(topItem)); @@ -448,7 +452,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { bot.getRoomUnit().setCurrentZ(bot.getRoomUnit().getCurrentPosition().getStackHeight()); - bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentPosition().getStackHeight()); } roomUnits.add(bot.getRoomUnit()); }); @@ -590,7 +593,7 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getHabboStats().getChatCounter().decrementAndGet(); } - habbo.getRoomUnit().cycle(this); + habbo.getRoomUnit().cycle(); if(habbo.getRoomUnit().isStatusUpdateNeeded()) { habbo.getRoomUnit().setStatusUpdateNeeded(false); @@ -622,7 +625,7 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } - bot.getRoomUnit().cycle(this); + bot.getRoomUnit().cycle(); if(bot.getRoomUnit().isStatusUpdateNeeded()) { bot.getRoomUnit().setStatusUpdateNeeded(false); @@ -647,7 +650,7 @@ public class Room implements Comparable, ISerialize, Runnable { break; } - pet.getRoomUnit().cycle(this); + pet.getRoomUnit().cycle(); pet.cycle(); if(pet.getRoomUnit().isStatusUpdateNeeded()) { @@ -804,9 +807,9 @@ public class Room implements Comparable, ISerialize, Runnable { if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) { Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { - RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); - if (riding != null) { - RoomUnit ridingUnit = riding.getRoomUnit(); + RideablePet ridingPet = rollingHabbo.getRoomUnit().getRidingPet(); + if (ridingPet != null) { + RoomUnit ridingUnit = ridingPet.getRoomUnit(); newZ = ridingUnit.getCurrentZ() + zOffset; rolledUnitIds.add(ridingUnit.getVirtualId()); updatedUnit.remove(ridingUnit); @@ -836,10 +839,6 @@ public class Room implements Comparable, ISerialize, Runnable { }, this.roomInfo.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); } } - - if (roomUnit.hasStatus(RoomUnitStatus.SIT)) { - roomUnit.setSitUpdate(true); - } } } @@ -1261,7 +1260,7 @@ public class Room implements Comparable, ISerialize, Runnable { } habbo.getRoomUnit().setKicked(true); - habbo.getRoomUnit().setGoalLocation(this.layout.getDoorTile()); + habbo.getRoomUnit().walkTo(this.layout.getDoorTile()); if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.roomInfo.isPublicRoom()) { habbo.getRoomUnit().setCanWalk(true); @@ -1318,9 +1317,8 @@ public class Room implements Comparable, ISerialize, Runnable { } roomUnit.setLocation(tile); - roomUnit.setGoalLocation(tile); + roomUnit.walkTo(tile); roomUnit.setCurrentZ(z); - roomUnit.setPreviousLocationZ(z); this.updateRoomUnit(roomUnit); @@ -1351,8 +1349,6 @@ public class Room implements Comparable, ISerialize, Runnable { } public void habboEntered(Habbo habbo) { - habbo.getRoomUnit().setAnimateWalk(false); - synchronized (this.roomUnitManager.getCurrentBots()) { if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) return; @@ -1744,6 +1740,10 @@ public class Room implements Comparable, ISerialize, Runnable { return this.getStackHeight(x, y, calculateHeightmap, null); } + public boolean canSitOrLayAt(RoomTile tile) { + return this.canSitOrLayAt(tile.getX(), tile.getY()); + } + public boolean canSitOrLayAt(int x, int y) { RoomTile tile = this.layout.getTile((short) x, (short) y); 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 7c9a530f..f3efbb36 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -128,7 +128,9 @@ public class RoomItemManager { try { this.currentItems.put(item.getId(), item); this.sortItem(item); + //Deprecated item.setRoomId(this.room.getRoomInfo().getId()); + item.setRoom(room); } catch (Exception ignored) { } @@ -344,7 +346,9 @@ public class RoomItemManager { this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose()); item.needsUpdate(true); this.addRoomItem(item); + //Deprecated item.setRoomId(this.room.getRoomInfo().getId()); + item.setRoom(this.room); item.onPlace(this.room); Emulator.getThreading().run(item); return FurnitureMovementError.NONE; @@ -543,7 +547,9 @@ public class RoomItemManager { this.removeRoomItem(item); item.onPickUp(this.room); + //Deprecated item.setRoomId(0); + item.setRoom(null); item.needsUpdate(true); if (item.getBaseItem().getType() == FurnitureType.FLOOR) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 8969b489..1f6ce701 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -210,7 +210,7 @@ public class RoomLayout { if(this.tileExists(x, y)) { RoomTile tile = this.getTile(x, y); - walkable = tile.getState().equals(RoomTileState.OPEN) && tile.isWalkable() && (this.room.getRoomUnitManager().areRoomUnitsAt(tile) && !this.room.getRoomInfo().isAllowWalkthrough()); + walkable = tile.isWalkable() && (this.room.getRoomUnitManager().areRoomUnitsAt(tile) && !this.room.getRoomInfo().isAllowWalkthrough()); } return walkable; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index fc8156ca..11c890d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -574,7 +574,6 @@ public class RoomManager { RoomHabbo roomHabbo = habbo.getRoomUnit(); roomHabbo.clear(); - roomHabbo.clearWalking(); if (roomHabbo.getCurrentPosition() == null) { RoomTile spawnTile = spawnLocation == null ? room.getLayout().getDoorTile() : spawnLocation; @@ -622,7 +621,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomRatingComposer(room.getRoomInfo().getScore(), !this.hasVotedForRoom(habbo, room))); - roomHabbo.setFastWalkEnabled(roomHabbo.isFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); + roomHabbo.setCmdFastWalkEnabled(roomHabbo.isCmdFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); if (room.isPromoted()) { habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion())); @@ -875,9 +874,8 @@ public class RoomManager { } public void leaveRoom(Habbo habbo, Room room, boolean redirectToHotelView) { - if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom() == room) { + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().equals(room)) { this.logExit(habbo); - room.getRoomUnitManager().removeHabbo(habbo, true); if (redirectToHotelView) { @@ -885,9 +883,8 @@ public class RoomManager { } habbo.getRoomUnit().setPreviousRoom(room); - habbo.getRoomUnit().setRoom(null); - if (room.getRoomInfo().getOwnerInfo().getId() != habbo.getHabboInfo().getId()) { + if (!room.getRoomInfo().isRoomOwner(habbo)) { AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0)); } @@ -902,13 +899,13 @@ public class RoomManager { control.getRoomUnit().getCacheable().remove("controller"); } - if (habbo.getHabboInfo().getRiding() != null) { - if (habbo.getHabboInfo().getRiding().getRoomUnit() != null) { - habbo.getHabboInfo().getRiding().getRoomUnit().setGoalLocation(habbo.getHabboInfo().getRiding().getRoomUnit().getCurrentPosition()); + if (habbo.getRoomUnit().isRiding()) { + if (habbo.getRoomUnit().getRidingPet().getRoomUnit() != null) { + habbo.getRoomUnit().getRidingPet().getRoomUnit().walkTo(habbo.getRoomUnit().getRidingPet().getRoomUnit().getCurrentPosition()); } - habbo.getHabboInfo().getRiding().setTask(PetTasks.FREE); - habbo.getHabboInfo().getRiding().setRider(null); - habbo.getHabboInfo().setRiding(null); + habbo.getRoomUnit().getRidingPet().setTask(PetTasks.FREE); + habbo.getRoomUnit().getRidingPet().setRider(null); + habbo.getRoomUnit().setRidingPet(null); } Room room = habbo.getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 26182f8b..22ae3dd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -57,6 +57,7 @@ public class RoomTile { if (this.state == RoomTileState.INVALID) { this.allowStack = false; } + this.roomUnits = tile.roomUnits; this.roomItems = tile.roomItems; } @@ -106,6 +107,10 @@ public class RoomTile { ((RoomTile) o).y == this.y; } + public boolean equals(int x, int y) { + return this.x == x && this.y == y; + } + public RoomTile copy() { return new RoomTile(this); } @@ -162,9 +167,7 @@ public class RoomTile { public void addRoomUnit(RoomUnit roomUnit) { synchronized (this.roomUnits) { - if (!this.roomUnits.contains(roomUnit)) { - this.roomUnits.add(roomUnit); - } + this.roomUnits.add(roomUnit); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java index b7f373fe..c7754a3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java @@ -266,7 +266,9 @@ public class RoomTraxManager implements Disposable { this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose()); + //Deprecated musicDisc.setRoomId(-1); + musicDisc.setRoom(null); musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); @@ -293,8 +295,9 @@ public class RoomTraxManager implements Disposable { } this.room.sendComposer(new JukeboxSongDisksMessageComposer(this.songs, this.totalLength).compose()); - + //Deprecated musicDisc.setRoomId(0); + musicDisc.setRoom(null); musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); @@ -324,7 +327,9 @@ public class RoomTraxManager implements Disposable { if (musicDisc != null) { if (musicDisc instanceof InteractionMusicDisc && musicDisc.getRoomId() == -1) { + //Deprecated musicDisc.setRoomId(0); + musicDisc.setRoom(null); musicDisc.needsUpdate(true); Emulator.getThreading().run(musicDisc); 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 23ff5231..9ddb2747 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -14,7 +14,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; @@ -67,10 +66,11 @@ public class RoomUnitManager { try (ResultSet set = statement.executeQuery()) { while (set.next()) { Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set); - + //TODO IMPROVE THIS if (bot != null) { bot.setRoom(this.room); bot.setRoomUnit(new RoomBot()); + bot.getRoomUnit().setUnit(bot); 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) { @@ -79,7 +79,6 @@ public class RoomUnitManager { bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection())); } else { bot.getRoomUnit().setCurrentZ(set.getDouble("z")); - bot.getRoomUnit().setPreviousLocationZ(set.getDouble("z")); bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); } bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); @@ -110,6 +109,7 @@ public class RoomUnitManager { pet.setRoom(this.room); pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setUnit(pet); 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) { @@ -227,15 +227,13 @@ public class RoomUnitManager { } pet.setRoomUnit(new RoomPet()); + pet.getRoomUnit().setUnit(pet); pet.setRoom(room); - pet.getRoomUnit() - .setGoalLocation(tile) - .setLocation(tile) + pet.getRoomUnit().walkTo(tile); + pet.getRoomUnit().setLocation(tile) .setRoomUnitType(RoomUnitType.PET) .setCanWalk(true) - .setPreviousLocationZ(z) - .setCurrentZ(z) - .setRoom(room); + .setCurrentZ(z); if (pet.getRoomUnit().getCurrentPosition() == null) { pet.getRoomUnit() @@ -291,11 +289,7 @@ public class RoomUnitManager { return; } - RoomUnit roomUnit = habbo.getRoomUnit(); - - if(roomUnit == null || !(roomUnit instanceof RoomHabbo roomHabbo)) { - return; - } + RoomHabbo roomHabbo = habbo.getRoomUnit(); if(roomHabbo.getCurrentPosition() != null) { roomHabbo.getCurrentPosition().removeUnit(habbo.getRoomUnit()); @@ -308,6 +302,7 @@ public class RoomUnitManager { roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); + //MOVE THIS TO RoomTile.java -> removeUnit() RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition()); if (item != null) { @@ -333,7 +328,6 @@ public class RoomUnitManager { } roomHabbo.getRoom().updateDatabaseUserCount(); - roomHabbo.clear(); } @@ -414,11 +408,9 @@ public class RoomUnitManager { public void dispose() { for(Habbo habbo : this.currentHabbos.values()) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room, true); } - this.room.sendComposer(new CloseConnectionMessageComposer().compose()); - this.currentHabbos.clear(); Iterator botIterator = this.currentBots.values().iterator(); @@ -450,7 +442,6 @@ public class RoomUnitManager { } this.currentPets.clear(); - this.currentRoomUnits.clear(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java index 1846f7f4..00b27ebc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/IRoomEntity.java @@ -19,6 +19,12 @@ public interface IRoomEntity { double getCurrentZ(); RoomEntity setCurrentZ(double currentZ); + RoomTile getNextPosition(); + RoomEntity setNextPosition(RoomTile nextPosition); + + double getNextZ(); + RoomEntity setNextZ(double nextZ); + RoomTile getTargetPosition(); RoomEntity setTargetPosition(RoomTile targetPosition); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java index bfa82b32..dd664a3a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/RoomEntity.java @@ -7,33 +7,35 @@ import lombok.Setter; import lombok.experimental.Accessors; import java.util.Deque; -import java.util.LinkedList; @Getter @Setter @Accessors(chain = true) public abstract class RoomEntity implements IRoomEntity { - private Room room; - private RoomTile previousPosition; - private double previousZ; - private RoomTile currentPosition; - private double currentZ; - private RoomTile targetPosition; - private double targetZ; - private Deque path = new LinkedList<>(); - private int tilesMoved; + protected Room room; + protected RoomTile previousPosition; + protected double previousZ; + protected RoomTile currentPosition; + protected double currentZ; + protected RoomTile nextPosition; + protected double nextZ; + protected RoomTile targetPosition; + protected double targetZ; + protected Deque path; + protected int tilesMoved; public boolean isAtGoal() { - if(this.currentPosition == null) { - return false; + if(this.targetPosition == null) { + return true; } return this.currentPosition.equals(this.targetPosition); } - public void setPreviousLocation(RoomTile previousLocation) { - this.previousPosition = previousLocation; - this.previousZ = this.getCurrentZ(); + public RoomEntity setCurrentPosition(RoomTile tile) { + this.previousPosition = this.currentPosition; + this.currentPosition = tile; + return this; } public RoomEntity setCurrentZ(double currentZ) { @@ -42,6 +44,11 @@ public abstract class RoomEntity implements IRoomEntity { return this; } + protected void clearNextLocation() { + this.nextPosition = null; + this.nextZ = 0; + } + public synchronized void incrementTilesMoved() { this.tilesMoved++; } @@ -49,4 +56,22 @@ public abstract class RoomEntity implements IRoomEntity { public synchronized void decrementTilesMoved() { this.tilesMoved--; } + + public void clear() { + this.room = null; + + this.previousPosition = null; + this.previousZ = 0; + + this.currentPosition = null; + this.currentZ = 0; + + this.nextPosition = null; + this.nextZ = 0; + + this.targetPosition = null; + this.targetZ = 0; + + this.path = null; + } } \ No newline at end of file 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 66ced663..d8b22003 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 @@ -53,15 +53,20 @@ import java.util.List; public abstract class RoomItem extends RoomEntity implements Runnable, IEventTriggers { private final int id; private HabboInfo ownerInfo; + /** + * TODO FINISH GET RID OF THIS + */ + @Deprecated private int roomId; + private final Item baseItem; private String wallPosition; private int rotation; private String extraData; private int limitedStack; private int limitedSells; - private boolean needsUpdate = false; - private boolean needsDelete = false; + private boolean sqlUpdateNeeded = false; + private boolean sqlDeleteNeeded = false; private boolean isFromGift = false; @SuppressWarnings("rawtypes") @@ -75,6 +80,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri public RoomItem(ResultSet set, Item baseItem) throws SQLException { this.id = set.getInt("id"); this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt(DatabaseConstants.USER_ID)); + this.roomId = set.getInt("room_id"); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id")); @@ -84,8 +90,14 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri this.wallPosition = set.getString("wall_pos"); if(room != null) { - this.setCurrentPosition(room.getLayout().getTile(set.getShort("x"), set.getShort("y"))); - this.setCurrentZ(set.getDouble("z")); + RoomTile itemTile = room.getLayout().getTile(set.getShort("x"), set.getShort("y")); + + if(itemTile == null) { + this.setRoom(null); + } else { + this.setCurrentPosition(itemTile); + this.setCurrentZ(set.getDouble("z")); + } } this.rotation = set.getInt("rot"); @@ -96,8 +108,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri this.limitedStack = Integer.parseInt(set.getString("limited_data").split(":")[0]); this.limitedSells = Integer.parseInt(set.getString("limited_data").split(":")[1]); } - - this.setRoom(Emulator.getGameEnvironment().getRoomManager().getRoom(set.getInt("room_id"))); } public RoomItem(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) { @@ -171,19 +181,19 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri } public boolean needsUpdate() { - return this.needsUpdate; + return this.sqlUpdateNeeded; } public boolean needsDelete() { - return needsDelete; + return sqlDeleteNeeded; } public void needsUpdate(boolean value) { - this.needsUpdate = value; + this.sqlUpdateNeeded = value; } public void needsDelete(boolean value) { - this.needsDelete = value; + this.sqlDeleteNeeded = value; } public boolean isLimited() { @@ -195,24 +205,24 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri @Override public void run() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - if (this.needsDelete) { - this.needsUpdate = false; - this.needsDelete = false; + if (this.sqlDeleteNeeded) { + this.sqlUpdateNeeded = false; + this.sqlDeleteNeeded = false; try (PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) { statement.setInt(1, this.getId()); statement.execute(); } - } else if (this.needsUpdate) { + } else if (this.sqlUpdateNeeded) { try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET user_id = ?, room_id = ?, wall_pos = ?, x = ?, y = ?, z = ?, rot = ?, extra_data = ?, limited_data = ? WHERE id = ?")) { statement.setInt(1, this.ownerInfo.getId()); - statement.setInt(2, this.roomId); + statement.setInt(2, (this.getRoom() == null) ? 0 : this.getRoom().getRoomInfo().getId()); statement.setString(3, this.wallPosition); statement.setInt(4, this.getCurrentPosition().getX()); statement.setInt(5, this.getCurrentPosition().getY()); statement.setDouble(6, Math.max(-9999, Math.min(9999, Math.round(this.getCurrentZ() * Math.pow(10, 6)) / Math.pow(10, 6)))); statement.setInt(7, this.rotation); - statement.setString(8, this instanceof InteractionGuildGate ? "" : this.getDatabaseExtraData()); + statement.setString(8, this instanceof InteractionGuildGate ? "" : this.extraData); statement.setString(9, this.limitedStack + ":" + this.limitedSells); statement.setInt(10, this.id); statement.execute(); @@ -221,7 +231,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri log.error("SQLException trying to save HabboItem: " + this); } - this.needsUpdate = false; + this.sqlUpdateNeeded = false; } } catch (SQLException e) { @@ -259,7 +269,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); - if (habbo != null && habbo.getHabboInfo().getRiding() == null) { + if (habbo != null && !habbo.getRoomUnit().isRiding()) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1); return; @@ -299,7 +309,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar); - if (habbo != null && habbo.getHabboInfo().getRiding() == null) { + if (habbo != null && !habbo.getRoomUnit().isRiding()) { if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { roomAvatar.giveEffect(0, -1); } @@ -459,10 +469,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri } } - public String getDatabaseExtraData() { - return this.getExtraData(); - } - @Override public String toString() { return "ID: " + this.id + ", BaseID: " + this.getBaseItem().getId() + ", X: " + this.getCurrentPosition().getX() + ", Y: " + this.getCurrentPosition().getY() + ", Z: " + this.getCurrentZ() + ", Extradata: " + this.extraData; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 2ff43d7e..c46eff23 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -10,13 +10,13 @@ import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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.types.RoomAvatar; +import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent; import com.eu.habbo.util.pathfinding.Rotation; -import gnu.trove.map.TMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -24,10 +24,7 @@ import lombok.Setter; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Deque; -import java.util.List; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; @Slf4j @@ -37,6 +34,8 @@ public abstract class RoomUnit extends RoomEntity { @Setter private int virtualId; @Setter + private Unit unit; + @Setter private RoomUnitType roomUnitType; @Setter private RoomRotation bodyRotation; @@ -49,8 +48,6 @@ public abstract class RoomUnit extends RoomEntity { @Setter private boolean isTeleporting; @Setter - private boolean cmdTeleportEnabled = false; - @Setter private boolean cmdSitEnabled = false; @Setter private boolean cmdStandEnabled = false; @@ -59,50 +56,31 @@ public abstract class RoomUnit extends RoomEntity { @Setter private boolean isSwimming = false; @Setter - private boolean fastWalkEnabled; + private boolean cmdFastWalkEnabled; private final ConcurrentHashMap statuses; @Setter private boolean statusUpdateNeeded; - @Getter @Setter private boolean isWiredTeleporting = false; - @Getter @Setter private boolean isLeavingTeleporter = false; private final THashMap cacheable; - @Getter - @Setter - private boolean animateWalk = false; - @Setter - @Getter - private boolean sitUpdate = false; @Setter private boolean isKicked; @Setter private int kickCount = 0; - @Getter - private RoomTile startLocation; - @Getter - @Setter - private RoomTile botStartLocation; - @Getter - @Setter - @Accessors(chain = true) - private double previousLocationZ; - @Getter @Setter private boolean inRoom; - @Getter @Setter @Accessors(chain = true) private boolean invisible = false; @Setter private boolean canLeaveRoomByDoor = true; + @Setter private int walkTimeOut; private int previousEffectId; private int previousEffectEndTimestamp; private int timeInRoom; - @Getter private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private final THashSet overridableTiles; @@ -113,7 +91,7 @@ public abstract class RoomUnit extends RoomEntity { this.canWalk = true; this.canRotate = true; this.isTeleporting = false; - this.fastWalkEnabled = false; + this.cmdFastWalkEnabled = false; this.statuses = new ConcurrentHashMap<>(); this.statusUpdateNeeded = false; @@ -132,17 +110,21 @@ public abstract class RoomUnit extends RoomEntity { this.overridableTiles = new THashSet<>(); } - public abstract boolean cycle(Room room); + public RoomItem getCurrentItem() { + return this.room.getRoomItemManager().getTopItemAt(this.currentPosition); + } + + public abstract void cycle(); @Override public RoomUnit setCurrentPosition(RoomTile tile) { - if (this.getCurrentPosition() != null) { - this.getCurrentPosition().removeUnit(this); - } - super.setCurrentPosition(tile); - if(this.getCurrentPosition() != null) { + if (this.previousPosition != null) { + this.previousPosition.removeUnit(this); + } + + if(this.currentPosition != null) { tile.addRoomUnit(this); } @@ -155,18 +137,14 @@ public abstract class RoomUnit extends RoomEntity { this.statusUpdateNeeded = true; } - public void clearWalking() { - this.setTargetPosition(null); - this.startLocation = this.getCurrentPosition(); - this.statuses.clear(); - this.cacheable.clear(); - } - public void stopWalking() { synchronized (this.statuses) { - this.statuses.remove(RoomUnitStatus.MOVE); - this.statusUpdateNeeded = true; - this.setGoalLocation(this.getCurrentPosition()); + this.path.clear(); + this.nextPosition = null; + this.targetPosition = null; + this.removeStatus(RoomUnitStatus.MOVE); + this.handleSitStatus(); + this.handleLayStatus(); } } @@ -174,8 +152,8 @@ public abstract class RoomUnit extends RoomEntity { public RoomUnit setCurrentZ(double currentZ) { super.setCurrentZ(currentZ); - if (this.getRoom() != null) { - Bot bot = this.getRoom().getRoomUnitManager().getRoomBotById(getVirtualId()); + if (this.room != null) { + Bot bot = this.room.getRoomUnitManager().getRoomBotById(getVirtualId()); if (bot != null) { bot.needsUpdate(true); } @@ -185,54 +163,79 @@ public abstract class RoomUnit extends RoomEntity { return this; } - public RoomUnit setGoalLocation(RoomTile goalLocation) { - if (goalLocation != null) { - this.setGoalLocation(goalLocation, false); + /** + * Sets the target position for the character's movement and calculates the path to reach the destination. + * + * @param goalLocation The target location (represented by a {@link RoomTile}) to which the character should move. + * @return {@code true} if the path calculation to the goal location is successful, {@code false} otherwise. + * Returns {@code false} if the goal location is not walkable or the character's current room does not allow sitting or laying at that location. + * Additionally, the path calculation may be canceled by registered plugins listening to {@link RoomUnitSetGoalEvent}. + * In such cases, the method also returns {@code false}. + */ + public boolean walkTo(RoomTile goalLocation) { + if(!goalLocation.isWalkable() && !this.room.canSitOrLayAt(goalLocation)) { + return false; } - return this; - } - public void setGoalLocation(RoomTile goalLocation, boolean noReset) { if (Emulator.getPluginManager().isRegistered(RoomUnitSetGoalEvent.class, false)) { - Event event = new RoomUnitSetGoalEvent(this.getRoom(), this, goalLocation); + Event event = new RoomUnitSetGoalEvent(this.room, this, goalLocation); Emulator.getPluginManager().fireEvent(event); if (event.isCancelled()) - return; + return false; } - /// Set start location - this.startLocation = this.getCurrentPosition(); - - if (goalLocation != null && !noReset) { - boolean isWalking = this.hasStatus(RoomUnitStatus.MOVE); - this.setTargetPosition(goalLocation); - - this.findPath(); ///< Quadral: this is where we start formulating a path - if (!this.getPath().isEmpty()) { - this.setTilesMoved(isWalking ? this.getTilesMoved() : 0); - this.setCmdSitEnabled(false); - } else { - this.setTargetPosition(this.getCurrentPosition()); - } + if(this.nextPosition != null) { + this.currentPosition = this.nextPosition; + this.currentZ = this.nextZ; } + + this.targetPosition = goalLocation; + this.findPath(); + return true; } public RoomUnit setLocation(RoomTile location) { if (location != null) { - this.startLocation = location; - this.setPreviousLocation(location); - this.setCurrentPosition(location); - this.setTargetPosition(location); - this.botStartLocation = location; + this.currentPosition = location; + this.targetPosition = location; } return this; } + /** + * Finds a path from the current position to the target position within a room's layout, if valid. + * The method checks if the room, layout, and target position are valid, and if the target position is walkable + * or can be occupied by sitting or laying, or if it can be overridden. + * If all conditions are met, the method attempts to find a path from the current position to the target position + * using the room's layout and sets the path accordingly. + * + * Pre-conditions: + * - The current object must have a valid room set (using the `setRoom(Room room)` method). + * - The target position must be set (using the `setTargetPosition(RoomTile targetPosition)` method). + * + * Post-conditions: + * - If a valid path is found from the current position to the target position, the path is set using the `setPath(Deque path)` method. + * + * Note: + * - The method relies on the validity of the room and layout, and whether the target position is walkable, or can be occupied by sitting or laying, + * or can be overridden. If any of these conditions are not met, the method will not attempt to find a path. + * - The `findPath()` method assumes that the room and layout are well-defined and consistent, and that the target position is within the boundaries of the room's layout. + * - The method may return `null` if no valid path is found from the current position to the target position. + */ public void findPath() { - if (this.getRoom() != null && this.getRoom().getLayout() != null && this.getTargetPosition() != null && (this.getTargetPosition().isWalkable() || this.getRoom().canSitOrLayAt(this.getTargetPosition().getX(), this.getTargetPosition().getY()) || this.canOverrideTile(this.getTargetPosition()))) { - Deque newPath = this.getRoom().getLayout().findPath(this.getCurrentPosition(), this.getTargetPosition(), this.getTargetPosition(), this); - if (newPath != null) this.setPath(newPath); + boolean hasValidRoom = this.room != null; + boolean hasValidLayout = hasValidRoom && this.room.getLayout() != null; + boolean hasValidTargetPosition = this.targetPosition != null; + boolean isTargetPositionWalkable = hasValidTargetPosition && this.targetPosition.isWalkable(); + boolean canSitOrLayAtTarget = hasValidTargetPosition && hasValidRoom && this.room.canSitOrLayAt(this.targetPosition.getX(), this.targetPosition.getY()); + boolean canOverrideTile = hasValidTargetPosition && this.canOverrideTile(this.targetPosition); + + if (hasValidLayout && (isTargetPositionWalkable || canSitOrLayAtTarget || canOverrideTile)) { + Deque newPath = this.room.getLayout().findPath(this.currentPosition, this.targetPosition, this.targetPosition, this); + if (newPath != null) { + this.setPath(newPath); + } } } @@ -248,6 +251,16 @@ public abstract class RoomUnit extends RoomEntity { return this.statuses.get(key); } + public String getCurrentStatuses() { + StringBuilder status = new StringBuilder("/"); + + for (Map.Entry entry : this.statuses.entrySet()) { + status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); + } + + return status.toString(); + } + public void addStatus(RoomUnitStatus key, String value) { if (key != null && value != null) { this.statuses.put(key, value); @@ -275,9 +288,9 @@ public abstract class RoomUnit extends RoomEntity { } public void makeStand() { - RoomItem item = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem item = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { - this.setCmdStandEnabled(true); + this.cmdStandEnabled = true; this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); this.removeStatus(RoomUnitStatus.SIT); this.instantUpdate(); @@ -289,9 +302,9 @@ public abstract class RoomUnit extends RoomEntity { return; } - this.setCmdSitEnabled(true); + this.cmdSitEnabled = true; this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); - this.addStatus(RoomUnitStatus.SIT, 0.5 + ""); + this.addStatus(RoomUnitStatus.SIT, "0.5"); if(this instanceof RoomAvatar roomAvatar) { roomAvatar.setDance(DanceType.NONE); @@ -300,26 +313,10 @@ public abstract class RoomUnit extends RoomEntity { this.instantUpdate(); } - public TMap getCacheable() { - return this.cacheable; - } - - public int getWalkTimeOut() { - return this.walkTimeOut; - } - - public void setWalkTimeOut(int walkTimeOut) { - this.walkTimeOut = walkTimeOut; - } - public void increaseTimeInRoom() { this.timeInRoom++; } - public int getTimeInRoom() { - return this.timeInRoom; - } - public void resetTimeInRoom() { this.timeInRoom = 0; } @@ -330,7 +327,7 @@ public abstract class RoomUnit extends RoomEntity { } if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) { - Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.getRoom(), this, location); + Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location); Emulator.getPluginManager().fireEvent(lookAtPointEvent); if (lookAtPointEvent.isCancelled()) @@ -341,7 +338,7 @@ public abstract class RoomUnit extends RoomEntity { return; } - RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), location.getX(), location.getY())]); + RoomRotation rotation = (RoomRotation.values()[Rotation.Calculate(this.currentPosition.getX(), this.currentPosition.getY(), location.getX(), location.getY())]); if (!this.statuses.containsKey(RoomUnitStatus.SIT)) { this.bodyRotation = rotation; @@ -355,9 +352,9 @@ public abstract class RoomUnit extends RoomEntity { } public boolean canOverrideTile(RoomTile tile) { - if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false; + if (tile == null || this.room == null || this.room.getLayout() == null) return false; - if (this.getRoom().getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile))) + if (this.room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.room, tile))) return true; int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); @@ -372,28 +369,28 @@ public abstract class RoomUnit extends RoomEntity { } public void removeOverrideTile(RoomTile tile) { - if (this.getRoom() == null || this.getRoom().getLayout() == null) return; + if (this.room == null || this.room.getLayout() == null) return; int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); this.overridableTiles.remove(tileIndex); } public boolean canForcePosture() { - if (this.getRoom() == null) return false; + if (this.room == null) return false; - RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); + RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY()); return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); } public RoomTile getClosestTile(List tiles) { - return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentPosition()))).orElse(null); + return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.currentPosition))).orElse(null); } public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { - if (this.getRoom() == null) return null; + if (this.room == null) return null; - RoomTile baseTile = this.getRoom().getLayout().getTile(x, y); + RoomTile baseTile = this.room.getLayout().getTile(x, y); if (baseTile == null) return null; @@ -412,75 +409,191 @@ public abstract class RoomUnit extends RoomEntity { return this.getClosestTile( rotations.stream() - .map(rotation -> this.getRoom().getLayout().getTileInFront(baseTile, rotation)) - .filter(t -> t != null && t.isWalkable() && (this.getCurrentPosition().equals(t) || !this.getRoom().getRoomUnitManager().hasHabbosAt(t))) + .map(rotation -> this.room.getLayout().getTileInFront(baseTile, rotation)) + .filter(t -> t != null && t.isWalkable() && (this.currentPosition.equals(t) || !this.room.getRoomUnitManager().hasHabbosAt(t))) .toList() ); } - public boolean handleSitStatus(RoomItem topItem) { - if(topItem == null || !topItem.getBaseItem().allowSit()) { - return false; + public void handleSitStatus() { + if(this.getCurrentItem() == null || !this.getCurrentItem().getBaseItem().allowSit()) { + return; } if(!this.isCmdSitEnabled()) { - if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { - this.addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem))); - this.setCurrentZ(topItem.getCurrentZ()); - this.setRotation(RoomRotation.values()[topItem.getRotation()]); - return true; - } else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { + if(this.currentPosition.getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) { + this.addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(this.getCurrentItem()))); + this.setCurrentZ(this.getCurrentItem().getCurrentZ()); + this.setRotation(RoomRotation.values()[this.getCurrentItem().getRotation()]); + } else if(!this.getCurrentItem().getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) { this.removeStatus(RoomUnitStatus.SIT); this.instantUpdate(); - return true; } } - - return false; } - public boolean handleLayStatus(RoomItem topItem) { - if(topItem == null || !topItem.getBaseItem().allowLay()) { - return false; + public void handleLayStatus() { + if(this.getCurrentItem() == null || !this.getCurrentItem().getBaseItem().allowLay()) { + return; } if(!this.isCmdLayEnabled()) { - if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { - this.addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem))); - this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]); - - if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { - this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getCurrentPosition().getY())); - } else { - this.setLocation(this.getRoom().getLayout().getTile(topItem.getCurrentPosition().getX(), this.getCurrentPosition().getY())); - } - return true; - } else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { + if(this.currentPosition.getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) { + this.addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(this.getCurrentItem()))); + this.setRotation(RoomRotation.values()[this.getCurrentItem().getRotation() % 4]); + } else if (!this.getCurrentItem().getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) { this.removeStatus(RoomUnitStatus.LAY); this.instantUpdate(); - return true; } } - - return false; } + /** + * Performs an instant update of the character's status to the connected room, if needed. + * The method checks if a status update is required based on the internal flag `statusUpdateNeeded`. + * If an update is needed, the method sends the character's updated status information to the room + * using the {@link UserUpdateComposer}, effectively synchronizing the character's status with other room participants. + * After the update is sent, the `statusUpdateNeeded` flag is reset to false until the next change in the character's status. + * Note: This method is typically called when an immediate status update is necessary, such as when a status change occurs + * and should be communicated to other room users without delay. + */ public void instantUpdate() { if(this.statusUpdateNeeded) { this.statusUpdateNeeded = false; - this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); + this.room.sendComposer(new UserUpdateComposer(this).compose()); } } + /** + * Processes the character's walking behavior based on its current walking state. + * If the character is currently walking, the method executes the necessary steps to continue the movement. + * The process involves updating the character's status, position, rotation, and height while moving along the computed path. + * If the character reaches the destination tile, walking is stopped. + * If the character encounters an invalid tile during its path, it recalculates the path to find an alternative route. + * The method also handles fast walking when enabled, allowing the character to move more quickly through the path. + * Note: This method is typically called in a loop to facilitate continuous character movement. + */ + public void processWalking() { + if(this.isWalking()) { + this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking()); + + if(this.getNextPosition() != null) { + this.currentPosition = this.getNextPosition(); + this.currentZ = this.getNextZ(); + } + + if(!this.path.isEmpty()) { + RoomTile next = this.path.poll(); + + if(this.path.size() > 1 && this.cmdFastWalkEnabled) { + next = this.path.poll(); + } + + if(next == null || !this.isValidTile(next)) { + this.path.clear(); + this.findPath(); + + if(this.path.isEmpty()) { + return; + } + + next = this.path.poll(); + } + + RoomRotation nextRotation = this.handleNextRotation(next); + double nextHeight = this.handleNextHeight(next); + + this.setRotation(nextRotation); + this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + nextHeight); + this.nextPosition = next; + this.nextZ = nextHeight; + } else { + this.stopWalking(); + } + } + } + + private RoomRotation handleNextRotation(RoomTile next) { + return RoomRotation.values()[Rotation.Calculate(this.currentPosition.getX(), this.currentPosition.getY(), next.getX(), next.getY())]; + } + + private double handleNextHeight(RoomTile next) { + double height = 0.0D; + + RoomItem nextTileItem = this.room.getRoomItemManager().getTopItemAt(next); + + if(nextTileItem != null) { + height += nextTileItem.getNextZ(); + + if (!nextTileItem.getBaseItem().allowSit() && !nextTileItem.getBaseItem().allowLay()) { + height += Item.getCurrentHeight(nextTileItem); + } + } else { + height += this.room.getLayout().getHeightAtSquare(next.getX(), next.getY()); + } + + return height; + } + + /** + * Checks whether the provided {@link RoomTile} is a valid tile for the character to walk on. + * + * @param tile The {@link RoomTile} to be validated. + * @return {@code true} if the tile is valid for walking, {@code false} otherwise. + * Returns {@code true} if the character can override the tile (e.g., walk on furniture). + * Otherwise, the method checks various conditions to determine the tile's validity: + * - The tile's height difference from the character's current height should be within the allowable step height range. + * - The tile should not be blocked, invalid, or have an open state with a height difference above the maximum step height. + * - If the room allows walkthrough, the tile should not be occupied by other room units (excluding the character's target position). + * - If the room disallows walkthrough, the tile should not be occupied by any room units. + * - If there's a room item on the tile, it is considered a valid tile. + */ + private boolean isValidTile(RoomTile tile) { + boolean canOverrideTile = this.canOverrideTile(tile); + if (canOverrideTile) { + return true; + } + + double heightDifference = tile.getStackHeight() - this.currentZ; + + boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile); + boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT); + boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT); + boolean isTileBlocked = tile.getState().equals(RoomTileState.BLOCKED) || tile.getState().equals(RoomTileState.INVALID); + + if(isTileBlocked || isAboveMaximumStepHeight || isOpenTileAboveMaxHeight) { + return false; + } else { + if(this.room.getRoomInfo().isAllowWalkthrough()) { + if(areRoomUnitsAtTile && !this.targetPosition.equals(tile)) { + return false; + } + } else { + if(areRoomUnitsAtTile) { + return false; + } + } + } + + RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile); + + if(item != null) { + return true; + } + + return true; + } + public void clear() { - this.setRoom(null); + super.clear(); + this.canWalk = true; this.canRotate = true; - this.fastWalkEnabled = false; - this.cmdTeleportEnabled = false; + this.cmdFastWalkEnabled = false; this.clearStatuses(); this.previousEffectId = 0; this.previousEffectEndTimestamp = -1; this.isKicked = false; + this.cacheable.clear(); } } 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 c7fbd1c7..cea754ad 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 @@ -1,12 +1,10 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.pets.PetTasks; 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.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.DanceType; @@ -16,37 +14,33 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; -import com.eu.habbo.plugin.Event; -import com.eu.habbo.plugin.events.users.UserIdleEvent; -import com.eu.habbo.plugin.events.users.UserTakeStepEvent; -import com.eu.habbo.threading.runnables.RoomUnitKick; -import com.eu.habbo.util.pathfinding.Rotation; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; -import java.util.*; +import java.util.ArrayList; +import java.util.List; @Slf4j @Getter @Setter @Accessors(chain = true) public class RoomAvatar extends RoomUnit { - private RideablePet rideablePet; - private boolean rideLock; - private DanceType danceType; - private int handItem; - private long handItemTimestamp; - private int effectId; - private int effectEndTimestamp; - private int previousEffectId; - private int previousEffectEndTimestamp; + protected RideablePet ridingPet; + protected boolean rideLocked; + protected DanceType danceType; + protected int handItem; + protected long handItemTimestamp; + protected int effectId; + protected int effectEndTimestamp; + protected int previousEffectId; + protected int previousEffectEndTimestamp; public RoomAvatar() { super(); - this.rideablePet = null; + this.ridingPet = null; this.danceType = DanceType.NONE; this.handItem = 0; this.handItemTimestamp = 0; @@ -57,267 +51,61 @@ public class RoomAvatar extends RoomUnit { } @Override - public boolean cycle(Room room) { - try { - if (this.hasStatus(RoomUnitStatus.SIGN)) { - this.getRoom().sendComposer(new UserUpdateComposer(this).compose()); - this.removeStatus(RoomUnitStatus.SIGN); - } + public void cycle() { + this.handleSignStatus(); + this.processWalking(); + } - if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) { - if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) { - this.removeStatus(RoomUnitStatus.MOVE); - } - - if(!this.isWalking()) { - RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition()); - return this.handleSitStatus(topItem) || this.handleLayStatus(topItem); - } - } - - Habbo habbo = null; - boolean canFastWalk = false; - - if(this instanceof RoomHabbo roomHabbo) { - habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo); - canFastWalk = habbo == null || habbo.getHabboInfo().getRiding() == null; - } - - for (Map.Entry set : this.getStatuses().entrySet()) { - if (set.getKey().isRemoveWhenWalking()) { - this.removeStatus(set.getKey()); - } - } - - if (this.getPath() == null || this.getPath().isEmpty()) { - return true; - } - - RoomTile next = this.getPath().poll(); - boolean overrideTile = next != null && this.canOverrideTile(next); - - if (this.getPath().isEmpty()) { - this.setSitUpdate(true); - - if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideTile) { - return false; - } - } - - Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this); - - if (peekPath == null) { - peekPath = new LinkedList<>(); - } - - if (peekPath.size() >= 3) { - if (this.getPath().isEmpty()) { - this.setStatusUpdateNeeded(true); - return true; - } - - this.getPath().pop(); - //peekPath.pop(); //Start - peekPath.removeLast(); //End - - if (peekPath.peek() != next) { - next = peekPath.poll(); - for (int i = 0; i < peekPath.size(); i++) { - this.getPath().addFirst(peekPath.removeLast()); - } - } - } - - if (canFastWalk && this.isFastWalkEnabled() && this.getPath().size() > 1) { - next = this.getPath().poll(); - } - - if (next == null) { - this.setStatusUpdateNeeded(true); - return true; - } - - this.removeStatus(RoomUnitStatus.DEAD); - - if (habbo != null) { - RoomHabbo roomHabbo = (RoomHabbo) this; - if (roomHabbo.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled() && !event.isIdle()) { - roomHabbo.unIdle(); - } - } - - if (Emulator.getPluginManager().isRegistered(UserTakeStepEvent.class, false)) { - Event e = new UserTakeStepEvent(habbo, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), next); - Emulator.getPluginManager().fireEvent(e); - - if (e.isCancelled()) { - this.setStatusUpdateNeeded(true); - return true; - } - - } - } - - RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); - - double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); - - if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.getPath().clear(); - this.findPath(); - - if (this.getPath().isEmpty()) { - this.removeStatus(RoomUnitStatus.MOVE); - return false; - } - next = this.getPath().pop(); - } - - boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); - - if (canSitNextTile) { - RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next); - - if (tallestChair != null) - item = tallestChair; - } - - if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideTile && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.removeStatus(RoomUnitStatus.MOVE); + @Override + public boolean walkTo(RoomTile goalLocation) { + if (this.hasStatus(RoomUnitStatus.LAY)) { + if (this.room.getLayout().getTilesInFront(this.getCurrentPosition(), this.getBodyRotation().getValue(), 2).contains(goalLocation)) return false; - } - - double zHeight = 0.0D; - - if(habbo != null && habbo.getHabboInfo().getRiding() != null) { - zHeight += 1.0D; - } - - RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); - if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) - roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); - - - this.incrementTilesMoved(); - - RoomRotation oldRotation = this.getBodyRotation(); - - this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); - if (item != null) { - if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { - if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); - } else if (item instanceof ConditionalGate conditionalGate) { - this.setRotation(oldRotation); - this.decrementTilesMoved(); - this.setGoalLocation(this.getCurrentPosition()); - this.removeStatus(RoomUnitStatus.MOVE); - this.instantUpdate(); - - if(this instanceof RoomHabbo) { - conditionalGate.onRejected(this, this.getRoom(), new Object[]{}); - } - - return false; - } - } else { - item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); - } - - zHeight += item.getCurrentZ(); - - if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { - zHeight += Item.getCurrentHeight(item); - } - } else { - zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); - } - - this.setPreviousLocation(this.getCurrentPosition()); - - this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); - - if(habbo != null) { - RideablePet rideablePet = habbo.getHabboInfo().getRiding(); - - if(rideablePet != null) { - RoomUnit ridingUnit = rideablePet.getRoomUnit(); - - if (ridingUnit != null) { - ridingUnit.setPreviousLocationZ(this.getCurrentZ()); - this.setCurrentZ(zHeight - 1.0); - ridingUnit.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); - ridingUnit.setPreviousLocation(this.getCurrentPosition()); - ridingUnit.setGoalLocation(this.getTargetPosition()); - ridingUnit.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0)); - room.sendComposer(new UserUpdateComposer(ridingUnit).compose()); - } - } - } - - this.setCurrentZ(zHeight); - this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); - - if(this instanceof RoomHabbo roomHabbo) { - roomHabbo.resetIdleTicks(); - } - - if(habbo != null) { - RoomItem topItem = room.getRoomItemManager().getTopItemAt(next); - - boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); - boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); - boolean invalidated = topItem != null && topItem.invalidatesToRoomKick(); - - if (this.isCanLeaveRoomByDoor() && isAtDoor && publicRoomKicks && !invalidated) { - Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500); - } - } - - return false; - - } catch (Exception e) { - log.error("Caught exception", e); - return false; } + + if (this.room.canLayAt(goalLocation)) { + RoomItem bed = this.room.getRoomItemManager().getTopItemAt(goalLocation.getX(), goalLocation.getY()); + + if (bed != null && bed.getBaseItem().allowLay()) { + this.room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); + RoomTile pillow = switch (bed.getRotation()) { + case 0, 4 -> this.room.getLayout().getTile(goalLocation.getX(), bed.getCurrentPosition().getY()); + case 2, 8 -> this.room.getLayout().getTile(bed.getCurrentPosition().getX(), goalLocation.getY()); + default -> this.room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); + }; + + if (pillow != null && this.room.canLayAt(pillow)) { + goalLocation = pillow; + } + } + } + + return super.walkTo(goalLocation); } public void dismountPet(boolean isRemoving) { - Habbo habbo = null; - - if(this instanceof RoomHabbo roomHabbo) { - habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomHabbo); - } - - if(habbo == null || habbo.getHabboInfo().getRiding() == null) { + if(!this.isRiding()) { return; } - RideablePet ridingPet = habbo.getHabboInfo().getRiding(); + this.ridingPet.setRider(null); + this.ridingPet.setTask(PetTasks.FREE); - ridingPet.setRider(null); - ridingPet.setTask(PetTasks.FREE); - - habbo.getHabboInfo().setRiding(null); + this.ridingPet = null; this.giveEffect(0, -1); - this.setCurrentZ(ridingPet.getRoomUnit().getCurrentZ()); - this.setPreviousLocationZ(ridingPet.getRoomUnit().getCurrentZ()); + this.setCurrentZ(this.ridingPet.getRoomUnit().getCurrentZ()); this.stopWalking(); - ridingPet.getRoomUnit().stopWalking(); + this.ridingPet.getRoomUnit().stopWalking(); this.instantUpdate(); - ridingPet.getRoomUnit().instantUpdate(); + this.ridingPet.getRoomUnit().instantUpdate(); - List availableTiles = isRemoving ? new ArrayList<>() : this.getRoom().getLayout().getWalkableTilesAround(this.getCurrentPosition()); + List availableTiles = isRemoving ? new ArrayList<>() : this.room.getLayout().getWalkableTilesAround(this.getCurrentPosition()); RoomTile tile = availableTiles.isEmpty() ? this.getCurrentPosition() : availableTiles.get(0); - this.setGoalLocation(tile); + this.walkTo(tile); this.setStatusUpdateNeeded(true); } @@ -325,12 +113,12 @@ public class RoomAvatar extends RoomUnit { if (this.danceType != danceType) { boolean isDancing = !this.danceType.equals(DanceType.NONE); this.danceType = danceType; - this.getRoom().sendComposer(new DanceMessageComposer(this).compose()); + this.room.sendComposer(new DanceMessageComposer(this).compose()); if (danceType.equals(DanceType.NONE) && isDancing) { - WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.getRoom(), new Object[]{this}); + WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.room, new Object[]{this}); } else if (!danceType.equals(DanceType.NONE) && !isDancing) { - WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.getRoom(), new Object[]{this}); + WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.room, new Object[]{this}); } } } @@ -355,7 +143,7 @@ public class RoomAvatar extends RoomUnit { } if(this instanceof RoomHabbo) { - Habbo habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(this); + Habbo habbo = this.room.getRoomUnitManager().getHabboByRoomUnit(this); if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) { return; } @@ -367,11 +155,11 @@ public class RoomAvatar extends RoomUnit { duration += Emulator.getIntUnixTimestamp(); } - if ((this.getRoom().isAllowEffects() || forceEffect) && !this.isSwimming()) { + if ((this.room.isAllowEffects() || forceEffect) && !this.isSwimming()) { this.effectId = effectId; this.effectEndTimestamp = duration; - this.getRoom().sendComposer(new AvatarEffectMessageComposer(this).compose()); + this.room.sendComposer(new AvatarEffectMessageComposer(this).compose()); } } @@ -380,11 +168,22 @@ public class RoomAvatar extends RoomUnit { this.previousEffectEndTimestamp = endTimestamp; } + private void handleSignStatus() { + if (this.hasStatus(RoomUnitStatus.SIGN)) { + this.room.sendComposer(new UserUpdateComposer(this).compose()); + this.removeStatus(RoomUnitStatus.SIGN); + } + } + + public boolean isRiding() { + return this.ridingPet != null; + } + @Override public void clear() { super.clear(); - this.rideablePet = null; + this.ridingPet = null; this.danceType = DanceType.NONE; this.handItem = 0; this.handItemTimestamp = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java index 9ca00a75..3f15cfde 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java @@ -1,71 +1,20 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.habbohotel.wired.WiredTriggerType; import lombok.Getter; @Getter public class RoomBot extends RoomAvatar { + private Bot unit; + public RoomBot() { super(); } @Override - public boolean cycle(Room room) { - Bot bot = this.getRoom().getRoomUnitManager().getBotByRoomUnit(this); - - if(bot == null) { - return false; - } - - if (this.getRoom().isAllowBotsWalk()) { - if(bot.canWalk()) { - if (!this.isWalking()) { - if (this.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && bot.getFollowingHabboId() == 0) { - this.setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.getRoom().getLayout().getTile(this.getBotStartLocation().getX(), this.getBotStartLocation().getY()), this.getRoom(), Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile()); - int timeOut = Emulator.getRandom().nextInt(20) * 2; - this.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); - } - } - } - } - - if (!bot.getChatLines().isEmpty() && bot.getChatTimeOut() <= Emulator.getIntUnixTimestamp() && bot.isChatAuto()) { - if (this.getRoom() != null) { - short test = 0; - - if(bot.isChatRandom()) { - bot.setLastChatIndex((short) Emulator.getRandom().nextInt(bot.getChatLines().size())); - } else if(bot.getLastChatIndex() == bot.getChatLines().size() - 1) { - bot.resetLastChatIndex(); - } else { - bot.incrementLastChatIndex(); - } - - if (bot.getLastChatIndex() >= bot.getChatLines().size()) { - bot.resetLastChatIndex(); - } - - String message = bot.getChatLines().get(bot.getLastChatIndex()) - .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.getRoom().getRoomInfo().getOwnerInfo().getUsername()) - .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), String.valueOf(this.getRoom().getRoomItemManager().getCurrentItems().size())) - .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), bot.getName()) - .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.getRoom().getRoomInfo().getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), String.valueOf(this.getRoom().getRoomUnitManager().getRoomHabbosCount())); - - if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this, room, new Object[]{ message })) { - bot.talk(message); - } - - bot.setChatTimeOut(Emulator.getIntUnixTimestamp() + bot.getChatDelay()); - } - } - - return super.cycle(room); + public void cycle() { + super.cycle(); } public RoomUnitType getRoomUnitType() { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java index 518ec753..66cbe021 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java @@ -1,11 +1,17 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.DanceType; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.SleepMessageComposer; +import com.eu.habbo.plugin.events.users.UserIdleEvent; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -16,9 +22,12 @@ import lombok.extern.slf4j.Slf4j; @Setter @Accessors(chain = true) public class RoomHabbo extends RoomAvatar { + private Habbo unit; private Room loadingRoom; private Room previousRoom; + private boolean cmdTeleportEnabled; + // @Setter // private boolean isKicked; private int kickCount; @@ -28,13 +37,50 @@ public class RoomHabbo extends RoomAvatar { public RoomHabbo() { super(); - + this.cmdTeleportEnabled = false; // this.isKicked = false; // this.overridableTiles = new HashSet<>(); } - public boolean cycle(Room room) { - return super.cycle(room); + @Override + public void cycle() { + super.cycle(); + } + + @Override + public boolean walkTo(RoomTile goalLocation) { + if(this.rideLocked || this.isTeleporting() || this.isKicked()) { + return false; + } + + if(this.cmdTeleportEnabled) { + if (this.isRiding()) { + this.room.sendComposer(new RoomUnitOnRollerComposer(this, null, this.currentPosition, this.currentZ, goalLocation, goalLocation.getStackHeight() + 1.0D, this.room).compose()); + this.room.sendComposer(new RoomUnitOnRollerComposer(this.ridingPet.getRoomUnit(), goalLocation, this.room).compose()); + } else { + this.room.sendComposer(new RoomUnitOnRollerComposer(this, goalLocation, this.room).compose()); + } + + return false; + } + + if (this.isRiding() && this.ridingPet.getTask() != null && this.ridingPet.getTask().equals(PetTasks.JUMP)) { + return false; + } + + // Reset idle status + if (this.isIdle()) { + UserIdleEvent event = new UserIdleEvent(this.unit, UserIdleEvent.IdleReason.WALKED, false); + Emulator.getPluginManager().fireEvent(event); + + if (!event.isCancelled()) { + if (!event.isIdle()) { + this.unIdle(); + } + } + } + + return super.walkTo(goalLocation); } public boolean isLoadingRoom() { @@ -56,17 +102,17 @@ public class RoomHabbo extends RoomAvatar { this.setDance(DanceType.NONE); } - this.getRoom().sendComposer(new SleepMessageComposer(this).compose()); + this.room.sendComposer(new SleepMessageComposer(this).compose()); - WiredHandler.handle(WiredTriggerType.IDLES, this, this.getRoom(), new Object[]{this}); + WiredHandler.handle(WiredTriggerType.IDLES, this, this.room, new Object[]{this}); } public void unIdle() { this.resetIdleTicks(); - this.getRoom().sendComposer(new SleepMessageComposer(this).compose()); + this.room.sendComposer(new SleepMessageComposer(this).compose()); - WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.getRoom(), new Object[]{this}); + WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.room, new Object[]{this}); } public boolean isIdle() { @@ -92,5 +138,6 @@ public class RoomHabbo extends RoomAvatar { @Override public void clear() { super.clear(); + this.cmdTeleportEnabled = false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 9607678a..45cee9b3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -1,184 +1,24 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; -import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate; import com.eu.habbo.habbohotel.pets.Pet; 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.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.util.pathfinding.Rotation; import lombok.extern.slf4j.Slf4j; -import java.util.Deque; -import java.util.LinkedList; -import java.util.Map; - @Slf4j public class RoomPet extends RoomUnit { + private Pet unit; + public RoomPet() { super(); } @Override - public boolean cycle(Room room) { - try { - Pet pet = this.getRoom().getRoomUnitManager().getPetByRoomUnit(this); - - if(pet == null) { - return false; - } - - if (this.handleRider(pet, room)) { - return true; - } - - if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) { - if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) { - this.removeStatus(RoomUnitStatus.MOVE); - } - - if(!this.isWalking()) { - RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition()); - return this.handleSitStatus(topItem) || this.handleLayStatus(topItem); - } - } - - for (Map.Entry set : this.getStatuses().entrySet()) { - if (set.getKey().isRemoveWhenWalking()) { - this.removeStatus(set.getKey()); - } - } - - if (this.getPath() == null || this.getPath().isEmpty()) { - return true; - } - - RoomTile next = this.getPath().poll(); - boolean overrideChecks = next != null && this.canOverrideTile(next); - - if (this.getPath().isEmpty()) { - this.setSitUpdate(true); - - if (next != null && room.getRoomUnitManager().areRoomUnitsAt(next) && !overrideChecks) { - return false; - } - } - - Deque peekPath = room.getLayout().findPath(this.getCurrentPosition(), this.getPath().peek(), this.getTargetPosition(), this); - - if (peekPath == null) { - peekPath = new LinkedList<>(); - } - - if (peekPath.size() >= 3) { - if (this.getPath().isEmpty()) { - this.setStatusUpdateNeeded(true); - return true; - } - - this.getPath().pop(); - //peekPath.pop(); //Start - peekPath.removeLast(); //End - - if (peekPath.peek() != next) { - next = peekPath.poll(); - for (int i = 0; i < peekPath.size(); i++) { - this.getPath().addFirst(peekPath.removeLast()); - } - } - } - - if (next == null) { - this.setStatusUpdateNeeded(true); - return true; - } - - this.removeStatus(RoomUnitStatus.DEAD); - - RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY()); - - double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); - if (!room.getLayout().tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.getPath().clear(); - this.findPath(); - - if (this.getPath().isEmpty()) { - this.removeStatus(RoomUnitStatus.MOVE); - return false; - } - next = this.getPath().pop(); - - } - - boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); - - if (canSitNextTile) { - RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next); - - if (tallestChair != null) - item = tallestChair; - } - - if (next.equals(this.getTargetPosition()) && next.getState() == RoomTileState.SIT && !overrideChecks && (item == null || item.getCurrentZ() - this.getCurrentZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) { - this.removeStatus(RoomUnitStatus.MOVE); - return false; - } - - double zHeight = 0.0D; - - RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); - if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getCurrentPosition().getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getCurrentPosition().getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) - roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); - - - this.incrementTilesMoved(); - - RoomRotation oldRotation = this.getBodyRotation(); - this.setRotation(RoomRotation.values()[Rotation.Calculate(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), next.getX(), next.getY())]); - if (item != null) { - if (item != roomItem || !RoomLayout.pointInSquare(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentPosition().getX() + item.getBaseItem().getWidth() - 1, item.getCurrentPosition().getY() + item.getBaseItem().getLength() - 1, this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) { - if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, new Object[]{this.getCurrentPosition(), next}); - } else if (item instanceof ConditionalGate conditionalGate) { - this.setRotation(oldRotation); - this.decrementTilesMoved(); - this.setGoalLocation(this.getCurrentPosition()); - this.removeStatus(RoomUnitStatus.MOVE); - this.instantUpdate(); - - return false; - } - } else { - item.onWalk(this, room, new Object[]{this.getCurrentPosition(), next}); - } - - zHeight += item.getCurrentZ(); - - if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) { - zHeight += Item.getCurrentHeight(item); - } - } else { - zHeight += room.getLayout().getHeightAtSquare(next.getX(), next.getY()); - } - - - this.setPreviousLocation(this.getCurrentPosition()); - - this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight); - - this.setCurrentZ(zHeight); - this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); - - return false; - } catch (Exception e) { - log.error("Caught exception", e); - return false; - } - } + public void cycle() {} public boolean handleRider(Pet pet, Room room) { Habbo rider = null; @@ -198,8 +38,6 @@ public class RoomPet extends RoomUnit { if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) { this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); - this.setPreviousLocation(rider.getRoomUnit().getPreviousPosition()); - this.setPreviousLocationZ(rider.getRoomUnit().getPreviousPosition().getStackHeight()); this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition()); this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/units/Unit.java b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java index 52e6e721..aece2d88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/units/Unit.java +++ b/src/main/java/com/eu/habbo/habbohotel/units/Unit.java @@ -6,6 +6,6 @@ import lombok.Setter; @Getter @Setter -public class Unit { +public abstract class Unit { private RoomUnit roomUnit; } \ No newline at end of file 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 6d9b98e2..2b0bd2e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -70,6 +70,8 @@ public class Habbo extends Unit implements Runnable { this.messenger.loadFriendRequests(this); this.roomUnit = new RoomHabbo(); + this.roomUnit.setUnit(this); + this.update = false; } 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 f72e7a18..0affa40a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.PermissionGroup; -import com.eu.habbo.habbohotel.pets.RideablePet; import gnu.trove.map.hash.TIntIntHashMap; import lombok.Getter; import lombok.Setter; @@ -40,7 +39,6 @@ public class HabboInfo implements Runnable { private int homeRoom; private boolean online; private int roomQueueId; - private RideablePet riding; private Class currentGame; private TIntIntHashMap currencies; private GamePlayer gamePlayer; diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java index 7a8b5c0b..9ed3a345 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java @@ -28,9 +28,7 @@ public class QuitEvent extends MessageHandler { this.client.sendResponse(new CloseConnectionMessageComposer()); } - if (roomHabbo != null) { - roomHabbo.clearWalking(); - roomHabbo.setInRoom(false); - } + roomHabbo.clear(); + roomHabbo.setInRoom(false); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java index a5d0a21f..b507f0b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/CustomizeAvatarWithFurniEvent.java @@ -35,7 +35,9 @@ public class CustomizeAvatarWithFurniEvent extends MessageHandler { if (clothing != null) { if (!this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().contains(clothing.getId())) { + //Deprecated item.setRoomId(0); + item.setRoom(null); RoomTile tile = this.client.getHabbo().getRoomUnit().getRoom().getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()); this.client.getHabbo().getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(item); this.client.getHabbo().getRoomUnit().getRoom().updateTile(tile); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index e5bc4c86..c925be10 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -29,7 +29,9 @@ public class PlacePostItEvent extends MessageHandler { if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) { room.getRoomItemManager().addRoomItem(item); item.setExtraData("FFFF33"); + //Deprecated item.setRoomId(this.client.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()); + item.setRoom(this.client.getHabbo().getRoomUnit().getRoom()); item.setWallPosition(location); item.setOwnerInfo(this.client.getHabbo().getHabboInfo()); item.needsUpdate(true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java index 6841f9fa..879979aa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RemoveItemEvent.java @@ -24,7 +24,9 @@ public class RemoveItemEvent extends MessageHandler { if (item instanceof InteractionPostIt || item instanceof InteractionExternalImage) { if (item.getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { + //Deprecated item.setRoomId(0); + item.setRoom(null); room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new ItemRemoveMessageComposer(item).compose()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 46737ae3..7dfc73a3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -85,7 +85,9 @@ public class CustomizePetWithFurniEvent extends MessageHandler { room.getRoomItemManager().removeRoomItem(item); room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); + //Deprecated item.setRoomId(0); + item.setRoom(null); Emulator.getGameEnvironment().getItemManager().deleteItem(item); } } else if (pet instanceof MonsterplantPet) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index 291983e0..18c4941d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -29,8 +29,8 @@ public class MountPetEvent extends MessageHandler { } //dismount - if (habbo.getHabboInfo().getRiding() != null) { - boolean mountAnotherPet = petId != habbo.getHabboInfo().getRiding().getId(); + if (habbo.getRoomUnit().isRiding()) { + boolean mountAnotherPet = petId != habbo.getRoomUnit().getRidingPet().getId(); habbo.getRoomUnit().dismountPet(false); @@ -57,8 +57,8 @@ public class MountPetEvent extends MessageHandler { } RoomTile goalTile = availableTiles.get(0); - habbo.getRoomUnit().setGoalLocation(goalTile); - habbo.getRoomUnit().setRideLock(true); + habbo.getRoomUnit().walkTo(goalTile); + habbo.getRoomUnit().setRideLocked(true); Emulator.getThreading().run(new RoomUnitRidePet(rideablePet, habbo, goalTile)); rideablePet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp()); rideablePet.getRoomUnit().stopWalking(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index 94a18293..be3ad3b0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -24,10 +24,8 @@ public class MovePetEvent extends MessageHandler { if (tile != null) { pet.getRoomUnit().setLocation(tile); - pet.getRoomUnit().setPreviousLocation(tile); pet.getRoomUnit().setCurrentZ(tile.getZ()); pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt())); - pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getCurrentZ()); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); pet.setNeedsUpdate(true); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index 8bad80f6..83e081da 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.messages.incoming.MessageHandler; @@ -17,6 +16,7 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; public class PlacePetEvent extends MessageHandler { @Override public void handle() { + //TODO Improve This Room room = this.client.getHabbo().getRoomUnit().getRoom(); if (room == null) @@ -74,22 +74,23 @@ public class PlacePetEvent extends MessageHandler { } pet.setRoom(room); - RoomUnit roomUnit = pet.getRoomUnit(); + RoomPet roomPet = pet.getRoomUnit(); - if (roomUnit == null) { - roomUnit = new RoomPet(); + if (roomPet == null) { + roomPet = new RoomPet(); + roomPet.setUnit(pet); } - roomUnit.setRoom(room); + roomPet.setRoom(room); - roomUnit.setLocation(tile); - roomUnit.setCurrentZ(tile.getStackHeight()); - roomUnit.addStatus(RoomUnitStatus.SIT, "0"); - roomUnit.setRoomUnitType(RoomUnitType.PET); + roomPet.setLocation(tile); + roomPet.setCurrentZ(tile.getStackHeight()); + roomPet.addStatus(RoomUnitStatus.SIT, "0"); + roomPet.setRoomUnitType(RoomUnitType.PET); if (playerTile != null) { - roomUnit.lookAtPoint(playerTile); + roomPet.lookAtPoint(playerTile); } - pet.setRoomUnit(roomUnit); + pet.setRoomUnit(roomPet); room.getRoomUnitManager().addRoomUnit(pet); pet.setNeedsUpdate(true); Emulator.getThreading().run(pet); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java index e61b8109..76ef0283 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java @@ -37,7 +37,7 @@ public class RespectPetEvent extends MessageHandler { RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getCurrentPosition().getX(), pet.getRoomUnit().getCurrentPosition().getY(), true); if(tile != null) { - habbo.getRoomUnit().setGoalLocation(tile); + habbo.getRoomUnit().walkTo(tile); } Emulator.getThreading().run(new RoomUnitWalkToLocation(habbo.getRoomUnit(), tile, room, tasks, tasks)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 9cca3aa2..cbdc673e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -1,23 +1,14 @@ package com.eu.habbo.messages.incoming.rooms.users; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; -import com.eu.habbo.plugin.events.users.UserIdleEvent; -import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @Slf4j public class MoveAvatarEvent extends MessageHandler { - - @Override public int getRatelimit() { return 500; @@ -25,156 +16,52 @@ public class MoveAvatarEvent extends MessageHandler { @Override public void handle() throws Exception { - if (this.client.getHabbo().getRoomUnit().getRoom() != null) { - int x = this.packet.readInt(); // Position X - int y = this.packet.readInt(); // Position Y + int x = this.packet.readInt(); + int y = this.packet.readInt(); - // Get Habbo object - Habbo habbo = this.client.getHabbo(); + Habbo habbo = this.client.getHabbo(); - if(habbo == null) { + if(habbo == null) { + return; + } + + RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit(); + + if(roomHabbo == null) { + return; + } + + Room room = habbo.getRoomUnit().getRoom(); + + if (room == null || room.getLayout() == null) { + return; + } + + if (roomHabbo.getCurrentPosition().equals(x,y)) { + return; + } + + if (roomHabbo.getCacheable().get("control") != null) { + habbo = (Habbo) roomHabbo.getCacheable().get("control"); + + if (habbo.getRoomUnit().getRoom() != room) { + habbo.getRoomUnit().getCacheable().remove("controller"); + this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); + habbo = this.client.getHabbo(); + } + } + + roomHabbo = habbo.getRoomUnit(); + + if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) { + RoomTile tile = room.getLayout().getTile((short) x, (short) y); + + if (tile == null) { return; } - // Get Room Habbo object (Unique GUID?) - RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit(); - - if(roomHabbo == null) { - return; - } - - // If habbo is teleporting, don't calculate a new path - if (roomHabbo.isTeleporting()) { - return; - } - - // If habbo is being kicked don't calculate a new path - if (roomHabbo.isKicked()) { - return; - } - - //Is going to ride a pet, can't cancel - if(roomHabbo.isRideLock()) { - return; - } - - // Get the room the habbo is in - Room room = habbo.getRoomUnit().getRoom(); - - if (room == null || room.getLayout() == null) { - return; - } - - // Don't calulcate a new path if are already at the end position - if (x == roomHabbo.getCurrentPosition().getX() && y == roomHabbo.getCurrentPosition().getY()) { - return; - } - - // If habbo has control (im assuming admin, do something else, but we dont care about this part here) - if (roomHabbo.getCacheable().get("control") != null) { - habbo = (Habbo) roomHabbo.getCacheable().get("control"); - - if (habbo.getRoomUnit().getRoom() != room) { - habbo.getRoomUnit().getCacheable().remove("controller"); - this.client.getHabbo().getRoomUnit().getCacheable().remove("control"); - habbo = this.client.getHabbo(); - } - } - - // Recover roomUnit if necessary - roomHabbo = habbo.getRoomUnit(); - - // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path - if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) { - - //If teleport command is enabled - if(roomHabbo.isCmdTeleportEnabled()) { - RoomTile t = room.getLayout().getTile((short) x, (short) y); - - if (habbo.getHabboInfo().getRiding() != null) { - room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, null, roomHabbo.getCurrentPosition(), roomHabbo.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose()); - room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose()); - } else { - room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, t, room).compose()); - } - - return; - } - - // Don't calculate a new path if we are on a horse - if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) { - return; - } - - // Reset idle status - if (roomHabbo.isIdle()) { - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled()) { - if (!event.isIdle()) { - if (roomHabbo.getRoom() != null) { - roomHabbo.unIdle(); - } - } - } - } - - // Get room height map - RoomTile tile = room.getLayout().getTile((short) x, (short) y); - - // this should never happen, if it does it would be a design flaw - if (tile == null) { - return; - } - - // Don't care - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { - if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentPosition(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) - return; - } - - if (room.canLayAt(tile)) { - RoomItem bed = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); - - if (bed != null && bed.getBaseItem().allowLay()) { - room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); - RoomTile pillow = switch (bed.getRotation()) { - case 0, 4 -> room.getLayout().getTile((short) x, bed.getCurrentPosition().getY()); - case 2, 8 -> room.getLayout().getTile(bed.getCurrentPosition().getX(), (short) y); - default -> - room.getLayout().getTile(bed.getCurrentPosition().getX(), bed.getCurrentPosition().getY()); - }; - - if (pillow != null && room.canLayAt(pillow)) { - roomHabbo.setGoalLocation(pillow); - return; - } - } - } - - THashSet items = room.getRoomItemManager().getItemsAt(tile); - - if (items.size() > 0) { - for (RoomItem item : items) { - RoomTile overriddenTile = item.getOverrideGoalTile(roomHabbo, room, tile); - - if (overriddenTile == null) { - return; // null cancels the entire event - } - - if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) { - tile = overriddenTile; - break; - } - } - } - - // This is where we set the end location and begin finding a path - if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { - roomHabbo.setGoalLocation(tile); - } - } + log.info("CLICKED ON TILE [x]: {} [y]: {}", tile.getX(), tile.getY()); + roomHabbo.walkTo(tile); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 0b45d625..ffa13289 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -83,7 +83,6 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.roomUnit.setLocation(this.newLocation); this.roomUnit.setCurrentZ(this.newLocation.getStackHeight()); - this.roomUnit.setPreviousLocationZ(this.newLocation.getStackHeight()); if (topItemNewLocation != null && topItemNewLocation != roller && oldTopItem != topItemNewLocation) { try { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java index 39239c4c..45dd404e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserUpdateComposer.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; @@ -9,7 +8,6 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; import java.util.Collection; -import java.util.Map; public class UserUpdateComposer extends MessageComposer { private Collection habbos; @@ -41,42 +39,29 @@ public class UserUpdateComposer extends MessageComposer { this.response.appendInt(this.roomUnits.size()); for (RoomUnit roomUnit : this.roomUnits) { this.response.appendInt(roomUnit.getVirtualId()); - this.response.appendInt(roomUnit.getPreviousPosition().getX()); - this.response.appendInt(roomUnit.getPreviousPosition().getY()); - this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); - + this.response.appendInt(roomUnit.getCurrentPosition().getX()); + this.response.appendInt(roomUnit.getCurrentPosition().getY()); + this.response.appendString(String.valueOf(this.overrideZ != -1 ? this.overrideZ : roomUnit.getCurrentZ())); this.response.appendInt(roomUnit.getHeadRotation().getValue()); this.response.appendInt(roomUnit.getBodyRotation().getValue()); - StringBuilder status = new StringBuilder("/"); - for (Map.Entry entry : roomUnit.getStatuses().entrySet()) { - status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); - } - - this.response.appendString(status.toString()); - roomUnit.setPreviousLocation(roomUnit.getCurrentPosition()); + this.response.appendString(roomUnit.getCurrentStatuses()); } } else { synchronized (this.habbos) { this.response.appendInt(this.habbos.size()); for (Habbo habbo : this.habbos) { this.response.appendInt(habbo.getRoomUnit().getVirtualId()); - this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getX()); - this.response.appendInt(habbo.getRoomUnit().getPreviousPosition().getY()); - this.response.appendString(habbo.getRoomUnit().getPreviousLocationZ() + ""); + this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getX()); + this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getY()); + this.response.appendString(String.valueOf(habbo.getRoomUnit().getCurrentZ())); this.response.appendInt(habbo.getRoomUnit().getHeadRotation().getValue()); this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); - StringBuilder status = new StringBuilder("/"); - - for (Map.Entry entry : habbo.getRoomUnit().getStatuses().entrySet()) { - status.append(entry.getKey()).append(" ").append(entry.getValue()).append("/"); - } - this.response.appendString(status.toString()); - habbo.getRoomUnit().setPreviousLocation(habbo.getRoomUnit().getCurrentPosition()); + this.response.appendString(habbo.getRoomUnit().getCurrentStatuses()); } } } diff --git a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java index 4e1e0902..c361c32b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/roomunit/RoomUnitSetGoalEvent.java @@ -16,6 +16,6 @@ public class RoomUnitSetGoalEvent extends RoomUnitEvent { public void setGoal(RoomTile t) { - super.roomUnit.setGoalLocation(t); + super.roomUnit.walkTo(t); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java index 478c4168..5b122bf5 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BotFollowHabbo.java @@ -40,7 +40,7 @@ public class BotFollowHabbo implements Runnable { } if (target.getX() >= 0 && target.getY() >= 0) { - this.bot.getRoomUnit().setGoalLocation(target); + this.bot.getRoomUnit().walkTo(target); this.bot.getRoomUnit().setCanWalk(true); Emulator.getThreading().run(this, 500); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index 068122d9..a7f3d280 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -24,7 +24,9 @@ public class ClearRentedSpace implements Runnable { for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) { if (i.getOwnerInfo().getId() == this.item.getRenterId()) { items.add(i); + //Deprecated i.setRoomId(0); + i.setRoom(null); i.needsUpdate(true); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index 614df84a..f5aa2255 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -31,7 +31,9 @@ public class CrackableExplode implements Runnable { if (!this.habboItem.resetable()) { this.room.getRoomItemManager().removeRoomItem(this.habboItem); this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose()); + //Deprecated this.habboItem.setRoomId(0); + this.habboItem.setRoom(null); Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem); } else { this.habboItem.reset(this.room); @@ -51,8 +53,9 @@ public class CrackableExplode implements Runnable { } else { newItem.setCurrentPosition(this.tile); newItem.setCurrentZ(this.room.getStackHeight(this.tile.getX(), this.tile.getY(), false)); - + //Deprecated newItem.setRoomId(this.room.getRoomInfo().getId()); + newItem.setRoom(this.room); newItem.needsUpdate(true); this.room.getRoomItemManager().addRoomItem(newItem); this.room.updateItem(newItem); diff --git a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java index 0f074672..ad3b71db 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OneWayGateActionOne.java @@ -21,13 +21,9 @@ public class OneWayGateActionOne implements Runnable { RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getCurrentPosition().getX(), this.oneWayGate.getCurrentPosition().getY()), (this.oneWayGate.getRotation() + 4) % 8); - if (this.client.getHabbo().getRoomUnit().isAnimateWalk()) { - this.client.getHabbo().getRoomUnit().setAnimateWalk(false); - } - if (t.isWalkable()) { if (this.room.getLayout().tileWalkable(t) && this.client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.oneWayGate.getCurrentPosition().getX() && this.client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.oneWayGate.getCurrentPosition().getY()) { - this.client.getHabbo().getRoomUnit().setGoalLocation(t); + this.client.getHabbo().getRoomUnit().walkTo(t); if (!this.oneWayGate.getExtraData().equals("0")) { Emulator.getThreading().run(new HabboItemNewState(this.oneWayGate, this.room, "0"), 1000); diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java index edc3ab1a..b7230e04 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetFollowHabbo.java @@ -30,7 +30,7 @@ public class PetFollowHabbo implements Runnable { if (target.getX() >= 0 && target.getY() >= 0) { if (this.pet.getRoom().getLayout().tileWalkable(target)) { - this.pet.getRoomUnit().setGoalLocation(target); + this.pet.getRoomUnit().walkTo(target); this.pet.getRoomUnit().setCanWalk(true); this.pet.setTask(PetTasks.FOLLOW); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index 0d7d2e59..cc63da40 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -24,13 +24,11 @@ public class RoomUnitRidePet implements Runnable { if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) { habbo.getRoomUnit().stopWalking(); habbo.getRoomUnit().giveEffect(77, -1); - habbo.getHabboInfo().setRiding(pet); + habbo.getRoomUnit().setRidingPet(pet); habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition()); - habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentPosition()); habbo.getRoomUnit().setCurrentZ(this.pet.getRoomUnit().getCurrentZ() + 1); - habbo.getRoomUnit().setPreviousLocationZ(this.pet.getRoomUnit().getCurrentZ() + 1); habbo.getRoomUnit().setRotation(this.pet.getRoomUnit().getBodyRotation()); - habbo.getRoomUnit().setRideLock(false); + habbo.getRoomUnit().setRideLocked(false); pet.setRider(habbo); habbo.getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose()); habbo.getRoomUnit().getRoom().sendComposer(new AvatarEffectMessageComposer(habbo.getRoomUnit()).compose()); @@ -38,7 +36,7 @@ public class RoomUnitRidePet implements Runnable { } else { pet.getRoomUnit().setWalkTimeOut(3 + Emulator.getIntUnixTimestamp()); pet.getRoomUnit().stopWalking(); - habbo.getRoomUnit().setGoalLocation(goalTile); + habbo.getRoomUnit().walkTo(goalTile); Emulator.getThreading().run(this, 500); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 197c6f89..2ae7a6f2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -46,9 +46,7 @@ public class RoomUnitTeleport implements Runnable { } this.roomUnit.setPath(new LinkedList<>()); this.roomUnit.setCurrentPosition(newLocation); - this.roomUnit.setPreviousLocation(newLocation); this.roomUnit.setCurrentZ(this.z); - this.roomUnit.setPreviousLocationZ(this.z); this.roomUnit.removeStatus(RoomUnitStatus.MOVE); //ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose(); this.roomUnit.setLocation(newLocation); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 208f773e..bd73bbf7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -35,7 +35,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { log.error("Caught exception", e); } } else if (tile.isWalkable()) { - this.habbo.getRoomUnit().setGoalLocation(tile); + this.habbo.getRoomUnit().walkTo(tile); Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 999b0b1d..df9e9c86 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -36,7 +36,7 @@ public class RoomUnitVendingMachineAction implements Runnable { } } else { if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) { - this.habbo.getRoomUnit().setGoalLocation(tile); + this.habbo.getRoomUnit().walkTo(tile); Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index 118f2a98..88fa53f8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -64,7 +64,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { return; } - this.walker.setGoalLocation(this.goalTile); + this.walker.walkTo(this.goalTile); if (this.walker.getPath().isEmpty() && this.failedReached != null) { for (Runnable r : this.failedReached) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index dbb92645..22092b4f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -42,7 +42,7 @@ class TeleportInteraction extends Thread { this.room.updateItem(this.teleportOne); RoomTile tile = RoomItem.getSquareInFront(this.room.getLayout(), this.teleportTwo); if (tile != null) { - this.client.getHabbo().getRoomUnit().setGoalLocation(tile); + this.client.getHabbo().getRoomUnit().walkTo(tile); } Emulator.getThreading().run(this.teleportTwo, 500); Emulator.getThreading().run(this.teleportOne, 500); @@ -95,7 +95,7 @@ class TeleportInteraction extends Thread { this.state = 4; Emulator.getThreading().run(this, 500); } else if (this.state == 2) { - this.client.getHabbo().getRoomUnit().setGoalLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY())); + this.client.getHabbo().getRoomUnit().walkTo(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY())); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[this.newRotation(this.teleportOne.getRotation())]); this.client.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.MOVE, this.teleportOne.getCurrentPosition().getX() + "," + this.teleportOne.getCurrentPosition().getY() + "," + this.teleportOne.getCurrentZ()); //room.sendComposer(new RoomUserStatusComposer(this.client.getHabbo().getRoomUnit())); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java index 408e82a9..0e41dea4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionFive.java @@ -19,7 +19,7 @@ class HopperActionFive implements Runnable { this.client.getHabbo().getRoomUnit().setTeleporting(false); RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getCurrentPosition().getX(), this.currentTeleport.getCurrentPosition().getY()), this.currentTeleport.getRotation()); if (tile != null) { - this.client.getHabbo().getRoomUnit().setGoalLocation(tile); + this.client.getHabbo().getRoomUnit().walkTo(tile); } Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java index 1b97cbd9..3f7c1188 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionOne.java @@ -23,7 +23,6 @@ public class HopperActionOne implements Runnable { this.room.scheduledComposers.add(new UserUpdateComposer(this.client.getHabbo().getRoomUnit()).compose()); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(this.teleportOne.getCurrentPosition().getX(), this.teleportOne.getCurrentPosition().getY())); this.client.getHabbo().getRoomUnit().setCurrentZ(this.teleportOne.getCurrentZ()); - this.client.getHabbo().getRoomUnit().setPreviousLocationZ(this.teleportOne.getCurrentZ()); Emulator.getThreading().run(() -> { HopperActionOne.this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java index 2cd4aa22..aca84321 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionThree.java @@ -43,7 +43,6 @@ class HopperActionThree implements Runnable { targetTeleport.setExtraData("2"); targetRoom.updateItem(targetTeleport); this.client.getHabbo().getRoomUnit().setLocation(this.room.getLayout().getTile(targetTeleport.getCurrentPosition().getX(), targetTeleport.getCurrentPosition().getY())); - this.client.getHabbo().getRoomUnit().setPreviousLocationZ(targetTeleport.getCurrentZ()); this.client.getHabbo().getRoomUnit().setCurrentZ(targetTeleport.getCurrentZ()); this.client.getHabbo().getRoomUnit().setRotation(RoomRotation.values()[targetTeleport.getRotation() % 8]); this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index df1826e9..034c1d1c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -49,7 +49,7 @@ class TeleportActionFive implements Runnable { }); unit.setCanLeaveRoomByDoor(false); - unit.setGoalLocation(tile); + unit.walkTo(tile); unit.setStatusUpdateNeeded(true); unit.setLeavingTeleporter(true); Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess)); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 16400f3c..a80e13c2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -56,7 +56,6 @@ class TeleportActionThree implements Runnable { this.client.getHabbo().getRoomUnit().getPath().clear(); this.client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); this.client.getHabbo().getRoomUnit().setCurrentZ(teleportLocation.getStackHeight()); - this.client.getHabbo().getRoomUnit().setPreviousLocationZ(teleportLocation.getStackHeight()); if (targetRoom != this.room) { this.room.getRoomUnitManager().removeHabbo(this.client.getHabbo(), false); @@ -67,10 +66,7 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtraData("2"); targetRoom.updateItem(targetTeleport); - //targetRoom.updateHabbo(this.client.getHabbo()); - //LOGGER.info((targetTeleport.getX() + " | " + targetTeleport.getY()); this.client.getHabbo().getRoomUnit().setRoom(targetRoom); - //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500); } From a56abbed355817a4dc68fb116eea4cb8eddb63bf Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 2 Aug 2023 16:22:46 -0500 Subject: [PATCH 35/42] Fixed some status issue when walking --- .../habbohotel/rooms/RoomUnitStatus.java | 2 +- .../rooms/entities/units/RoomUnit.java | 67 ++++++++++--------- .../entities/units/types/RoomAvatar.java | 2 +- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java index c77c6326..734a28af 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -6,7 +6,7 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum RoomUnitStatus { - MOVE("mv", true), + MOVE("mv"), // SIT SIT_IN("sit-in"), diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index c46eff23..8803282b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -108,13 +108,18 @@ public abstract class RoomUnit extends RoomEntity { //RoomHabbo this.isKicked = false; this.overridableTiles = new THashSet<>(); + this.statusUpdateNeeded = false; } public RoomItem getCurrentItem() { return this.room.getRoomItemManager().getTopItemAt(this.currentPosition); } - public abstract void cycle(); + public void cycle() { + if(this.isWalking()) { + this.processWalking(); + } + }; @Override public RoomUnit setCurrentPosition(RoomTile tile) { @@ -291,7 +296,7 @@ public abstract class RoomUnit extends RoomEntity { RoomItem item = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY()); if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { this.cmdStandEnabled = true; - this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); + this.bodyRotation = RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]; this.removeStatus(RoomUnitStatus.SIT); this.instantUpdate(); } @@ -303,7 +308,7 @@ public abstract class RoomUnit extends RoomEntity { } this.cmdSitEnabled = true; - this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); + this.bodyRotation = RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]; this.addStatus(RoomUnitStatus.SIT, "0.5"); if(this instanceof RoomAvatar roomAvatar) { @@ -474,42 +479,40 @@ public abstract class RoomUnit extends RoomEntity { * Note: This method is typically called in a loop to facilitate continuous character movement. */ public void processWalking() { - if(this.isWalking()) { - this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking()); + this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking()); - if(this.getNextPosition() != null) { - this.currentPosition = this.getNextPosition(); - this.currentZ = this.getNextZ(); + if(this.getNextPosition() != null) { + this.currentPosition = this.getNextPosition(); + this.currentZ = this.getNextZ(); + } + + if(!this.path.isEmpty()) { + RoomTile next = this.path.poll(); + + if(this.path.size() > 1 && this.cmdFastWalkEnabled) { + next = this.path.poll(); } - if(!this.path.isEmpty()) { - RoomTile next = this.path.poll(); + if(next == null || !this.isValidTile(next)) { + this.path.clear(); + this.findPath(); - if(this.path.size() > 1 && this.cmdFastWalkEnabled) { - next = this.path.poll(); + if(this.path.isEmpty()) { + return; } - if(next == null || !this.isValidTile(next)) { - this.path.clear(); - this.findPath(); - - if(this.path.isEmpty()) { - return; - } - - next = this.path.poll(); - } - - RoomRotation nextRotation = this.handleNextRotation(next); - double nextHeight = this.handleNextHeight(next); - - this.setRotation(nextRotation); - this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + nextHeight); - this.nextPosition = next; - this.nextZ = nextHeight; - } else { - this.stopWalking(); + next = this.path.poll(); } + + RoomRotation nextRotation = this.handleNextRotation(next); + double nextHeight = this.handleNextHeight(next); + + this.setRotation(nextRotation); + this.addStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + nextHeight); + this.nextPosition = next; + this.nextZ = nextHeight; + } else { + this.stopWalking(); } } 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 cea754ad..4d90050d 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 @@ -53,7 +53,7 @@ public class RoomAvatar extends RoomUnit { @Override public void cycle() { this.handleSignStatus(); - this.processWalking(); + super.cycle(); } @Override From 83d1436983838f82f3a7d79998221ab9fee54f0a Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 2 Aug 2023 16:39:03 -0500 Subject: [PATCH 36/42] Enabled fast click walk --- .../messages/incoming/rooms/users/MoveAvatarEvent.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index cbdc673e..3f2d183d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -19,6 +19,8 @@ public class MoveAvatarEvent extends MessageHandler { int x = this.packet.readInt(); int y = this.packet.readInt(); + log.info("CLICKED ON TILE [x]: {} [y]: {}", x, y); + Habbo habbo = this.client.getHabbo(); if(habbo == null) { @@ -37,7 +39,8 @@ public class MoveAvatarEvent extends MessageHandler { return; } - if (roomHabbo.getCurrentPosition().equals(x,y)) { + + if (roomHabbo.getCurrentPosition().equals(x,y) && roomHabbo.isAtGoal()) { return; } @@ -60,7 +63,6 @@ public class MoveAvatarEvent extends MessageHandler { return; } - log.info("CLICKED ON TILE [x]: {} [y]: {}", tile.getX(), tile.getY()); roomHabbo.walkTo(tile); } } From e11def59655dc912b56c528e55b8091f84ddc064 Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 2 Aug 2023 17:45:43 -0500 Subject: [PATCH 37/42] Stankman Easter Egg --- .../habbohotel/rooms/entities/units/RoomUnit.java | 14 ++++++++++++-- .../incoming/rooms/users/MoveAvatarEvent.java | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 8803282b..6ecdb699 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -57,6 +57,8 @@ public abstract class RoomUnit extends RoomEntity { private boolean isSwimming = false; @Setter private boolean cmdFastWalkEnabled; + @Setter + private boolean temporalFastWalkEnabled; private final ConcurrentHashMap statuses; @Setter private boolean statusUpdateNeeded; @@ -118,6 +120,8 @@ public abstract class RoomUnit extends RoomEntity { public void cycle() { if(this.isWalking()) { this.processWalking(); + } else { + this.stopWalking(); } }; @@ -144,12 +148,18 @@ public abstract class RoomUnit extends RoomEntity { public void stopWalking() { synchronized (this.statuses) { - this.path.clear(); + if(this.path != null) { + this.path.clear(); + } + this.nextPosition = null; this.targetPosition = null; + this.removeStatus(RoomUnitStatus.MOVE); this.handleSitStatus(); this.handleLayStatus(); + + this.temporalFastWalkEnabled = false; } } @@ -489,7 +499,7 @@ public abstract class RoomUnit extends RoomEntity { if(!this.path.isEmpty()) { RoomTile next = this.path.poll(); - if(this.path.size() > 1 && this.cmdFastWalkEnabled) { + if(this.path.size() > 1 && (this.cmdFastWalkEnabled || this.temporalFastWalkEnabled)) { next = this.path.poll(); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index 3f2d183d..b5ca2447 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -39,7 +39,6 @@ public class MoveAvatarEvent extends MessageHandler { return; } - if (roomHabbo.getCurrentPosition().equals(x,y) && roomHabbo.isAtGoal()) { return; } @@ -63,6 +62,9 @@ public class MoveAvatarEvent extends MessageHandler { return; } + //STANKMAN EASTER EGG + roomHabbo.setTemporalFastWalkEnabled(roomHabbo.getTargetPosition() != null && roomHabbo.getTargetPosition().equals(tile)); + roomHabbo.walkTo(tile); } } From 71062dc2fc7f6374ae8a1dfedd93ddee10598a41 Mon Sep 17 00:00:00 2001 From: Stankman Date: Wed, 2 Aug 2023 20:43:44 -0500 Subject: [PATCH 38/42] Bot Placement --- .../habbohotel/rooms/RoomUnitManager.java | 67 +++++++++++++++++-- .../rooms/entities/units/RoomUnit.java | 12 ++-- .../rooms/entities/units/types/RoomPet.java | 4 +- .../incoming/rooms/bots/PlaceBotEvent.java | 3 +- .../incoming/rooms/users/MoveAvatarEvent.java | 2 - 5 files changed, 71 insertions(+), 17 deletions(-) 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 9ddb2747..ab5b85f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; @@ -14,9 +15,14 @@ import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; +import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.bots.BotPlacedEvent; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -218,19 +224,66 @@ public class RoomUnitManager { return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } + public void placeBot(Bot bot, Habbo habbo, int x, int y) { + synchronized (this.currentBots) { + RoomTile spawnTile = room.getLayout().getTile((short) x, (short) y); + + if(spawnTile == null) { + spawnTile = room.getLayout().getDoorTile(); + } + + if (Emulator.getPluginManager().isRegistered(BotPlacedEvent.class, false)) { + Event event = new BotPlacedEvent(bot, spawnTile, habbo); + Emulator.getPluginManager().fireEvent(event); + + if (event.isCancelled()) { + return; + } + } + + if(this.currentBots.size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { + habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); + return; + } + + if((!spawnTile.isWalkable() && !this.room.canSitOrLayAt(spawnTile)) || this.areRoomUnitsAt(spawnTile)) { + habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); + return; + } + + RoomBot roomBot = bot.getRoomUnit(); + + roomBot.setRoom(this.room); + roomBot.setCurrentPosition(spawnTile); + roomBot.setCurrentZ(spawnTile.getZ()); + roomBot.setRotation(RoomRotation.SOUTH); + roomBot.setCanWalk(this.room.isAllowBotsWalk()); + + this.addRoomUnit(bot); + + this.room.sendComposer(new RoomUsersComposer(bot).compose()); + + roomBot.instantUpdate(); + + habbo.getInventory().getBotsComponent().removeBot(bot); + habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); + bot.onPlace(habbo, room); + } + } + public void placePet(Pet pet, Room room, short x, short y, double z) { synchronized (this.currentPets) { - RoomTile tile = room.getLayout().getTile(x, y); + RoomTile spawnTile = room.getLayout().getTile(x, y); - if (tile == null) { - tile = room.getLayout().getDoorTile(); + if (spawnTile == null) { + spawnTile = room.getLayout().getDoorTile(); } pet.setRoomUnit(new RoomPet()); pet.getRoomUnit().setUnit(pet); pet.setRoom(room); - pet.getRoomUnit().walkTo(tile); - pet.getRoomUnit().setLocation(tile) + pet.getRoomUnit().walkTo(spawnTile); + pet.getRoomUnit().setLocation(spawnTile) .setRoomUnitType(RoomUnitType.PET) .setCanWalk(true) .setCurrentZ(z); @@ -343,8 +396,8 @@ public class RoomUnitManager { bot.getRoomUnit().setInRoom(false); bot.setRoom(null); - bot.getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); - bot.setRoomUnit(null); + + this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 6ecdb699..efdefff8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -201,8 +201,8 @@ public abstract class RoomUnit extends RoomEntity { } if(this.nextPosition != null) { - this.currentPosition = this.nextPosition; - this.currentZ = this.nextZ; + this.setCurrentPosition(this.nextPosition); + this.setCurrentZ(this.nextZ); } this.targetPosition = goalLocation; @@ -212,7 +212,7 @@ public abstract class RoomUnit extends RoomEntity { public RoomUnit setLocation(RoomTile location) { if (location != null) { - this.currentPosition = location; + this.setCurrentPosition(location); this.targetPosition = location; } return this; @@ -492,8 +492,8 @@ public abstract class RoomUnit extends RoomEntity { this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking()); if(this.getNextPosition() != null) { - this.currentPosition = this.getNextPosition(); - this.currentZ = this.getNextZ(); + this.setCurrentPosition(this.getNextPosition()); + this.setCurrentZ(this.getNextZ()); } if(!this.path.isEmpty()) { @@ -563,12 +563,14 @@ public abstract class RoomUnit extends RoomEntity { */ private boolean isValidTile(RoomTile tile) { boolean canOverrideTile = this.canOverrideTile(tile); + if (canOverrideTile) { return true; } double heightDifference = tile.getStackHeight() - this.currentZ; + //TODO Why bots are not being detected? boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile); boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT); boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 45cee9b3..2b59408f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -18,7 +18,9 @@ public class RoomPet extends RoomUnit { } @Override - public void cycle() {} + public void cycle() { + super.cycle(); + } public boolean handleRider(Pet pet, Room room) { Habbo rider = null; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java index 1325ee9e..3e81a536 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/PlaceBotEvent.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.incoming.rooms.bots; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; @@ -23,6 +22,6 @@ public class PlaceBotEvent extends MessageHandler { int x = this.packet.readInt(); int y = this.packet.readInt(); - Emulator.getGameEnvironment().getBotManager().placeBot(bot, this.client.getHabbo(), room, room.getLayout().getTile((short) x, (short) y)); + room.getRoomUnitManager().placeBot(bot, this.client.getHabbo(), x, y); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java index b5ca2447..499fafa5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/MoveAvatarEvent.java @@ -19,8 +19,6 @@ public class MoveAvatarEvent extends MessageHandler { int x = this.packet.readInt(); int y = this.packet.readInt(); - log.info("CLICKED ON TILE [x]: {} [y]: {}", x, y); - Habbo habbo = this.client.getHabbo(); if(habbo == null) { From e99af600c363e7857d65949623336c0c2562f5ef Mon Sep 17 00:00:00 2001 From: Stankman Date: Fri, 4 Aug 2023 14:11:04 -0500 Subject: [PATCH 39/42] Bot rework --- .../com/eu/habbo/habbohotel/bots/Bot.java | 266 ++++++------------ .../eu/habbo/habbohotel/bots/BotManager.java | 81 +----- .../eu/habbo/habbohotel/bots/ButlerBot.java | 26 +- .../eu/habbo/habbohotel/bots/VisitorBot.java | 4 - .../habbohotel/catalog/CatalogManager.java | 2 +- .../wired/effects/WiredEffectBotTeleport.java | 2 +- .../effects/WiredEffectBotWalkToFurni.java | 2 +- .../eu/habbo/habbohotel/pets/RideablePet.java | 4 + .../com/eu/habbo/habbohotel/rooms/Room.java | 80 +----- .../habbohotel/rooms/RoomItemManager.java | 12 +- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 6 +- .../habbo/habbohotel/rooms/RoomManager.java | 2 +- .../habbohotel/rooms/RoomRightsManager.java | 16 +- .../habbohotel/rooms/RoomUnitManager.java | 179 ++++++++++-- .../rooms/RoomWordFilterManager.java | 13 + .../rooms/entities/units/RoomUnit.java | 99 +++---- .../entities/units/types/RoomAvatar.java | 7 +- .../rooms/entities/units/types/RoomBot.java | 74 +++++ .../rooms/entities/units/types/RoomPet.java | 11 +- .../habbo/habbohotel/units/type/Avatar.java | 10 + .../com/eu/habbo/habbohotel/users/Habbo.java | 38 ++- .../users/inventory/BotsComponent.java | 4 +- .../incoming/navigator/DeleteRoomEvent.java | 159 +++++------ .../incoming/rooms/bots/CommandBotEvent.java | 20 +- .../rooms/bots/RemoveBotFromFlatEvent.java | 15 +- .../rooms/users/RoomUsersComposer.java | 145 +--------- .../users/UserRemoveMessageComposer.java | 2 +- .../threading/runnables/RoomUnitTeleport.java | 4 +- 28 files changed, 590 insertions(+), 693 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/units/type/Avatar.java diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 1fd17654..26360efd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -1,17 +1,18 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; -import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; -import com.eu.habbo.habbohotel.units.Unit; +import com.eu.habbo.habbohotel.units.type.Avatar; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.plugin.events.bots.BotChatEvent; import com.eu.habbo.plugin.events.bots.BotShoutEvent; @@ -28,86 +29,53 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; @Slf4j -public class Bot extends Unit implements Runnable { - @Getter - @Setter +@Getter +@Setter +@Accessors(chain = true) +public class Bot extends Avatar implements Runnable { private transient int id; - @Getter private String name; - @Getter private String motto; - @Getter private String figure; - @Getter private HabboGender gender; - @Getter private int ownerId; - @Getter private String ownerName; - @Getter - @Setter - private Room room; - @Getter + + private HabboInfo ownerInfo; + private boolean chatAuto; - @Getter private boolean chatRandom; - @Getter private short chatDelay; - @Getter - @Setter private int chatTimeOut; private int chatTimestamp; - @Getter - @Setter private short lastChatIndex; - @Getter private final int bubbleId; - @Getter private final String type; - @Getter private int effect; - private transient boolean canWalk = true; - private boolean needsUpdate; - @Getter - @Setter + private transient boolean canWalk; + private boolean sqlUpdateNeeded; + private boolean xyzUpdateNeeded; private transient int followingHabboId; - @Getter - @Setter - @Accessors(chain = true) - private RoomBot roomUnit; + protected final RoomBot roomUnit; public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); - @Getter private final ArrayList chatLines; - public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) { - this.id = id; - this.name = name; - this.motto = motto; - this.figure = figure; - this.gender = gender; - this.ownerId = ownerId; - this.ownerName = ownerName; - this.chatAuto = false; - this.chatRandom = false; - this.chatDelay = 1000; - this.chatLines = new ArrayList<>(); - this.type = "generic_bot"; - this.room = null; - this.bubbleId = RoomChatMessageBubbles.BOT_RENTABLE.getType(); - } - public Bot(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.name = set.getString("name"); this.motto = set.getString("motto"); this.figure = set.getString("figure"); this.gender = HabboGender.valueOf(set.getString("gender")); - this.ownerId = set.getInt(DatabaseConstants.USER_ID); + + //@Deprecated + this.ownerId = set.getInt("owner_id"); this.ownerName = set.getString("owner_name"); + + this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt("owner_id")); + this.chatAuto = set.getString("chat_auto").equals("1"); this.chatRandom = set.getString("chat_random").equals("1"); this.chatDelay = set.getShort("chat_delay"); @@ -115,61 +83,30 @@ public class Bot extends Unit implements Runnable { this.type = set.getString("type"); this.effect = set.getInt("effect"); this.canWalk = set.getString("freeroam").equals("1"); - this.room = null; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; - this.needsUpdate = false; + this.sqlUpdateNeeded = false; this.bubbleId = set.getInt("bubble_id"); this.roomUnit = new RoomBot(); this.roomUnit.setUnit(this); } - public Bot(Bot bot) { - this.name = bot.getName(); - this.motto = bot.getMotto(); - this.figure = bot.getFigure(); - this.gender = bot.getGender(); - this.ownerId = bot.getOwnerId(); - this.ownerName = bot.getOwnerName(); - this.chatAuto = true; - this.chatRandom = false; - this.chatDelay = 10; - this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; - this.chatLines = new ArrayList<>(List.of("Default Message :D")); - this.type = bot.getType(); - this.effect = bot.getEffect(); - this.bubbleId = bot.getBubbleId(); - this.needsUpdate = false; - } + public static void initialise() {} - public static void initialise() { - - } - - public static void dispose() { - - } - - public void needsUpdate(boolean needsUpdate) { - this.needsUpdate = needsUpdate; - } - - public boolean needsUpdate() { - return this.needsUpdate; - } + public static void dispose() {} @Override public void run() { - if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { + if (this.sqlUpdateNeeded) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, owner_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.motto); statement.setString(3, this.figure); statement.setString(4, this.gender.toString()); - statement.setInt(5, this.ownerId); - statement.setInt(6, this.room == null ? 0 : this.room.getRoomInfo().getId()); - statement.setInt(7, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getBodyRotation().getValue()); - statement.setInt(8, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getDanceType().getType()); + statement.setInt(5, this.ownerInfo.getId()); + statement.setInt(6, this.roomUnit.getRoom() == null ? 0 : this.roomUnit.getRoom().getRoomInfo().getId()); + statement.setInt(7, this.roomUnit.getBodyRotation().getValue()); + statement.setInt(8, this.roomUnit.getDanceType().getType()); statement.setString(9, this.canWalk ? "1" : "0"); StringBuilder text = new StringBuilder(); for (String s : this.chatLines) { @@ -183,7 +120,7 @@ public class Bot extends Unit implements Runnable { statement.setInt(15, this.bubbleId); statement.setInt(16, this.id); statement.execute(); - this.needsUpdate = false; + this.sqlUpdateNeeded = false; } catch (SQLException e) { log.error("Caught SQL exception", e); } @@ -191,122 +128,108 @@ public class Bot extends Unit implements Runnable { } public void talk(String message) { - if (this.room != null) { + if (this.roomUnit.getRoom() != null) { BotChatEvent event = new BotTalkEvent(this, message); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); + this.roomUnit.getRoom().botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { - this.room.sendComposer(new ExpressionMessageComposer(this.getRoomUnit(), RoomUserAction.WAVE).compose()); + this.roomUnit.getRoom().sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose()); } } } public void shout(String message) { - if (this.room != null) { + if (this.roomUnit.getRoom() != null) { BotChatEvent event = new BotShoutEvent(this, message); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); + this.roomUnit.getRoom().botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { - this.room.sendComposer(new ExpressionMessageComposer(this.getRoomUnit(), RoomUserAction.WAVE).compose()); + this.roomUnit.getRoom().sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose()); } } } public void whisper(String message, Habbo habbo) { - if (this.room != null && habbo != null) { + if (this.roomUnit.getRoom() != null && habbo != null) { BotWhisperEvent event = new BotWhisperEvent(this, message, habbo); if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - event.getTarget().getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getMessage(), this.getRoomUnit(), RoomChatMessageBubbles.getBubble(this.getBubbleId())))); + event.getTarget().getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId())))); } } public void onPlace(Habbo habbo, Room room) { - if (this.getRoomUnit() != null) { - this.getRoomUnit().giveEffect(this.effect, -1); + if (this.roomUnit != null) { + this.roomUnit.giveEffect(this.effect, -1); } if(PLACEMENT_MESSAGES.length > 0) { String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]; - if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) { + if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, room, new Object[]{message})) { this.talk(message); } } } - public void onPickUp(Habbo habbo, Room room) { - - } + public void onPickUp(Habbo habbo, Room room) {} public void onUserSay(final RoomChatMessage message) {} - public int getBubbleId() { - return bubbleId; - } - public void setName(String name) { this.name = name; - this.needsUpdate = true; + this.sqlUpdateNeeded = true; //if(this.room != null) - //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose()); + //this.roomUnit.getRoom().sendComposer(new ChangeNameUpdatedComposer(this.roomUnit, this.getName()).compose()); } public void setMotto(String motto) { this.motto = motto; - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } public void setFigure(String figure) { this.figure = figure; - this.needsUpdate = true; - - if (this.room != null) - this.room.sendComposer(new RoomUsersComposer(this).compose()); + this.sqlUpdateNeeded = true; + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); } public void setGender(HabboGender gender) { this.gender = gender; - this.needsUpdate = true; - - if (this.room != null) - this.room.sendComposer(new RoomUsersComposer(this).compose()); + this.sqlUpdateNeeded = true; + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); } public void setOwnerId(int ownerId) { this.ownerId = ownerId; - this.needsUpdate = true; - - if (this.room != null) - this.room.sendComposer(new RoomUsersComposer(this).compose()); + this.sqlUpdateNeeded = true; + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); } public void setOwnerName(String ownerName) { this.ownerName = ownerName; - this.needsUpdate = true; - - if (this.room != null) - this.room.sendComposer(new RoomUsersComposer(this).compose()); + this.sqlUpdateNeeded = true; + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); } public void setChatAuto(boolean chatAuto) { this.chatAuto = chatAuto; - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } public void setChatRandom(boolean chatRandom) { this.chatRandom = chatRandom; - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } public boolean hasChat() { @@ -315,28 +238,24 @@ public class Bot extends Unit implements Runnable { public void setChatDelay(short chatDelay) { this.chatDelay = (short) Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED); - this.needsUpdate = true; + this.sqlUpdateNeeded = true; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; } - public int getChatTimestamp() { - return this.chatTimestamp; - } - public void clearChat() { synchronized (this.chatLines) { this.chatLines.clear(); - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } } public void setEffect(int effect, int duration) { this.effect = effect; - this.needsUpdate = true; + this.sqlUpdateNeeded = true; - if (this.getRoomUnit() != null) { - if (this.room != null) { - this.getRoomUnit().giveEffect(this.effect, duration); + if (this.roomUnit != null) { + if (this.roomUnit.getRoom() != null) { + this.roomUnit.giveEffect(this.effect, duration); } } } @@ -344,14 +263,14 @@ public class Bot extends Unit implements Runnable { public void addChatLines(ArrayList chatLines) { synchronized (this.chatLines) { this.chatLines.addAll(chatLines); - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } } public void addChatLine(String chatLine) { synchronized (this.chatLines) { this.chatLines.add(chatLine); - this.needsUpdate = true; + this.sqlUpdateNeeded = true; } } @@ -363,37 +282,6 @@ public class Bot extends Unit implements Runnable { this.canWalk = canWalk; } - public void onPlaceUpdate() { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { - statement.setString(1, this.name); - statement.setString(2, this.motto); - statement.setString(3, this.figure); - statement.setString(4, this.gender.toString()); - statement.setInt(5, this.ownerId); - statement.setInt(6, this.room == null ? 0 : this.room.getRoomInfo().getId()); - statement.setInt(7, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentPosition().getX()); - statement.setInt(8, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentPosition().getY()); - statement.setDouble(9, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getCurrentZ()); - statement.setInt(10, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getBodyRotation().getValue()); - statement.setInt(11, this.getRoomUnit() == null ? 0 : this.getRoomUnit().getDanceType().getType()); - statement.setString(12, this.canWalk ? "1" : "0"); - StringBuilder text = new StringBuilder(); - for (String s : this.chatLines) { - text.append(s).append("\r"); - } - statement.setString(13, text.toString()); - statement.setString(14, this.chatAuto ? "1" : "0"); - statement.setString(15, this.chatRandom ? "1" : "0"); - statement.setInt(16, this.chatDelay); - statement.setInt(17, this.effect); - statement.setInt(18, this.bubbleId); - statement.setInt(19, this.id); - statement.execute(); - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - } - public void incrementLastChatIndex() { this.lastChatIndex++; } @@ -401,4 +289,32 @@ public class Bot extends Unit implements Runnable { public void resetLastChatIndex() { this.lastChatIndex = 0; } + + @Override + public void serialize(ServerMessage message) { + message.appendInt(-this.id); + message.appendString(this.name); + message.appendString(this.motto); + message.appendString(this.figure); + message.appendInt(this.roomUnit.getVirtualId()); + message.appendInt(this.roomUnit.getCurrentPosition().getX()); + message.appendInt(this.roomUnit.getCurrentPosition().getY()); + message.appendString(String.valueOf(this.roomUnit.getCurrentZ())); + message.appendInt(this.roomUnit.getBodyRotation().getValue()); + message.appendInt(4); + message.appendString(this.gender.name().toUpperCase()); + message.appendInt(this.ownerId); + message.appendString(this.ownerName); + message.appendInt(10); + message.appendShort(0); + message.appendShort(1); + message.appendShort(2); + message.appendShort(3); + message.appendShort(4); + message.appendShort(5); + message.appendShort(6); + message.appendShort(7); + message.appendShort(8); + message.appendShort(9); + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index c0914662..a06492db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -2,25 +2,11 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; 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.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; -import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; -import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer; import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer; -import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; -import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; import com.eu.habbo.plugin.events.bots.BotPickUpEvent; -import com.eu.habbo.plugin.events.bots.BotPlacedEvent; import gnu.trove.map.hash.THashMap; import lombok.extern.slf4j.Slf4j; @@ -103,71 +89,6 @@ public class BotManager { return bot; } - public void placeBot(Bot bot, Habbo habbo, Room room, RoomTile location) { - BotPlacedEvent event = new BotPlacedEvent(bot, location, habbo); - - Emulator.getPluginManager().fireEvent(event); - - if (event.isCancelled()) - return; - - if (room != null && bot != null && habbo != null) { - if (room.getRoomInfo().isRoomOwner(habbo) || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_PLACEFURNI)) { - if (room.getRoomUnitManager().getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); - return; - } - - if (room.getRoomUnitManager().hasHabbosAt(location) || (!location.isWalkable() && location.getState() != RoomTileState.SIT && location.getState() != RoomTileState.LAY)) - return; - - if (!room.getRoomUnitManager().getBotsAt(location).isEmpty()) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); - return; - } - - RoomBot roomBot = bot.getRoomUnit(); - roomBot.setRotation(RoomRotation.SOUTH); - roomBot.setLocation(location); - double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY()); - roomBot.setCurrentZ(stackHeight); - roomBot.setRoom(room); - roomBot.setRoomUnitType(RoomUnitType.BOT); - roomBot.setCanWalk(room.isAllowBotsWalk()); - - bot.setRoom(room); - - bot.onPlaceUpdate(); - - room.getRoomUnitManager().addRoomUnit(bot); - Emulator.getThreading().run(bot); - room.sendComposer(new RoomUsersComposer(bot).compose()); - room.sendComposer(new UserUpdateComposer(bot.getRoomUnit()).compose()); - habbo.getInventory().getBotsComponent().removeBot(bot); - habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); - bot.onPlace(habbo, room); - - RoomItem topItem = room.getRoomItemManager().getTopItemAt(location.getX(), location.getY()); - - if (topItem != null) { - try { - topItem.onWalkOn(bot.getRoomUnit(), room, null); - } catch (Exception e) { - log.error("Caught exception", e); - } - } - } else { - habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode())); - } - } - } - - public void pickUpBot(int botId, Habbo habbo, Room room) { - if (habbo.getRoomUnit().getRoom() != null) { - this.pickUpBot(habbo.getRoomUnit().getRoom().getRoomUnitManager().getRoomBotById(Math.abs(botId)), habbo, room); - } - } - public void pickUpBot(Bot bot, Habbo habbo, Room room) { HabboInfo botOwnerInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo(); @@ -190,7 +111,7 @@ public class BotManager { bot.setFollowingHabboId(0); bot.setOwnerId(botOwnerInfo.getId()); bot.setOwnerName(botOwnerInfo.getUsername()); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); Emulator.getThreading().run(bot); Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index a4ad12ef..c07261cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -30,10 +30,6 @@ public class ButlerBot extends Bot { super(set); } - public ButlerBot(Bot bot) { - super(bot); - } - public static void initialise() { if (serveItems == null) serveItems = new THashMap<>(); @@ -58,11 +54,11 @@ public class ButlerBot extends Bot { @Override public void onUserSay(final RoomChatMessage message) { - if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || this.getRoom() == null) { + if (this.roomUnit.hasStatus(RoomUnitStatus.MOVE) || this.roomUnit.getRoom() == null) { return; } - double distanceBetweenBotAndHabbo = this.getRoomUnit().getCurrentPosition().distance(message.getHabbo().getRoomUnit().getCurrentPosition()); + double distanceBetweenBotAndHabbo = this.roomUnit.getCurrentPosition().distance(message.getHabbo().getRoomUnit().getCurrentPosition()); if (distanceBetweenBotAndHabbo <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance")) { @@ -81,7 +77,7 @@ public class ButlerBot extends Bot { } // Start give handitem process - if (this.getRoomUnit().isCanWalk()) { + if (this.roomUnit.isCanWalk()) { final String key = keyword; final Bot bot = this; @@ -91,16 +87,16 @@ public class ButlerBot extends Bot { // Step 2: Prepare tasks for when the Bot (carrying the handitem) reaches the Habbo final List tasks = new ArrayList<>(); tasks.add(new RoomUnitGiveHanditem(serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId())); - tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), 0)); + tasks.add(new RoomUnitGiveHanditem(this.roomUnit, serveEvent.getHabbo().getRoomUnit().getRoom(), 0)); tasks.add(() -> { - if (this.getRoom() != null) { + if (this.roomUnit.getRoom() != null) { String botMessage = Emulator.getTexts() .getValue("bots.butler.given") .replace("%key%", key) .replace("%username%", serveEvent.getHabbo().getHabboInfo().getUsername()); - if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{botMessage})) { + if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, this.roomUnit.getRoom(), new Object[]{botMessage})) { bot.talk(botMessage); } } @@ -116,20 +112,20 @@ public class ButlerBot extends Bot { }); // Give bot the handitem that it's going to give the Habbo - Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId())); + Emulator.getThreading().run(new RoomUnitGiveHanditem(this.roomUnit, serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId())); if (distanceBetweenBotAndHabbo > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) { - Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3))); + Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.roomUnit, serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3))); } else { Emulator.getThreading().run(failedReached.get(0), 1000); } } else { - if (this.getRoom() != null) { + if (this.roomUnit.getRoom() != null) { serveEvent.getHabbo().getRoomUnit().setHandItem(serveEvent.getItemId()); - this.getRoom().sendComposer(new CarryObjectMessageComposer(serveEvent.getHabbo().getRoomUnit()).compose()); + this.roomUnit.getRoom().sendComposer(new CarryObjectMessageComposer(serveEvent.getHabbo().getRoomUnit()).compose()); String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.getHabbo().getHabboInfo().getUsername()); - if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) { + if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, this.roomUnit.getRoom(), new Object[]{msg})) { this.talk(msg); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java index 672dfff2..bcca553e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java @@ -20,10 +20,6 @@ public class VisitorBot extends Bot { super(set); } - public VisitorBot(Bot bot) { - super(bot); - } - public static void initialise() { DATE_FORMAT = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat")); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 386753b4..6885f3c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -902,7 +902,7 @@ public class CatalogManager { if (bot != null) { bot.setOwnerId(habbo.getClient().getHabbo().getHabboInfo().getId()); bot.setOwnerName(habbo.getClient().getHabbo().getHabboInfo().getUsername()); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); Emulator.getThreading().run(bot); habbo.getClient().getHabbo().getInventory().getBotsComponent().addBot(bot); habbo.getClient().sendResponse(new BotAddedToInventoryComposer(bot)); 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 930c2c09..7c2d7607 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 @@ -51,7 +51,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { for (RoomItem item : this.getWiredSettings().getItems(room)) { if (item.getRoomId() != 0) { - Room room1 = bot.getRoom(); + Room room1 = bot.getRoomUnit().getRoom(); if (item.getRoomId() == room1.getRoomInfo().getId()) { if (i == j) { teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index 4a845ae0..07f50e2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -54,7 +54,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { RoomItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size())); if (item.getRoomId() != 0) { - Room room1 = bot.getRoom(); + Room room1 = bot.getRoomUnit().getRoom(); if (item.getRoomId() == room1.getRoomInfo().getId()) { bot.getRoomUnit().walkTo(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java index fb26f720..d846e793 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java @@ -37,6 +37,10 @@ public class RideablePet extends Pet { this.hasSaddle = hasSaddle; } + public boolean hasRider() { + return this.rider != null; + } + public boolean anyoneCanRide() { return this.anyoneCanRide; } 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 24946e74..abbe4d51 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; -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.rooms.entities.units.RoomUnitType; @@ -392,75 +391,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new UserUpdateComposer(roomUnit).compose()); } - public void updateHabbosAt(RoomTile tile) { - RoomItem item = this.roomItemManager.getTopItemAt(tile.getX(), tile.getY()); - - Collection habbos = this.roomUnitManager.getHabbosAt(tile); - - if(habbos == null || habbos.isEmpty()) { - return; - } - - //Improve this - for (Habbo habbo : habbos) { - double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight(); - - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) { - habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); - } - - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) { - habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); - } - - if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { - if(item.getBaseItem().allowSit()) { - habbo.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item))); - } else if(item.getBaseItem().allowLay()) { - habbo.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item))); - } - - habbo.getRoomUnit().setCurrentZ(item.getCurrentZ()); - habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); - } else { - habbo.getRoomUnit().setCurrentZ(z); - } - } - } - - public void updateBotsAt(RoomTile tile) { - this.updateBotsAt(tile.getX(), tile.getY()); - } - - public void updateBotsAt(short x, short y) { - RoomItem topItem = this.roomItemManager.getTopItemAt(x, y); - - THashSet roomUnits = new THashSet<>(); - - RoomTile tile = this.layout.getTile(x, y); - this.roomUnitManager.getBotsAt(tile).forEach(bot -> { - if (topItem != null) { - if (topItem.getBaseItem().allowSit()) { - bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ()); - bot.getRoomUnit().setRotation(RoomRotation.fromValue(topItem.getRotation())); - } else { - bot.getRoomUnit().setCurrentZ(topItem.getCurrentZ() + Item.getCurrentHeight(topItem)); - - if (topItem.getBaseItem().allowLay()) { - bot.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(topItem.getCurrentZ() + topItem.getBaseItem().getHeight())); - } - } - } else { - bot.getRoomUnit().setCurrentZ(bot.getRoomUnit().getCurrentPosition().getStackHeight()); - } - roomUnits.add(bot.getRoomUnit()); - }); - - if (!roomUnits.isEmpty()) { - this.sendComposer(new UserUpdateComposer(roomUnits).compose()); - } - } - public void startTrade(Habbo userOne, Habbo userTwo) { RoomTrade trade = new RoomTrade(userOne, userTwo, this); synchronized (this.activeTrades) { @@ -1741,12 +1671,6 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canSitOrLayAt(RoomTile tile) { - return this.canSitOrLayAt(tile.getX(), tile.getY()); - } - - public boolean canSitOrLayAt(int x, int y) { - RoomTile tile = this.layout.getTile((short) x, (short) y); - if(tile == null) { return false; } @@ -1754,7 +1678,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.roomUnitManager.hasHabbosAt(tile)) return false; - THashSet items = this.roomItemManager.getItemsAt(x, y); + THashSet items = this.roomItemManager.getItemsAt(tile); return this.canSitAt(items) || this.canLayAt(items); } @@ -1769,7 +1693,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.roomUnitManager.hasHabbosAt(tile)) return false; - return this.canSitAt(this.roomItemManager.getItemsAt(x, y)); + return this.canSitAt(this.roomItemManager.getItemsAt(tile)); } boolean canSitAt(THashSet items) { 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 f3efbb36..71c1610d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -318,8 +318,8 @@ public class RoomItemManager { this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose()); for (RoomTile t : occupiedTiles) { - this.room.updateHabbosAt(t); - this.room.updateBotsAt(t); + this.room.getRoomUnitManager().updateHabbosAt(t); + this.room.getRoomUnitManager().updateBotsAt(t); } Emulator.getThreading().run(item); @@ -514,8 +514,8 @@ public class RoomItemManager { //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.room.updateHabbosAt(t); - this.room.updateBotsAt(t); + this.room.getRoomUnitManager().updateHabbosAt(t); + this.room.getRoomUnitManager().updateBotsAt(t); } if (Emulator.getConfig().getBoolean("wired.place.under", false)) { @@ -572,8 +572,8 @@ public class RoomItemManager { 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()); + this.room.getRoomUnitManager().updateHabbosAt(tile); + this.room.getRoomUnitManager().updateBotsAt(tile); }); } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.room.sendComposer(new ItemRemoveMessageComposer(item).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 1f6ce701..f7ccff0a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -562,8 +563,9 @@ public class RoomLayout { public RoomTile getRandomWalkableTilesAround(RoomUnit roomUnit, RoomTile tile, Room room, int radius) { if(!this.tileExists(tile.getX(), tile.getY())) { tile = this.getTile(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); - room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()).needsUpdate(true); - } + Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); + bot.setSqlUpdateNeeded(true); + } List newTiles = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 11c890d5..8f2a4395 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -710,7 +710,7 @@ public class RoomManager { } - habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentBots().values(), true)); + habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentBots().values())); if (!room.getRoomUnitManager().getCurrentBots().isEmpty()) { room.getRoomUnitManager().getCurrentBots().values().stream() diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java index 2f88a241..be3a7955 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java @@ -87,14 +87,14 @@ public class RoomRightsManager { return; } - if (this.rights.add(habbo.getHabboInfo().getId())) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { - statement.setInt(1, this.room.getRoomInfo().getId()); - statement.setInt(2, habbo.getHabboInfo().getId()); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } + this.rights.add(habbo.getHabboInfo().getId()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_rights VALUES (?, ?)")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.setInt(2, habbo.getHabboInfo().getId()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); } this.room.getRoomRightsManager().refreshRightsForHabbo(habbo); 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 ab5b85f1..589fa924 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.bots.BotManager; +import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; @@ -15,13 +17,16 @@ import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; +import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer; import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.bots.BotPickUpEvent; import com.eu.habbo.plugin.events.bots.BotPlacedEvent; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -67,28 +72,31 @@ public class RoomUnitManager { private synchronized void loadBots(Connection connection) { this.currentBots.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 = ?")) { + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.owner_id = users.id WHERE room_id = ?")) { statement.setInt(1, this.room.getRoomInfo().getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set); //TODO IMPROVE THIS if (bot != null) { - bot.setRoom(this.room); - bot.setRoomUnit(new RoomBot()); - bot.getRoomUnit().setUnit(bot); 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) { + + RoomTile spawnTile = this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")); + + if(spawnTile == null) { + bot.getRoomUnit().setCurrentPosition(this.room.getLayout().getDoorTile()); 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().setCurrentPosition(spawnTile); bot.getRoomUnit().setCurrentZ(set.getDouble("z")); bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); } - bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); + bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); + + //@DEPRECATED bot.getRoomUnit().setInRoom(true); bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false); @@ -150,7 +158,9 @@ public class RoomUnitManager { this.currentHabbos.put(((Habbo) unit).getHabboInfo().getId(), (Habbo) unit); unit.getRoomUnit().getRoom().updateDatabaseUserCount(); } - case BOT -> this.currentBots.put(((Bot) unit).getId(), (Bot) unit); + case BOT -> { + this.currentBots.put(((Bot) unit).getId(), (Bot) unit); + } case PET -> { this.currentPets.put(((Pet) unit).getId(), (Pet) unit); Habbo habbo = this.getRoomHabboById(((Pet) unit).getUserId()); @@ -170,6 +180,10 @@ public class RoomUnitManager { return this.currentRoomUnits.values().stream().anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); } + public boolean areRoomUnitsAt(RoomTile tile, RoomUnit skippedRoomUnit) { + return this.currentRoomUnits.values().stream().filter(roomUnit -> !roomUnit.equals(skippedRoomUnit)).anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); + } + public List getAvatarsAt(RoomTile tile) { return Stream.concat(this.getHabbosAt(tile).stream(), this.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList()); } @@ -202,6 +216,41 @@ public class RoomUnitManager { return this.currentHabbos.values().stream().filter(habbo -> habbo.getRoomUnit() == roomUnit).findFirst().orElse(null); } + public void updateHabbosAt(RoomTile tile) { + Collection habbos = this.getHabbosAt(tile); + + if(habbos == null || habbos.isEmpty()) { + return; + } + + RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); + + for (Habbo habbo : habbos) { + double z = habbo.getRoomUnit().getCurrentPosition().getStackHeight(); + + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) { + habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); + } + + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) { + habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY); + } + + if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { + if(item.getBaseItem().allowSit()) { + habbo.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item))); + } else if(item.getBaseItem().allowLay()) { + habbo.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item))); + } + + habbo.getRoomUnit().setCurrentZ(item.getCurrentZ()); + habbo.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); + } else { + habbo.getRoomUnit().setCurrentZ(z); + } + } + } + public Bot getRoomBotById(int botId) { return this.currentBots.get(botId); } @@ -224,16 +273,17 @@ public class RoomUnitManager { return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } - public void placeBot(Bot bot, Habbo habbo, int x, int y) { + public void placeBot(Bot bot, Habbo botOwner, int x, int y) { synchronized (this.currentBots) { RoomTile spawnTile = room.getLayout().getTile((short) x, (short) y); - if(spawnTile == null) { - spawnTile = room.getLayout().getDoorTile(); + if(spawnTile == null || (!spawnTile.isWalkable() && !this.room.canSitOrLayAt(spawnTile)) || this.areRoomUnitsAt(spawnTile)) { + botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); + return; } if (Emulator.getPluginManager().isRegistered(BotPlacedEvent.class, false)) { - Event event = new BotPlacedEvent(bot, spawnTile, habbo); + Event event = new BotPlacedEvent(bot, spawnTile, botOwner); Emulator.getPluginManager().fireEvent(event); if (event.isCancelled()) { @@ -241,13 +291,8 @@ public class RoomUnitManager { } } - if(this.currentBots.size() >= Room.MAXIMUM_BOTS && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); - return; - } - - if((!spawnTile.isWalkable() && !this.room.canSitOrLayAt(spawnTile)) || this.areRoomUnitsAt(spawnTile)) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); + if(this.currentBots.size() >= Room.MAXIMUM_BOTS && !botOwner.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { + botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } @@ -259,15 +304,92 @@ public class RoomUnitManager { roomBot.setRotation(RoomRotation.SOUTH); roomBot.setCanWalk(this.room.isAllowBotsWalk()); + bot.setSqlUpdateNeeded(true); + Emulator.getThreading().run(bot); + this.addRoomUnit(bot); this.room.sendComposer(new RoomUsersComposer(bot).compose()); roomBot.instantUpdate(); - habbo.getInventory().getBotsComponent().removeBot(bot); - habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); - bot.onPlace(habbo, room); + botOwner.getInventory().getBotsComponent().removeBot(bot); + botOwner.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); + bot.onPlace(botOwner, room); + } + } + + public void updateBotsAt(RoomTile tile) { + Collection bots = this.getBotsAt(tile); + + if(bots == null || bots.isEmpty()) { + return; + } + + RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()); + + bots.forEach(bot -> { + double z = bot.getRoomUnit().getCurrentPosition().getStackHeight(); + + if (bot.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !bot.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) { + bot.getRoomUnit().removeStatus(RoomUnitStatus.SIT); + } + + if (bot.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !bot.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) { + bot.getRoomUnit().removeStatus(RoomUnitStatus.LAY); + } + + if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { + if(item.getBaseItem().allowSit()) { + bot.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item))); + } else if(item.getBaseItem().allowLay()) { + bot.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item))); + } + + bot.getRoomUnit().setCurrentZ(item.getCurrentZ()); + bot.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation())); + } else { + bot.getRoomUnit().setCurrentZ(z); + } + }); + } + + public void pickUpBot(Bot bot, Habbo picker) { + HabboInfo botOwnerInfo = picker == null ? bot.getOwnerInfo() : picker.getHabboInfo(); + + BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, picker); + Emulator.getPluginManager().fireEvent(pickedUpEvent); + + if (pickedUpEvent.isCancelled()) + return; + + if (picker == null || (bot.getOwnerInfo().getId() == picker.getHabboInfo().getId() || picker.hasPermissionRight(Permission.ACC_ANYROOMOWNER))) { + if (picker != null && !picker.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && picker.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { + picker.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", String.valueOf(BotManager.MAXIMUM_BOT_INVENTORY_SIZE))); + return; + } + + bot.onPickUp(picker, this.room); + + bot.setFollowingHabboId(0); + + //@DEPRECATED + bot.setOwnerId(botOwnerInfo.getId()); + bot.setOwnerName(botOwnerInfo.getUsername()); + + bot.setOwnerInfo(botOwnerInfo); + + this.removeBot(bot); + + bot.setSqlUpdateNeeded(true); + Emulator.getThreading().run(bot); + + Habbo receiver = picker == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : picker; + + if (receiver != null) { + receiver.getInventory().getBotsComponent().addBot(bot); + receiver.getClient().sendResponse(new BotAddedToInventoryComposer(bot)); + } } } @@ -384,9 +506,10 @@ public class RoomUnitManager { roomHabbo.clear(); } - public boolean removeBot(Bot bot) { + public void removeBot(Bot bot) { synchronized (this.currentBots) { if (this.currentBots.containsKey(bot.getId())) { + //TODO gotta do a method to removeUnit and clear tile if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentPosition() != null) { bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit()); } @@ -394,15 +517,13 @@ public class RoomUnitManager { this.currentBots.remove(bot.getId()); this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId()); + //@DEPRECATED bot.getRoomUnit().setInRoom(false); - bot.setRoom(null); + bot.getRoomUnit().setRoom(null); this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); - return true; } } - - return false; } public Pet removePet(int petId) { @@ -471,7 +592,7 @@ public class RoomUnitManager { while(botIterator.hasNext()) { try { Bot bot = botIterator.next(); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); Emulator.getThreading().run(bot); } catch (NoSuchElementException e) { log.error("Caught Exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java index 698a9790..446922b0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomWordFilterManager.java @@ -78,4 +78,17 @@ public class RoomWordFilterManager { } } } + + public void removeAllWords() { + synchronized (this.filteredWords) { + this.filteredWords.clear(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ?")) { + statement.setInt(1, this.room.getRoomInfo().getId()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index efdefff8..52b5dd07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -5,11 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWater; import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; +import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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.types.RoomAvatar; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; @@ -32,59 +34,57 @@ import java.util.concurrent.ConcurrentHashMap; @Accessors(chain = true) public abstract class RoomUnit extends RoomEntity { @Setter - private int virtualId; + protected int virtualId; @Setter - private Unit unit; + protected Unit unit; @Setter - private RoomUnitType roomUnitType; + protected RoomUnitType roomUnitType; @Setter - private RoomRotation bodyRotation; + protected RoomRotation bodyRotation; @Setter - private RoomRotation headRotation; + protected RoomRotation headRotation; @Setter - private boolean canWalk; + protected boolean canWalk; @Setter - private boolean canRotate; + protected boolean canRotate; @Setter - private boolean isTeleporting; + protected boolean isTeleporting; @Setter - private boolean cmdSitEnabled = false; + protected boolean cmdSitEnabled = false; @Setter - private boolean cmdStandEnabled = false; + protected boolean cmdStandEnabled = false; @Setter - private boolean cmdLayEnabled = false; + protected boolean cmdLayEnabled = false; @Setter - private boolean isSwimming = false; + protected boolean isSwimming = false; @Setter - private boolean cmdFastWalkEnabled; + protected boolean cmdFastWalkEnabled; @Setter - private boolean temporalFastWalkEnabled; - private final ConcurrentHashMap statuses; + protected boolean temporalFastWalkEnabled; + protected final ConcurrentHashMap statuses; @Setter - private boolean statusUpdateNeeded; + protected boolean statusUpdateNeeded; @Setter - private boolean isWiredTeleporting = false; + protected boolean isWiredTeleporting = false; @Setter - private boolean isLeavingTeleporter = false; - private final THashMap cacheable; + protected boolean isLeavingTeleporter = false; + protected final THashMap cacheable; @Setter - private boolean isKicked; + protected boolean isKicked; @Setter - private int kickCount = 0; + protected int kickCount = 0; @Setter - private boolean inRoom; + protected boolean inRoom; @Setter @Accessors(chain = true) - private boolean invisible = false; + protected boolean invisible = false; @Setter - private boolean canLeaveRoomByDoor = true; + protected boolean canLeaveRoomByDoor = true; @Setter - private int walkTimeOut; - private int previousEffectId; - private int previousEffectEndTimestamp; - private int timeInRoom; - private RoomRightLevels rightsLevel = RoomRightLevels.NONE; - private final THashSet overridableTiles; + protected int walkTimeOut; + protected int timeInRoom; + protected RoomRightLevels rightsLevel = RoomRightLevels.NONE; + protected final THashSet overridableTiles; public RoomUnit() { this.virtualId = 0; @@ -103,10 +103,6 @@ public abstract class RoomUnit extends RoomEntity { this.walkTimeOut = Emulator.getIntUnixTimestamp(); this.timeInRoom = 0; - //RoomAvatar - this.previousEffectId = 0; - this.previousEffectEndTimestamp = -1; - //RoomHabbo this.isKicked = false; this.overridableTiles = new THashSet<>(); @@ -170,7 +166,7 @@ public abstract class RoomUnit extends RoomEntity { if (this.room != null) { Bot bot = this.room.getRoomUnitManager().getRoomBotById(getVirtualId()); if (bot != null) { - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); } } @@ -243,7 +239,7 @@ public abstract class RoomUnit extends RoomEntity { boolean hasValidLayout = hasValidRoom && this.room.getLayout() != null; boolean hasValidTargetPosition = this.targetPosition != null; boolean isTargetPositionWalkable = hasValidTargetPosition && this.targetPosition.isWalkable(); - boolean canSitOrLayAtTarget = hasValidTargetPosition && hasValidRoom && this.room.canSitOrLayAt(this.targetPosition.getX(), this.targetPosition.getY()); + boolean canSitOrLayAtTarget = hasValidTargetPosition && hasValidRoom && this.room.canSitOrLayAt(this.targetPosition); boolean canOverrideTile = hasValidTargetPosition && this.canOverrideTile(this.targetPosition); if (hasValidLayout && (isTargetPositionWalkable || canSitOrLayAtTarget || canOverrideTile)) { @@ -496,7 +492,7 @@ public abstract class RoomUnit extends RoomEntity { this.setCurrentZ(this.getNextZ()); } - if(!this.path.isEmpty()) { + if(this.path != null && !this.path.isEmpty()) { RoomTile next = this.path.poll(); if(this.path.size() > 1 && (this.cmdFastWalkEnabled || this.temporalFastWalkEnabled)) { @@ -570,8 +566,18 @@ public abstract class RoomUnit extends RoomEntity { double heightDifference = tile.getStackHeight() - this.currentZ; - //TODO Why bots are not being detected? boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile); + + if(this instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) { + areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, roomAvatar.getRidingPet().getRoomUnit()); + } + + if(this instanceof RoomPet roomPet) { + if(roomPet.getUnit() instanceof RideablePet rideablePet && rideablePet.hasRider()) { + areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, rideablePet.getRider().getRoomUnit()); + } + } + boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT); boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT); boolean isTileBlocked = tile.getState().equals(RoomTileState.BLOCKED) || tile.getState().equals(RoomTileState.INVALID); @@ -579,14 +585,13 @@ public abstract class RoomUnit extends RoomEntity { if(isTileBlocked || isAboveMaximumStepHeight || isOpenTileAboveMaxHeight) { return false; } else { - if(this.room.getRoomInfo().isAllowWalkthrough()) { - if(areRoomUnitsAtTile && !this.targetPosition.equals(tile)) { - return false; - } - } else { - if(areRoomUnitsAtTile) { - return false; - } + if(areRoomUnitsAtTile && this.targetPosition.equals(tile)) { + this.stopWalking(); + return false; + } + + if(areRoomUnitsAtTile && !this.room.getRoomInfo().isAllowWalkthrough()) { + return false; } } @@ -606,8 +611,6 @@ public abstract class RoomUnit extends RoomEntity { this.canRotate = true; this.cmdFastWalkEnabled = false; this.clearStatuses(); - this.previousEffectId = 0; - this.previousEffectEndTimestamp = -1; this.isKicked = false; this.cacheable.clear(); } 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 4d90050d..0e978c4b 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 @@ -26,7 +26,7 @@ import java.util.List; @Getter @Setter @Accessors(chain = true) -public class RoomAvatar extends RoomUnit { +public abstract class RoomAvatar extends RoomUnit { protected RideablePet ridingPet; protected boolean rideLocked; protected DanceType danceType; @@ -91,8 +91,6 @@ public class RoomAvatar extends RoomUnit { this.ridingPet.setRider(null); this.ridingPet.setTask(PetTasks.FREE); - this.ridingPet = null; - this.giveEffect(0, -1); this.setCurrentZ(this.ridingPet.getRoomUnit().getCurrentZ()); this.stopWalking(); @@ -102,6 +100,8 @@ public class RoomAvatar extends RoomUnit { this.instantUpdate(); this.ridingPet.getRoomUnit().instantUpdate(); + this.ridingPet = null; + List availableTiles = isRemoving ? new ArrayList<>() : this.room.getLayout().getWalkableTilesAround(this.getCurrentPosition()); RoomTile tile = availableTiles.isEmpty() ? this.getCurrentPosition() : availableTiles.get(0); @@ -184,6 +184,7 @@ public class RoomAvatar extends RoomUnit { super.clear(); this.ridingPet = null; + this.rideLocked = false; this.danceType = DanceType.NONE; this.handItem = 0; this.handItemTimestamp = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java index 3f15cfde..b522a776 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java @@ -1,10 +1,26 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.outgoing.rooms.users.ChatMessageComposer; +import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.bots.BotTalkEvent; import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Getter +@Setter +@Accessors(chain = true) public class RoomBot extends RoomAvatar { private Bot unit; @@ -14,9 +30,67 @@ public class RoomBot extends RoomAvatar { @Override public void cycle() { + if(this.room.isAllowBotsWalk() && this.unit.canWalk()) { + if (!this.isWalking()) { + if (this.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.unit.getFollowingHabboId() == 0) { + this.walkTo(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.currentPosition, this.getRoom(), Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile()); + int timeOut = Emulator.getRandom().nextInt(20) * 2; + this.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); + } + } + } + + boolean hasChatLines = !this.unit.getChatLines().isEmpty(); + boolean hasAutoChatEnabled = this.unit.isChatAuto(); + boolean chatTimeOutPassed = Emulator.getIntUnixTimestamp() >= this.unit.getChatTimeOut(); + + if (hasChatLines && chatTimeOutPassed && hasAutoChatEnabled) { + if(this.unit.isChatRandom()) { + this.unit.setLastChatIndex((short) Emulator.getRandom().nextInt(this.unit.getChatLines().size())); + } else if(this.unit.getLastChatIndex() == this.unit.getChatLines().size() - 1) { + this.unit.resetLastChatIndex(); + } else { + this.unit.incrementLastChatIndex(); + } + + if (this.unit.getLastChatIndex() >= this.unit.getChatLines().size()) { + this.unit.resetLastChatIndex(); + } + + String message = this.unit.getChatLines().get(this.unit.getLastChatIndex()) + .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.getRoom().getRoomInfo().getOwnerInfo().getUsername()) + .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), String.valueOf(this.getRoom().getRoomItemManager().getCurrentItems().size())) + .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.unit.getName()) + .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.getRoom().getRoomInfo().getName()) + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), String.valueOf(this.getRoom().getRoomUnitManager().getRoomHabbosCount())); + + if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this, room, new Object[]{ message })) { + this.talk(message); + } + + this.unit.setChatTimeOut(Emulator.getIntUnixTimestamp() + this.unit.getChatDelay()); + } + super.cycle(); } + public void talk(String message) { + if (Emulator.getPluginManager().isRegistered(BotTalkEvent.class, false)) { + Event event = new BotTalkEvent(this.unit, message); + Emulator.getPluginManager().fireEvent(event); + + if (event.isCancelled()) + return; + } + + this.unit.setChatTimestamp(Emulator.getIntUnixTimestamp()); + this.room.botChat(new ChatMessageComposer(new RoomChatMessage(message, this, RoomChatMessageBubbles.getBubble(this.unit.getBubbleId()))).compose()); + + if (message.equals("o/") || message.equals("_o/")) { + this.room.sendComposer(new ExpressionMessageComposer(this, RoomUserAction.WAVE).compose()); + } + } + public RoomUnitType getRoomUnitType() { return RoomUnitType.BOT; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 2b59408f..9e0f13c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; -import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; @@ -19,13 +18,15 @@ public class RoomPet extends RoomUnit { @Override public void cycle() { - super.cycle(); + if (!this.handleRider()) { + super.cycle(); + } } - public boolean handleRider(Pet pet, Room room) { + public boolean handleRider() { Habbo rider = null; - if (pet instanceof RideablePet rideablePet) { + if (this.unit instanceof RideablePet rideablePet) { rider = rideablePet.getRider(); } @@ -38,7 +39,7 @@ public class RoomPet extends RoomUnit { this.removeStatus(RoomUnitStatus.MOVE); } - if (!this.getCurrentPosition().equals(rider.getRoomUnit().getCurrentPosition())) { + if (!this.currentPosition.equals(rider.getRoomUnit().getCurrentPosition())) { this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition()); this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight()); diff --git a/src/main/java/com/eu/habbo/habbohotel/units/type/Avatar.java b/src/main/java/com/eu/habbo/habbohotel/units/type/Avatar.java new file mode 100644 index 00000000..becf31e0 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/units/type/Avatar.java @@ -0,0 +1,10 @@ +package com.eu.habbo.habbohotel.units.type; + +import com.eu.habbo.habbohotel.units.Unit; +import com.eu.habbo.messages.ISerialize; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public abstract class Avatar extends Unit implements ISerialize {} 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 2b0bd2e2..74fe2c3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.catalog.ClothItem; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; @@ -14,8 +15,9 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; -import com.eu.habbo.habbohotel.units.Unit; +import com.eu.habbo.habbohotel.units.type.Avatar; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; +import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.generic.alerts.*; import com.eu.habbo.messages.outgoing.inventory.*; import com.eu.habbo.messages.outgoing.rooms.FloodControlMessageComposer; @@ -40,7 +42,7 @@ import java.util.*; import java.util.stream.Collectors; @Slf4j -public class Habbo extends Unit implements Runnable { +public class Habbo extends Avatar implements Runnable { @Getter private RoomHabbo roomUnit; @Getter @@ -345,7 +347,7 @@ public class Habbo extends Unit implements Runnable { public void deleteBot(Bot bot) { this.removeBot(bot); - bot.getRoom().getRoomUnitManager().removeBot(bot); + bot.getRoomUnit().getRoom().getRoomUnitManager().removeBot(bot); Emulator.getGameEnvironment().getBotManager().deleteBot(bot); } @@ -467,4 +469,34 @@ public class Habbo extends Unit implements Runnable { .flatMap(c -> Arrays.stream(c).boxed()) .collect(Collectors.toSet()); } + + @Override + public void serialize(ServerMessage message) { + message.appendInt(this.habboInfo.getId()); + message.appendString(this.habboInfo.getUsername()); + message.appendString(this.habboInfo.getMotto()); + message.appendString(this.habboInfo.getLook()); + message.appendInt(this.roomUnit.getVirtualId()); + message.appendInt(this.roomUnit.getCurrentPosition().getX()); + message.appendInt(this.roomUnit.getCurrentPosition().getY()); + message.appendString(String.valueOf(this.roomUnit.getCurrentZ())); + message.appendInt(this.roomUnit.getBodyRotation().getValue()); + message.appendInt(1); + message.appendString(this.habboInfo.getGender().name().toUpperCase()); + message.appendInt(this.habboStats.getGuild() != 0 ? this.habboStats.getGuild() : -1); + message.appendInt(this.habboStats.getGuild() != 0 ? 1 : -1); + + String name = ""; + if (this.habboStats.getGuild() != 0) { + Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.habboStats.getGuild()); + + if (g != null) + name = g.getName(); + } + message.appendString(name); + + message.appendString(""); + message.appendInt(this.habboStats.getAchievementScore()); + message.appendBoolean(true); + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index e97a3f5e..81e07d5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java @@ -25,7 +25,7 @@ public class BotsComponent { private void loadBots(Habbo habbo) { synchronized (this.bots) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.user_id WHERE user_id = ? AND room_id = 0 ORDER BY id ASC")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.owner_id WHERE owner_id = ? AND room_id = 0 ORDER BY id ASC")) { statement.setInt(1, habbo.getHabboInfo().getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { @@ -60,7 +60,7 @@ public class BotsComponent { public void dispose() { synchronized (this.bots) { for (Map.Entry map : this.bots.entrySet()) { - if (map.getValue().needsUpdate()) { + if (map.getValue().isSqlUpdateNeeded()) { Emulator.getThreading().run(map.getValue()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index 7c790233..25cf6167 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -2,7 +2,6 @@ package com.eu.habbo.messages.incoming.navigator; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -29,92 +28,82 @@ public class DeleteRoomEvent extends MessageHandler { Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(roomId); - if (room != null) { - if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { - if (room.getRoomInfo().getId() == this.client.getHabbo().getHabboInfo().getHomeRoom()) { - return; + if(room == null) { + return; + } + + if(!room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { + String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getRoomInfo().getName()).replace("%roomowner%", room.getRoomInfo().getOwnerInfo().getUsername()); + ScripterManager.scripterDetected(this.client, message); + log.info(message); + return; + } + + if (room.getRoomInfo().getId() == this.client.getHabbo().getHabboInfo().getHomeRoom()) { + return; + } + + if (Emulator.getPluginManager().fireEvent(new NavigatorRoomDeletedEvent(this.client.getHabbo(), room)).isCancelled()) { + return; + } + + room.getRoomItemManager().ejectAllFurni(); + room.getRoomItemManager().ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); + + List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentBots().values()); + for (Bot bot : bots) { + Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room); + } + + List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentPets().values()); + for (Pet pet : pets) { + if (pet instanceof RideablePet rideablePet) { + if (rideablePet.getRider() != null) { + rideablePet.getRider().getRoomUnit().dismountPet(true); } - - if (Emulator.getPluginManager().fireEvent(new NavigatorRoomDeletedEvent(this.client.getHabbo(), room)).isCancelled()) { - return; - } - - room.getRoomItemManager().ejectAllFurni(); - room.getRoomItemManager().ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId()); - - List bots = new ArrayList<>(room.getRoomUnitManager().getCurrentBots().values()); - for (Bot bot : bots) { - Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room); - } - - List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentPets().values()); - for (Pet pet : pets) { - if (pet instanceof RideablePet rideablePet) { - if (rideablePet.getRider() != null) { - rideablePet.getRider().getRoomUnit().dismountPet(true); - } - } - - pet.removeFromRoom(); - Emulator.getThreading().run(pet); - - Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); - - if (owner != null) { - owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - owner.getInventory().getPetsComponent().addPet(pet); - } - } - - if (room.getRoomInfo().getGuild().getId() > 0) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(room.getRoomInfo().getGuild().getId()); - - if (guild != null) { - Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); - } - } - - room.preventUnloading = false; - room.dispose(); - Emulator.getGameEnvironment().getRoomManager().uncacheRoom(room); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement statement = connection.prepareStatement("DELETE FROM rooms WHERE id = ? LIMIT 1")) { - statement.setInt(1, roomId); - statement.execute(); - } - - if (room.getRoomInfo().isModelOverridden()) { - try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_models_custom WHERE id = ? LIMIT 1")) { - stmt.setInt(1, roomId); - stmt.execute(); - } - } - - room.dispose(); - - try (PreparedStatement rights = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { - rights.setInt(1, roomId); - rights.execute(); - } - - try (PreparedStatement votes = connection.prepareStatement("DELETE FROM room_votes WHERE room_id = ?")) { - votes.setInt(1, roomId); - votes.execute(); - } - - try (PreparedStatement filter = connection.prepareStatement("DELETE FROM room_wordfilter WHERE room_id = ?")) { - filter.setInt(1, roomId); - filter.execute(); - } - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - } else { - String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getRoomInfo().getName()).replace("%roomowner%", room.getRoomInfo().getOwnerInfo().getUsername()); - ScripterManager.scripterDetected(this.client, message); - log.info(message); } + + pet.removeFromRoom(); + Emulator.getThreading().run(pet); + + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); + + if (owner != null) { + owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); + owner.getInventory().getPetsComponent().addPet(pet); + } + } + + if (room.getRoomInfo().hasGuild()) { + Emulator.getGameEnvironment().getGuildManager().deleteGuild(room.getRoomInfo().getGuild()); + } + + room.preventUnloading = false; + + room.getRoomRightsManager().removeAllRights(); + room.getRoomWordFilterManager().removeAllWords(); + room.dispose(); + Emulator.getGameEnvironment().getRoomManager().uncacheRoom(room); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("DELETE FROM rooms WHERE id = ? LIMIT 1")) { + statement.setInt(1, roomId); + statement.execute(); + } + + if (room.getRoomInfo().isModelOverridden()) { + try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_models_custom WHERE id = ? LIMIT 1")) { + stmt.setInt(1, roomId); + stmt.execute(); + } + } + + try (PreparedStatement votes = connection.prepareStatement("DELETE FROM room_votes WHERE room_id = ?")) { + votes.setInt(1, roomId); + votes.execute(); + } + } catch (SQLException e) { + log.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java index ab11a546..657a96ad 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java @@ -26,13 +26,14 @@ public class CommandBotEvent extends MessageHandler { if (room == null) return; - if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { + if (room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); - if (bot == null) + if (bot == null) { return; + } int settingId = this.packet.readInt(); @@ -45,10 +46,11 @@ public class CommandBotEvent extends MessageHandler { Emulator.getPluginManager().fireEvent(lookEvent); if (lookEvent.isCancelled()) break; + bot.setFigure(lookEvent.getNewLook()); bot.setGender(lookEvent.getGender()); bot.setEffect(lookEvent.getEffect(), -1); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); } case 2 -> { String messageString = this.packet.readString(); @@ -102,16 +104,16 @@ public class CommandBotEvent extends MessageHandler { bot.setChatDelay((short) chatEvent.getChatDelay()); bot.clearChat(); bot.addChatLines(chat); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); } case 3 -> { bot.setCanWalk(!bot.canWalk()); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); } case 4 -> { bot.getRoomUnit().setDanceType(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) % DanceType.values().length]); room.sendComposer(new DanceMessageComposer(bot.getRoomUnit()).compose()); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); } case 5 -> { String name = this.packet.readString(); @@ -128,7 +130,7 @@ public class CommandBotEvent extends MessageHandler { break; bot.setName(nameEvent.getName()); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); room.sendComposer(new UserNameChangedMessageComposer(bot.getRoomUnit().getVirtualId(), bot.getRoomUnit().getVirtualId(), nameEvent.getName()).compose()); } } @@ -140,12 +142,12 @@ public class CommandBotEvent extends MessageHandler { String motto = this.packet.readString(); if (motto.length() > Emulator.getConfig().getInt("motto.max_length", 38)) break; bot.setMotto(motto); - bot.needsUpdate(true); + bot.setSqlUpdateNeeded(true); room.sendComposer(new RoomUsersComposer(bot).compose()); } } - if (bot.needsUpdate()) { + if (bot.isSqlUpdateNeeded()) { Emulator.getThreading().run(bot); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java index 9a351609..d55a372a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/RemoveBotFromFlatEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.incoming.rooms.bots; -import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; @@ -11,9 +11,18 @@ public class RemoveBotFromFlatEvent extends MessageHandler { public void handle() { Room room = this.client.getHabbo().getRoomUnit().getRoom(); - if (room == null) + if (room == null) { return; + } - Emulator.getGameEnvironment().getBotManager().pickUpBot(this.packet.readInt(), this.client.getHabbo(), room); + int botId = this.packet.readInt(); + + Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId)); + + if(bot == null) { + return; + } + + room.getRoomUnitManager().pickUpBot(bot, this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java index c491cb35..4a1be99d 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUsersComposer.java @@ -1,153 +1,36 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.guilds.Guild; -import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.units.type.Avatar; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import java.util.Collection; +import java.util.List; public class RoomUsersComposer extends MessageComposer { - private Habbo habbo; - private Collection habbos; - private Bot bot; - private Collection bots; + private final Collection avatars; - public RoomUsersComposer(Habbo habbo) { - this.habbo = habbo; + public RoomUsersComposer(Avatar avatar) { + this.avatars = List.of(avatar); } - public RoomUsersComposer(Collection habbos) { - this.habbos = habbos; - } - - public RoomUsersComposer(Bot bot) { - this.bot = bot; - } - - public RoomUsersComposer(Collection bots, boolean isBot) { - this.bots = bots; + public RoomUsersComposer(Collection avatars) { + this.avatars = avatars; } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.usersComposer); - if (this.habbo != null) { - this.response.appendInt(1); - this.response.appendInt(this.habbo.getHabboInfo().getId()); - this.response.appendString(this.habbo.getHabboInfo().getUsername()); - this.response.appendString(this.habbo.getHabboInfo().getMotto()); - this.response.appendString(this.habbo.getHabboInfo().getLook()); - this.response.appendInt(this.habbo.getRoomUnit().getVirtualId()); //Room Unit ID - this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getX()); - this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getY()); - this.response.appendString(this.habbo.getRoomUnit().getCurrentZ() + ""); - this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue()); - this.response.appendInt(1); - this.response.appendString(this.habbo.getHabboInfo().getGender().name().toUpperCase()); - this.response.appendInt(this.habbo.getHabboStats().getGuild() != 0 ? this.habbo.getHabboStats().getGuild() : -1); - this.response.appendInt(this.habbo.getHabboStats().getGuild() != 0 ? 1 : -1); - - String name = ""; - if (this.habbo.getHabboStats().getGuild() != 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(this.habbo.getHabboStats().getGuild()); - - if (g != null) - name = g.getName(); - } - this.response.appendString(name); - - this.response.appendString(""); - this.response.appendInt(this.habbo.getHabboStats().getAchievementScore()); - this.response.appendBoolean(true); - } else if (this.habbos != null) { - this.response.appendInt(this.habbos.size()); - for (Habbo habbo : this.habbos) { - if (habbo != null) { - this.response.appendInt(habbo.getHabboInfo().getId()); - this.response.appendString(habbo.getHabboInfo().getUsername()); - this.response.appendString(habbo.getHabboInfo().getMotto()); - this.response.appendString(habbo.getHabboInfo().getLook()); - this.response.appendInt(habbo.getRoomUnit().getVirtualId()); //Room Unit ID - this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getX()); - this.response.appendInt(habbo.getRoomUnit().getCurrentPosition().getY()); - this.response.appendString(habbo.getRoomUnit().getCurrentZ() + ""); - this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); - this.response.appendInt(1); - this.response.appendString(habbo.getHabboInfo().getGender().name().toUpperCase()); - this.response.appendInt(habbo.getHabboStats().getGuild() != 0 ? habbo.getHabboStats().getGuild() : -1); - this.response.appendInt(habbo.getHabboStats().getGuild() != 0 ? habbo.getHabboStats().getGuild() : -1); - String name = ""; - if (habbo.getHabboStats().getGuild() != 0) { - Guild g = Emulator.getGameEnvironment().getGuildManager().getGuild(habbo.getHabboStats().getGuild()); - - if (g != null) - name = g.getName(); - } - this.response.appendString(name); - this.response.appendString(""); - this.response.appendInt(habbo.getHabboStats().getAchievementScore()); - this.response.appendBoolean(true); + if (this.avatars != null) { + this.response.appendInt(this.avatars.size()); + for (Avatar avatar : this.avatars) { + if (avatar != null) { + avatar.serialize(this.response); } } - } else if (this.bot != null) { - this.response.appendInt(1); - this.response.appendInt(-this.bot.getId()); - this.response.appendString(this.bot.getName()); - this.response.appendString(this.bot.getMotto()); - this.response.appendString(this.bot.getFigure()); - this.response.appendInt(this.bot.getRoomUnit().getVirtualId()); - this.response.appendInt(this.bot.getRoomUnit().getCurrentPosition().getX()); - this.response.appendInt(this.bot.getRoomUnit().getCurrentPosition().getY()); - this.response.appendString(this.bot.getRoomUnit().getCurrentZ() + ""); - this.response.appendInt(this.bot.getRoomUnit().getBodyRotation().getValue()); - this.response.appendInt(4); - this.response.appendString(this.bot.getGender().name().toUpperCase()); - this.response.appendInt(this.bot.getOwnerId()); - this.response.appendString(this.bot.getOwnerName()); - this.response.appendInt(10); - this.response.appendShort(0); - this.response.appendShort(1); - this.response.appendShort(2); - this.response.appendShort(3); - this.response.appendShort(4); - this.response.appendShort(5); - this.response.appendShort(6); - this.response.appendShort(7); - this.response.appendShort(8); - this.response.appendShort(9); - } else if (this.bots != null) { - this.response.appendInt(this.bots.size()); - for (Bot bot : this.bots) { - this.response.appendInt(-bot.getId()); - this.response.appendString(bot.getName()); - this.response.appendString(bot.getMotto()); - this.response.appendString(bot.getFigure()); - this.response.appendInt(bot.getRoomUnit().getVirtualId()); - this.response.appendInt(bot.getRoomUnit().getCurrentPosition().getX()); - this.response.appendInt(bot.getRoomUnit().getCurrentPosition().getY()); - this.response.appendString(bot.getRoomUnit().getCurrentZ() + ""); - this.response.appendInt(bot.getRoomUnit().getBodyRotation().getValue()); - this.response.appendInt(4); - this.response.appendString(bot.getGender().name().toUpperCase()); - this.response.appendInt(bot.getOwnerId()); - this.response.appendString(bot.getOwnerName()); - this.response.appendInt(10); - this.response.appendShort(0); - this.response.appendShort(1); - this.response.appendShort(2); - this.response.appendShort(3); - this.response.appendShort(4); - this.response.appendShort(5); - this.response.appendShort(6); - this.response.appendShort(7); - this.response.appendShort(8); - this.response.appendShort(9); - } } + return this.response; } -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java index deab7c0f..b846b460 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserRemoveMessageComposer.java @@ -13,7 +13,7 @@ public class UserRemoveMessageComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.userRemoveMessageComposer); - this.response.appendString(this.roomUnit.getVirtualId() + ""); + this.response.appendString(String.valueOf(this.roomUnit.getVirtualId())); return this.response; } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 2ae7a6f2..4cf9b23c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -54,8 +54,8 @@ public class RoomUnitTeleport implements Runnable { this.roomUnit.setStatusUpdateNeeded(true); roomUnit.setWiredTeleporting(false); - this.room.updateHabbosAt(newLocation); - this.room.updateBotsAt(newLocation.getX(), newLocation.getY()); + this.room.getRoomUnitManager().updateHabbosAt(newLocation); + this.room.getRoomUnitManager().updateBotsAt(newLocation); topItem = room.getRoomItemManager().getTopItemAt(x, y); if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) { From 15061113f41c7b4b4de65dba3fc6f42e87150e95 Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 7 Aug 2023 12:43:38 -0500 Subject: [PATCH 40/42] Fixed Bot Walking and purchase --- .../com/eu/habbo/habbohotel/bots/Bot.java | 44 +++++++++---------- .../eu/habbo/habbohotel/bots/BotManager.java | 4 +- .../habbohotel/catalog/CatalogManager.java | 4 ++ .../eu/habbo/habbohotel/rooms/RoomLayout.java | 26 ++++++----- .../habbohotel/rooms/RoomUnitManager.java | 16 ++++--- .../entities/units/types/RoomAvatar.java | 4 ++ .../rooms/entities/units/types/RoomBot.java | 8 +++- .../incoming/rooms/bots/CommandBotEvent.java | 8 +--- 8 files changed, 65 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 26360efd..738e7883 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -54,9 +54,7 @@ public class Bot extends Avatar implements Runnable { private final int bubbleId; private final String type; private int effect; - private transient boolean canWalk; private boolean sqlUpdateNeeded; - private boolean xyzUpdateNeeded; private transient int followingHabboId; protected final RoomBot roomUnit; public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; @@ -82,13 +80,14 @@ public class Bot extends Avatar implements Runnable { this.chatLines = new ArrayList<>(Arrays.asList(set.getString("chat_lines").split("\r"))); this.type = set.getString("type"); this.effect = set.getInt("effect"); - this.canWalk = set.getString("freeroam").equals("1"); this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.sqlUpdateNeeded = false; this.bubbleId = set.getInt("bubble_id"); this.roomUnit = new RoomBot(); this.roomUnit.setUnit(this); + + this.roomUnit.setCanWalk(set.getString("freeroam").equals("1")); } public static void initialise() {} @@ -97,8 +96,8 @@ public class Bot extends Avatar implements Runnable { @Override public void run() { - if (this.sqlUpdateNeeded) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, owner_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { + if (this.sqlUpdateNeeded) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, owner_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ?, x = ?, y = ?, z = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.motto); statement.setString(3, this.figure); @@ -107,7 +106,7 @@ public class Bot extends Avatar implements Runnable { statement.setInt(6, this.roomUnit.getRoom() == null ? 0 : this.roomUnit.getRoom().getRoomInfo().getId()); statement.setInt(7, this.roomUnit.getBodyRotation().getValue()); statement.setInt(8, this.roomUnit.getDanceType().getType()); - statement.setString(9, this.canWalk ? "1" : "0"); + statement.setString(9, this.roomUnit.isCanWalk() ? "1" : "0"); StringBuilder text = new StringBuilder(); for (String s : this.chatLines) { text.append(s).append("\r"); @@ -118,7 +117,10 @@ public class Bot extends Avatar implements Runnable { statement.setInt(13, this.chatDelay); statement.setInt(14, this.effect); statement.setInt(15, this.bubbleId); - statement.setInt(16, this.id); + statement.setInt(16, this.roomUnit.getSpawnTile() == null ? 0 : this.roomUnit.getSpawnTile().getX()); + statement.setInt(17, this.roomUnit.getSpawnTile() == null ? 0 : this.roomUnit.getSpawnTile().getY()); + statement.setDouble(18, this.roomUnit.getSpawnHeight()); + statement.setInt(19, this.id); statement.execute(); this.sqlUpdateNeeded = false; } catch (SQLException e) { @@ -213,13 +215,19 @@ public class Bot extends Avatar implements Runnable { public void setOwnerId(int ownerId) { this.ownerId = ownerId; this.sqlUpdateNeeded = true; - this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); + + if(this.roomUnit.getRoom() != null) { + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); + } } public void setOwnerName(String ownerName) { this.ownerName = ownerName; this.sqlUpdateNeeded = true; - this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); + + if(this.roomUnit.getRoom() != null) { + this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose()); + } } public void setChatAuto(boolean chatAuto) { @@ -253,10 +261,8 @@ public class Bot extends Avatar implements Runnable { this.effect = effect; this.sqlUpdateNeeded = true; - if (this.roomUnit != null) { - if (this.roomUnit.getRoom() != null) { - this.roomUnit.giveEffect(this.effect, duration); - } + if (this.roomUnit.getRoom() != null) { + this.roomUnit.giveEffect(this.effect, duration); } } @@ -274,14 +280,6 @@ public class Bot extends Avatar implements Runnable { } } - public boolean canWalk() { - return this.canWalk; - } - - public void setCanWalk(boolean canWalk) { - this.canWalk = canWalk; - } - public void incrementLastChatIndex() { this.lastChatIndex++; } @@ -297,8 +295,8 @@ public class Bot extends Avatar implements Runnable { message.appendString(this.motto); message.appendString(this.figure); message.appendInt(this.roomUnit.getVirtualId()); - message.appendInt(this.roomUnit.getCurrentPosition().getX()); - message.appendInt(this.roomUnit.getCurrentPosition().getY()); + message.appendInt(this.roomUnit.getCurrentPosition() == null ? 0 : this.roomUnit.getCurrentPosition().getX()); + message.appendInt(this.roomUnit.getCurrentPosition() == null ? 0 : this.roomUnit.getCurrentPosition().getY()); message.appendString(String.valueOf(this.roomUnit.getCurrentZ())); message.appendInt(this.roomUnit.getBodyRotation().getValue()); message.appendInt(4); diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index a06492db..f14b26f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -61,7 +61,7 @@ public class BotManager { public Bot createBot(THashMap data, String type) { Bot bot = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setString(1, data.get("name")); statement.setString(2, data.get("motto")); statement.setString(3, data.get("figure")); @@ -70,7 +70,7 @@ public class BotManager { statement.execute(); try (ResultSet set = statement.getGeneratedKeys()) { if (set.next()) { - try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.user_id = users.id WHERE bots.id = ? LIMIT 1")) { + try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.owner_id = users.id WHERE bots.id = ? LIMIT 1")) { stmt.setInt(1, set.getInt(1)); try (ResultSet resultSet = stmt.executeQuery()) { if (resultSet.next()) { diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 6885f3c1..b932d6a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -900,8 +900,12 @@ public class CatalogManager { Bot bot = Emulator.getGameEnvironment().getBotManager().createBot(data, type); if (bot != null) { + //TODO @Deprecated bot.setOwnerId(habbo.getClient().getHabbo().getHabboInfo().getId()); bot.setOwnerName(habbo.getClient().getHabbo().getHabboInfo().getUsername()); + + bot.setOwnerInfo(habbo.getHabboInfo()); + bot.setSqlUpdateNeeded(true); Emulator.getThreading().run(bot); habbo.getClient().getHabbo().getInventory().getBotsComponent().addBot(bot); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index f7ccff0a..85cd6f1a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; @@ -560,27 +560,33 @@ public class RoomLayout { return availableTiles; } - public RoomTile getRandomWalkableTilesAround(RoomUnit roomUnit, RoomTile tile, Room room, int radius) { - if(!this.tileExists(tile.getX(), tile.getY())) { - tile = this.getTile(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); - Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId()); - bot.setSqlUpdateNeeded(true); + public RoomTile getRandomWalkableTilesAround(RoomBot roomBot, RoomTile tile, int radius) { + if(tile == null || !this.tileExists(tile.getX(), tile.getY()) || tile.getState().equals(RoomTileState.INVALID)) { + roomBot.setCanWalk(false); + return null; } List newTiles = new ArrayList<>(); int minX = Math.max(0, tile.getX() - radius); int minY = Math.max(0, tile.getY() - radius); - int maxX = Math.min(room.getLayout().getMapSizeX(), tile.getX() + radius); - int maxY = Math.min(room.getLayout().getMapSizeY(), tile.getY() + radius); + int maxX = Math.min(this.room.getLayout().getMapSizeX(), tile.getX() + radius); + int maxY = Math.min(this.room.getLayout().getMapSizeY(), tile.getY() + radius); for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { - RoomTile tile2 = room.getLayout().getTile((short) x, (short) y); - if (tile2 != null && tile.getState() != RoomTileState.BLOCKED && tile.getState() != RoomTileState.INVALID) + RoomTile tile2 = this.room.getLayout().getTile((short) x, (short) y); + if (tile2 != null && tile2.getState() != RoomTileState.BLOCKED && tile2.getState() != RoomTileState.INVALID) { newTiles.add(tile2); + } } } + + if(newTiles.isEmpty()) { + log.debug("No Random tiles found."); + return null; + } + Collections.shuffle(newTiles); return newTiles.get(0); } 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 589fa924..d3c2d7c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -77,21 +77,24 @@ public class RoomUnitManager { try (ResultSet set = statement.executeQuery()) { while (set.next()) { Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set); - //TODO IMPROVE THIS + if (bot != null) { bot.getRoomUnit().setRoom(this.room); RoomTile spawnTile = this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")); if(spawnTile == null) { - bot.getRoomUnit().setCurrentPosition(this.room.getLayout().getDoorTile()); - bot.getRoomUnit().setCurrentZ(this.room.getLayout().getDoorTile().getStackHeight()); - bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection())); + bot.getRoomUnit().setCanWalk(false); } else { + if(spawnTile.getState().equals(RoomTileState.INVALID)) { + bot.getRoomUnit().setCanWalk(false); + } bot.getRoomUnit().setCurrentPosition(spawnTile); bot.getRoomUnit().setCurrentZ(set.getDouble("z")); bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]); + bot.getRoomUnit().setSpawnTile(spawnTile); + bot.getRoomUnit().setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight()); } bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); @@ -300,9 +303,10 @@ public class RoomUnitManager { roomBot.setRoom(this.room); roomBot.setCurrentPosition(spawnTile); - roomBot.setCurrentZ(spawnTile.getZ()); + roomBot.setCurrentZ(spawnTile.getStackHeight()); roomBot.setRotation(RoomRotation.SOUTH); - roomBot.setCanWalk(this.room.isAllowBotsWalk()); + roomBot.setSpawnTile(spawnTile); + roomBot.setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight()); bot.setSqlUpdateNeeded(true); Emulator.getThreading().run(bot); 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 0e978c4b..5b19e1db 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 @@ -58,6 +58,10 @@ public abstract class RoomAvatar extends RoomUnit { @Override public boolean walkTo(RoomTile goalLocation) { + if(goalLocation == null) { + return false; + } + if (this.hasStatus(RoomUnitStatus.LAY)) { if (this.room.getLayout().getTilesInFront(this.getCurrentPosition(), this.getBodyRotation().getValue(), 2).contains(goalLocation)) return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java index b522a776..9368064c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomBot.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -24,16 +25,19 @@ import lombok.extern.slf4j.Slf4j; public class RoomBot extends RoomAvatar { private Bot unit; + private RoomTile spawnTile; + private double spawnHeight; + public RoomBot() { super(); } @Override public void cycle() { - if(this.room.isAllowBotsWalk() && this.unit.canWalk()) { + if (this.room.isAllowBotsWalk() && this.isCanWalk()) { if (!this.isWalking()) { if (this.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.unit.getFollowingHabboId() == 0) { - this.walkTo(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.currentPosition, this.getRoom(), Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile()); + this.walkTo(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.getRoom().getLayout().getRandomWalkableTilesAround(this, this.currentPosition, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.getRoom().getRandomWalkableTile()); int timeOut = Emulator.getRandom().nextInt(20) * 2; this.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java index 657a96ad..08befe11 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/CommandBotEvent.java @@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; -import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserNameChangedMessageComposer; import com.eu.habbo.plugin.events.bots.BotSavedChatEvent; @@ -50,7 +49,6 @@ public class CommandBotEvent extends MessageHandler { bot.setFigure(lookEvent.getNewLook()); bot.setGender(lookEvent.getGender()); bot.setEffect(lookEvent.getEffect(), -1); - bot.setSqlUpdateNeeded(true); } case 2 -> { String messageString = this.packet.readString(); @@ -107,12 +105,11 @@ public class CommandBotEvent extends MessageHandler { bot.setSqlUpdateNeeded(true); } case 3 -> { - bot.setCanWalk(!bot.canWalk()); + bot.getRoomUnit().setCanWalk(!bot.getRoomUnit().isCanWalk()); bot.setSqlUpdateNeeded(true); } case 4 -> { - bot.getRoomUnit().setDanceType(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) % DanceType.values().length]); - room.sendComposer(new DanceMessageComposer(bot.getRoomUnit()).compose()); + bot.getRoomUnit().setDance(DanceType.values()[(bot.getRoomUnit().getDanceType().getType() + 1) % DanceType.values().length]); bot.setSqlUpdateNeeded(true); } case 5 -> { @@ -142,7 +139,6 @@ public class CommandBotEvent extends MessageHandler { String motto = this.packet.readString(); if (motto.length() > Emulator.getConfig().getInt("motto.max_length", 38)) break; bot.setMotto(motto); - bot.setSqlUpdateNeeded(true); room.sendComposer(new RoomUsersComposer(bot).compose()); } } From 59290bae8dc21848464fce2d177827c7dfb494fe Mon Sep 17 00:00:00 2001 From: Stankman Date: Mon, 7 Aug 2023 14:40:56 -0500 Subject: [PATCH 41/42] Fixed Picked Up floor items --- .../habbohotel/rooms/RoomItemManager.java | 186 ++++++++++-------- .../habbo/habbohotel/rooms/RoomManager.java | 1 + 2 files changed, 100 insertions(+), 87 deletions(-) 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 71c1610d..ae0631ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -137,83 +137,89 @@ public class RoomItemManager { } } - public void removeRoomItem(RoomItem item) { - if (item != null) { + public void removeRoomItem(RoomItem roomItem) { + if (roomItem != null) { - RoomItem i; + RoomItem removedItem; synchronized (this.currentItems) { - i = this.currentItems.remove(item.getId()); + removedItem = this.currentItems.remove(roomItem.getId()); } - if (i != null) { - if (item instanceof ICycleable) { - this.removeCycleTask((ICycleable) item); + if(removedItem.getBaseItem().getType().equals(FurnitureType.FLOOR)) { + this.floorItems.remove(removedItem.getId()); + } else if (removedItem.getBaseItem().getType().equals(FurnitureType.WALL)) { + this.wallItems.remove(removedItem.getId()); + } + + if (removedItem != null) { + if (roomItem instanceof ICycleable) { + this.removeCycleTask((ICycleable) roomItem); } - if (item instanceof InteractionWired wired) { + if (roomItem 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); + } else if (roomItem instanceof InteractionBattleBanzaiTeleporter) { + this.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) roomItem); + } else if (roomItem instanceof InteractionRoller) { + this.removeRoller((InteractionRoller) roomItem); + } else if (roomItem instanceof InteractionGameScoreboard) { + this.removeScoreboard((InteractionGameScoreboard) roomItem); + } else if (roomItem instanceof InteractionGameGate) { + this.removeGameGate((InteractionGameGate) roomItem); + } else if (roomItem instanceof InteractionGameTimer) { + this.removeGameTimer((InteractionGameTimer) roomItem); + } else if (roomItem instanceof InteractionFreezeExitTile) { + this.removeFreezeExitTile((InteractionFreezeExitTile) roomItem); + } else if (roomItem instanceof InteractionNest) { + this.removeNest((InteractionNest) roomItem); + } else if (roomItem instanceof InteractionPetDrink) { + this.removePetDrink((InteractionPetDrink) roomItem); + } else if (roomItem instanceof InteractionPetFood) { + this.removePetFood((InteractionPetFood) roomItem); + } else if (roomItem instanceof InteractionPetToy) { + this.removePetToy((InteractionPetToy) roomItem); + } else if (roomItem instanceof InteractionPetTree) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionPetTrampoline) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionMoodLight) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionPyramid) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionMusicDisc) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionBattleBanzaiSphere) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionTalkingFurniture) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionWaterItem) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionWater) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionMuteArea) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionTagPole) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionTagField) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionJukeBox) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionPetBreedingNest) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionBlackHole) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionWiredHighscore) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionStickyPole) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof WiredBlob) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionTent) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionSnowboardSlope) { + this.removeUndefined(roomItem); + } else if (roomItem instanceof InteractionBuildArea) { + this.removeUndefined(roomItem); } } } @@ -533,30 +539,31 @@ public class RoomItemManager { return FurnitureMovementError.NONE; } - public void pickUpItem(RoomItem item, Habbo picker) { - if (item == null) + public void pickUpItem(RoomItem roomItem, Habbo picker) { + if (roomItem == null) { return; + } if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) { - Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker); + Event furniturePickedUpEvent = new FurniturePickedUpEvent(roomItem, picker); Emulator.getPluginManager().fireEvent(furniturePickedUpEvent); if (furniturePickedUpEvent.isCancelled()) return; } - this.removeRoomItem(item); - item.onPickUp(this.room); + this.removeRoomItem(roomItem); + roomItem.onPickUp(this.room); //Deprecated - item.setRoomId(0); - item.setRoom(null); - item.needsUpdate(true); + roomItem.setRoomId(0); + roomItem.setRoom(null); + roomItem.needsUpdate(true); - if (item.getBaseItem().getType() == FurnitureType.FLOOR) { - this.room.sendComposer(new RemoveFloorItemComposer(item).compose()); + if (roomItem.getBaseItem().getType() == FurnitureType.FLOOR) { + this.room.sendComposer(new RemoveFloorItemComposer(roomItem).compose()); THashSet updatedTiles = new THashSet<>(); - Rectangle rectangle = RoomLayout.getRectangle(item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); + Rectangle rectangle = RoomLayout.getRectangle(roomItem.getCurrentPosition().getX(), roomItem.getCurrentPosition().getY(), roomItem.getBaseItem().getWidth(), roomItem.getBaseItem().getLength(), roomItem.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++) { @@ -569,24 +576,26 @@ public class RoomItemManager { } } } + this.room.sendComposer(new HeightMapUpdateMessageComposer(this.room, updatedTiles).compose()); this.room.updateTiles(updatedTiles); + updatedTiles.forEach(tile -> { this.room.getRoomUnitManager().updateHabbosAt(tile); this.room.getRoomUnitManager().updateBotsAt(tile); }); - } else if (item.getBaseItem().getType() == FurnitureType.WALL) { - this.room.sendComposer(new ItemRemoveMessageComposer(item).compose()); + } else if (roomItem.getBaseItem().getType() == FurnitureType.WALL) { + this.room.sendComposer(new ItemRemoveMessageComposer(roomItem).compose()); } Habbo habbo; - habbo = picker != null && picker.getHabboInfo().getId() == item.getId() ? (picker) : (Emulator.getGameServer().getGameClientManager().getHabbo(item.getOwnerInfo().getId())); + habbo = picker != null && picker.getHabboInfo().getId() == roomItem.getId() ? (picker) : (Emulator.getGameServer().getGameClientManager().getHabbo(roomItem.getOwnerInfo().getId())); if (habbo != null) { - habbo.getInventory().getItemsComponent().addItem(item); - habbo.getClient().sendResponse(new UnseenItemsComposer(item)); + habbo.getInventory().getItemsComponent().addItem(roomItem); + habbo.getClient().sendResponse(new UnseenItemsComposer(roomItem)); habbo.getClient().sendResponse(new FurniListInvalidateComposer()); } - Emulator.getThreading().run(item); + Emulator.getThreading().run(roomItem); } public void ejectUserItem(RoomItem item) { @@ -1098,6 +1107,9 @@ public class RoomItemManager { this.currentItems.remove(roomItem.getId()); }); + this.floorItems.clear(); + this.wallItems.clear(); + this.currentItems.clear(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 8f2a4395..e5b12499 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -594,6 +594,7 @@ public class RoomManager { habbo.getClient().sendResponse(new OpenConnectionMessageComposer()); + //@Deprecated roomHabbo.setInRoom(true); if (!habbo.getHabboStats().isBlockFollowing() && roomHabbo.getRoom() == null) { From 6dcb02d6f034d3cc723d1f1a1d9878f1af9fd8a2 Mon Sep 17 00:00:00 2001 From: Stankman Date: Tue, 8 Aug 2023 17:55:54 -0500 Subject: [PATCH 42/42] Horse Riding fixed --- .../com/eu/habbo/habbohotel/bots/Bot.java | 4 +- .../habbohotel/catalog/CatalogManager.java | 4 +- .../catalog/layouts/RoomBundleLayout.java | 2 +- .../catalog/marketplace/MarketPlace.java | 4 +- .../commands/list/InvisibleCommand.java | 3 +- .../InteractionBackgroundToner.java | 4 +- .../interactions/InteractionColorPlate.java | 2 +- .../interactions/InteractionCrackable.java | 2 +- .../interactions/InteractionDefault.java | 2 +- .../interactions/InteractionFireworks.java | 2 +- .../items/interactions/InteractionGate.java | 2 +- .../interactions/InteractionLoveLock.java | 2 +- .../interactions/InteractionMannequin.java | 2 +- .../interactions/InteractionMoodLight.java | 2 +- .../interactions/InteractionMultiHeight.java | 4 +- .../interactions/InteractionOneWayGate.java | 2 +- .../interactions/InteractionPuzzleBox.java | 4 +- .../InteractionRentableSpace.java | 4 +- .../InteractionSwitchRemoteControl.java | 2 +- .../interactions/InteractionTeleport.java | 5 - .../interactions/InteractionVoteCounter.java | 4 +- .../items/interactions/InteractionWater.java | 2 +- .../interactions/InteractionWaterItem.java | 4 +- .../items/interactions/InteractionWired.java | 2 +- .../games/InteractionGameTimer.java | 8 +- .../football/InteractionFootballGate.java | 4 +- .../InteractionFootballScoreboard.java | 4 +- .../pets/InteractionMonsterPlantSeed.java | 4 +- .../pets/InteractionPetBreedingNest.java | 2 +- .../pets/InteractionPetDrink.java | 2 +- .../totems/InteractionTotemHead.java | 2 +- .../eu/habbo/habbohotel/pets/GnomePet.java | 2 +- .../eu/habbo/habbohotel/pets/HorsePet.java | 2 +- .../habbohotel/pets/MonsterplantPet.java | 4 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 165 +++++------------- .../eu/habbo/habbohotel/pets/PetManager.java | 17 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 1 + .../habbohotel/rooms/RoomItemManager.java | 10 +- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 9 +- .../habbo/habbohotel/rooms/RoomManager.java | 3 - .../eu/habbo/habbohotel/rooms/RoomTile.java | 9 + .../habbohotel/rooms/RoomTraxManager.java | 6 +- .../habbohotel/rooms/RoomUnitManager.java | 46 +++-- .../rooms/entities/items/RoomItem.java | 23 --- .../rooms/entities/units/RoomUnit.java | 23 ++- .../rooms/entities/units/types/RoomPet.java | 40 +++-- .../users/inventory/ItemsComponent.java | 3 +- .../users/inventory/PetsComponent.java | 2 +- .../incoming/camera/PurchasePhotoEvent.java | 2 +- .../PurchaseFromCatalogAsGiftEvent.java | 4 +- .../incoming/hotelview/QuitEvent.java | 1 - .../rooms/RequestRoomPropertySet.java | 2 +- .../SetRoomBackgroundColorDataEvent.java | 2 +- .../rooms/items/AddSpamWallPostItEvent.java | 2 +- .../incoming/rooms/items/DiceOffEvent.java | 2 +- .../rooms/items/MoveWallItemEvent.java | 2 +- .../rooms/items/PlacePostItEvent.java | 2 +- .../items/RoomDimmerChangeStateEvent.java | 2 +- .../items/RoomDimmerSavePresetEvent.java | 2 +- .../items/SetCustomStackingHeightEvent.java | 2 +- .../rooms/items/SetItemDataEvent.java | 2 +- .../rooms/items/SetMannequinFigureEvent.java | 2 +- .../rooms/items/SetMannequinNameEvent.java | 2 +- .../rooms/items/SetObjectDataEvent.java | 2 +- .../rooms/items/UseWallItemEvent.java | 2 +- .../SetYoutubeDisplayPlaylistEvent.java | 2 +- .../pets/CustomizePetWithFurniEvent.java | 10 +- .../incoming/rooms/pets/MountPetEvent.java | 4 - .../incoming/rooms/pets/MovePetEvent.java | 2 +- .../rooms/pets/OpenPetPackageEvent.java | 2 +- .../incoming/rooms/pets/PlacePetEvent.java | 18 +- .../rooms/pets/RemoveSaddleFromPetEvent.java | 2 +- .../pets/TogglePetRidingPermissionEvent.java | 2 +- .../incoming/wired/UpdateActionEvent.java | 2 +- .../incoming/wired/UpdateConditionEvent.java | 2 +- .../incoming/wired/UpdateTriggerEvent.java | 2 +- .../items/FloorItemOnRollerComposer.java | 2 +- .../wired/WiredConditionDataComposer.java | 2 +- .../wired/WiredEffectDataComposer.java | 2 +- .../wired/WiredTriggerDataComposer.java | 2 +- .../threading/runnables/ClearRentedSpace.java | 2 +- .../habbo/threading/runnables/CloseGate.java | 2 +- .../threading/runnables/CrackableExplode.java | 2 +- .../habbo/threading/runnables/OpenGift.java | 2 +- .../threading/runnables/RandomDiceNumber.java | 2 +- .../runnables/RandomSpinningBottleNumber.java | 2 +- .../threading/runnables/RoomUnitRidePet.java | 21 ++- 87 files changed, 253 insertions(+), 332 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 738e7883..c888aacb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -30,6 +30,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + @Slf4j @Getter @Setter @@ -124,7 +126,7 @@ public class Bot extends Avatar implements Runnable { statement.execute(); this.sqlUpdateNeeded = false; } catch (SQLException e) { - log.error("Caught SQL exception", e); + log.error(CAUGHT_SQL_EXCEPTION, e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index b932d6a5..ba31a4f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1010,7 +1010,7 @@ public class CatalogManager { if (guild != null && Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo) != null) { InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata); habboItem.setExtraData(""); - habboItem.needsUpdate(true); + habboItem.setSqlUpdateNeeded(true); Emulator.getThreading().run(habboItem); Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId); @@ -1031,7 +1031,7 @@ public class CatalogManager { } InteractionMusicDisc habboItem = (InteractionMusicDisc) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, habbo.getClient().getHabbo().getHabboInfo().getUsername() + "\n" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "\n" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "\n" + Calendar.getInstance().get(Calendar.YEAR) + "\n" + track.getLength() + "\n" + track.getName() + "\n" + track.getId()); - habboItem.needsUpdate(true); + habboItem.setSqlUpdateNeeded(true); Emulator.getThreading().run(habboItem); itemsList.add(habboItem); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index f86d8612..289e3940 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -189,7 +189,7 @@ public class RoomBundleLayout extends SingleBundle { } if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { synchronized (this.room.getRoomUnitManager().getCurrentBots()) { statement.setInt(1, userId); statement.setInt(2, roomId); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index ce152637..80668dee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -282,7 +282,7 @@ public class MarketPlace { event.price = calculateCommision(event.price); item.setOwnerInfo(client.getHabbo().getHabboInfo()); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); client.getHabbo().getInventory().getItemsComponent().addItem(item); @@ -363,7 +363,7 @@ public class MarketPlace { client.getHabbo().getInventory().addMarketplaceOffer(offer); client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.getItem()); item.setOwnerInfo(null); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java index 3d58cd98..4e02621b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java @@ -25,8 +25,7 @@ public class InvisibleCommand extends Command { new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().getX(), roomLayout.getDoorTile().getY(), roomLayout.getDoorTile().getZ(), 0).run(); - roomUnit.setInvisible(false) - .setInRoom(true); + roomUnit.setInvisible(false); roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose()); roomUnit.getRoom().sendComposer(new UserUpdateComposer(roomUnit).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java index 3c04a3e6..9239c6a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java @@ -39,7 +39,7 @@ public class InteractionBackgroundToner extends RoomItem { serverMessage.appendInt(126); serverMessage.appendInt(126); this.setExtraData("0:126:126:126"); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); } @@ -86,7 +86,7 @@ public class InteractionBackgroundToner extends RoomItem { this.setExtraData("0:126:126:126"); room.updateItem(this); } - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index 43d2ca82..c01803cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -57,7 +57,7 @@ public class InteractionColorPlate extends InteractionDefault { } this.setExtraData(state + ""); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index fcfc9515..7ebe0137 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -107,7 +107,7 @@ public class InteractionCrackable extends RoomItem { } this.ticks++; this.setExtraData("" + (this.ticks)); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); if (!rewardData.getAchievementTick().isEmpty()) { 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 a198504d..c3fcd2a5 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 @@ -88,7 +88,7 @@ public class InteractionDefault extends RoomItem { } this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount()); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index 50a3bff1..b4763a98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -135,7 +135,7 @@ public class InteractionFireworks extends InteractionDefault { Emulator.getThreading().run(() -> { this.setExtraData(STATE_CHARGED); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); }, explodeDuration); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index ec9eee39..abb1fabf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -55,7 +55,7 @@ public class InteractionGate extends RoomItem { this.setExtraData((Integer.parseInt(this.getExtraData()) + 1) % 2 + ""); room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java index 630fad81..a0db0e72 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java @@ -111,7 +111,7 @@ public class InteractionLoveLock extends RoomItem { data += Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR); this.setExtraData(data); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); room.updateItem(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java index 6d9d71db..af830c07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java @@ -49,7 +49,7 @@ public class InteractionMannequin extends RoomItem { serverMessage.appendString("OUTFIT_NAME"); serverMessage.appendString("My Look"); this.setExtraData("m: :My look"); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); } super.serializeExtradata(serverMessage); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java index 42474010..7c16ea07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java @@ -51,7 +51,7 @@ public class InteractionMoodLight extends RoomItem { for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) { if (data.isEnabled()) { this.setExtraData(data.toString()); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); Emulator.getThreading().run(this); } 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 5b19d9bd..5b9ee060 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 @@ -62,7 +62,7 @@ public class InteractionMultiHeight extends RoomItem { return; } - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); if (this.getExtraData().length() == 0) { this.setExtraData("0"); @@ -70,7 +70,7 @@ public class InteractionMultiHeight extends RoomItem { if (this.getBaseItem().getMultiHeights().length > 0) { this.setExtraData(String.valueOf((Integer.parseInt(this.getExtraData()) + 1) % (this.getBaseItem().getMultiHeights().length))); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java index 9d8185a5..084affc3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java @@ -51,7 +51,7 @@ public class InteractionOneWayGate extends RoomItem { public void serializeExtradata(ServerMessage serverMessage) { if (this.getExtraData().length() == 0) { this.setExtraData("0"); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } serverMessage.appendInt((this.isLimited() ? 256 : 0)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index aafe8fa3..1087cbbd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -71,7 +71,7 @@ public class InteractionPuzzleBox extends RoomItem { return; this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false)); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); @@ -81,7 +81,7 @@ public class InteractionPuzzleBox extends RoomItem { room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().walkTo(boxLocation)); }); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } @Override 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 ca66792d..99af029c 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 @@ -145,7 +145,7 @@ public class InteractionRentableSpace extends RoomItem { habbo.getHabboStats().setRentedItemId(this.getId()); habbo.getHabboStats().setRentedTimeEnd(this.endTimestamp); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); this.run(); } @@ -192,7 +192,7 @@ public class InteractionRentableSpace extends RoomItem { this.setRenterId(0); this.setRenterName(""); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); this.run(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java index c5da00e3..3a013ce7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java @@ -54,7 +54,7 @@ public class InteractionSwitchRemoteControl extends InteractionDefault { } this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount()); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 78671ede..b4313254 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -232,9 +232,4 @@ public class InteractionTeleport extends RoomItem { public boolean isUsable() { return true; } - - @Override - public boolean invalidatesToRoomKick() { - return true; - } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java index 6f4cfee2..71fa2071 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -80,7 +80,7 @@ public class InteractionVoteCounter extends RoomItem { } updateExtradata(); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); } @@ -100,7 +100,7 @@ public class InteractionVoteCounter extends RoomItem { votes += vote; updateExtradata(); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); } } 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 a91eb450..eb779f16 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 @@ -284,7 +284,7 @@ public class InteractionWater extends InteractionDefault { if (!this.getExtraData().equals(updatedData)) { this.setExtraData(updatedData); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java index 0be5c28b..95c6c138 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java @@ -32,7 +32,7 @@ public class InteractionWaterItem extends InteractionMultiHeight { public void onPickUp(Room room) { super.onPickUp(room); this.setExtraData("0"); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } @Override @@ -82,7 +82,7 @@ public class InteractionWaterItem extends InteractionMultiHeight { if (!this.getExtraData().equals(updatedData)) { this.setExtraData(updatedData); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 176fc794..c0680ef6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -141,7 +141,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi */ @Override public void run() { - if (this.needsUpdate()) { + if (this.isSqlUpdateNeeded()) { //TODO HERE IS WHERE WIRED_SAVE_EXCEPTION WILL BE THROWN //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers this.loadDefaultIntegerParams(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index c9bd0cad..a822f2ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -155,7 +155,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { @Override public void run() { - if (this.needsUpdate() || this.needsDelete()) { + if (this.isSqlUpdateNeeded() || this.isSqlDeleteNeeded()) { super.run(); } } @@ -165,7 +165,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { this.endGame(room); this.setExtraData(this.baseTime + "\t" + this.baseTime); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } @Override @@ -178,7 +178,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { this.setExtraData(this.timeNow + "\t" + this.baseTime); room.updateItem(this); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); super.onPlace(room); } @@ -318,7 +318,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable { this.timeNow = this.baseTime; room.updateItem(this); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } @Override 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 cbe737e2..c1b6bf32 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 @@ -78,7 +78,7 @@ public class InteractionFootballGate extends RoomItem { this.figureM = look; this.setExtraData(this.figureM + ";" + this.figureF); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); } @@ -86,7 +86,7 @@ public class InteractionFootballGate extends RoomItem { this.figureF = look; this.setExtraData(this.figureM + ";" + this.figureF); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Emulator.getThreading().run(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java index 2305665a..16338413 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java @@ -60,7 +60,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { } this.setExtraData(this.score + ""); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { @@ -86,7 +86,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard { } this.setExtraData(this.score + ""); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId()); if (room != null) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java index f4349444..40d0f0b0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java @@ -18,7 +18,7 @@ public class InteractionMonsterPlantSeed extends RoomItem { if (this.getExtraData().isEmpty()) { this.setExtraData("" + randomRarityLevel()); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } } @@ -27,7 +27,7 @@ public class InteractionMonsterPlantSeed extends RoomItem { if (this.getExtraData().isEmpty()) { this.setExtraData("" + randomRarityLevel()); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index f2e18be4..68d56385 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -153,7 +153,7 @@ public class InteractionPetBreedingNest extends RoomItem { habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ()); - offspring.setNeedsUpdate(true); + offspring.setSqlUpdateNeeded(true); offspring.run(); InteractionPetBreedingNest.this.freePets(); habbo.getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(box); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index ae9951db..88cbd152 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -123,7 +123,7 @@ public class InteractionPetDrink extends InteractionDefault { } this.setExtraData(state + ""); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index 938a940f..19cadf05 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -70,7 +70,7 @@ public class InteractionTotemHead extends InteractionDefault { public void updateTotemState(Room room, RoomTile tile) { this.setExtraData(getTotemType().getType() - 1 + ""); update(room, tile); - this.needsUpdate(true); + this.setSqlUpdateNeeded(true); room.updateItem(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java index d4ac7222..67b628d7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -41,7 +41,7 @@ public class GnomePet extends Pet implements IPetLook { @Override public void run() { - if (this.isNeedsUpdate()) { + if (this.isSqlUpdateNeeded()) { super.run(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET gnome_data = ? WHERE id = ? LIMIT 1")) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java index c63b742c..3f814c26 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -36,7 +36,7 @@ public class HorsePet extends RideablePet { @Override public void run() { - if (this.isNeedsUpdate()) { + if (this.isSqlUpdateNeeded()) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) { statement.setInt(1, this.hairStyle); statement.setInt(2, this.hairColor); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index 74079858..141887b0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -119,7 +119,7 @@ public class MonsterplantPet extends Pet implements IPetLook { @Override public void run() { - if (this.isNeedsUpdate()) { + if (this.isSqlUpdateNeeded()) { super.run(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ?, mp_is_dead = ? WHERE id = ?")) { @@ -153,7 +153,7 @@ public class MonsterplantPet extends Pet implements IPetLook { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath")); this.hasDied = true; - this.setNeedsUpdate(true); + this.setSqlUpdateNeeded(true); } this.getRoomUnit().clearStatuses(); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 1132de60..1d728066 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -19,9 +19,13 @@ import com.eu.habbo.plugin.events.pets.PetTalkEvent; import gnu.trove.map.hash.THashMap; import lombok.Getter; import lombok.Setter; +import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.Calendar; import java.util.Map; import java.util.TimeZone; @@ -29,108 +33,39 @@ import java.util.TimeZone; import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; @Slf4j +@Getter +@Setter +@Accessors(chain = true) public class Pet extends Unit implements ISerialize, Runnable { - - @Getter - @Setter - public int levelThirst; - @Getter - @Setter - public int levelHunger; - - @Setter - @Getter - private boolean needsUpdate = false; - - @Setter - @Getter - private boolean packetUpdate = false; - @Getter - protected int id; - @Getter - @Setter + protected final int id; protected int userId; - @Getter - @Setter protected Room room; - @Getter - @Setter protected String name; - @Setter - @Getter protected PetData petData; - @Setter - @Getter protected int race; - @Getter - @Setter protected String color; - @Getter - @Setter protected int happiness; - @Getter - @Setter protected int experience; - @Setter - @Getter protected int energy; - - /** - * The respect points of the pet. - */ protected int respect; - @Getter - @Setter protected int created; - @Getter - @Setter protected int level; - - /** - * The chat timeout of the pet. - */ private int chatTimeout; - - /** - * The tick timeout of the pet. - */ private int tickTimeout = Emulator.getIntUnixTimestamp(); private int happinessDelay = Emulator.getIntUnixTimestamp(); private int gestureTickTimeout = Emulator.getIntUnixTimestamp(); - - /** - * The random action tick timeout of the pet. - */ private int randomActionTickTimeout = Emulator.getIntUnixTimestamp(); - - /** - * The posture timeout of the pet. - */ private int postureTimeout = Emulator.getIntUnixTimestamp(); - @Getter - @Setter private int stayStartedAt = 0; - /** - * The number of ticks that the pet has spent idle while waiting for a command. - */ private int idleCommandTicks = 0; - - /** - * The number of ticks that the pet has spent free after completing a command. - */ private int freeCommandTicks = -1; - - @Getter - @Setter private PetTasks task = PetTasks.FREE; - - @Setter - @Getter private boolean muted = false; - - @Getter - @Setter - private RoomPet roomUnit; + private final RoomPet roomUnit; + public int levelThirst; + public int levelHunger; + private boolean sqlUpdateNeeded = false; + private boolean packetUpdate = false; /** * Creates a new pet using the given result set, which should contain data retrieved from a @@ -159,6 +94,9 @@ public class Pet extends Unit implements ISerialize, Runnable { this.levelThirst = set.getInt("thirst"); this.levelHunger = set.getInt("hunger"); this.level = PetManager.getLevel(this.experience); + + this.roomUnit = new RoomPet(); + this.roomUnit.setUnit(this); } /** @@ -191,6 +129,9 @@ public class Pet extends Unit implements ISerialize, Runnable { this.levelHunger = 0; this.created = Emulator.getIntUnixTimestamp(); this.level = 1; + + this.roomUnit = new RoomPet(); + this.roomUnit.setUnit(this); } /** @@ -283,52 +224,26 @@ public class Pet extends Unit implements ISerialize, Runnable { */ @Override public void run() { - if (this.isNeedsUpdate()) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - if (this.id > 0) { - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happiness = ?, created = ? WHERE id = ?")) { - statement.setInt(1, (this.room == null ? 0 : this.room.getRoomInfo().getId())); - statement.setInt(2, this.experience); - statement.setInt(3, this.energy); - statement.setInt(4, this.respect); - statement.setInt(5, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getX() : 0); - statement.setInt(6, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getY() : 0); - statement.setDouble(7, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentZ() : 0.0); - statement.setInt(8, this.getRoomUnit() != null ? this.getRoomUnit().getBodyRotation().getValue() : 0); - statement.setInt(9, this.levelHunger); - statement.setInt(10, this.levelThirst); - statement.setInt(11, this.happiness); - statement.setInt(12, this.created); - statement.setInt(13, this.id); - statement.execute(); - } - } else if (this.id == 0) { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_pets (user_id, room_id, name, race, type, color, experience, energy, respect, created) VALUES (?, 0, ?, ?, ?, ?, 0, 0, 0, ?)", Statement.RETURN_GENERATED_KEYS)) { - statement.setInt(1, this.userId); - statement.setString(2, this.name); - statement.setInt(3, this.race); - statement.setInt(4, 0); - - if (this.petData != null) { - statement.setInt(4, this.petData.getType()); - } - - statement.setString(5, this.color); - statement.setInt(6, this.created); - statement.execute(); - - try (ResultSet set = statement.getGeneratedKeys()) { - if (set.next()) { - this.id = set.getInt(1); - } - } - } - } + if (this.sqlUpdateNeeded) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happiness = ?, created = ? WHERE id = ?")) { + statement.setInt(1, (this.room == null ? 0 : this.room.getRoomInfo().getId())); + statement.setInt(2, this.experience); + statement.setInt(3, this.energy); + statement.setInt(4, this.respect); + statement.setInt(5, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getX() : 0); + statement.setInt(6, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getY() : 0); + statement.setDouble(7, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentZ() : 0.0); + statement.setInt(8, this.getRoomUnit() != null ? this.getRoomUnit().getBodyRotation().getValue() : 0); + statement.setInt(9, this.levelHunger); + statement.setInt(10, this.levelThirst); + statement.setInt(11, this.happiness); + statement.setInt(12, this.created); + statement.setInt(13, this.id); + statement.execute(); + this.sqlUpdateNeeded = false; } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); } - - this.setNeedsUpdate(false); } } @@ -788,7 +703,7 @@ public class Pet extends Unit implements ISerialize, Runnable { this.addHappiness(10); this.addExperience(10); this.addRespect(); - this.setNeedsUpdate(true); + this.setSqlUpdateNeeded(true); if (habbo != null) { habbo.getHabboStats().decreasePetRespectPointsToGive(); @@ -825,9 +740,9 @@ public class Pet extends Unit implements ISerialize, Runnable { room.getRoomUnitManager().removePet(this.id); } - this.setRoomUnit(null); + this.roomUnit.setRoom(null); this.room = null; - this.setNeedsUpdate(true); + this.setSqlUpdateNeeded(true); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index 354d4f5a..3de9317a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.pets.actions.*; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.TIntIntMap; import gnu.trove.map.hash.THashMap; @@ -407,7 +406,7 @@ public class PetManager { client.getHabbo().getHabboInfo().getId() ); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); return pet; } @@ -421,7 +420,7 @@ public class PetManager { public Pet createPet(int type, int race, String name, GameClient client) { if (this.petData.containsKey(type)) { Pet pet = new Pet(type, race, "FFFFFF", name, client.getHabbo().getHabboInfo().getId()); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); return pet; } @@ -443,10 +442,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); return pet; } @@ -463,10 +460,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); return pet; @@ -484,10 +479,8 @@ public class PetManager { pet.setUserId(habbo.getHabboInfo().getId()); pet.setRoom(room); - pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setUnit(pet); pet.getRoomUnit().setRoom(room); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); return pet; 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 abbe4d51..3dd6ee2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -995,6 +995,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Game game : this.games) { game.dispose(); } + this.games.clear(); this.roomUnitManager.removeAllPetsExceptRoomOwner(); 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 ae0631ff..8e32ced6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomItemManager.java @@ -314,7 +314,7 @@ public class RoomItemManager { item.setCurrentPosition(tile); item.setCurrentZ(height); item.setRotation(rotation); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); this.addRoomItem(item); @@ -350,7 +350,7 @@ public class RoomItemManager { this.room.getFurniOwnerNames().put(item.getOwnerInfo().getId(), owner.getHabboInfo().getUsername()); } this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose()); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); this.addRoomItem(item); //Deprecated item.setRoomId(this.room.getRoomInfo().getId()); @@ -504,7 +504,7 @@ public class RoomItemManager { //Update Furniture item.onMove(this.room, oldLocation, targetTile); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); @@ -557,7 +557,7 @@ public class RoomItemManager { //Deprecated roomItem.setRoomId(0); roomItem.setRoom(null); - roomItem.needsUpdate(true); + roomItem.setSqlUpdateNeeded(true); if (roomItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.room.sendComposer(new RemoveFloorItemComposer(roomItem).compose()); @@ -1101,7 +1101,7 @@ public class RoomItemManager { public void dispose() { this.currentItems.values().parallelStream() - .filter(RoomItem::needsUpdate) + .filter(roomItem1 -> roomItem1.isSqlUpdateNeeded()) .forEach(roomItem -> { roomItem.run(); this.currentItems.remove(roomItem.getId()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 85cd6f1a..c147095b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -276,7 +277,13 @@ public class RoomLayout { continue; } - if (this.room.getRoomUnitManager().areRoomUnitsAt(currentAdj) && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + RoomUnit exception = null; + + if(roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) { + exception = roomAvatar.getRidingPet().getRoomUnit(); + } + + if (this.room.getRoomUnitManager().areRoomUnitsAt(currentAdj, exception) && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index e5b12499..9fb80e42 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -594,9 +594,6 @@ public class RoomManager { habbo.getClient().sendResponse(new OpenConnectionMessageComposer()); - //@Deprecated - roomHabbo.setInRoom(true); - if (!habbo.getHabboStats().isBlockFollowing() && roomHabbo.getRoom() == null) { habbo.getMessenger().connectionChanged(habbo, true, true); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 22ae3dd3..463df5cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import lombok.Getter; import lombok.Setter; @@ -173,7 +174,15 @@ public class RoomTile { public void removeUnit(RoomUnit roomUnit) { synchronized (this.roomUnits) { + if(!this.roomUnits.contains(roomUnit)) { + return; + } + this.roomUnits.remove(roomUnit); + + if(roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) { + this.roomUnits.remove(roomAvatar.getRidingPet().getRoomUnit()); + } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java index c7754a3f..02727127 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTraxManager.java @@ -269,7 +269,7 @@ public class RoomTraxManager implements Disposable { //Deprecated musicDisc.setRoomId(-1); musicDisc.setRoom(null); - musicDisc.needsUpdate(true); + musicDisc.setSqlUpdateNeeded(true); Emulator.getThreading().run(musicDisc); habbo.getInventory().getItemsComponent().removeHabboItem(musicDisc); @@ -298,7 +298,7 @@ public class RoomTraxManager implements Disposable { //Deprecated musicDisc.setRoomId(0); musicDisc.setRoom(null); - musicDisc.needsUpdate(true); + musicDisc.setSqlUpdateNeeded(true); Emulator.getThreading().run(musicDisc); Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().getId()); @@ -330,7 +330,7 @@ public class RoomTraxManager implements Disposable { //Deprecated musicDisc.setRoomId(0); musicDisc.setRoom(null); - musicDisc.needsUpdate(true); + musicDisc.setSqlUpdateNeeded(true); Emulator.getThreading().run(musicDisc); Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().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 d3c2d7c0..5a111020 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; @@ -99,9 +98,6 @@ public class RoomUnitManager { bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); - //@DEPRECATED - bot.getRoomUnit().setInRoom(true); - bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false); this.addRoomUnit(bot); @@ -125,8 +121,6 @@ public class RoomUnitManager { Pet pet = PetManager.loadPet(set); pet.setRoom(this.room); - pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setUnit(pet); 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) { @@ -152,6 +146,8 @@ public class RoomUnitManager { public void addRoomUnit(Unit unit) { synchronized (this.roomUnitLock) { + //TODO Maybe set the room in this method + unit.getRoomUnit().setVirtualId(this.roomUnitCounter); this.currentRoomUnits.put(unit.getRoomUnit().getVirtualId(), unit.getRoomUnit()); this.roomUnitCounter++; @@ -184,6 +180,10 @@ public class RoomUnitManager { } public boolean areRoomUnitsAt(RoomTile tile, RoomUnit skippedRoomUnit) { + if(skippedRoomUnit == null) { + return this.areRoomUnitsAt(tile); + } + return this.currentRoomUnits.values().stream().filter(roomUnit -> !roomUnit.equals(skippedRoomUnit)).anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); } @@ -405,8 +405,6 @@ public class RoomUnitManager { spawnTile = room.getLayout().getDoorTile(); } - pet.setRoomUnit(new RoomPet()); - pet.getRoomUnit().setUnit(pet); pet.setRoom(room); pet.getRoomUnit().walkTo(spawnTile); pet.getRoomUnit().setLocation(spawnTile) @@ -420,7 +418,7 @@ public class RoomUnitManager { .setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); } - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); room.getFurniOwnerNames().put(pet.getUserId(), this.getRoomHabboById(pet.getUserId()).getHabboInfo().getUsername()); this.addRoomUnit(pet); room.sendComposer(new RoomPetComposer(pet).compose()); @@ -511,22 +509,18 @@ public class RoomUnitManager { } public void removeBot(Bot bot) { - synchronized (this.currentBots) { - if (this.currentBots.containsKey(bot.getId())) { - //TODO gotta do a method to removeUnit and clear tile - if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentPosition() != null) { - bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit()); - } - - this.currentBots.remove(bot.getId()); - this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId()); - - //@DEPRECATED - bot.getRoomUnit().setInRoom(false); - bot.getRoomUnit().setRoom(null); - - this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); + if (this.currentBots.containsKey(bot.getId())) { + //TODO gotta do a method to removeUnit and clear tile + if (bot.getRoomUnit().getCurrentPosition() != null) { + bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit()); } + + this.currentBots.remove(bot.getId()); + this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId()); + + bot.getRoomUnit().setRoom(null); + + this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose()); } } @@ -564,7 +558,7 @@ public class RoomUnitManager { habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); } - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.run(); } @@ -611,7 +605,7 @@ public class RoomUnitManager { while(petIterator.hasNext()) { try { Pet pet = petIterator.next(); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); Emulator.getThreading().run(pet); } catch (NoSuchElementException e) { log.error("Caught Exception", e); 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 d8b22003..f828a1bf 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 @@ -142,7 +142,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri serverMessage.appendInt(this.getCurrentPosition().getY()); serverMessage.appendInt(this.getRotation()); serverMessage.appendString(Double.toString(this.getCurrentZ())); - serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().equalsIgnoreCase("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? String.valueOf(Item.getCurrentHeight(this)) : "")); } catch (Exception e) { log.error("Caught exception", e); @@ -180,22 +179,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri this.rotation = (byte) (rotation % 8); } - public boolean needsUpdate() { - return this.sqlUpdateNeeded; - } - - public boolean needsDelete() { - return sqlDeleteNeeded; - } - - public void needsUpdate(boolean value) { - this.sqlUpdateNeeded = value; - } - - public void needsDelete(boolean value) { - this.sqlDeleteNeeded = value; - } - public boolean isLimited() { return this.limitedStack > 0; } @@ -486,8 +469,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri return true; } - public boolean invalidatesToRoomKick() { return false; } - public List getOccupyingTiles(RoomLayout layout) { List tiles = new ArrayList<>(); @@ -502,10 +483,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri return tiles; } - public RoomTile getOverrideGoalTile(RoomUnit unit, Room room, RoomTile tile) { - return tile; - } - public RoomTileState getOverrideTileState(RoomTile tile, Room room) { return null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java index 52b5dd07..2ac2257d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/RoomUnit.java @@ -5,13 +5,11 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWater; import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; -import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; 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.types.RoomAvatar; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; @@ -74,8 +72,6 @@ public abstract class RoomUnit extends RoomEntity { @Setter protected int kickCount = 0; @Setter - protected boolean inRoom; - @Setter @Accessors(chain = true) protected boolean invisible = false; @Setter @@ -97,7 +93,6 @@ public abstract class RoomUnit extends RoomEntity { this.statuses = new ConcurrentHashMap<>(); this.statusUpdateNeeded = false; - this.inRoom = false; this.cacheable = new THashMap<>(); this.roomUnitType = RoomUnitType.UNKNOWN; this.walkTimeOut = Emulator.getIntUnixTimestamp(); @@ -121,6 +116,10 @@ public abstract class RoomUnit extends RoomEntity { } }; + public boolean isInRoom() { + return this.room != null; + } + @Override public RoomUnit setCurrentPosition(RoomTile tile) { super.setCurrentPosition(tile); @@ -529,6 +528,10 @@ public abstract class RoomUnit extends RoomEntity { private double handleNextHeight(RoomTile next) { double height = 0.0D; + if(this instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) { + height += 1.0D; + } + RoomItem nextTileItem = this.room.getRoomItemManager().getTopItemAt(next); if(nextTileItem != null) { @@ -566,17 +569,13 @@ public abstract class RoomUnit extends RoomEntity { double heightDifference = tile.getStackHeight() - this.currentZ; - boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile); + RoomUnit exception = null; if(this instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) { - areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, roomAvatar.getRidingPet().getRoomUnit()); + exception = roomAvatar.getRidingPet().getRoomUnit(); } - if(this instanceof RoomPet roomPet) { - if(roomPet.getUnit() instanceof RideablePet rideablePet && rideablePet.hasRider()) { - areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, rideablePet.getRider().getRoomUnit()); - } - } + boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, exception); boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT); boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java index 9e0f13c0..d06c8c81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java @@ -6,9 +6,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.Habbo; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; @Slf4j +@Getter +@Setter +@Accessors(chain = true) public class RoomPet extends RoomUnit { private Pet unit; @@ -23,26 +29,38 @@ public class RoomPet extends RoomUnit { } } + /** + * Handles the interaction between a RideablePet unit and its rider (Habbo) in the virtual room. + * If the unit is a RideablePet and has a rider, this method updates the unit's position and status + * to reflect the rider's movement and actions. + * + * @return {@code true} if the interaction was successfully handled, {@code false} pet walks normally. + */ public boolean handleRider() { - Habbo rider = null; - - if (this.unit instanceof RideablePet rideablePet) { - rider = rideablePet.getRider(); + if (!(this.unit instanceof RideablePet rideablePet)) { + return false; } + Habbo rider = rideablePet.getRider(); + if(rider == null) { return false; } - // copy things from rider - if (this.hasStatus(RoomUnitStatus.MOVE) && !rider.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || !rider.getRoomUnit().isWalking()) { - this.removeStatus(RoomUnitStatus.MOVE); + RoomAvatar riderAvatar = rider.getRoomUnit(); + + if(this.getNextPosition() != null) { + this.setCurrentPosition(this.getNextPosition()); + this.setCurrentZ(this.getNextZ()); } - if (!this.currentPosition.equals(rider.getRoomUnit().getCurrentPosition())) { - this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight())); - this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition()); - this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight()); + if(riderAvatar.isWalking()) { + this.addStatus(RoomUnitStatus.MOVE, riderAvatar.getNextPosition().getX() + "," + riderAvatar.getNextPosition().getY() + "," + (riderAvatar.getNextZ() - 1.0D)); + this.setNextPosition(riderAvatar.getNextPosition()); + this.setNextZ(riderAvatar.getNextZ() - 1.0D); + this.setRotation(riderAvatar.getBodyRotation()); + } else if(!riderAvatar.isWalking() && this.hasStatus(RoomUnitStatus.MOVE)) { + this.stopWalking(); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index f6d1ec1f..9aff218d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -159,7 +159,8 @@ public class ItemsComponent { } catch (NoSuchElementException e) { break; } - if (items.value().needsUpdate()) + RoomItem roomItem = items.value(); + if (roomItem.isSqlUpdateNeeded()) Emulator.getThreading().run(items.value()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java index 76e6855c..2aed6703 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java @@ -81,7 +81,7 @@ public class PetsComponent { } catch (NoSuchElementException e) { break; } - if (petIterator.value().isNeedsUpdate()) + if (petIterator.value().isSqlUpdateNeeded()) Emulator.getThreading().run(petIterator.value()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java index 211c170a..a96ce15f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/PurchasePhotoEvent.java @@ -40,7 +40,7 @@ public class PurchasePhotoEvent extends MessageHandler { if (photoItem != null) { photoItem.setExtraData(photoItem.getExtraData().replace("%id%", photoItem.getId() + "")); - photoItem.needsUpdate(true); + photoItem.setSqlUpdateNeeded(true); this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java index bc714081..0340d360 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogAsGiftEvent.java @@ -11,9 +11,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; 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.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; @@ -285,7 +285,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler { } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) { InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); habboItem.setExtraData(""); - habboItem.needsUpdate(true); + habboItem.setSqlUpdateNeeded(true); int guildId; try { guildId = Integer.parseInt(extraData); diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java index 9ed3a345..6a90397e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/QuitEvent.java @@ -29,6 +29,5 @@ public class QuitEvent extends MessageHandler { } roomHabbo.clear(); - roomHabbo.setInRoom(false); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java index 4ad3455d..44dfe13d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RequestRoomPropertySet.java @@ -49,7 +49,7 @@ public class RequestRoomPropertySet extends MessageHandler { this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); room.setNeedsUpdate(true); room.sendComposer(new RoomPropertyMessageComposer(item.getBaseItem().getName(), item.getExtraData()).compose()); - item.needsDelete(true); + item.setSqlDeleteNeeded(true); Emulator.getThreading().run(item); this.client.sendResponse(new FurniListRemoveComposer(itemId)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java index b820bffc..de92ddba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetRoomBackgroundColorDataEvent.java @@ -36,7 +36,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler { brightness = event.getBrightness() % 256; item.setExtraData(item.getExtraData().split(":")[0] + ":" + hue + ":" + saturation + ":" + brightness); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java index f8f35f1b..5e216071 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AddSpamWallPostItEvent.java @@ -49,7 +49,7 @@ public class AddSpamWallPostItEvent extends MessageHandler { sticky.setOwnerInfo(room.getRoomInfo().getOwnerInfo()); sticky.setExtraData(color + " " + text); - sticky.needsUpdate(true); + sticky.setSqlUpdateNeeded(true); room.updateItem(sticky); Emulator.getThreading().run(sticky); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java index ed5d896b..1da05b08 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/DiceOffEvent.java @@ -25,7 +25,7 @@ public class DiceOffEvent extends MessageHandler { if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) { if (!item.getExtraData().equals("-1")) { item.setExtraData("0"); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java index d8869f6d..185c3c1b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoveWallItemEvent.java @@ -36,7 +36,7 @@ public class MoveWallItemEvent extends MessageHandler { return; item.setWallPosition(wallPosition); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); room.updateItem(item); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index c925be10..c2d610ae 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -34,7 +34,7 @@ public class PlacePostItEvent extends MessageHandler { item.setRoom(this.client.getHabbo().getRoomUnit().getRoom()); item.setWallPosition(location); item.setOwnerInfo(this.client.getHabbo().getHabboInfo()); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); room.sendComposer(new ItemAddMessageComposer(item, this.client.getHabbo().getHabboInfo().getUsername()).compose()); this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item); this.client.sendResponse(new FurniListRemoveComposer(item.getGiftAdjustedId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java index f8130a7f..927803b8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerChangeStateEvent.java @@ -32,7 +32,7 @@ public class RoomDimmerChangeStateEvent extends MessageHandler { if (RoomMoodlightData.fromString(moodLight.getExtraData()).isEnabled()) adjusted.disable(); moodLight.setExtraData(adjusted.toString()); - moodLight.needsUpdate(true); + moodLight.setSqlUpdateNeeded(true); room.updateItem(moodLight); Emulator.getThreading().run(moodLight); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java index 2d75a54b..499ca932 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomDimmerSavePresetEvent.java @@ -50,7 +50,7 @@ public class RoomDimmerSavePresetEvent extends MessageHandler { for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { item.setExtraData(data.toString()); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); room.updateItem(item); Emulator.getThreading().run(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index 6d570d08..2774d8e9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -48,7 +48,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { item.setCurrentZ(height); item.setExtraData(String.valueOf((int) (height * 100))); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); this.client.getHabbo().getRoomUnit().getRoom().updateItem(item); this.client.getHabbo().getRoomUnit().getRoom().updateTiles(tiles); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java index 03d731f4..853af0dc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetItemDataEvent.java @@ -52,7 +52,7 @@ public class SetItemDataEvent extends MessageHandler { color = PostItColor.YELLOW.hexColor; item.setExtraData(color + " " + text); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); room.updateItem(item); Emulator.getThreading().run(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java index 3f785e48..66ac6978 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinFigureEvent.java @@ -41,7 +41,7 @@ public class SetMannequinFigureEvent extends MessageHandler { item.setExtraData(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + habbo.getHabboInfo().getUsername() + "'s look."); } - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java index 3be84b84..892d2d68 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetMannequinNameEvent.java @@ -29,7 +29,7 @@ public class SetMannequinNameEvent extends MessageHandler { } else { item.setExtraData(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + this.client.getHabbo().getHabboInfo().getLook() + ":" + name); } - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); room.updateItem(item); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java index fd5873f2..7ee64b0c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetObjectDataEvent.java @@ -43,7 +43,7 @@ public class SetObjectDataEvent extends MessageHandler { } item.setExtraData(((InteractionCustomValues) item).toExtraData()); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); Emulator.getThreading().run(item); room.updateItem(item); ((InteractionCustomValues) item).onCustomValuesSaved(room, this.client, oldValues); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java index 882351b3..6d1ca0e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseWallItemEvent.java @@ -32,7 +32,7 @@ public class UseWallItemEvent extends MessageHandler { if (item.getBaseItem().getName().equalsIgnoreCase("poster")) return; - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); item.onClick(this.client, room, new Object[]{state}); room.updateItem(item); Emulator.getThreading().run(item); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java index 9f60330b..2e5c6193 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java @@ -43,7 +43,7 @@ public class SetYoutubeDisplayPlaylistEvent extends YoutubeEvent { room.sendComposer(new YoutubeDisplayVideoMessageComposer(itemId, video, true, 0).compose()); ((InteractionYoutubeTV) item).autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo((InteractionYoutubeTV) item), video.getDuration() * 1000L); - item.needsUpdate(true); + item.setSqlUpdateNeeded(true); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 7dfc73a3..96361b73 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -44,7 +44,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { raceType = 0; pet.setRace(raceType); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairdye")) { int splittedHairdye = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairdye = 48; @@ -60,7 +60,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { } ((HorsePet) pet).setHairColor(newHairdye); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairstyle")) { int splittedHairstyle = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]); int newHairstyle = 100; @@ -72,14 +72,14 @@ public class CustomizePetWithFurniEvent extends MessageHandler { } ((HorsePet) pet).setHairStyle(newHairstyle); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) { ((HorsePet) pet).hasSaddle(true); ((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId()); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); } - if (pet.isNeedsUpdate()) { + if (pet.isSqlUpdateNeeded()) { Emulator.getThreading().run(pet); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index 18c4941d..fa1996e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -28,10 +28,8 @@ public class MountPetEvent extends MessageHandler { return; } - //dismount if (habbo.getRoomUnit().isRiding()) { boolean mountAnotherPet = petId != habbo.getRoomUnit().getRidingPet().getId(); - habbo.getRoomUnit().dismountPet(false); if(!mountAnotherPet) { @@ -39,12 +37,10 @@ public class MountPetEvent extends MessageHandler { } } - // someone is already on it if (rideablePet.getRider() != null) { return; } - // check if able to ride if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) { return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index be3ad3b0..9f8b0342 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -27,7 +27,7 @@ public class MovePetEvent extends MessageHandler { pet.getRoomUnit().setCurrentZ(tile.getZ()); pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt())); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index 26a43454..e82a68e8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -57,7 +57,7 @@ public class OpenPetPackageEvent extends MessageHandler { if (pet != null) { room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); pet.setUserId(this.client.getHabbo().getHabboInfo().getId()); - pet.setNeedsUpdate(true); + pet.setSqlUpdateNeeded(true); pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); pet.getRoomUnit().setCurrentZ(item.getCurrentZ()); Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index 83e081da..fa9df07b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -73,27 +73,31 @@ public class PlacePetEvent extends MessageHandler { return; } + //TODO REMOVE THIS pet.setRoom(room); - RoomPet roomPet = pet.getRoomUnit(); - if (roomPet == null) { - roomPet = new RoomPet(); - roomPet.setUnit(pet); - } + RoomPet roomPet = pet.getRoomUnit(); roomPet.setRoom(room); roomPet.setLocation(tile); roomPet.setCurrentZ(tile.getStackHeight()); + roomPet.addStatus(RoomUnitStatus.SIT, "0"); + + //TODO I dont think I need this anymore roomPet.setRoomUnitType(RoomUnitType.PET); + if (playerTile != null) { roomPet.lookAtPoint(playerTile); } - pet.setRoomUnit(roomPet); + room.getRoomUnitManager().addRoomUnit(pet); - pet.setNeedsUpdate(true); + + //This to update room on DB + pet.setSqlUpdateNeeded(true); Emulator.getThreading().run(pet); + room.sendComposer(new RoomPetComposer(pet).compose()); this.client.getHabbo().getInventory().getPetsComponent().removePet(pet); this.client.sendResponse(new PetRemovedFromInventoryComposer(pet)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java index 2f80abbc..c0030713 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java @@ -53,7 +53,7 @@ public class RemoveSaddleFromPetEvent extends MessageHandler { if (saddleItem == null) return; horse.hasSaddle(false); - horse.setNeedsUpdate(true); + horse.setSqlUpdateNeeded(true); Emulator.getThreading().run(pet); this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer(horse).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java index 368b837a..7de47b2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java @@ -20,7 +20,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { return; rideablePet.setAnyoneCanRide(!rideablePet.anyoneCanRide()); - rideablePet.setNeedsUpdate(true); + rideablePet.setSqlUpdateNeeded(true); if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) { rideablePet.getRider().getRoomUnit().dismountPet(false); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java index a889df0d..e7b0fc5a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateActionEvent.java @@ -28,7 +28,7 @@ public class UpdateActionEvent extends MessageHandler { effect.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); - effect.needsUpdate(true); + effect.setSqlUpdateNeeded(true); Emulator.getThreading().run(effect); } catch (WiredSaveException e) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java index de5a7571..49cf8f8a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateConditionEvent.java @@ -26,7 +26,7 @@ public class UpdateConditionEvent extends MessageHandler { condition.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); - condition.needsUpdate(true); + condition.setSqlUpdateNeeded(true); Emulator.getThreading().run(condition); } catch (WiredSaveException e) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java index d5572b6c..e8a375f5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/UpdateTriggerEvent.java @@ -26,7 +26,7 @@ public class UpdateTriggerEvent extends MessageHandler { trigger.saveWiredSettings(this.packet, room); this.client.sendResponse(new WiredSavedComposer()); - trigger.needsUpdate(true); + trigger.setSqlUpdateNeeded(true); Emulator.getThreading().run(trigger); } catch (WiredSaveException e) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java index f23c8fa7..18db005c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java @@ -54,7 +54,7 @@ public class FloorItemOnRollerComposer extends MessageComposer { this.item.setCurrentPosition(this.newLocation); this.item.setCurrentZ(this.item.getCurrentZ() + this.heightOffset); - this.item.needsUpdate(true); + this.item.setSqlUpdateNeeded(true); //TODO This is bad // diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java index ed3c8305..8ce80a87 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredConditionDataComposer.java @@ -37,7 +37,7 @@ public class WiredConditionDataComposer extends MessageComposer { this.response.appendInt(this.condition.getWiredSettings().getSelectionType()); this.response.appendInt(this.condition.getType().getCode()); - this.condition.needsUpdate(true); + this.condition.setSqlUpdateNeeded(true); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java index be8e0ae6..07301e81 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredEffectDataComposer.java @@ -44,7 +44,7 @@ public class WiredEffectDataComposer extends MessageComposer { this.response.appendInt(blockedTrigger); } - this.effect.needsUpdate(true); + this.effect.setSqlUpdateNeeded(true); return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java index 706a60fa..ce5b7d03 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/wired/WiredTriggerDataComposer.java @@ -42,7 +42,7 @@ public class WiredTriggerDataComposer extends MessageComposer { this.response.appendInt(blockedTrigger); } - this.trigger.needsUpdate(true); + this.trigger.setSqlUpdateNeeded(true); return this.response; } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java index a7f3d280..c82e129a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java +++ b/src/main/java/com/eu/habbo/threading/runnables/ClearRentedSpace.java @@ -27,7 +27,7 @@ public class ClearRentedSpace implements Runnable { //Deprecated i.setRoomId(0); i.setRoom(null); - i.needsUpdate(true); + i.setSqlUpdateNeeded(true); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java index 775d0536..5466cb30 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CloseGate.java @@ -23,7 +23,7 @@ public class CloseGate implements Runnable { if (!this.room.getRoomUnitManager().hasHabbosAt(tile)) { this.gate.setExtraData("0"); this.room.updateItem(this.gate); - this.gate.needsUpdate(true); + this.gate.setSqlUpdateNeeded(true); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index f5aa2255..42e74d8d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -56,7 +56,7 @@ public class CrackableExplode implements Runnable { //Deprecated newItem.setRoomId(this.room.getRoomInfo().getId()); newItem.setRoom(this.room); - newItem.needsUpdate(true); + newItem.setSqlUpdateNeeded(true); this.room.getRoomItemManager().addRoomItem(newItem); this.room.updateItem(newItem); this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerInfo().getId())).compose()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 702f3e0a..b6323c92 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -34,7 +34,7 @@ public class OpenGift implements Runnable { inside = i; i.setOwnerInfo(this.habbo.getHabboInfo()); - i.needsUpdate(true); + i.setSqlUpdateNeeded(true); i.run(); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java index 2e41d251..f07f3bd8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java @@ -31,7 +31,7 @@ public class RandomDiceNumber implements Runnable { this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1); this.item.setExtraData(this.result + ""); - this.item.needsUpdate(true); + this.item.setSqlUpdateNeeded(true); Emulator.getThreading().run(this.item); this.room.updateItem(this.item); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java index 1a76da07..33c11516 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RandomSpinningBottleNumber.java @@ -30,7 +30,7 @@ public class RandomSpinningBottleNumber implements Runnable { this.result = Emulator.getRandom().nextInt(this.maxNumber); this.item.setExtraData(this.result + ""); - this.item.needsUpdate(true); + this.item.setSqlUpdateNeeded(true); Emulator.getThreading().run(this.item); this.room.updateItem(this.item); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java index cc63da40..36d67f99 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitRidePet.java @@ -7,19 +7,34 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer; -import lombok.AllArgsConstructor; -@AllArgsConstructor public class RoomUnitRidePet implements Runnable { + private final int MAX_RETRIES = 3; private final RideablePet pet; private final Habbo habbo; private final RoomTile goalTile; + private int retries; + public RoomUnitRidePet(RideablePet pet, Habbo rider, RoomTile petTile) { + this.pet = pet; + this.habbo = rider; + this.goalTile = petTile; + this.retries = 0; + } @Override public void run() { - if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getRoomUnit().getRoom() || this.goalTile == null || this.habbo.getRoomUnit().getTargetPosition() != this.goalTile) + if (this.pet.getRoom() != this.habbo.getRoomUnit().getRoom()) { + this.habbo.getRoomUnit().setRideLocked(false); return; + } + + if(this.retries >= MAX_RETRIES) { + this.habbo.getRoomUnit().setRideLocked(false); + return; + } + + this.retries++; if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) { habbo.getRoomUnit().stopWalking();