mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
WiredConditionDateRangeActive now saves as JSON
This commit is contained in:
parent
069bffb907
commit
0769e85a27
@ -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.RoomUnit;
|
||||
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.ServerMessage;
|
||||
|
||||
@ -64,25 +65,46 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.startDate + "\t" + this.endDate;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.startDate,
|
||||
this.endDate
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.startDate = data.startDate;
|
||||
this.endDate = data.endDate;
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 2) {
|
||||
try {
|
||||
this.startDate = Integer.valueOf(data[0]);
|
||||
this.endDate = Integer.valueOf(data[1]);
|
||||
this.startDate = Integer.parseInt(data[0]);
|
||||
this.endDate = Integer.parseInt(data[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.startDate = 0;
|
||||
this.endDate = 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int startDate;
|
||||
int endDate;
|
||||
|
||||
public JsonData(int startDate, int endDate) {
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user