WiredTriggerRepeaterLong now saves as json

This commit is contained in:
Remco 2021-01-04 10:27:26 -05:00
parent 9b62b43907
commit eaeafd21ad

View File

@ -40,13 +40,22 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
@Override
public String getWiredData() {
return this.repeatTime + "";
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.repeatTime
));
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException {
if (set.getString("wired_data").length() >= 1) {
this.repeatTime = (Integer.valueOf(set.getString("wired_data")));
String wiredData = set.getString("wired_data");
if (wiredData.startsWith("{")) {
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.repeatTime = data.repeatTime;
} else {
if (wiredData.length() >= 1) {
this.repeatTime = (Integer.valueOf(wiredData));
}
}
if (this.repeatTime < 5000) {
@ -130,4 +139,12 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
}
}
}
static class JsonData {
int repeatTime;
public JsonData(int repeatTime) {
this.repeatTime = repeatTime;
}
}
}