Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
1. 删除变量文档中的空行
2、添加变量{Player-Health}的if判断
  • Loading branch information
stevei5mc committed Apr 28, 2024
1 parent de8334c commit 3ea2a73
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/main/java/cn/stevei5mc/NewTipsVariables/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cn.nukkit.plugin.PluginManager;
import tip.utils.Api;
import cn.stevei5mc.NewTipsVariables.variables.BaseVariables;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.loadSupportPlugins;
import cn.stevei5mc.NewTipsVariables.variables.LoadSupportPlugins;
import cn.nukkit.Player;
import cn.nukkit.utils.Config;
import cn.stevei5mc.NewTipsVariables.command.NewTipsVariablesCommand;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void deBugMode() {

public void tipsvariables() {
Api.registerVariables("BaseVariables", BaseVariables.class);
loadSupportPlugins.loadSupportVariables(player);
LoadSupportPlugins.loadSupportVariables(player);
}

public void loadover() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import cn.stevei5mc.NewTipsVariables.Main;
import cn.nukkit.Player;
import cn.nukkit.Server;
import healthapi.PlayerHealth;
import cn.stevei5mc.NewTipsVariables.variables.LoadSupportPlugins;

public class GetConfigInfo {
//获取服务器TPS
public static String getServerTps(Player player) {
Expand Down Expand Up @@ -60,9 +63,19 @@ public static String getPlayerHealth(Player player) {
int playerHealthHgihValue = Main.getInstance().getConfigInPlayer().getInt("HP.high_value");//hgih值
String playerHealthHgihColor = Main.getInstance().getConfigInPlayer().getString("HP.high_color");
String playerHealth;
float healthValue = player.getHealth();
String healthValue2 = String.valueOf(healthValue);
String healthMaxValue = String.valueOf(player.getMaxHealth());
double healthValue;
String healthValue2;
String healthMaxValue;
if (LoadSupportPlugins.pl5) {
PlayerHealth health = PlayerHealth.getPlayerHealth(player);
healthValue = health.getHealth();
healthValue2 = String.valueOf(healthValue);
healthMaxValue = String.valueOf(health.getMaxHealth());
}else {
healthValue = player.getHealth();
healthValue2 = String.valueOf(healthValue);
healthMaxValue = String.valueOf(player.getMaxHealth());
}
//low=1
if (healthValue >= playerHealthHgihValue) {
playerHealth = playerHealthHgihColor.replace("{0}",healthValue2).replace("{1}",healthMaxValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.stevei5mc.NewTipsVariables.variables.supportPlugins;
package cn.stevei5mc.NewTipsVariables.variables;

import tip.utils.Api;
import cn.nukkit.Server;
Expand All @@ -12,7 +12,8 @@
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.LevelAwakenSystemVariable;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.RSWeaponVariable;

public class loadSupportPlugins{
public class LoadSupportPlugins{
public static boolean pl5 = false;
//加载相关插件的变量时的提示
public static String debugPerfix = "§7[§cDEBUG§7] ";
public static String successMsg = debugPerfix+"§a找到插件§e【§b{0}§e】§a相关变量已加载";
Expand Down Expand Up @@ -55,6 +56,7 @@ public static void loadSupportVariables(Player player) {
plugin = "HealthAPI";
if (Server.getInstance().getPluginManager().getPlugin(plugin) != null) {
Api.registerVariables("HealthAPIVariable", HealthAPIVariable.class);
pl5 = true;
if (debug) {Main.getInstance().getLogger().info(successMsg.replace("{0}",plugin));}
} else if (debug) {
Main.getInstance().getLogger().info(failureMsg.replace("{0}",plugin));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,5 @@ public void HealthAPIVar() {
addStrReplaceString("{h}", String.format("%.1f", health.getHealth()));
addStrReplaceString("{mh}", health.getMaxHealth() + "");
addStrReplaceString("{hb}", String.format("%.2f", health.getHealthPercentage() * 100.0D));
addStrReplaceString("{Player-Health}", this.getPlayerHealth(player));//这个除外
}

public String getPlayerHealth(Player player) {
PlayerHealth health = PlayerHealth.getPlayerHealth(this.player);
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");//hgih值
String playerHealthHgihColor = Main.getInstance().getConfigInPlayer().getString("HP.high_color");
String playerHealth;
double healthValue = health.getHealth();
String healthValue2 = String.valueOf(healthValue);
String healthMaxValue = String.valueOf(health.getMaxHealth());
//low=1
if (healthValue >= playerHealthHgihValue) {
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;
}
}
4 changes: 0 additions & 4 deletions src/main/resources/SupportPluginsVariables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ NewTipsVariables(变量文档)

EconomyAPI
{economyApi-money} 玩家金钱数量

HealthAPI
{h} 玩家血量
{mh} 玩家血量上限
{hb} 玩家血量百分比

LevelAwakenSystem
{属性} 玩家的RPG属性
{天赋} 玩家评分
Expand All @@ -26,7 +24,6 @@ LevelAwakenSystem
{c} 玩家穿透
{饰品} 玩家当前装备的饰品
{pvp} 玩家PVP 状态 (暂时不可用)

OreArea
{orearea-level-this} 获取玩家的矿区等级
{orearea-level-next} 获取玩家的矿区下一等级
Expand All @@ -35,7 +32,6 @@ OreArea
{orearea-name} 获取玩家所在的矿区等级
playerPoints
{point} 获取玩家的点券数量

RsTask
{task-name} 正在进行中的任务 (显示第一个)
{task-count} 玩家任务积分
Expand Down

1 comment on commit 3ea2a73

@stevei5mc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充:
3. 调整了一个class的位置

Please sign in to comment.