Пытаюсь вывести продажу в комьюнити. Прикол в том, что окно продажи открывается, но продать туда ничего не получается. Под админом всё работает. Не могу понять в чем проблема.
Обработка байпасса:
public void onBypassCommand(Player player, String bypass) {
switch (bypass) {
case "_bbssell":
case "_bbs_itemsell":
if (!check(player))
return;
player.sendPacket(new ExBuyList(null, player), new ExBuySellList(player, false));
break;
}
}
Пакет ExBuyList
package org.mmocore.gameserver.network.lineage.serverpackets;
import org.mmocore.gameserver.model.buylist.BuyList;
import org.mmocore.gameserver.object.Player;
import java.util.Optional;
public class ExBuyList extends L2GameServerPacket {
private final int listId;
private final Optional<BuyList> buyList;
private final long adena;
public ExBuyList(final BuyList tradeList, final Player activeChar) {
adena = activeChar.getAdena();
if (tradeList != null) {
listId = tradeList.getListId();
buyList = Optional.of(tradeList);
activeChar.setBuyListId(listId);
} else {
listId = 0;
buyList = Optional.empty();
activeChar.setBuyListId(0);
}
}
@Override
protected void writeImpl() {
writeEx(0xB7);
writeD(0x00);
writeQ(adena); // current money
writeD(listId);
writeH(buyList.isPresent() ? buyList.get().getProducts().size() : 0);
if (buyList.isPresent()) {
buyList.get().getProducts().stream().filter(item -> item.getCount() > 0 || !item.hasLimitedStock()).forEach(item -> {
writeItemInfo(item);
writeQ(item.getPrice());
});
}
}
}
Пакет ExBuySellList
package org.mmocore.gameserver.network.lineage.serverpackets;
import org.mmocore.gameserver.object.Player;
import org.mmocore.gameserver.object.components.items.ItemInstance;
import org.mmocore.gameserver.object.components.items.TradeItem;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ExBuySellList extends L2GameServerPacket {
private final List<TradeItem> sellList;
private final List<TradeItem> refundList;
private final int done;
public ExBuySellList(final Player activeChar, final boolean done) {
this.done = done ? 1 : 0;
if (done) {
refundList = Collections.emptyList();
sellList = Collections.emptyList();
} else {
ItemInstance[] items = activeChar.getRefund().getItems();
refundList = new ArrayList<>(items.length);
for (final ItemInstance item : items) {
refundList.add(new TradeItem(item));
}
items = activeChar.getInventory().getItems();
sellList = new ArrayList<>(items.length);
for (final ItemInstance item : items) {
if (item.canBeSold(activeChar)) {
sellList.add(new TradeItem(item));
}
}
}
}
@Override
protected void writeImpl() {
writeEx(0xB7);
writeD(0x01);
writeH(sellList.size());
for (final TradeItem item : sellList) {
writeItemInfo(item);
writeQ(item.getReferencePrice() / 2);
}
writeH(refundList.size());
for (final TradeItem item : refundList) {
writeItemInfo(item);
writeD(item.getObjectId());
writeQ(item.getCount() * item.getReferencePrice() / 2);
}
writeC(done);
}
}