mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
WiredTriggerBotReachedFurni now saves as json
This commit is contained in:
parent
abe70991a0
commit
fd90c23a3a
@ -124,38 +124,45 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.botName + ":");
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.botName,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.botName = data.botName;
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length == 1) {
|
||||
this.botName = data[0];
|
||||
} else if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
if (data.length == 1) {
|
||||
this.botName = data[0];
|
||||
} else if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,4 +173,13 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
this.items.clear();
|
||||
this.botName = "";
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String botName;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(String botName, List<Integer> itemIds) {
|
||||
this.executeTime = executeTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user