WiredTriggerAtSetTime now saves as json

This commit is contained in:
Remco 2021-01-04 07:53:32 -05:00
parent a849328412
commit 7c8789a124

View File

@ -39,13 +39,22 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
@Override
public String getWiredData() {
return this.executeTime + "";
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.executeTime
));
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException {
if (set.getString("wired_data").length() >= 1) {
this.executeTime = (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.executeTime = data.executeTime;
} else {
if (wiredData.length() >= 1) {
this.executeTime = (Integer.valueOf(wiredData));
}
}
if (this.executeTime < 500) {
@ -115,4 +124,12 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
}
static class JsonData {
int executeTime;
public JsonData(int executeTime) {
this.executeTime = executeTime;
}
}
}