From 277464b365a84aaeedf11cea0afaabdcf21b3072 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 22:30:17 +0100 Subject: [PATCH] WiredConditionMoreTimeElapsed now saves as JSON --- .../WiredConditionMoreTimeElapsed.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 a1fa3c5c..0be6ba15 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; +import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; @@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { @Override public String getWiredData() { - return this.cycles + ""; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.cycles + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String data = set.getString("wired_data"); + String wiredData = set.getString("wired_data"); try { - if (!data.equals("")) - this.cycles = Integer.valueOf(data); + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.cycles = data.cycles; + } else { + if (!wiredData.equals("")) + this.cycles = Integer.parseInt(wiredData); + } } catch (Exception e) { } } @@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { return true; } + + static class JsonData { + int cycles; + + public JsonData(int cycles) { + this.cycles = cycles; + } + } }