From 7cf3e3e86383add55de41ad9c5f900492a0330f0 Mon Sep 17 00:00:00 2001 From: Stankman Date: Thu, 15 Jun 2023 16:28:23 -0500 Subject: [PATCH] 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; }