🆙 Fix the multiple selections
This commit is contained in:
parent
505d2144fb
commit
f0be6533f0
@ -26,6 +26,7 @@ import java.util.stream.Collectors;
|
|||||||
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
||||||
protected THashSet<HabboItem> items;
|
protected THashSet<HabboItem> items;
|
||||||
|
private boolean all;
|
||||||
|
|
||||||
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
|
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -40,31 +41,44 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
this.all = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|
||||||
if (this.items.isEmpty())
|
if (this.items.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<Habbo> habbos = room.getHabbos();
|
Collection<Habbo> habbos = room.getHabbos();
|
||||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||||
|
|
||||||
|
if (this.all) {
|
||||||
return this.items.stream().allMatch(item -> {
|
return this.items.stream().allMatch(item -> {
|
||||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return this.items.stream().anyMatch(item -> {
|
||||||
|
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||||
|
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||||
|
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||||
|
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.all,
|
||||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -76,6 +90,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.all = data.all;
|
||||||
|
|
||||||
for(int id : data.itemIds) {
|
for(int id : data.itemIds) {
|
||||||
HabboItem item = room.getHabboItem(id);
|
HabboItem item = room.getHabboItem(id);
|
||||||
@ -88,6 +103,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
String[] data = wiredData.split(":");
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length >= 1) {
|
if (data.length >= 1) {
|
||||||
|
this.all = (data[0].equals("1"));
|
||||||
|
|
||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
@ -170,9 +186,11 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class JsonData {
|
static class JsonData {
|
||||||
|
boolean all;
|
||||||
List<Integer> itemIds;
|
List<Integer> itemIds;
|
||||||
|
|
||||||
public JsonData(List<Integer> itemIds) {
|
public JsonData(boolean all, List<Integer> itemIds) {
|
||||||
|
this.all = all;
|
||||||
this.itemIds = itemIds;
|
this.itemIds = itemIds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user