From 6db9fdb41b3067209bce92be066bc9f8f7ec71dd Mon Sep 17 00:00:00 2001 From: stevei5mc <2978383306@qq.com> Date: Thu, 4 Apr 2024 23:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E5=B0=86=E9=83=A8=E5=88=86=E6=8F=92=E4=BB=B6=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=94=BE=E5=9C=A8=E4=B8=80=E8=B5=B7=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E8=BF=87=E4=BA=8E=E5=88=86=E6=95=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- .../cn/stevei5mc/NewTipsVariables/Main.java | 2 + .../supportPlugins/SmallasWaterPlugins.java | 128 ++++++++++++++++++ .../supportPlugins/loadSupportPlugins.java | 56 ++------ .../smallasWater/HealthAPIVariable.java | 22 --- .../smallasWater/OreAreaVariable.java | 78 ----------- .../smallasWater/RsTaskVariable.java | 33 ----- .../smallasWater/playerPointsVariable.java | 19 --- 8 files changed, 145 insertions(+), 199 deletions(-) create mode 100644 src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/SmallasWaterPlugins.java delete mode 100644 src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/HealthAPIVariable.java delete mode 100644 src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/OreAreaVariable.java delete mode 100644 src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/RsTaskVariable.java delete mode 100644 src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/playerPointsVariable.java diff --git a/README.md b/README.md index 43c274d..03c7515 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ - **如果你有开发能力可以为其提供[PR](https://github.com/stevei5mc/NewTipsVariables/pulls)来增加更多变量或修复问题** ## **使用方法** -> **1、将插件放进`plugins`文件夹** -> **2、需确保安装`Tips`插件后重启服务器** -> **3、在`/plugins/NewTipsVariables`文件夹中的`.txt`文件获取相关变量介绍,也可在本页面获取相关的变量介绍** +1. **将插件放进`plugins`文件夹** +2. **需确保安装`Tips`插件后重启服务器** +3. **在`/plugins/NewTipsVariables`文件夹中的`.txt`文件获取相关变量介绍,也可在本页面获取相关的变量介绍** ### **[配置文件使用说明](./docs/config-info.md)** ### **变量介绍** **[文字相关变量](./docs/text-variables.md) [玩家相关变量](./docs/player-variables.md) [服务器相关变量](./docs/server-variables.md) [支持的插件](./docs/SupportPluginsVariables.md)** diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java b/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java index 9369bec..3049879 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java @@ -22,6 +22,7 @@ public class Main extends PluginBase { private Config configInPlayer; private Config worldName; private Config language; + public static boolean deBug = false; //定义配置文件的一些信息 public static int config1Version = 1; //config.yml public static int config2Version = 1; //player.yml @@ -86,6 +87,7 @@ public void loadVarRes() { public void deBugMode() { boolean deBug = this.config.getBoolean("debug", false); //这个功能默认关闭,不在config.yml中,需手动加上 if (deBug) { + deBug =t rue; String debugPerfix = "§7[§cDEBUG§7] "; this.getLogger().warning(debugPerfix + "§cdebug模式已开启"); } diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/SmallasWaterPlugins.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/SmallasWaterPlugins.java new file mode 100644 index 0000000..f691f54 --- /dev/null +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/SmallasWaterPlugins.java @@ -0,0 +1,128 @@ +package cn.stevei5mc.NewTipsVariables.variables.supportPlugins; + +import tip.utils.Api; +import cn.nukkit.Server; +import cn.nukkit.Player; +import cn.stevei5mc.NewTipsVariables.Main; +import tip.utils.variables.BaseVariable; +import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.loadSupportPlugins; +import healthapi.PlayerHealth; +import net.player.api.Point; +import com.task.utils.tasks.PlayerFile; +import com.task.utils.tasks.taskitems.PlayerTask; +import java.util.LinkedList; +import ore.area.utils.player.PlayerClass; +import ore.area.utils.area.AreaClass; +import ore.area.utils.Tools; +import ore.area.AreaMainClass; +import java.util.LinkedHashMap; + +public class SmallasWaterPlugins extends BaseVariable { + public SmallasWaterPlugins(Player player) { + super(player); + } + + public void strReplace() { + ruoShuiPlugins(); + } + + public void ruoShuiPlugins() { + String loadPlugin; + boolean debug = Main.deBug; + String loadSMsg = loadSupportPlugins.loadSuccessMsg; + String loadFMsg = loadSupportPlugins.loadFailureMsg; + //需要加载的变量的插件 + loadPlugin = "playerPoints"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { + //存在 + addStrReplaceString("{point}", String.format("%.2f", Point.myPoint(player))); + if (debug) {Main.getInstance().getLogger().info(loadSMsg.replace("{0}",loadPlugin));} + } else { + if (debug) {Main.getInstance().getLogger().info(loadFMsg.replace("{0}",loadPlugin));} + } + loadPlugin = "OreArea"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { + //这个代码的是复制TipsVeriable的 + PlayerClass playerClass = PlayerClass.getPlayerClass(player.getName()); + addStrReplaceString("{orearea-level-this}", playerClass.getMaxAreaLevel() + ""); + addStrReplaceString("{orearea-level-next}", playerClass.getMaxAreaLevel() + 1 + ""); + AreaClass areaClass = Tools.getDefaultArea(player, 2); + String time = "§c不在范围,无法获取可使用时间"; + String reset = "§c不在范围,无法获取刷新时间"; + String name = "§c没有解锁矿区"; + if(areaClass != null){ + if(AreaMainClass.getInstance().useTime.containsKey(player.getName())) { + LinkedHashMap map = AreaMainClass.getInstance().useTime.get(player.getName()); + if(map.containsKey(areaClass.getName())){ + int i = Math.round(map.get(areaClass.getName()) /60); + if(i != 0) { + time = "§7" +i + "§2分钟"; + }else{ + time = "§7" +areaClass.getUseTime() + "§2秒"; + } + } + }else{ + if(!areaClass.isKey()){ + time = "§c未开启"; + }else{ + if(playerClass.canKey(areaClass.getName())) { + if(areaClass.getUseTime() == -1) { + time = "§7无时限"; + }else{ + int i = Math.round(areaClass.getUseTime() /60); + if(i != 0) { + time = "§7" +i + "§2分钟"; + }else{ + time = "§7" +areaClass.getUseTime() + "§2秒"; + } + } + }else{ + time = "§c未解锁矿区"; + } + } + + } + if(AreaMainClass.timer.containsKey(areaClass.getName())) { + reset = String.valueOf(AreaMainClass.timer.get(areaClass.getName())); + }else{ + reset = "§c未刷新"; + } + name = areaClass.getName(); + } + addStrReplaceString("{orearea-time-use}", time); + addStrReplaceString("{orearea-time-reset}", reset); + addStrReplaceString("{orearea-name}", name); + if (debug) {Main.getInstance().getLogger().info(loadSMsg.replace("{0}",loadPlugin));} + } else { + if (debug) {Main.getInstance().getLogger().info(loadFMsg.replace("{0}",loadPlugin));} + } + loadPlugin = "RSTask"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { + PlayerFile file = PlayerFile.getPlayerFile(this.player.getName()); + LinkedList tasks = file.getInviteTasks(); + String taskName = "暂无"; + if (tasks.size() > 0) { + PlayerTask task = (PlayerTask)tasks.get(0); + if (task != null) { + taskName = task.getTaskName(); + } + } + + this.addStrReplaceString("{task-name}", taskName); + this.addStrReplaceString("{task-count}", file.getCount() + ""); + if (debug) {Main.getInstance().getLogger().info(loadSMsg.replace("{0}",loadPlugin));} + } else { + if (debug) {Main.getInstance().getLogger().info(loadFMsg.replace("{0}",loadPlugin));} + } + loadPlugin = "HealthAPI"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { + PlayerHealth health = PlayerHealth.getPlayerHealth(player); + addStrReplaceString("{h}", String.format("%.1f", health.getHealth())); + addStrReplaceString("{mh}", health.getMaxHealth() + ""); + addStrReplaceString("{hb}", String.format("%.2f", health.getHealthPercentage() * 100.0D)); + if (debug) {Main.getInstance().getLogger().info(loadSMsg.replace("{0}",loadPlugin));} + } else { + if (debug) {Main.getInstance().getLogger().info(loadFMsg.replace("{0}",loadPlugin));} + } + } +} \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java index cee5b3f..65c7030 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java @@ -4,59 +4,27 @@ import cn.nukkit.Server; import cn.nukkit.Player; import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.economyApiVariable; -import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.playerPointsVariable; -import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.OreAreaVariable; -import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.RsTaskVariable; import cn.stevei5mc.NewTipsVariables.Main; -import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.HealthAPIVariable; +import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.SmallasWaterPlugins; + +public class loadSupportPlugins{ + //加载相关插件的变量时的提示 + public static String debugPerfix = "§7[§cDEBUG§7] "; + public static String loadSuccessMsg = debugPerfix+"§a找到插件§e【§b{0}§e】§a相关变量已加载"; + public static String loadFailureMsg = debugPerfix+"§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试"; -public class loadSupportPlugins { - public static void loadSupportVariables(Player player) { - boolean debug = Main.getInstance().getConfig().getBoolean("debug", false); - //加载相关插件的变量时的提示 - String debugPerfix = "§7[§cDEBUG§7] "; - String loadPlugin; - String loadSuccessMsg = "§a找到插件§e【§b{0}§e】§a相关变量已加载"; - String loadFailureMsg = "§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试"; //需要加载的变量的插件 - loadPlugin = "playerPoints"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { - //存在 - Api.registerVariables("playerPointsVariable", playerPointsVariable.class); - if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));} - } else { - if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));} - } + String loadPlugin; + boolean debug = Main.deBug; loadPlugin = "EconomyAPI"; if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { //存在 Api.registerVariables("economyApiVariable", economyApiVariable.class); if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));} - } else { - if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));} - } - loadPlugin = "OreArea"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { - //存在 - Api.registerVariables("OreAreaVariable", OreAreaVariable.class); - if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));} - } else { - if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));} - } - loadPlugin = "RSTask"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { - Api.registerVariables("RsTaskVariable", RsTaskVariable.class); - if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));} - } else { - if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));} + } else if (debug){ + Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin)); } - loadPlugin = "HealthAPI"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { - Api.registerVariables("HealthAPIVariable", HealthAPIVariable.class); - if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));} - } else { - if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));} - } + Api.registerVariables("SmallasWaterPlugins", SmallasWaterPlugins.class); } } \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/HealthAPIVariable.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/HealthAPIVariable.java deleted file mode 100644 index b38f697..0000000 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/HealthAPIVariable.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater; - -import cn.nukkit.Player; -import tip.utils.variables.BaseVariable; -import healthapi.PlayerHealth; - -public class HealthAPIVariable extends BaseVariable { - public HealthAPIVariable(Player player) { - super(player); - } - - public void strReplace() { - HealthAPIVar(); - } - - public void HealthAPIVar() { - PlayerHealth health = PlayerHealth.getPlayerHealth(this.player); - this.addStrReplaceString("{h}", String.format("%.1f", health.getHealth())); - this.addStrReplaceString("{mh}", health.getMaxHealth() + ""); - this.addStrReplaceString("{hb}", String.format("%.2f", health.getHealthPercentage() * 100.0D)); - } -} \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/OreAreaVariable.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/OreAreaVariable.java deleted file mode 100644 index 13087a3..0000000 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/OreAreaVariable.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater; - -import cn.nukkit.Player; -import tip.utils.variables.BaseVariable; -import ore.area.utils.player.PlayerClass; -import ore.area.utils.area.AreaClass; -import ore.area.utils.Tools; -import ore.area.AreaMainClass; -import java.util.LinkedHashMap; - -public class OreAreaVariable extends BaseVariable { - public OreAreaVariable(Player player) { - super(player); - } - - public void strReplace() { - OreAreaVarPlayer(); - OreAreaVarArea(); - } - - public void OreAreaVarPlayer() { - //这个代码的是复制TipsVeriable的 - PlayerClass playerClass = PlayerClass.getPlayerClass(player.getName()); - addStrReplaceString("{orearea-level-this}", playerClass.getMaxAreaLevel() + ""); - addStrReplaceString("{orearea-level-next}", playerClass.getMaxAreaLevel() + 1 + ""); - } - - //参考(复制但有改动) https://github.com/SmallasWater/OreArea/blob/master/src/main/java/ore/area/utils/OreAreaVariable.java - public void OreAreaVarArea() { - AreaClass areaClass = Tools.getDefaultArea(player, 2); - String time = "§c不在范围,无法获取可使用时间"; - String reset = "§c不在范围,无法获取刷新时间"; - String name = "§c没有解锁矿区"; - if(areaClass != null){ - if(AreaMainClass.getInstance().useTime.containsKey(player.getName())) { - LinkedHashMap map = AreaMainClass.getInstance().useTime.get(player.getName()); - if(map.containsKey(areaClass.getName())){ - int i = Math.round(map.get(areaClass.getName()) /60); - if(i != 0) { - time = "§7" +i + "§2分钟"; - }else{ - time = "§7" +areaClass.getUseTime() + "§2秒"; - } - } - }else{ - if(!areaClass.isKey()){ - time = "§c未开启"; - }else{ - PlayerClass playerClass = PlayerClass.getPlayerClass(player.getName()); - if(playerClass.canKey(areaClass.getName())) { - if(areaClass.getUseTime() == -1) { - time = "§7无时限"; - }else{ - int i = Math.round(areaClass.getUseTime() /60); - if(i != 0) { - time = "§7" +i + "§2分钟"; - }else{ - time = "§7" +areaClass.getUseTime() + "§2秒"; - } - } - }else{ - time = "§c未解锁矿区"; - } - } - - } - if(AreaMainClass.timer.containsKey(areaClass.getName())) { - reset = String.valueOf(AreaMainClass.timer.get(areaClass.getName())); - }else{ - reset = "§c未刷新"; - } - name = areaClass.getName(); - } - addStrReplaceString("{orearea-time-use}", time); - addStrReplaceString("{orearea-time-reset}", reset); - addStrReplaceString("{orearea-name}", name); - } -} \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/RsTaskVariable.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/RsTaskVariable.java deleted file mode 100644 index c3a42d7..0000000 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/RsTaskVariable.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater; - -import cn.nukkit.Player; -import tip.utils.variables.BaseVariable; -import com.task.utils.tasks.PlayerFile; -import com.task.utils.tasks.taskitems.PlayerTask; -import java.util.LinkedList; - -public class RsTaskVariable extends BaseVariable { - public RsTaskVariable(Player player) { - super(player); - } - - public void strReplace() { - RsTaskVar(); - } - - public void RsTaskVar() { - //这个代码的是复制TipsVeriable的 - PlayerFile file = PlayerFile.getPlayerFile(this.player.getName()); - LinkedList tasks = file.getInviteTasks(); - String taskName = "暂无"; - if (tasks.size() > 0) { - PlayerTask task = (PlayerTask)tasks.get(0); - if (task != null) { - taskName = task.getTaskName(); - } - } - - this.addStrReplaceString("{task-name}", taskName); - this.addStrReplaceString("{task-count}", file.getCount() + ""); - } -} \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/playerPointsVariable.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/playerPointsVariable.java deleted file mode 100644 index e1f1737..0000000 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/smallasWater/playerPointsVariable.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater; - -import cn.nukkit.Player; -import tip.utils.variables.BaseVariable; -import net.player.api.Point; - -public class playerPointsVariable extends BaseVariable { - public playerPointsVariable(Player player) { - super(player); - } - - public void strReplace() { - playerPoint(); - } - - public void playerPoint() { - addStrReplaceString("{point}", String.format("%.2f", Point.myPoint(player))); //这个代码的是复制TipsVeriable的 - } -} \ No newline at end of file