WiredEffectResetTimers now saves as json

This commit is contained in:
Remco 2021-01-04 06:20:28 -05:00
parent b1e9276940
commit 9b6ae05ac3

View File

@ -85,17 +85,25 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
@Override @Override
public String getWiredData() { public String getWiredData() {
return this.delay + ""; return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.delay
));
} }
@Override @Override
public void loadWiredData(ResultSet set, Room room) throws SQLException { public void loadWiredData(ResultSet set, Room room) throws SQLException {
String data = set.getString("wired_data"); String data = set.getString("wired_data");
try { if (data.startsWith("{")) {
if (!data.equals("")) JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.delay = Integer.valueOf(data); this.delay = data.delay;
} catch (Exception e) { } else {
try {
if (!data.equals("")) {
this.delay = Integer.valueOf(data);
}
} catch (Exception e) {
}
} }
this.setDelay(this.delay); this.setDelay(this.delay);
@ -111,4 +119,12 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
public WiredEffectType getType() { public WiredEffectType getType() {
return type; return type;
} }
static class JsonData {
int delay;
public JsonData(int delay) {
this.delay = delay;
}
}
} }