From 6d49cfc37cf6298d05a61bc1e13a50fd33c80357 Mon Sep 17 00:00:00 2001 From: Stankman Date: Sat, 17 Jun 2023 17:33:42 -0500 Subject: [PATCH] Default Params and JSON serialization done --- pom.xml | 19 ++++++++++ .../items/interactions/InteractionWired.java | 19 +++++----- .../interactions/wired/WiredSettings.java | 11 ++++-- .../WiredConditionDateRangeActive.java | 8 +++++ .../WiredConditionFurniHaveFurni.java | 7 ++++ .../conditions/WiredConditionHabboCount.java | 8 +++++ .../WiredConditionHabboHasEffect.java | 7 ++++ .../WiredConditionHabboHasHandItem.java | 7 ++++ .../WiredConditionLessTimeElapsed.java | 7 ++++ .../WiredConditionMatchStatePosition.java | 19 +++++++--- .../WiredConditionMoreTimeElapsed.java | 10 +++++- .../WiredConditionNotFurniHaveFurni.java | 7 ++++ .../conditions/WiredConditionNotInTeam.java | 10 ++++++ .../conditions/WiredConditionTeamMember.java | 10 ++++++ .../effects/WiredEffectBotFollowHabbo.java | 7 ++++ .../effects/WiredEffectBotGiveHandItem.java | 7 ++++ .../wired/effects/WiredEffectBotTalk.java | 7 ++++ .../effects/WiredEffectBotTalkToHabbo.java | 7 ++++ .../WiredEffectChangeFurniDirection.java | 8 +++++ .../wired/effects/WiredEffectGiveScore.java | 8 +++++ .../effects/WiredEffectGiveScoreToTeam.java | 11 ++++++ .../wired/effects/WiredEffectJoinTeam.java | 8 +++++ .../wired/effects/WiredEffectMatchFurni.java | 15 ++++---- .../wired/effects/WiredEffectMoveFurniTo.java | 15 ++++---- .../wired/triggers/WiredTriggerAtSetTime.java | 7 ++++ .../triggers/WiredTriggerAtTimeLong.java | 7 ++++ .../triggers/WiredTriggerHabboEntersRoom.java | 12 +------ .../WiredTriggerHabboSaysKeyword.java | 16 ++++----- .../triggers/WiredTriggerRepeaterLong.java | 2 +- .../triggers/WiredTriggerScoreAchieved.java | 7 ++++ .../wired/WiredExclusionStrategy.java | 35 ------------------- .../habbo/habbohotel/wired/WiredHandler.java | 11 ++++++ 32 files changed, 252 insertions(+), 87 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java diff --git a/pom.xml b/pom.xml index 4f2ad716..ef4c1a5a 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,25 @@ 2.8.9 + + + com.fasterxml.jackson.core + jackson-core + 2.15.2 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + mysql diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index f216e3c8..1a926b1e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -15,6 +14,7 @@ import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageCompose import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer; +import com.fasterxml.jackson.core.JsonProcessingException; import gnu.trove.map.hash.TLongLongHashMap; import lombok.Getter; import lombok.Setter; @@ -32,7 +32,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi @Getter @Setter private WiredSettings wiredSettings; - private long cooldown; private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); @@ -64,13 +63,11 @@ public abstract class InteractionWired extends InteractionDefault implements IWi if(wiredData.startsWith("{")) { this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class); } - - this.loadDefaultParams(); } /** * - * When double clicking into the wired, verify items first and load its default parameters + * When double-clicking into the wired, verify items first and load its default parameters * then create a composer based on it's Wired Settings * * @param client @@ -82,9 +79,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi public void onClick(GameClient client, Room room, Object[] objects) throws Exception { this.wiredSettings.getItems(room); - //TODO Im not sure about this, the function is optional on its children maybe later just make it abstract - this.loadDefaultParams(); - if (client != null) { if (room.hasRights(client.getHabbo())) { MessageComposer composer = null; @@ -148,10 +142,15 @@ public abstract class InteractionWired extends InteractionDefault implements IWi if (this.needsUpdate()) { //TODO HERE IS WERE WIRED_SAVE_EXCEPTION WILL BE THROWN //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers + this.loadDefaultParams(); - WiredExclusionStrategy exclusionStrategy = new WiredExclusionStrategy(this.wiredSettings); + String wiredData = ""; - String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings); + try { + wiredData = WiredHandler.getObjectMapper().writeValueAsString(this.wiredSettings); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } if(wiredData.equalsIgnoreCase("{}")) { wiredData = ""; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java index 8fdba9dc..7264bca5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import gnu.trove.map.hash.THashMap; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import gnu.trove.set.hash.THashSet; import lombok.Getter; import lombok.Setter; @@ -15,22 +15,27 @@ import java.util.List; public class WiredSettings implements IWiredSettings { @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List integerParams; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private String stringParam; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List itemIds; @Getter @Setter + @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int delay; @Getter @Setter - private transient int selectionType; + @JsonIgnore + private int selectionType; public WiredSettings() { this.itemIds = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index 5a6ef2ee..a7f6ed4a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -59,6 +59,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { return startDate < time && endDate >= time; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + /** * Returns the {@link WiredConditionType} of this object. * @return the type of this wired condition diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index 61297586..70a575ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -51,6 +51,13 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.FURNI_HAS_FURNI; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index 3ab4ca4a..2c048889 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -33,6 +33,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { return userCount >= lowerLimit && userCount <= upperLimit; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.USER_COUNT; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 84047e17..57174423 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -34,6 +34,13 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { return roomUnit.getEffectId() == effectId; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_WEARS_EFFECT; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 3270ce20..416e9f06 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -33,6 +33,13 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { return roomUnit.getHandItem() == handItemId; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_HAS_HANDITEM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index e5c71a6c..7d562667 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -30,6 +30,13 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < cycles; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.TIME_LESS_THAN; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 3592eceb..cea8ed52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -32,11 +32,6 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition super(id, userId, item, extradata, limitedStack, limitedSells); } - @Override - public WiredConditionType getType() { - return WiredConditionType.MATCH_SSHOT; - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if(this.getWiredSettings().getItemIds().isEmpty()) { @@ -74,6 +69,15 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; @@ -88,4 +92,9 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition public boolean shouldMatchPosition() { return this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1; } + + @Override + public WiredConditionType getType() { + return WiredConditionType.MATCH_SSHOT; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index 289c8faf..feb39c35 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -13,7 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { - private static final int PARAM_CYCLE = 0; + public final int PARAM_CYCLE = 0; public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -28,6 +28,14 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE); return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > cycles; } + + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.TIME_MORE_THAN; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 6f5481e7..88dae5fd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -52,6 +52,13 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.NOT_FURNI_HAVE_FURNI; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index e5b7130c..375329a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java @@ -16,6 +16,7 @@ import java.sql.SQLException; public class WiredConditionNotInTeam extends InteractionWiredCondition { public final int PARAM_TEAM = 0; + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -44,6 +45,15 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.NOT_ACTOR_IN_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java index db2c0aab..cb178496 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java @@ -16,6 +16,7 @@ import java.sql.SQLException; public class WiredConditionTeamMember extends InteractionWiredCondition { public final int PARAM_TEAM = 0; + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -46,6 +47,15 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredConditionType getType() { return WiredConditionType.ACTOR_IN_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index 906ace42..c4f81483 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -50,6 +50,13 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_FOLLOW_AVATAR; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index aaff903f..73b3afa5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java @@ -66,6 +66,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_GIVE_HANDITEM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java index 9dff1030..45f1786f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java @@ -69,6 +69,13 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_TALK; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index a772444a..32f90687 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -74,6 +74,13 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.BOT_TALK_TO_AVATAR; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index baa91bfa..42e591b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -108,6 +108,14 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + private RoomUserRotation nextRotation(RoomUserRotation currentRotation) { return switch (this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION)) { case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index 647e4440..68b8c78e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -97,6 +97,14 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.GIVE_SCORE; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index c0153cb8..03d60277 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -23,6 +23,8 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { public final int PARAM_TEAM = 2; private final TIntIntHashMap startTimes = new TIntIntHashMap(); + private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; + public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } @@ -69,6 +71,15 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(1); + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.GIVE_SCORE_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index 01a05aea..04a16702 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -23,6 +23,7 @@ import java.util.List; public class WiredEffectJoinTeam extends InteractionWiredEffect { public final int PARAM_TEAM = 0; + private GameTeamColors DEFAULT_TEAM = GameTeamColors.RED; public WiredEffectJoinTeam(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -62,6 +63,13 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type); + } + } + @Override public WiredEffectType getType() { return WiredEffectType.JOIN_TEAM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 95b7506b..c39962bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -1,15 +1,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import lombok.Getter; @@ -17,9 +14,6 @@ import lombok.extern.slf4j.Slf4j; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; @Slf4j public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings { @@ -86,6 +80,15 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public boolean shouldMatchState() { return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 1d018a22..56167acc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -8,18 +8,11 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class WiredEffectMoveFurniTo extends InteractionWiredEffect { public final int PARAM_DIRECTION = 0; @@ -79,6 +72,14 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().isEmpty()) { + this.getWiredSettings().getIntegerParams().add(0); + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override protected long requiredCooldown() { return 495; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index 6d429b35..8b90322e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -32,6 +32,13 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public void resetTimer() { this.taskId++; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 9e3761bd..1dc95757 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -32,6 +32,13 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W return true; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public void resetTimer() { this.taskId++; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index c6b86584..4250a2b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -11,7 +11,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { - public final int PARAM_ANY_USER = 0; public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -22,9 +21,7 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - boolean anyUser = this.getWiredSettings().getIntegerParams().get(PARAM_ANY_USER) == 0; - - if(this.getWiredSettings().getStringParam().isEmpty() && !anyUser || anyUser) { + if(this.getWiredSettings().getStringParam().isEmpty()) { return true; } @@ -37,13 +34,6 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { return false; } - @Override - public void loadDefaultParams() { - if(this.getWiredSettings().getIntegerParams().size() == 0) { - this.getWiredSettings().getIntegerParams().add(0); - } - } - @Override public WiredTriggerType getType() { return WiredTriggerType.ENTER_ROOM; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index 18b05113..bae1ebfb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { - private static int PARAM_OWNER_ONLY = 0; + public int PARAM_OWNER_ONLY = 0; public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -24,13 +24,6 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { super(id, userId, item, extraData, limitedStack, limitedSells); } - @Override - public void loadDefaultParams() { - if(this.getWiredSettings().getIntegerParams().size() == 0) { - this.getWiredSettings().getIntegerParams().add(0); - } - } - @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { if (this.getWiredSettings().getStringParam().isEmpty()) { @@ -49,6 +42,13 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(0); + } + } + @Override public WiredTriggerType getType() { return WiredTriggerType.SAY_SOMETHING; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 58314aa2..bad6837c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { - private static final int PARAM_REPEAT_TIME = 0; + public final int PARAM_REPEAT_TIME = 0; private int counter = 0; public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index f7d712fa..ac31e535 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -35,6 +35,13 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { return false; } + @Override + public void loadDefaultParams() { + if(this.getWiredSettings().getIntegerParams().size() == 0) { + this.getWiredSettings().getIntegerParams().add(1); + } + } + @Override public WiredTriggerType getType() { return WiredTriggerType.SCORE_ACHIEVED; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java deleted file mode 100644 index c281029c..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredExclusionStrategy.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.eu.habbo.habbohotel.wired; - -import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; -import com.google.gson.ExclusionStrategy; -import com.google.gson.FieldAttributes; - -public class WiredExclusionStrategy implements ExclusionStrategy { - private WiredSettings wiredSettings; - public WiredExclusionStrategy(WiredSettings settings) { - this.wiredSettings = settings; - } - @Override - public boolean shouldSkipField(FieldAttributes fieldAttributes) { - String fieldName = fieldAttributes.getName(); - - switch (fieldName) { - case "stringParam": - return this.wiredSettings.getStringParam().isEmpty(); - case "integerParams": - return this.wiredSettings.getIntegerParams().size() == 0; - case "delay": - return this.wiredSettings.getDelay() == 0; - case "itemIds": - return this.wiredSettings.getItemIds().size() == 0; - case "selectionType": - default: - return true; - } - } - - @Override - public boolean shouldSkipClass(Class aClass) { - return false; - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 79c0bad8..fe21586a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -27,6 +27,7 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredConditionFailedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceivedEvent; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.GsonBuilder; import gnu.trove.set.hash.THashSet; import lombok.extern.slf4j.Slf4j; @@ -48,6 +49,8 @@ public class WiredHandler { private static GsonBuilder gsonBuilder = null; + private static ObjectMapper objectMapper = null; + public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) { if (triggerType == WiredTriggerType.CUSTOM) return false; @@ -257,6 +260,14 @@ public class WiredHandler { return gsonBuilder; } + public static ObjectMapper getObjectMapper() { + if(objectMapper == null) { + objectMapper = new ObjectMapper(); + } + + return objectMapper; + } + public static boolean executeEffectsAtTiles(THashSet tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { for (RoomTile tile : tiles) { if (room != null) {