mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 05:44:36 +01:00
Fix starlight/ember exchange stores
This commit is contained in:
@@ -2,8 +2,8 @@ package emu.lunarcore.data.excel;
|
||||
|
||||
import emu.lunarcore.data.GameResource;
|
||||
import emu.lunarcore.data.ResourceType;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -15,7 +15,7 @@ public class ShopExcel extends GameResource {
|
||||
private transient Int2ObjectMap<ShopGoodsExcel> goods;
|
||||
|
||||
public ShopExcel() {
|
||||
this.goods = new Int2ObjectOpenHashMap<>();
|
||||
this.goods = new Int2ObjectAVLTreeMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,9 @@ public class ShopGoodsExcel extends GameResource {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Skip if we dont have an item id associated with this goods excel
|
||||
if (this.getItemID() == 0) return;
|
||||
|
||||
// Add to shop excel
|
||||
ShopExcel shop = GameData.getShopExcelMap().get(this.ShopID);
|
||||
if (shop == null) return;
|
||||
|
||||
@@ -26,18 +26,20 @@ public class ShopService extends BaseGameService {
|
||||
ShopGoodsExcel goods = shop.getGoods().get(goodsId);
|
||||
if (goods == null) return null;
|
||||
|
||||
ItemExcel itemExcel = GameData.getItemExcelMap().get(goods.getItemID());
|
||||
if (itemExcel == null) return null;
|
||||
|
||||
// Verify item params
|
||||
if (!player.getInventory().verifyItems(goods.getCostList(), count)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Pay items
|
||||
// Handle payment
|
||||
player.getInventory().removeItemsByParams(goods.getCostList(), count);
|
||||
|
||||
// Buy items
|
||||
List<GameItem> items = new ArrayList<>();
|
||||
|
||||
ItemExcel itemExcel = GameData.getItemExcelMap().get(goods.getItemID());
|
||||
if (!itemExcel.isEquippable()) {
|
||||
GameItem item = new GameItem(itemExcel, goods.getItemCount() * count);
|
||||
items.add(item);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class PacketGetShopListScRsp extends BasePacket {
|
||||
.setShopType(shopType);
|
||||
|
||||
for (ShopExcel shopExcel : GameData.getShopExcelMap().values()) {
|
||||
if (shopExcel.getShopType() != shopType) {
|
||||
if (shopExcel.getShopType() != shopType || shopExcel.getGoods().size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PacketGetShopListScRsp extends BasePacket {
|
||||
.setShopId(shopExcel.getId())
|
||||
.setCityLevel(1)
|
||||
.setEndTime(Integer.MAX_VALUE);
|
||||
|
||||
|
||||
for (var goodsExcel : shopExcel.getGoods().values()) {
|
||||
shop.addGoodsList(goodsExcel.toProto());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user