use of server.maps.AbstractMapleMapObject in project HeavenMS by ronancpl.
the class World method getAvailableItemBundles.
public List<Pair<MaplePlayerShopItem, AbstractMapleMapObject>> getAvailableItemBundles(int itemid) {
List<Pair<MaplePlayerShopItem, AbstractMapleMapObject>> hmsAvailable = new ArrayList<>();
for (MapleHiredMerchant hm : getActiveMerchants()) {
List<MaplePlayerShopItem> itemBundles = hm.sendAvailableBundles(itemid);
for (MaplePlayerShopItem mpsi : itemBundles) {
hmsAvailable.add(new Pair<>(mpsi, (AbstractMapleMapObject) hm));
}
}
for (MaplePlayerShop ps : getActivePlayerShops()) {
List<MaplePlayerShopItem> itemBundles = ps.sendAvailableBundles(itemid);
for (MaplePlayerShopItem mpsi : itemBundles) {
hmsAvailable.add(new Pair<>(mpsi, (AbstractMapleMapObject) ps));
}
}
Collections.sort(hmsAvailable, new Comparator<Pair<MaplePlayerShopItem, AbstractMapleMapObject>>() {
@Override
public int compare(Pair<MaplePlayerShopItem, AbstractMapleMapObject> p1, Pair<MaplePlayerShopItem, AbstractMapleMapObject> p2) {
return p1.getLeft().getPrice() - p2.getLeft().getPrice();
}
});
// truncates the list to have up to 200 elements
hmsAvailable.subList(0, Math.min(hmsAvailable.size(), 200));
return hmsAvailable;
}
use of server.maps.AbstractMapleMapObject in project HeavenMS by ronancpl.
the class MaplePacketCreator method owlOfMinerva.
public static byte[] owlOfMinerva(MapleClient c, int itemid, List<Pair<MaplePlayerShopItem, AbstractMapleMapObject>> hmsAvailable) {
byte itemType = ItemConstants.getInventoryType(itemid).getType();
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
// header.
mplew.writeShort(SendOpcode.SHOP_SCANNER_RESULT.getValue());
mplew.write(6);
mplew.writeInt(0);
mplew.writeInt(itemid);
mplew.writeInt(hmsAvailable.size());
for (Pair<MaplePlayerShopItem, AbstractMapleMapObject> hme : hmsAvailable) {
MaplePlayerShopItem item = hme.getLeft();
AbstractMapleMapObject mo = hme.getRight();
if (mo instanceof MaplePlayerShop) {
MaplePlayerShop ps = (MaplePlayerShop) mo;
MapleCharacter owner = ps.getOwner();
mplew.writeMapleAsciiString(owner.getName());
mplew.writeInt(owner.getMapId());
mplew.writeMapleAsciiString(ps.getDescription());
mplew.writeInt(item.getBundles());
mplew.writeInt(item.getItem().getQuantity());
mplew.writeInt(item.getPrice());
mplew.writeInt(owner.getId());
mplew.write(owner.getClient().getChannel() - 1);
} else {
MapleHiredMerchant hm = (MapleHiredMerchant) mo;
mplew.writeMapleAsciiString(hm.getOwner());
mplew.writeInt(hm.getMapId());
mplew.writeMapleAsciiString(hm.getDescription());
mplew.writeInt(item.getBundles());
mplew.writeInt(item.getItem().getQuantity());
mplew.writeInt(item.getPrice());
mplew.writeInt(hm.getOwnerId());
mplew.write(hm.getChannel() - 1);
}
mplew.write(itemType);
if (itemType == MapleInventoryType.EQUIP.getType()) {
addItemInfo(mplew, item.getItem(), true);
}
}
return mplew.getPacket();
}
Aggregations