mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
WiredConditionHabboCount now saves as JSON
This commit is contained in:
parent
da751cca42
commit
4d10af2b41
@ -5,6 +5,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;
|
||||
|
||||
@ -34,15 +35,26 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.lowerLimit + ":" + this.upperLimit;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
this.lowerLimit = Integer.valueOf(data[0]);
|
||||
this.upperLimit = Integer.valueOf(data[1]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
this.lowerLimit = Integer.parseInt(data[0]);
|
||||
this.upperLimit = Integer.parseInt(data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,4 +94,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
public JsonData(int lowerLimit, int upperLimit) {
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user