diff --git a/src/main/java/cn/lanink/crystalwars/supplier/SupplyConfigManager.java b/src/main/java/cn/lanink/crystalwars/supplier/SupplyConfigManager.java index 5dba6af..66fa07a 100644 --- a/src/main/java/cn/lanink/crystalwars/supplier/SupplyConfigManager.java +++ b/src/main/java/cn/lanink/crystalwars/supplier/SupplyConfigManager.java @@ -1,6 +1,7 @@ package cn.lanink.crystalwars.supplier; import cn.lanink.crystalwars.CrystalWars; +import cn.lanink.gamecore.utils.ZipUtils; import cn.nukkit.item.Item; import lombok.Getter; @@ -37,20 +38,16 @@ public static void loadAllSupplyConfig() { File dir = new File(CRYSTAL_WARS.getDataFolder(), "/Supply/"); if(!dir.exists()) { dir.mkdirs(); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/goldenApple.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/swordDiamond.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/swordIron.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/swordIronKnockback.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/swordStone.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/items/wool.yml"); - - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageBlock.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageQuickBuy.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageProp.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageTool.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageWeapon.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageFood.yml"); - CRYSTAL_WARS.saveResource("Supply/DefaultSupply/pages/pageArmor.yml"); + CRYSTAL_WARS.saveResource("Supply/DefaultSupply.data", true); + try { + ZipUtils.unzip(dir + "/DefaultSupply.data", dir.getAbsolutePath()); + File file = new File(dir, "/DefaultSupply.data"); + if(file.exists()) { + file.delete(); + } + } catch (Exception e) { + CRYSTAL_WARS.getLogger().error(CrystalWars.getInstance().getLang().translateString("supply_createDefaultSupplyError"), e); + } } final File[] files = dir.listFiles(); if(files == null) { diff --git a/src/main/resources/Resources/Language/en_US.properties b/src/main/resources/Resources/Language/en_US.properties index 1ebc2ab..0453762 100644 --- a/src/main/resources/Resources/Language/en_US.properties +++ b/src/main/resources/Resources/Language/en_US.properties @@ -102,6 +102,7 @@ buyItem_notInRoom=§c[Warning] You're not in a game room! buyItem_success=Success! buyItem_ReturnToMainPage=Return to Main Page themeManager_loadTemplate=%1% templates loaded +supply_createDefaultSupplyError=Default store configuration creation failed! Please try unzip the plugin configuration file manually! supply_loadShopConfig=%1% shops loaded! supply_loadItemsFailed="Item:%s% load failed, please check your config! supply_undefinedItemCost=Item:%1% 's cost is undefined! Player can buy it for free! diff --git a/src/main/resources/Resources/Language/zh_CN.properties b/src/main/resources/Resources/Language/zh_CN.properties index 388d3a6..65407c2 100644 --- a/src/main/resources/Resources/Language/zh_CN.properties +++ b/src/main/resources/Resources/Language/zh_CN.properties @@ -102,6 +102,7 @@ buyItem_notInRoom=§c[警告] 你没有加入任何游戏! buyItem_success=购买成功! buyItem_ReturnToMainPage=返回到主界面 themeManager_loadTemplate=成功加载 %1% 个模板 +supply_createDefaultSupplyError=默认商店配置创建失败!请尝试在插件配置文件手动解压! supply_loadShopConfig=已成功加载 %1% 个商店配置 supply_loadItemsFailed="物品:%s% 加载失败,请检查配置文件! supply_undefinedItemCost=物品:%1% 未设置成本!玩家可以免费获取! diff --git a/src/main/resources/Supply/DefaultSupply.data b/src/main/resources/Supply/DefaultSupply.data new file mode 100644 index 0000000..c4954fe Binary files /dev/null and b/src/main/resources/Supply/DefaultSupply.data differ diff --git a/src/main/resources/Supply/DefaultSupply/items/goldenApple.yml b/src/main/resources/Supply/DefaultSupply/items/goldenApple.yml deleted file mode 100644 index cd74537..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/goldenApple.yml +++ /dev/null @@ -1,10 +0,0 @@ -title: 金苹果 -item: "322:0" -count: 1 -subTitle: (3个金锭 x1) -pos: 9 -cost: - - "266:0x3" -lore: - - "吃了就会变强" -overtimeCanBuy: false \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/items/swordDiamond.yml b/src/main/resources/Supply/DefaultSupply/items/swordDiamond.yml deleted file mode 100644 index 48e1942..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/swordDiamond.yml +++ /dev/null @@ -1,8 +0,0 @@ -title: 钻石剑 -item: "276:0" -count: 1 -subTitle: (4个钻石 x1) -pos: 9 -cost: - - "264:0x4" -lore: [] \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/items/swordIron.yml b/src/main/resources/Supply/DefaultSupply/items/swordIron.yml deleted file mode 100644 index 3be8ebb..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/swordIron.yml +++ /dev/null @@ -1,8 +0,0 @@ -title: 铁剑 -item: "267:0" -count: 1 -subTitle: (6个金锭 x1) -pos: 9 -cost: - - "266:0x6" -lore: [] \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/items/swordIronKnockback.yml b/src/main/resources/Supply/DefaultSupply/items/swordIronKnockback.yml deleted file mode 100644 index 652389b..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/swordIronKnockback.yml +++ /dev/null @@ -1,12 +0,0 @@ -title: 铁剑(击退一) -item: "267:0" -count: 1 -subTitle: (20个金锭 x1) -pos: 9 -cost: - - "266:0x20" -lore: - - "击退一附魔的铁剑!" -enchantment: - - id: 12 - level: 1 \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/items/swordStone.yml b/src/main/resources/Supply/DefaultSupply/items/swordStone.yml deleted file mode 100644 index 3cbee10..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/swordStone.yml +++ /dev/null @@ -1,9 +0,0 @@ -title: 石剑 -item: "272:0" -count: 1 -subTitle: (10个铁锭 x1) -pos: 9 -cost: - - "265:0x10" -lore: - - "比木剑强一点" \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/items/wool.yml b/src/main/resources/Supply/DefaultSupply/items/wool.yml deleted file mode 100644 index 97fe1e2..0000000 --- a/src/main/resources/Supply/DefaultSupply/items/wool.yml +++ /dev/null @@ -1,9 +0,0 @@ -title: 羊毛 -item: "35:0" -count: 16 -subTitle: (5个铁锭 x16) -pos: 9 -cost: - - "265:0x5" -lore: - - "想变成你的形状~" \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageArmor.yml b/src/main/resources/Supply/DefaultSupply/pages/pageArmor.yml deleted file mode 100644 index e82abf7..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageArmor.yml +++ /dev/null @@ -1,33 +0,0 @@ -# 护甲页面 ---- -title: 护甲 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageBlock.yml b/src/main/resources/Supply/DefaultSupply/pages/pageBlock.yml deleted file mode 100644 index de48eb6..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageBlock.yml +++ /dev/null @@ -1,34 +0,0 @@ -# 方块页面 ---- -title: 方块 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: - - wool diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageFood.yml b/src/main/resources/Supply/DefaultSupply/pages/pageFood.yml deleted file mode 100644 index 413e05d..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageFood.yml +++ /dev/null @@ -1,34 +0,0 @@ -# 补给页面 ---- -title: 战斗补给 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: - - goldenApple \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageProp.yml b/src/main/resources/Supply/DefaultSupply/pages/pageProp.yml deleted file mode 100644 index 7eccab2..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageProp.yml +++ /dev/null @@ -1,34 +0,0 @@ -# 道具页面 ---- -title: 道具 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: - - goldenApple \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageQuickBuy.yml b/src/main/resources/Supply/DefaultSupply/pages/pageQuickBuy.yml deleted file mode 100644 index 6b16b33..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageQuickBuy.yml +++ /dev/null @@ -1,36 +0,0 @@ -# 快速购买 默认页面 ---- -title: 快速购买 -default: true -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: - - goldenApple - - wool diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageTool.yml b/src/main/resources/Supply/DefaultSupply/pages/pageTool.yml deleted file mode 100644 index 7f68a85..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageTool.yml +++ /dev/null @@ -1,33 +0,0 @@ -# 工具页面 ---- -title: 工具 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: \ No newline at end of file diff --git a/src/main/resources/Supply/DefaultSupply/pages/pageWeapon.yml b/src/main/resources/Supply/DefaultSupply/pages/pageWeapon.yml deleted file mode 100644 index ea3d8b1..0000000 --- a/src/main/resources/Supply/DefaultSupply/pages/pageWeapon.yml +++ /dev/null @@ -1,37 +0,0 @@ -# 武器页面 ---- -title: 武器 -linkItems: - "288:0": - pos: "0" - link: "pageQuickBuy" - afterClick: "399:0" - "35:0": - pos: "1" - link: "pageBlock" - afterClick: "399:0" - "341:0": - pos: "2" - link: "pageProp" - afterClick: "399:0" - "276:0": - pos: "3" - link: "pageWeapon" - afterClick: "399:0" - "260:0": - pos: "4" - link: "pageFood" - afterClick: "399:0" - "315:0": - pos: "5" - link: "pageArmor" - afterClick: "399:0" - "257:0": - pos: "6" - link: "pageTool" - afterClick: "399:0" -items: - - swordStone - - swordIron - - swordIronKnockback - - swordDiamond \ No newline at end of file