diff --git a/src/main/java/com/yuyu/srappraise/SrAppraise.java b/src/main/java/com/yuyu/srappraise/SrAppraise.java index 3b26908..6678f32 100644 --- a/src/main/java/com/yuyu/srappraise/SrAppraise.java +++ b/src/main/java/com/yuyu/srappraise/SrAppraise.java @@ -2,6 +2,7 @@ package com.yuyu.srappraise; import com.sakurarealm.sritem.bukkit.command.CommandBase; import com.yuyu.srappraise.command.OpenCommand; +import com.yuyu.srappraise.config.ConfigManager; import lombok.Getter; import org.bukkit.ChatColor; import org.bukkit.plugin.java.JavaPlugin; @@ -10,14 +11,21 @@ public final class SrAppraise extends JavaPlugin { @Getter private static SrAppraise instance;//用于获取实例 + @Getter + private static ConfigManager configManager;//用于鉴定 @Override public void onEnable() { getLogger().info(ChatColor.MAGIC+"鉴定插件启动"); + //加载配置文件 + this.configManager = loadConfig(); + //注册指令 CommandBase commandBase = new CommandBase(); this.getCommand("srappraise").setExecutor(commandBase); commandBase.registerSubCommand("open",new OpenCommand()); + commandBase.registerSubCommand("reload",new OpenCommand()); + } @Override @@ -25,5 +33,9 @@ public final class SrAppraise extends JavaPlugin { // Plugin shutdown logic } + public ConfigManager loadConfig(){ + ConfigManager configManager1 = new ConfigManager(this); + return configManager1; + } } diff --git a/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java b/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java index 319c8d9..3dcde70 100644 --- a/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java +++ b/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java @@ -34,7 +34,7 @@ public class AppraiseManager { public void open(Player player,String guiName){ //获取鉴定的窗口 - AppraiseScreen screen = new AppraiseScreen(getAppraiseInventory(),guiName); + AppraiseGuiService screen = new AppraiseGuiService(getAppraiseInventory(),guiName); //获取gui的配置,此处会把读取到的gui配置传到ForgeScreen的构造类中 GermGuiScreen packscreen = GermGuiScreen.getGermGuiScreen("player_inventory-forge", getForgePlayerInventory()); @@ -42,6 +42,5 @@ public class AppraiseManager { //为玩家打开鉴定窗口和背包窗口 packscreen.openGui(player); screen.openChildGui(player); - } } diff --git a/src/main/java/com/yuyu/srappraise/command/OpenCommand.java b/src/main/java/com/yuyu/srappraise/command/OpenCommand.java index d016d99..9f4dfd5 100644 --- a/src/main/java/com/yuyu/srappraise/command/OpenCommand.java +++ b/src/main/java/com/yuyu/srappraise/command/OpenCommand.java @@ -1,6 +1,7 @@ package com.yuyu.srappraise.command; import com.sakurarealm.sritem.bukkit.command.SubCommand; +import com.yuyu.srappraise.SrAppraise; import com.yuyu.srappraise.appraise.AppraiseManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -19,6 +20,13 @@ import org.bukkit.entity.Player; public class OpenCommand implements SubCommand { @Override public void onCommand(CommandSender commandSender, String[] strings) { + if (strings.length == 1){ + if (strings[0].equalsIgnoreCase("reload")){ + SrAppraise.getConfigManager().reloadConfig(); + commandSender.sendMessage(ChatColor.GREEN+"SrAppraise文件重载成功"); + return; + } + } if (strings.length < 3){ commandSender.sendMessage(ChatColor.RED+"正确的格式为:/srappraise open 姓名 GUIname"); diff --git a/src/main/resources/AppraiseItem.yml b/src/main/resources/AppraiseItem.yml index 6d64434..798279c 100644 --- a/src/main/resources/AppraiseItem.yml +++ b/src/main/resources/AppraiseItem.yml @@ -1,5 +1,4 @@ SrItem: Appraise: - - 巴尔伐楼伽的怨牙 #这下面填上可以鉴定的物品的名称 - - 环齿原胚 + - 巴尔伐楼伽的怨牙 #这下面填上可以鉴定的物品的名称 diff --git a/src/main/resources/ItemAppraiseProduct.yml b/src/main/resources/ItemAppraiseProduct.yml index f597a7b..4dcf9df 100644 --- a/src/main/resources/ItemAppraiseProduct.yml +++ b/src/main/resources/ItemAppraiseProduct.yml @@ -1,6 +1,10 @@ SrItem: 巴尔伐楼伽的怨牙: #这一行填可以鉴定的物品 环齿原胚: #这下面填鉴定物品可以得到的结果 - probability: 0.2 #概率,每个可以鉴定的物品下面的概率和要为1,不然可能出现没有鉴定无结果的可能 + probabilityMax: 0.4 #概率,相当于一个转盘,多少到多少是这个产物,必定会有结果,比如[0,0.4],左闭右开的范围区间,若随机到0则为此产物,0.4则跳过 + probabilityMin: 0 #概率,相当于一个转盘,多少到多少是这个产物,必定会有结果,比如[0,0.4],左闭右开的范围区间,若随机到0则为此产物,0.4则跳过 + index: public.material.巴尔伐楼伽的怨牙 #这里填材料的索引名 保密试作品HC-03原胚: #这下面填鉴定物品可以得到的结果 - probability: 0.8 #概率 \ No newline at end of file + probabilityMax: 1 #概率 + probabilityMin: 0.4 #概率 + index: public.test.保密试作品HC-03原胚 #这里填材料的索引名