1

Plugin Developer's Expertise Needed

Samstrongman's Avatar Samstrongman4/13/14 4:27 pm
1 emeralds 277 5
4/14/2014 6:07 pm
Blackveiled's Avatar Blackveiled
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.


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));
}
}
Posted by Samstrongman's Avatar
Samstrongman
Level 48 : Master Ninja
46

Create an account or sign in to comment.

5

Blackveiled
04/14/2014 6:07 pm
Level 12 : Journeyman Network
Blackveiled's Avatar
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));
}
1
Quaffle82
04/14/2014 5:59 pm
Level 46 : Master Lad
Quaffle82's Avatar
Errors being thrown?
1
Namizy
04/14/2014 5:57 pm
Level 12 : Journeyman Network
Namizy's Avatar
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
1
CoderMusgrove
04/14/2014 5:56 pm
Level 1 : New Crafter
CoderMusgrove's Avatar
This video contains the usage of BarAPI.
https://www.youtube.com/watch?v=XtBeQBRZikM
1
Namizy
04/14/2014 5:58 pm
Level 12 : Journeyman Network
Namizy's Avatar
It appears we had the same idea
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome