Default Params and JSON serialization done

This commit is contained in:
Stankman 2023-06-17 17:33:42 -05:00
parent a152105453
commit 6d49cfc37c
32 changed files with 252 additions and 87 deletions

19
pom.xml
View File

@ -104,6 +104,25 @@
<version>2.8.9</version>
</dependency>
<!-- JACKSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<!-- MySQL Connector -->
<dependency>
<groupId>mysql</groupId>

View File

@ -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 = "";

View File

@ -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<Integer> integerParams;
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String stringParam;
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<Integer> 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<>();

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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++;

View File

@ -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++;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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<RoomTile> tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
for (RoomTile tile : tiles) {
if (room != null) {