mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-19 07:56:26 +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
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.botName + ":");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.botName,
|
||||||
if (!this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
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) {
|
if (data.length == 1) {
|
||||||
this.botName = data[0];
|
this.botName = data[0];
|
||||||
} else if (data.length == 2) {
|
} else if (data.length == 2) {
|
||||||
this.botName = data[0];
|
this.botName = data[0];
|
||||||
|
|
||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
try {
|
try {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Caught exception", e);
|
LOGGER.error("Caught exception", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,4 +173,13 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
|||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.botName = "";
|
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