diff --git a/data/Shop.json b/data/Shop.json index 85d6ad9e8..9670b0bfc 100644 --- a/data/Shop.json +++ b/data/Shop.json @@ -1,86 +1,54 @@ [ { "shopId": 1004, - "goodsId": 1004202, - "goodsItem": { - "Id": 202, - "Count": 1000000 - }, - "scoin": 1, - "buyLimit": 500, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 - }, - { - "shopId": 1004, - "goodsId": 10048006, - "goodsItem": { - "Id": 108006, - "Count": 20 - }, - "scoin": 1, - "buyLimit": 50000, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 - }, - { - "shopId": 1004, - "goodsId": 10048033, - "goodsItem": { - "Id": 108033, - "Count": 20 - }, - "scoin": 1, - "buyLimit": 50000, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 - }, - { - "shopId": 1004, - "goodsId": 10040008, - "goodsItem": { - "Id": 220008, - "Count": 1 - }, - "scoin": 1, - "buyLimit": 1, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 - }, - { - "shopId": 1004, - "goodsId": 10044003, - "goodsItem": { - "Id": 104003, - "Count": 200 - }, - "scoin": 1, - "buyLimit": 50000, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 - }, - { - "shopId": 1004, - "goodsId": 10044013, - "goodsItem": { - "Id": 104013, - "Count": 200 - }, - "scoin": 1, - "buyLimit": 50000, - "beginTime": 1575129600, - "endTime": 2051193600, - "minLevel": 1, - "maxLevel": 99 + "items": [ + { + "goodsId": 1004202, + "goodsItem": { + "Id": 202, + "Count": 1000000 + }, + "scoin": 1, + "buyLimit": 500, + "beginTime": 1575129600, + "endTime": 2051193600, + "minLevel": 1, + "maxLevel": 99, + "costItemList": [ + { + "Id": 223, + "Count": 100 + } + ] + }, + { + "goodsId": 10048006, + "goodsItem": { + "Id": 108006, + "Count": 20 + }, + "scoin": 100, + "hcoin": 100, + "mcoin": 100, + "buyLimit": 50000, + "beginTime": 1575129600, + "endTime": 2051193600, + "minLevel": 1, + "maxLevel": 99 + }, + { + "goodsId": 10048033, + "goodsItem": { + "Id": 108033, + "Count": 20 + }, + "scoin": 1, + "buyLimit": 50000, + "beginTime": 1575129600, + "endTime": 2051193600, + "minLevel": 1, + "maxLevel": 99 + } + ] } ] \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/shop/ShopInfo.java b/src/main/java/emu/grasscutter/game/shop/ShopInfo.java index 510f0d479..b0e3b819b 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopInfo.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopInfo.java @@ -6,23 +6,22 @@ import java.util.ArrayList; import java.util.List; public class ShopInfo { - public int shopId = 1004; - public int goodsId = 0; - public ItemParamData goodsItem; - public int scoin = 0; - public List costItemList; - public int boughtNum = 0; - public int buyLimit = 0; - public int beginTime = 0; - public int endTime = 1924992000; - public int nextRefreshTime = 1924992000; - public int minLevel = 0; - public int maxLevel = 61; - public List preGoodsIdList = new ArrayList<>(); - public int mcoin = 0; - public int hcoin = 0; - public int disableType = 0; - public int secondarySheetId = 0; + private int goodsId = 0; + private ItemParamData goodsItem; + private int scoin = 0; + private List costItemList; + private int boughtNum = 0; + private int buyLimit = 0; + private int beginTime = 0; + private int endTime = 1924992000; + private int nextRefreshTime = 1924992000; + private int minLevel = 0; + private int maxLevel = 61; + private List preGoodsIdList = new ArrayList<>(); + private int mcoin = 0; + private int hcoin = 0; + private int disableType = 0; + private int secondarySheetId = 0; public int getHcoin() { return hcoin; @@ -64,14 +63,6 @@ public class ShopInfo { this.secondarySheetId = secondarySheetId; } - public int getShopId() { - return shopId; - } - - public void setShopId(int shopId) { - this.shopId = shopId; - } - public int getGoodsId() { return goodsId; } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopManager.java b/src/main/java/emu/grasscutter/game/shop/ShopManager.java index e591aa65e..63436e517 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopManager.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopManager.java @@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.io.FileReader; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -19,7 +18,7 @@ public class ShopManager { } private final Int2ObjectMap> shopData; - + public ShopManager(GameServer server) { this.server = server; this.shopData = new Int2ObjectOpenHashMap<>(); @@ -29,13 +28,10 @@ public class ShopManager { public synchronized void load() { try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) { getShopData().clear(); - List banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopInfo.class).getType()); + List banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopTable.class).getType()); if(banners.size() > 0) { - for (ShopInfo shopInfo : banners) { - if (!getShopData().containsKey(shopInfo.getShopId())) - getShopData().put(shopInfo.getShopId(), new ArrayList<>()); - getShopData().get(shopInfo.getShopId()).add(shopInfo); - Grasscutter.getLogger().info(String.format("Shop add: id [%d], data [%d*%d]", shopInfo.getShopId(), shopInfo.getGoodsItem().getId(), shopInfo.getGoodsItem().getCount())); + for (ShopTable shopTable : banners) { + getShopData().put(shopTable.getShopId(), shopTable.getItems()); } Grasscutter.getLogger().info("Shop data successfully loaded."); } else { diff --git a/src/main/java/emu/grasscutter/game/shop/ShopTable.java b/src/main/java/emu/grasscutter/game/shop/ShopTable.java new file mode 100644 index 000000000..7396cd028 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/shop/ShopTable.java @@ -0,0 +1,25 @@ +package emu.grasscutter.game.shop; + +import java.util.ArrayList; +import java.util.List; + +public class ShopTable { + private int shopId; + private List items = new ArrayList<>(); + + public int getShopId() { + return shopId; + } + + public void setShopId(int shopId) { + this.shopId = shopId; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } +}