mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +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.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;
|
||||||
|
|
||||||
@ -64,18 +65,29 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.startDate + "\t" + this.endDate;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.startDate,
|
||||||
|
this.endDate
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 == 2) {
|
if (wiredData.startsWith("{")) {
|
||||||
try {
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
this.startDate = Integer.valueOf(data[0]);
|
this.startDate = data.startDate;
|
||||||
this.endDate = Integer.valueOf(data[1]);
|
this.endDate = data.endDate;
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
|
if (data.length == 2) {
|
||||||
|
try {
|
||||||
|
this.startDate = Integer.parseInt(data[0]);
|
||||||
|
this.endDate = Integer.parseInt(data[1]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,4 +97,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
|||||||
this.startDate = 0;
|
this.startDate = 0;
|
||||||
this.endDate = 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