diff --git a/.github/workflows/dispatch.yml b/.github/workflows/dispatch.yml index 9b46b2e..32191f7 100644 --- a/.github/workflows/dispatch.yml +++ b/.github/workflows/dispatch.yml @@ -7,7 +7,7 @@ jobs: steps: - name: 获取信息 id: get_info - run: echo "repository_name=`basename ${{ github.repository }}`" >> $GITHUB_OUTPUT + run: echo "repository_name=${GITHUB_REPOSITORY/${{ github.repository_owner }}\//}" >> $GITHUB_OUTPUT - name: 拉取代码 uses: actions/checkout@v3 - name: 安装java8 diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 8829707..d4a8ce3 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -7,7 +7,7 @@ jobs: steps: - name: 获取信息 id: get_info - run: echo "repository_name=`basename ${{ github.repository }}`" >> $GITHUB_OUTPUT + run: echo "repository_name=${GITHUB_REPOSITORY/${{ github.repository_owner }}\//}" >> $GITHUB_OUTPUT - name: 拉取代码 uses: actions/checkout@v3 - name: 安装java8 diff --git a/.github/workflows/tagpush.yml b/.github/workflows/tagpush.yml index 5eed1f0..6e42344 100644 --- a/.github/workflows/tagpush.yml +++ b/.github/workflows/tagpush.yml @@ -11,7 +11,7 @@ jobs: id: get_info run: | echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT - echo "repository_name=`basename ${{ github.repository }}`" >> $GITHUB_OUTPUT + echo "repository_name=${GITHUB_REPOSITORY/${{ github.repository_owner }}\//}" >> $GITHUB_OUTPUT - name: 拉取代码 uses: actions/checkout@v3 - name: 安装java8 diff --git a/README.md b/README.md index bf62f21..57d81e2 100644 --- a/README.md +++ b/README.md @@ -12,29 +12,6 @@ > **1、将插件放进`plugins`文件夹** > **2、需确保安装`Tips`插件后重启服务器** > **3、在`/plugins/NewTipsVariables`文件夹中的`.txt`文件获取相关变量介绍,也可在本页面获取相关的变量介绍** -## **[配置文件使用说明](./docs/config-info.md)** -## 变量介绍 -### **文字相关的变量** -|变量名|对应内容|变量名|对应内容|变量名|对应内容|变量名|对应内容| -|-|-|-|-|-|-|-|-| -|{text-s0}|§0|{text-s1}|§1|{text-s2}|§2|{text-s3}|§3| -|{text-s4}|§4|{text-s5}|§5|{text-s6}|§6|{text-s7}|§7| -|{text-s8}|§8|{text-s9}|§9|{text-sa}|§a|{text-sb}|§b| -|{text-sc}|§c|{text-sd}|§d|{text-se}|§e|{text-sf}|§f| -|{text-bold}|§l|{text-italic}|§o|{text-reset}|§r|{text-mess}|§k| -|{text-next}|\n|---|---|---|---|---|---| -### **玩家相关的变量** -|变量|介绍|变量|介绍| -|-|-|-|-| -|{Player-Xp}|获取玩家在游戏中的经验等级|{Device-Model}|获取玩家使用的设备型号| -|{XUID}|获取玩家的xuid|{Player-Lang}|获取玩家客户端使用的语言| -|{Player-Ui}|获取玩家客户端使用的UI|{Device-Os}|获取玩家设备的系统| -|{{Player-Uuid}|获取玩家的uuid|{Player-Ping}|获取玩家当前的延迟| -|{Player-Food}|玩家当前的饥饿度|{Player-Health}|玩家当前的血量| -### **服务器相关的变量** -|变量|介绍|变量|介绍| -|-|-|-|-| -|{Server-Motd}|获取服务器主motd|{Server-SubMotd}|获取服务器副motd| -|{Server-Ip}|获取服务器IP|{Server-Port}|获取服务器端口| -|{Server-Tps}|获取服务器当前TPS|---|---| -### **[支持的插件](./docs/SupportPluginsVariables.md)** \ No newline at end of file +### **[配置文件使用说明](./docs/config-info.md)** +### **变量介绍** +**[文字相关变量](./docs/text-variables.md) [玩家相关变量](./docs/player-variables.md) [服务器相关变量](./docs/server-variables.md) [支持的插件](./docs/SupportPluginsVariables.md)** \ No newline at end of file diff --git a/docs/SupportPluginsVariables.md b/docs/SupportPluginsVariables.md index e79d4ca..b986da2 100644 --- a/docs/SupportPluginsVariables.md +++ b/docs/SupportPluginsVariables.md @@ -1,6 +1,16 @@ -[返回](../README.md) [配置文件说明](./config-info.md) -# **NewTipsVariables(变量文档)** -> **支持的插件篇** +[![0](https://img.shields.io/badge/%3C%3D-%E8%BF%94%E5%9B%9E-a?style=plastic&color=yellow)](.././README.md) [![1](https://img.shields.io/badge/doc-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E-a?style=plastic&color=blue) +](./config-info.md) +# **变量文档(支持的插件)** +[![1](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%96%87%E5%AD%97%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue) +](./text-variables.md) +[![2](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E7%8E%A9%E5%AE%B6%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue) +](./player-variables.md) +[![3](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue) +](./server-variables.md) +[![4](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6-a?style=plastic) +](./SupportPluginsVariables.md) + +--- > **按插件的英文字母排序** > **TipsVeriable 相关变量移值中,部分变量名有改动** diff --git a/docs/config-info.md b/docs/config-info.md index 3161179..36fb5c7 100644 --- a/docs/config-info.md +++ b/docs/config-info.md @@ -1,4 +1,9 @@ -[返回](../README.md) [支持的插件](./SupportPluginsVariables.md) +[![0](https://img.shields.io/badge/%3C%3D-%E8%BF%94%E5%9B%9E-a?style=plastic&color=yellow)](.././README.md) [![1](https://img.shields.io/badge/doc-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E-a?style=plastic)](./config-info.md) [![1](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%96%87%E5%AD%97%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./text-variables.md) +[![2](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E7%8E%A9%E5%AE%B6%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./player-variables.md) +[![3](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./server-variables.md) +[![4](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6-a?style=plastic&color=blue)](./SupportPluginsVariables.md) + +--- # **配置文件使用说明** > **若未在此说明中写配置项出则代表该配置项还没有支持** ## **[config.yml](../src/main/resources/config.yml)** @@ -10,6 +15,12 @@ save-variables-doc: true > **1、该配置项启用后,服务器每次启动后都会生成新的变量文档** > **2、若关闭后,就算删除变量文档也不会生成新的变量文档** > **3、该配置项默认启用** +### **debug功能** +``` +debug: false +``` +> 1、这个功能默认关闭并不在配置文件中,需要手动填写 +> 2、把`debug: true`复制进`config.yml`即可启用 ## **[server.yml](../src/main/resources/server.yml)** > **服务器相关变量配置文件** ``` @@ -41,11 +52,9 @@ Device: Switch: "Switch" Xbox: "Xbox" Windows_Phone: "windows但是手机" - Unknown: "未知的系统" UIProfile: classic: "classic ui" pocket: "pocket ui" - Unknown: "Unknown ui ``` > 1、**```OS```玩家的设备系统** > 2、**```UIProfile```玩家的设备UI** @@ -57,19 +66,18 @@ ping: high_value: 120 high_color: "§c" HP: - symbols: "§7/" - low_color: "§c" + low_color: "§c{0}§7/§c{1}" medium_value: 9 - medium_color: "§e" + medium_color: "§e{0}§7/§e{1}" high_value: 15 - high_color: "§a" + high_color: "§a{0}§7/§a{1}" Food: - symbols: "§7/" - low_color: "§c" + empty_color: "§7{0}/{1}" + low_color: "§c{0}§7/§c{1}" medium_value: 9 - medium_color: "§e" + medium_color: "§e{0}§7/§e{1}" high_value: 15 - high_color: "§a" + high_color: "§a{0}§7/§a{1}" ``` > **1、```color```设置显示的颜色,```low```、```medium```、```high```为显示的范围** > **2、```value```是一个范围值,```medium```、```high```为可设置的范围值,```low```值只能为```0```** diff --git a/docs/player-variables.md b/docs/player-variables.md new file mode 100644 index 0000000..f1398d5 --- /dev/null +++ b/docs/player-variables.md @@ -0,0 +1,22 @@ +[![0](https://img.shields.io/badge/%3C%3D-%E8%BF%94%E5%9B%9E-a?style=plastic&color=yellow)](.././README.md) [![1](https://img.shields.io/badge/doc-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E-a?style=plastic&color=blue)](./config-info.md) +# **变量文档(玩家相关)** +[![1](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%96%87%E5%AD%97%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./text-variables.md) +[![2](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E7%8E%A9%E5%AE%B6%E7%9B%B8%E5%85%B3-a?style=plastic)](./player-variables.md) +[![3](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./server-variables.md) +[![4](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6-a?style=plastic&color=blue)](./SupportPluginsVariables.md) + +--- +|变量|介绍|备注| +|-|-|-| +|{Player-Xp}|获取玩家在游戏中的经验等级|| +|{Device-Model}|获取玩家使用的设备型号|| +|{XUID}|获取玩家的xuid|| +|{Player-Lang}|获取玩家客户端使用的语言|| +|{Player-Ui}|获取玩家客户端使用的UI|| +|{Device-Os}|获取玩家设备的系统|| +|{{Player-Uuid}|获取玩家的uuid|| +|{Player-Ping}|获取玩家当前的延迟|| +|{Player-Food}|获取玩家当前的饥饿度|| +|{Player-Health}|获取玩家当前的血量|| +|{Player-World}|获取玩家所在的世界|**需在world_name.yml配置**| +|{Player-Controls}|获取玩家设备的操作方式|| \ No newline at end of file diff --git a/docs/server-variables.md b/docs/server-variables.md new file mode 100644 index 0000000..48f4b58 --- /dev/null +++ b/docs/server-variables.md @@ -0,0 +1,16 @@ +[![0](https://img.shields.io/badge/%3C%3D-%E8%BF%94%E5%9B%9E-a?style=plastic&color=yellow)](.././README.md) [![1](https://img.shields.io/badge/doc-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E-a?style=plastic&color=blue)](./config-info.md) +# **变量文档(服务器相关)** +[![1](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%96%87%E5%AD%97%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./text-variables.md) +[![2](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E7%8E%A9%E5%AE%B6%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./player-variables.md) +[![3](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9B%B8%E5%85%B3-a?style=plastic)](./server-variables.md) +[![4](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6-a?style=plastic&color=blue)](./SupportPluginsVariables.md) + +--- +|变量|介绍|备注| +|-|-|-| +|{Server-Motd}|获取服务器主motd|| +|{Server-SubMotd}|获取服务器副motd|| +|{Server-Ip}|获取服务器IP|| +|{Server-Port}|获取服务器端口|| +|{Server-Tps}|获取服务器当前TPS|| +|{WorldOnline@世界名}|获取指定世界的人数|| \ No newline at end of file diff --git a/docs/text-variables.md b/docs/text-variables.md new file mode 100644 index 0000000..f86376f --- /dev/null +++ b/docs/text-variables.md @@ -0,0 +1,16 @@ +[![0](https://img.shields.io/badge/%3C%3D-%E8%BF%94%E5%9B%9E-a?style=plastic&color=yellow)](.././README.md) [![1](https://img.shields.io/badge/doc-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E-a?style=plastic&color=blue)](./config-info.md) +# **变量文档(文字相关)** +[![1](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%96%87%E5%AD%97%E7%9B%B8%E5%85%B3-a?style=plastic)](./text-variables.md) +[![2](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E7%8E%A9%E5%AE%B6%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./player-variables.md) +[![3](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9B%B8%E5%85%B3-a?style=plastic&color=blue)](./server-variables.md) +[![4](https://img.shields.io/badge/%E5%8F%98%E9%87%8F-%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6-a?style=plastic&color=blue)](./SupportPluginsVariables.md) + +--- +|变量名|对应内容|变量名|对应内容|变量名|对应内容|变量名|对应内容| +|-|-|-|-|-|-|-|-| +|{text-s0}|§0|{text-s1}|§1|{text-s2}|§2|{text-s3}|§3| +|{text-s4}|§4|{text-s5}|§5|{text-s6}|§6|{text-s7}|§7| +|{text-s8}|§8|{text-s9}|§9|{text-sa}|§a|{text-sb}|§b| +|{text-sc}|§c|{text-sd}|§d|{text-se}|§e|{text-sf}|§f| +|{text-bold}|§l|{text-italic}|§o|{text-reset}|§r|{text-mess}|§k| +|{text-next}|\n|---|---|---|---|---|---| \ No newline at end of file diff --git a/pom.xml b/pom.xml index db64ac2..4caf469 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.stevei5mc NewTipsVariables - 1.0.0-beta6 + 1.0.0-beta7 diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java b/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java index a01f1ac..4365071 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/Main.java @@ -15,9 +15,11 @@ public class Main extends PluginBase { public static Player player; private static Main instance; - private static Config config; - private static Config configInServer; - private static Config configInPlayer; + private Config config; + private Config configInServer; + private Config configInPlayer; + private Config worldName; + private Config language; public static Main getInstance() { return instance; } @@ -32,6 +34,7 @@ public void onEnable() { //判断需要的前置插件是否存在 if (this.getServer().getPluginManager().getPlugin("Tips") != null) { //存在则加载该插件 + this.deBugMode();//用于加载debug信息 this.tipsvariables();//加载变量部分 this.loadover();//加载完成显示的内容 } else { @@ -52,14 +55,18 @@ public void loadConfigRes() { this.saveDefaultConfig(); this.saveResource("server.yml",false); this.saveResource("player.yml",false); + this.saveResource("world_name.yml",false); + this.saveResource("language.yml",false); this.config = new Config(this.getDataFolder() + "/config.yml", Config.YAML); this.configInServer = new Config(this.getDataFolder() + "/server.yml", Config.YAML); this.configInPlayer = new Config(this.getDataFolder() + "/player.yml", Config.YAML); + this.worldName = new Config(this.getDataFolder() + "/world_name.yml", Config.YAML); + this.language = new Config(this.getDataFolder() + "/language.yml", Config.YAML); } public void loadVarRes() { boolean saveVariablesDoc = this.config.getBoolean("save-variables-doc"); - if (saveVariablesDoc == true) { + if (saveVariablesDoc) { //为true时就每次都加载最新的变量信息 this.saveResource("base-variables.txt",true); this.saveResource("SupportPluginsVariables.txt",true); @@ -67,6 +74,14 @@ public void loadVarRes() { } } + public void deBugMode() { + boolean deBug = this.config.getBoolean("debug", false); //这个功能默认关闭,不在config.yml中,需手动加上 + if (deBug) { + String debugPerfix = "§7[§cDEBUG§7] "; + this.getLogger().warning(debugPerfix + "§cdebug模式已开启"); + } + } + public void tipsvariables() { Api.registerVariables("tipsText", tipsText.class); Api.registerVariables("tipsServer", tipsServer.class); @@ -83,16 +98,19 @@ public void loadover() { this.getLogger().info("§a开源链接和使用方法: §bhttps://github.com/stevei5mc/NewTipsVariables"); } - @Override public Config getConfig() { return this.config; } - public Config getConfigInServer() { return this.configInServer; } - public Config getConfigInPlayer() { return this.configInPlayer; } + public Config getWorldName() { + return this.worldName; + } + public Config getLanguage() { + return this.language; + } } \ 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 bd512d4..7fe3ce2 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/supportPlugins/loadSupportPlugins.java @@ -7,55 +7,65 @@ 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; public class loadSupportPlugins { public static void loadSupportVariables(Player player) { + boolean debug = Main.getInstance().getConfig().getBoolean("debug", false); //加载相关插件的变量时的提示 - String loadSuccessMsg1 = "§a找到插件§e【§b"; - String loadSuccessMsg2 = "§e】§a相关变量已加载"; - String loadFailureMsg1 = "§c无法找到插件§e【§b"; - String loadFailureMsg2 = "§e】§c相关变量加载失败,请安装相关插件再试"; + String debugPerfix = "§7[§cDEBUG§7] "; + String loadPlugin; + String loadSuccessMsg = Main.getInstance().getLanguage().getString("debug_plugins_found"); + String loadFailureMsg = Main.getInstance().getLanguage().getString("debug_plugins_not_found"); //需要加载的变量的插件 - - String loadPlugin1 = "playerPoints"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin1) != null) { + loadPlugin = "playerPoints"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { //存在 Api.registerVariables("playerPointsVariable", playerPointsVariable.class); - Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin1 + loadSuccessMsg2); - } else { - //不存在 - Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin1 + loadFailureMsg2); - } + if (debug) { + Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin)); + } - String loadPlugin2 = "EconomyAPI"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin2) != null) { + } else { + if (debug) { + Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin)); + } + } + loadPlugin = "EconomyAPI"; + if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) { //存在 Api.registerVariables("economyApiVariable", economyApiVariable.class); - Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin2 + loadSuccessMsg2); - } else { - //不存在 - Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin2 + loadFailureMsg2); - } - - String loadPlugin3 = "OreArea"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin3) != null) { + 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); - Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin3 + loadSuccessMsg2); - } else { - //不存在 - Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin3 + loadFailureMsg2); - } - - String loadPlugin4 = "RSTask"; - if (Server.getInstance().getPluginManager().getPlugin(loadPlugin4) != null) { - //存在 + 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); - Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin4 + loadSuccessMsg2); - } else { - //不存在 - Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin4 + loadFailureMsg2); + if (debug) { + Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin)); + } + } else { + if (debug) { + Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin)); + } } } } \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayer.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayer.java index 1648fb6..13dd852 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayer.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayer.java @@ -1,7 +1,6 @@ package cn.stevei5mc.NewTipsVariables.variables; import cn.nukkit.Player; -import cn.nukkit.Server; import tip.utils.variables.BaseVariable; public class tipsPlayer extends BaseVariable { diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayerConfig.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayerConfig.java index d0ca869..7302c1f 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayerConfig.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsPlayerConfig.java @@ -1,7 +1,6 @@ package cn.stevei5mc.NewTipsVariables.variables; import cn.nukkit.Player; -import cn.nukkit.Server; import tip.utils.variables.BaseVariable; import cn.stevei5mc.NewTipsVariables.Main; @@ -15,127 +14,155 @@ public void strReplace() { } public void playerVarConfig() { - addStrReplaceString("{Device-Os}", this.mapDeviceOSToString(player.getLoginChainData().getDeviceOS())); - addStrReplaceString("{Player-Ui}", this.playerUiString(player.getLoginChainData().getUIProfile())); + addStrReplaceString("{Device-Os}", this.getDeviceOS(player.getLoginChainData().getDeviceOS())); + addStrReplaceString("{Player-Ui}", getPlayerUi(player.getLoginChainData().getUIProfile())); addStrReplaceString("{Player-Ping}", this.getPlayerPing(player)); addStrReplaceString("{Player-Food}", this.getPlayerFood(player)); addStrReplaceString("{Player-Health}", this.getPlayerHealth(player)); + addStrReplaceString("{Player-World}", this.getPlayerWorld(player)); + addStrReplaceString("{Player-Controls}",getDeviceControls(player.getLoginChainData().getCurrentInputMode())); } /*这ui档案应该只有classic ui和pocket ui这两种UI(测试出来的) Unknown UI是为了保险起见加上去的*/ - private String playerUiString(int uiprofile) { + public String getPlayerUi(int ui) { String classicUi = Main.getInstance().getConfigInPlayer().getString("Device.UIProfile.classic"); String pocketUi = Main.getInstance().getConfigInPlayer().getString("Device.UIProfile.pocket"); - String unknownUi = Main.getInstance().getConfigInPlayer().getString("Device.UIProfile.Unknown"); - switch (uiprofile) { + String unknownUi = Main.getInstance().getLanguage().getString("Unknown_Device_UIProfile"); + switch (ui) { case 0: return classicUi; case 1: return pocketUi; default: return unknownUi; } - } + } //获取玩家的饱食度状态 public static String getPlayerFood(Player player) { - String playerFoodSymbols = Main.getInstance().getConfigInPlayer().getString("Food.symbols"); - String playerFoodLowColor = Main.getInstance().getConfigInPlayer().getString("Food.low_color"); - int playerFoodMediumValue = Main.getInstance().getConfigInPlayer().getInt("Food.medium_value"); + String playerFoodEmptyColor = Main.getInstance().getConfigInPlayer().getString("Food.empty_color");//empty值 + String playerFoodLowColor = Main.getInstance().getConfigInPlayer().getString("Food.low_color");//low值 + int playerFoodMediumValue = Main.getInstance().getConfigInPlayer().getInt("Food.medium_value");//medium值 String playerFoodMediumColor = Main.getInstance().getConfigInPlayer().getString("Food.medium_color"); - int playerFoodHgihValue = Main.getInstance().getConfigInPlayer().getInt("Food.high_value"); + int playerFoodHgihValue = Main.getInstance().getConfigInPlayer().getInt("Food.high_value");//hgih值 String playerFoodHgihColor = Main.getInstance().getConfigInPlayer().getString("Food.high_color"); - String playerFood = playerFoodHgihColor + playerFoodHgihValue; + String playerFood; float foodValue = player.getFoodData().getLevel(); - int foodMaxValue = player.getFoodData().getMaxLevel(); - //最低值为0 - if (foodValue >= 0) { - playerFood = playerFoodLowColor + foodValue + playerFoodSymbols + playerFoodLowColor + foodMaxValue; - } - if (foodValue >= playerFoodMediumValue) { - playerFood = playerFoodMediumColor + foodValue + playerFoodSymbols + playerFoodMediumColor + foodMaxValue; - } + String foodValue2 = String.valueOf(foodValue); + String foodMaxValue = String.valueOf(player.getFoodData().getMaxLevel()); + //empty=0 low=1 if (foodValue >= playerFoodHgihValue) { - playerFood = playerFoodHgihColor + foodValue + playerFoodSymbols + playerFoodHgihColor + foodMaxValue; + playerFood = playerFoodHgihColor.replace("{0}",foodValue2).replace("{1}",foodMaxValue); + }else if (foodValue >= playerFoodMediumValue) { + playerFood = playerFoodMediumColor.replace("{0}",foodValue2).replace("{1}",foodMaxValue); + }else if (foodValue >= 1) { + playerFood = playerFoodLowColor.replace("{0}",foodValue2).replace("{1}",foodMaxValue); + }else { + playerFood = playerFoodEmptyColor.replace("{0}",foodValue2).replace("{1}",foodMaxValue); } return playerFood; } //获取玩家的生命值状态 public static String getPlayerHealth(Player player) { - String playerHealthSymbols = Main.getInstance().getConfigInPlayer().getString("HP.symbols"); - String playerHealthLowColor = Main.getInstance().getConfigInPlayer().getString("HP.low_color"); - int playerHealthMediumValue = Main.getInstance().getConfigInPlayer().getInt("HP.medium_value"); + String playerHealthLowColor = Main.getInstance().getConfigInPlayer().getString("HP.low_color");//low值 + int playerHealthMediumValue = Main.getInstance().getConfigInPlayer().getInt("HP.medium_value");//medium值 String playerHealthMediumColor = Main.getInstance().getConfigInPlayer().getString("HP.medium_color"); - int playerHealthHgihValue = Main.getInstance().getConfigInPlayer().getInt("HP.high_value"); + int playerHealthHgihValue = Main.getInstance().getConfigInPlayer().getInt("HP.high_value");//hgih值 String playerHealthHgihColor = Main.getInstance().getConfigInPlayer().getString("HP.high_color"); - String playerHealth = playerHealthHgihColor + playerHealthHgihValue; + String playerHealth; float healthValue = player.getHealth(); - int healthMaxValue = player.getMaxHealth(); - //最低值为0 - if (healthValue >= 0) { - playerHealth = playerHealthLowColor + healthValue + playerHealthSymbols + playerHealthLowColor + healthMaxValue; - } - if (healthValue >= playerHealthMediumValue) { - playerHealth = playerHealthMediumColor + healthValue + playerHealthSymbols + playerHealthMediumColor + healthMaxValue; - } + String healthValue2 = String.valueOf(healthValue); + String healthMaxValue = String.valueOf(player.getMaxHealth()); + //low=1 if (healthValue >= playerHealthHgihValue) { - playerHealth = playerHealthHgihColor + healthValue + playerHealthSymbols + playerHealthHgihColor + healthMaxValue; + playerHealth = playerHealthHgihColor.replace("{0}",healthValue2).replace("{1}",healthMaxValue); + }else if (healthValue >= playerHealthMediumValue) { + playerHealth = playerHealthMediumColor.replace("{0}",healthValue2).replace("{1}",healthMaxValue); + }else { + playerHealth = playerHealthLowColor.replace("{0}",healthValue2).replace("{1}",healthMaxValue); } return playerHealth; } - private String mapDeviceOSToString(int os) { - String osAndroid = Main.getInstance().getConfigInPlayer().getString("Device.OS.Android"); - String osIOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.iOS"); - String osMacOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.macOS"); - String osFireOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.Fire_OS"); - String osGearVR = Main.getInstance().getConfigInPlayer().getString("Device.OS.Gear_VR"); - String osHoloLens = Main.getInstance().getConfigInPlayer().getString("Device.OS.HoloLens"); - String osWindows10 = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows_10"); - String osWindows = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows"); - String osDedicated = Main.getInstance().getConfigInPlayer().getString("Device.OS.Dedicated"); - String osTvOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.tvOS"); - String osPlayStation = Main.getInstance().getConfigInPlayer().getString("Device.OS.PlayStation"); - String osSwitch = Main.getInstance().getConfigInPlayer().getString("Device.OS.Switch"); - String osXbox = Main.getInstance().getConfigInPlayer().getString("Device.OS.Xbox"); - String osWindowsPhone = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows_Phone"); - String osUnknown = Main.getInstance().getConfigInPlayer().getString("Device.OS.Unknown"); + //获取玩家设备的系统 + public String getDeviceOS(int os) { + String android = Main.getInstance().getConfigInPlayer().getString("Device.OS.Android"); + String iOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.iOS"); + String macOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.macOS"); + String fireOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.Fire_OS"); + String gearVR = Main.getInstance().getConfigInPlayer().getString("Device.OS.Gear_VR"); + String holoLens = Main.getInstance().getConfigInPlayer().getString("Device.OS.HoloLens"); + String windows10 = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows_10"); + String windows = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows"); + String dedicated = Main.getInstance().getConfigInPlayer().getString("Device.OS.Dedicated"); + String tvOS = Main.getInstance().getConfigInPlayer().getString("Device.OS.tvOS"); + String playStation = Main.getInstance().getConfigInPlayer().getString("Device.OS.PlayStation"); + String switchh = Main.getInstance().getConfigInPlayer().getString("Device.OS.Switch"); + String xbox = Main.getInstance().getConfigInPlayer().getString("Device.OS.Xbox"); + String windowsPhone = Main.getInstance().getConfigInPlayer().getString("Device.OS.Windows_Phone"); + String unknownOs = Main.getInstance().getLanguage().getString("Unknown_Device_OS"); switch (os) { - case 1: return osAndroid; - case 2: return osIOS; - case 3: return osMacOS; - case 4: return osFireOS; - case 5: return osGearVR; - case 6: return osHoloLens; - case 7: return osWindows10; - case 8: return osWindows; - case 9: return osDedicated; - case 10: return osTvOS; - case 11: return osPlayStation; - case 12: return osSwitch; - case 13: return osXbox; - case 14: return osWindowsPhone; - default: return osUnknown; + case 1: return android; + case 2: return iOS; + case 3: return macOS; + case 4: return fireOS; + case 5: return gearVR; + case 6: return holoLens; + case 7: return windows10; + case 8: return windows; + case 9: return dedicated; + case 10: return tvOS; + case 11: return playStation; + case 12: return switchh; + case 13: return xbox; + case 14: return windowsPhone; + default: return unknownOs; } } + //获取玩家的延迟 public static String getPlayerPing(Player player) { - String playerPingLowColor = Main.getInstance().getConfigInPlayer().getString("ping.low_color"); - int playerPingMediumValue = Main.getInstance().getConfigInPlayer().getInt("ping.medium_value"); + String playerPingLowColor = Main.getInstance().getConfigInPlayer().getString("ping.low_color");//low值 + int playerPingMediumValue = Main.getInstance().getConfigInPlayer().getInt("ping.medium_value");//medium值 String playerPingMediumColor = Main.getInstance().getConfigInPlayer().getString("ping.medium_color"); - int playerPingHgihValue = Main.getInstance().getConfigInPlayer().getInt("ping.high_value"); + int playerPingHgihValue = Main.getInstance().getConfigInPlayer().getInt("ping.high_value");//hgih值 String playerPingHgihColor = Main.getInstance().getConfigInPlayer().getString("ping.high_color"); - String playerMS = playerPingHgihColor + playerPingHgihValue; + String playerMS; int pingValue = player.getPing(); - //最低值为0 - if (pingValue >= 0) { - playerMS = playerPingLowColor + pingValue; - } - if (pingValue >= playerPingMediumValue) { - playerMS = playerPingMediumColor + pingValue; - } + //low=0 if (pingValue >= playerPingHgihValue) { playerMS = playerPingHgihColor + pingValue; - } + }else if (pingValue >= playerPingMediumValue) { + playerMS = playerPingMediumColor + pingValue; + }else { + playerMS = playerPingLowColor + pingValue; + } return playerMS; } + + //获取玩家所在的世界名 + public static String getPlayerWorld(Player player) { + String worldName = player.getLevel().getFolderName(); + String levelName = Main.getInstance().getWorldName().getString(worldName); + String unknownWorld = Main.getInstance().getLanguage().getString("Unknown_World").replace("{0}", worldName); + if (levelName == "") { + levelName = unknownWorld; + } + return levelName; + } + + //获取玩家的操作方式 + public static String getDeviceControls(int ctrl) { + String keyboard = Main.getInstance().getConfigInPlayer().getString("Device.Controls.Keyboard"); + String touch = Main.getInstance().getConfigInPlayer().getString("Device.Controls.Touch"); + String pad = Main.getInstance().getConfigInPlayer().getString("Device.Controls.pad"); + String motionController = Main.getInstance().getConfigInPlayer().getString("Device.Controls.motion_controller"); + String unknownCtrl = Main.getInstance().getLanguage().getString("Unknown_Device_controls"); + switch (ctrl) { + case 1: return keyboard; + case 2: return touch; + case 3: return pad; + case 4: return motionController; + default: return unknownCtrl; + } + } } \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServer.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServer.java index b4603cb..1ca1937 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServer.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServer.java @@ -3,6 +3,7 @@ import cn.nukkit.Player; import cn.nukkit.Server; import tip.utils.variables.BaseVariable; +import cn.nukkit.level.Level; public class tipsServer extends BaseVariable { public tipsServer(Player player) { @@ -18,5 +19,9 @@ public void serverVar() { addStrReplaceString("{Server-SubMotd}", Server.getInstance().getSubMotd()); addStrReplaceString("{Server-Ip}", Server.getInstance().getIp()); addStrReplaceString("{Server-Port}", String.valueOf(Server.getInstance().getPort())); + //参考了RsNpcVariable的写法 + for (Level level : Server.getInstance().getLevels().values()) { + addStrReplaceString("{WorldOnline@"+ level.getFolderName() +"}", String.valueOf(level.getPlayers().size())); + } } } \ No newline at end of file diff --git a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServerConfig.java b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServerConfig.java index 3d59b4f..521a26c 100644 --- a/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServerConfig.java +++ b/src/main/java/cn/stevei5mc/NewTipsVariables/variables/tipsServerConfig.java @@ -19,22 +19,20 @@ public void serverVarConfig() { } public static String getServerTps(Player player) { - String serverTpslowColor = Main.getInstance().getConfigInServer().getString("TPS.low_color"); - int serverTpsMediumValue = Main.getInstance().getConfigInServer().getInt("TPS.medium_value"); + String serverTpslowColor = Main.getInstance().getConfigInServer().getString("TPS.low_color");//low值 + int serverTpsMediumValue = Main.getInstance().getConfigInServer().getInt("TPS.medium_value");//medium值 String serverTpsMediumColor = Main.getInstance().getConfigInServer().getString("TPS.medium_color"); - int serverTpsHgihValue = Main.getInstance().getConfigInServer().getInt("TPS.high_value"); + int serverTpsHgihValue = Main.getInstance().getConfigInServer().getInt("TPS.high_value");//hgih值 String serverTpsHgihColor = Main.getInstance().getConfigInServer().getString("TPS.high_color"); - String serverTps = serverTpsHgihColor + serverTpsHgihValue; + String serverTps; float tpsValue = Server.getInstance().getTicksPerSecond(); - //最低值为0 - if (tpsValue >= 0) { - serverTps = serverTpslowColor + tpsValue; - } - if (tpsValue >= serverTpsMediumValue) { - serverTps = serverTpsMediumColor + tpsValue; - } + //low=0 if (tpsValue >= serverTpsHgihValue) { serverTps = serverTpsHgihColor + tpsValue; + }else if (tpsValue >= serverTpsMediumValue) { + serverTps = serverTpsMediumColor + tpsValue; + }else { + serverTps = serverTpslowColor + tpsValue; } return serverTps; } diff --git a/src/main/resources/base-variables.txt b/src/main/resources/base-variables.txt index bc798da..aa155e4 100644 --- a/src/main/resources/base-variables.txt +++ b/src/main/resources/base-variables.txt @@ -10,12 +10,14 @@ {Player-Food} 玩家当前的饥饿度 {Device-Model} 获取玩家使用的设备型号 {Player-Health} 玩家当前的血量 +{Player-World} 获取玩家所在的世界(需在world_name.yml配置) 服务器相关变量: {Server-Ip} 获取服务器IP {Server-Tps} 获取服务器当前TPS {Server-Port} 获取服务器端口 {Server-Motd} 获取服务器主motd {Server-SubMotd} 获取服务器副motd +{WorldOnline@世界名} 获取指定世界的人数 文字相关的: {text-s0} §0 {text-s1} §1 diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml new file mode 100644 index 0000000..18a246c --- /dev/null +++ b/src/main/resources/language.yml @@ -0,0 +1,6 @@ +Unknown_World: §c未知世界§6{0}§c,请检查是否在§6world_name.yml§c中填写! +Unknown_Device_OS: §c未知的系统 +Unknown_Device_controls: §c未知的操作方式 +Unknown_Device_UIProfile: §cUnknown ui +debug_plugins_found: §a找到插件§e【§b{0}§e】§a相关变量已加载 +debug_plugins_not_found: §c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试 \ No newline at end of file diff --git a/src/main/resources/player.yml b/src/main/resources/player.yml index b953968..f290200 100644 --- a/src/main/resources/player.yml +++ b/src/main/resources/player.yml @@ -3,11 +3,11 @@ version: 1 Device: OS: - Android: "安卓" - iOS: "苹果" - macOS: "苹果但是电脑" - Fire_OS: "Fire_OS" - Gear_VR: "Gear_VR" + Android: "Android" + iOS: "iOS" + macOS: "macOS" + Fire_OS: "Fire OS" + Gear_VR: "Gear VR" HoloLens: "HoloLens" Windows_10: "Windows 10" Windows: "Windows" @@ -16,12 +16,15 @@ Device: PlayStation: "PlayStation" Switch: "Switch" Xbox: "Xbox" - Windows_Phone: "windows但是手机" - Unknown: "未知的系统" + Windows_Phone: "Windows Phone" + Controls: + Keyboard: Keyboard + Touch: Touch + pad: pad + motion_controller: motion_controller UIProfile: classic: "classic ui" pocket: "pocket ui" - Unknown: "Unknown ui" ping: low_color: "§a" medium_value: 80 @@ -29,16 +32,15 @@ ping: high_value: 120 high_color: "§c" HP: - symbols: "§7/" - low_color: "§c" + low_color: "§c{0}§7/§c{1}" medium_value: 9 - medium_color: "§e" + medium_color: "§e{0}§7/§e{1}" high_value: 15 - high_color: "§a" + high_color: "§a{0}§7/§a{1}" Food: - symbols: "§7/" - low_color: "§c" + empty_color: "§7{0}/{1}" + low_color: "§c{0}§7/§c{1}" medium_value: 9 - medium_color: "§e" + medium_color: "§e{0}§7/§e{1}" high_value: 15 - high_color: "§a" \ No newline at end of file + high_color: "§a{0}§7/§a{1}" \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4060c5f..8cbc5e5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: NewTipsVariables main: cn.stevei5mc.NewTipsVariables.Main -version: '1.0.0-beta6' +version: '1.0.0-beta7' author: stevei5mc api: ["1.0.14"] \ No newline at end of file diff --git a/src/main/resources/world_name.yml b/src/main/resources/world_name.yml new file mode 100644 index 0000000..5a3ec58 --- /dev/null +++ b/src/main/resources/world_name.yml @@ -0,0 +1,2 @@ +testWorld1: 测试世界1 +testWorld2: 测试世界2 \ No newline at end of file