WiredEffectMuteHabbo now saves as json

This commit is contained in:
Remco 2021-01-04 06:12:20 -05:00
parent 9341d164a9
commit b1e9276940

View File

@ -79,19 +79,32 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
@Override @Override
public String getWiredData() { 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 @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").split("\t"); String wiredData = set.getString("wired_data");
if (data.length >= 3) { if (wiredData.startsWith("{")) {
try { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.setDelay(Integer.valueOf(data[0])); this.setDelay(data.delay);
this.length = Integer.valueOf(data[1]); this.length = data.length;
this.message = data[2]; this.message = data.message;
} catch (Exception e) { } 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() { public boolean requiresTriggeringUser() {
return true; 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;
}
}
} }