mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
WiredConditionNotTriggerOnFurni now saves as JSON
This commit is contained in:
parent
190a5cf860
commit
ac1c6a3d9b
@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
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.RoomLayout;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
||||||
@ -44,28 +45,37 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder();
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
for (HabboItem item : this.items)
|
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.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("{")) {
|
||||||
|
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||||
|
|
||||||
for (String s : data) {
|
for(int id : data.itemIds) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(";");
|
||||||
|
|
||||||
|
for (String s : data) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -139,4 +149,12 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
|
|
||||||
this.items.removeAll(items);
|
this.items.removeAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user