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