mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Refactored LoadDefaultParams to LoadDefaultIntegerParams and removed GSON
This commit is contained in:
parent
6d49cfc37c
commit
eefcc5b89c
@ -55,13 +55,13 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
||||
* @param set
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void loadWiredSettings(ResultSet set) throws SQLException {
|
||||
public void loadWiredSettings(ResultSet set) throws SQLException, JsonProcessingException {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
this.wiredSettings = new WiredSettings();
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class);
|
||||
this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,9 +140,9 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate()) {
|
||||
//TODO HERE IS WERE WIRED_SAVE_EXCEPTION WILL BE THROWN
|
||||
//TODO HERE IS WHERE WIRED_SAVE_EXCEPTION WILL BE THROWN
|
||||
//EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers
|
||||
this.loadDefaultParams();
|
||||
this.loadDefaultIntegerParams();
|
||||
|
||||
String wiredData = "";
|
||||
|
||||
@ -181,7 +181,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
||||
this.wiredSettings.dispose();
|
||||
}
|
||||
|
||||
public void loadDefaultParams() {}
|
||||
public void loadDefaultIntegerParams() {}
|
||||
|
||||
public void activateBox(Room room) {
|
||||
this.activateBox(room, null, 0L);
|
||||
|
@ -60,7 +60,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -52,7 +52,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -35,7 +35,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -30,7 +30,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
|
@ -48,7 +48,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
|
@ -51,7 +51,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -98,7 +98,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
|
@ -72,7 +72,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
|
@ -64,7 +64,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -73,7 +73,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().isEmpty()) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
|
@ -33,7 +33,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
|
@ -33,7 +33,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
}
|
||||
|
@ -38,4 +38,4 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
||||
public WiredTriggerType getType() {
|
||||
return WiredTriggerType.ENTER_ROOM;
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(0);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultParams() {
|
||||
public void loadDefaultIntegerParams() {
|
||||
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||
this.getWiredSettings().getIntegerParams().add(1);
|
||||
}
|
||||
|
@ -500,8 +500,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (item instanceof InteractionWired interactionWired) {
|
||||
interactionWired.loadWiredSettings(set);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
} catch (Exception e) {
|
||||
log.error(CAUGHT_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredExtra;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectGiveReward;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTriggerStacks;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
@ -28,7 +28,6 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent;
|
||||
import com.eu.habbo.plugin.events.users.UserWiredRewardReceivedEvent;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -42,13 +41,9 @@ import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class WiredHandler {
|
||||
|
||||
//Configuration. Loaded from database & updated accordingly.
|
||||
public static int MAXIMUM_FURNI_SELECTION = 5;
|
||||
public static int TELEPORT_DELAY = 500;
|
||||
|
||||
private static GsonBuilder gsonBuilder = null;
|
||||
|
||||
private static ObjectMapper objectMapper = null;
|
||||
|
||||
public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
@ -253,13 +248,6 @@ public class WiredHandler {
|
||||
return executed;
|
||||
}
|
||||
|
||||
public static GsonBuilder getGsonBuilder() {
|
||||
if(gsonBuilder == null) {
|
||||
gsonBuilder = new GsonBuilder();
|
||||
}
|
||||
return gsonBuilder;
|
||||
}
|
||||
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
if(objectMapper == null) {
|
||||
objectMapper = new ObjectMapper();
|
||||
|
Loading…
Reference in New Issue
Block a user