WiredConditionMoreTimeElapsed now saves as JSON

This commit is contained in:
Remco 2021-01-04 22:30:17 +01:00
parent e6a5aaa279
commit 277464b365

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
@Override @Override
public String getWiredData() { public String getWiredData() {
return this.cycles + ""; return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.cycles
));
} }
@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 wiredData = set.getString("wired_data");
try { try {
if (!data.equals("")) if (wiredData.startsWith("{")) {
this.cycles = Integer.valueOf(data); JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.cycles = data.cycles;
} else {
if (!wiredData.equals(""))
this.cycles = Integer.parseInt(wiredData);
}
} catch (Exception e) { } catch (Exception e) {
} }
} }
@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
return true; return true;
} }
static class JsonData {
int cycles;
public JsonData(int cycles) {
this.cycles = cycles;
}
}
} }