From b1e9276940195de831692c4aac13d211598b2293 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 4 Jan 2021 06:12:20 -0500 Subject: [PATCH] WiredEffectMuteHabbo now saves as json --- .../wired/effects/WiredEffectMuteHabbo.java | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) 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 27a1d2b3..e6f7b020 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 @@ -79,19 +79,32 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { @Override public String getWiredData() { - return this.getDelay() + "\t" + this.length + "\t" + this.message; + return WiredHandler.getGsonBuilder().create().toJson(new JsonData( + this.getDelay(), + this.length, + this.message + )); } @Override public void loadWiredData(ResultSet set, Room room) throws SQLException { - String[] data = set.getString("wired_data").split("\t"); + String wiredData = set.getString("wired_data"); - if (data.length >= 3) { - try { - this.setDelay(Integer.valueOf(data[0])); - this.length = Integer.valueOf(data[1]); - this.message = data[2]; - } catch (Exception e) { + if (wiredData.startsWith("{")) { + JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); + this.setDelay(data.delay); + this.length = data.length; + this.message = data.message; + } else { + String[] data = wiredData.split("\t"); + + if (data.length >= 3) { + try { + this.setDelay(Integer.valueOf(data[0])); + this.length = Integer.valueOf(data[1]); + this.message = data[2]; + } catch (Exception e) { + } } } } @@ -112,4 +125,16 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { public boolean requiresTriggeringUser() { return true; } + + static class JsonData { + int delay; + int length; + String message; + + public JsonData(int delay, int length, String message) { + this.delay = delay; + this.length = length; + this.message = message; + } + } }