Skip to content

Commit

Permalink
添加对HealthAPI的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
stevei5mc committed Apr 4, 2024
1 parent b531259 commit 9d4ff7c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
Binary file added lib/healthapi_v1.2.9.jar
Binary file not shown.
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<url>https://repo.lanink.cn/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>cn.nukkit</groupId>
Expand All @@ -58,19 +58,26 @@
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.smallaswater.orearea</groupId>
<groupId>com.smallaswater</groupId>
<artifactId>OreArea</artifactId>
<version>1.3.8</version>
<scope>system</scope>
<systemPath> ${project.basedir}/lib/OreArea_v1.3.8.jar</systemPath>
</dependency>
<dependency>
<groupId>com.smallaswater.rstask</groupId>
<groupId>com.smallaswater</groupId>
<artifactId>RsTask</artifactId>
<version>1.8.4</version>
<scope>system</scope>
<systemPath> ${project.basedir}/lib/RsTask_v1.8.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.samllaswater</groupId>
<artifactId>healthapi</artifactId>
<version>1.2.9</version>
<scope>system</scope>
<systemPath> ${project.basedir}/lib/healthapi_v1.2.9.jar</systemPath>
</dependency>
</dependencies>

<properties>
Expand All @@ -80,7 +87,6 @@

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -91,7 +97,6 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;

public class loadSupportPlugins {

Expand All @@ -23,49 +24,39 @@ public static void loadSupportVariables(Player player) {
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) {
//存在
Api.registerVariables("playerPointsVariable", playerPointsVariable.class);
if (debug) {
Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));
}

if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));}
} else {
if (debug) {
Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));
}
if (debug) {Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));}
}
loadPlugin = "EconomyAPI";
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin) != null) {
//存在
Api.registerVariables("economyApiVariable", economyApiVariable.class);
if (debug) {
Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));
}
if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));}
} else {
if (debug) {
Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));
}
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));
}
if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));}
} else {
if (debug) {
Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));
}
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));
}
if (debug) {Main.getInstance().getLogger().info(loadSuccessMsg.replace("{0}",loadPlugin));}
} else {
if (debug) {
Main.getInstance().getLogger().info(loadFailureMsg.replace("{0}",loadPlugin));
}
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));}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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));
}
}

0 comments on commit 9d4ff7c

Please sign in to comment.