1
Plugin Developer's Expertise Needed
I've been working on a plugin and it won't work no matter what. I'm using the BarAPI to utilize the Ender Dragons health bar but for players on the server. I wrote the code and don't see an issue in it, but the health bar still won't display on the server. Could someone see what's the matter with it please?
I'm using Eclipse, the latest development CraftBukkit and BarAPI version.3
This is the code for the health bar that won't work.
I'm using Eclipse, the latest development CraftBukkit and BarAPI version.3
This is the code for the health bar that won't work.
package me.samuel.healthbar;
import me.confuser.barapi.BarAPI;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class HealthMain extends JavaPlugin implements Listener{
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onHealthUpEvent(EntityRegainHealthEvent event) {
if(event.getEntity().equals(EntityType.PLAYER)) {
Player p = (Player) event.getEntity();
Damageable player = p ;
BarAPI.setMessage(p, "Health Bar",(float) ((((player.getHealth() + 1) / player.getMaxHealth())) * 100));
}
}
Create an account or sign in to comment.
5
Here:
@EventHandler
public void onHealthUpEvent(EntityRegainHealthEvent event) {
if(event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
Damageable player = (Damageable) p ;
BarAPI.setMessage(p, "Health Bar",(float) ((((player.getHealth() + 1) / player.getMaxHealth())) * 100));
}
Errors being thrown?
It appears you are using the BarAPI. I would recomend that you use this tutorial or usage to set this up:
https://www.youtube.com/watch?v=XtBeQBRZikM
https://www.youtube.com/watch?v=XtBeQBRZikM
This video contains the usage of BarAPI.
https://www.youtube.com/watch?v=XtBeQBRZikM
https://www.youtube.com/watch?v=XtBeQBRZikM
It appears we had the same idea