BarAPI
BarAPI
Server Owners
This plugin does nothing on its own. It is simply an API for other plugins to implement with.
Developers
Simply add BarAPI.jar to your project build path.
This plugin makes use of reflection and therefore "shouldn't" break on craftbukkit updates.
Limitations
The message can not be more than 64 characters. If it is more, BarAPI will automatically cut it to 64 characters to prevent the client from crashing.
This is a client limitation and cannot be changed.
Examples
BarAPI.setMessage(Player player, String message)
Set a message for the player. It will remain there until the player logs off or another plugin overrides it.
BarAPI.setMessage(Player player, String message, float percent)
Same as above except you can set the % of the health bar. 100 shows the entire health bar, 50 shows half the health bar and so on.
BarAPI.setMessage(final Player player, String message, int seconds)
Sets a timed message for the player. It will remain until the timer runs out. The health automatically reduces based on how long the timer is.
BarAPI.hasBar(Player player)
Pretty self explanatory, returns a boolean.
BarAPI.removeBar(Player player)
Also pretty self explanatory.
BarAPI.setHealth(Player player, float percent)
Allows you to modify the health of an existing bar. If the player has no bar, this does nothing.
Tutorials
Source
Maven
<repositories> <repository> <id>confuser-repo</id> <url>http://ci.frostcast.net/plugin/repository/everything</url> </repository> </repositories> <dependencies> <dependency> <groupId>me.confuser</groupId> <artifactId>BarAPI</artifactId> <version>3.0</version> </dependency> </dependencies>
Developer Builds
These builds have not been approved by BukkitDev staff, therefore, use at your own risk.
Updater
This plugin contains an auto updater which is enabled by default. If you do not wish to automatically download new updates, edit BarAPI/config.yml and set autoUpdate to false.
To Dos
- Scroll messages if string is greater than 64 characters.
Plugins Using BarAPI
Metrics
To determine popularity and usage of BarAPI, plugin installs are automatically tracked by the Metrics plugin tracking system. Your Java version, OS, player count, server country location and plugin & server versions are collected. This is used to determine what environments are using the plugin to ensure full compatibility. This collection is anonymous. If you don't want this tracking, edit plugins/PluginMetrics/config.yml and set opt-out to true.
@NerdsWBNerds
Honestly, I've not tested it in the end so I can't give a definitive answer.
@confuser
What is the behavior of this plugin if a player is in the end with an enderdragon? If I try to use the api, will it work, will the end's actual enderdragon's stuff display or will the plugin work? If the API would work, how would I go about changing the name above the bar to what I want to display, but still display the enderdragons health?
@confuserr I want the bar show player HP like this http://m.imgur.com/2ubXVAQ Can you post the code for make that?
Hi
I have recently implemented BarAPI and have noticed a increase in lag. Previously we used our own system for the bar but it would disappear so we decided to try out BarAPI.
It seems to have lag bursts. Sometimes it will be fine and then all of a sudden the lag is unbearable. We are yet to determine why.
@joshwenke
This is an API for other plugins to implement. I won't be adding any commands or plugin-like functionality to it.
I would love to see a /setbar [message] where you could set a bar message with just a command. I think that would add a lot of functionality for server owners!
@MrTerrabyte
It would help if you posted the error message.
The download is broken! It comes up with error messages if I try to download the 1.6 or 1.7 versions!
@TheKingFalu
If you want a bar that represent a players hp you got to turn a double to a float like this;
(multiplies the 20 harts by 5 to equal 20 = 100 etc...)
@TheKingFalu
Use BarAPI.setMessage(Player player, String message, float percent)
So 10 hearts would be 100 percent, 9 hearts 90 percent and so on.
How can i make for setting of hearts into the bar api? ( Put the life in the bar, example show 10/10 ) Thanks :)
@tgndev
You receive an FPS drop when the enderdragon is removed?
@stonar96bukkit
Ensure you are using the v2.0 on your server.
@Tudedude
I would recommend posting on the bukkit forums for coding help rather than here. You'll get a quicker response.
When I do BarAPI.removeBars(p); (I think, i forget :) ) FPS Drop.
Hello, I have a problem, or maybe I found a bug. When I create a boss health bar and then teleport the player in another world, the boss health bar disappears and when I try to create a new one, it doesn't appear anymore. Only when I rejoin the server it works again and I can create a new boss health bar.
What should I do? Can you please fix this?
@confuserr
So, here is a question. I finally saw a error log on my previous code, and it was giving an error at the line, BarAPI.hasBar(player); How are you supposed to use hasBar, or do you even need to?
EDIT: Alright, so I found out I can be really idiotic. I forgot to add the BarAPI.jar into the plugin folder as a dependency... Scratch all of my above questions. But, I want to add a message from a config, so I made a String abMessage = getConfig().getString("abMessage"); and fed that in to a BarAPI.setMessage(player, abMessage); and it looked fine in Eclipse. When I loaded it, it returned an error saying, field "String" cannot be returned null. I defined the String in a player listener, so would it not pick up the config? If anyone has an answer, just reply to this, or drop me a pm.
I'm trying to set the percent of the bar to the health of the monster and its maximum health, however the bar always empties out when the method is called.
Here's my code:
int health = (int) plugin.cmm.getBoss(instancenumber).getHealth();
if(health == 0) return;
float barpercent = (health / 600) * 100;
BarAPI.setHealth(Bukkit.getPlayer(name), barpercent);
Hey, this is awesome! Works great, thanks.
i have a timer, and how to update it? i'm new to bukkit codings. thanks
@confuser
I knew it was something nooby, but even after doing that, it still doesn't work. I tested it by doing event.setJoinMessage("Welcome!"); but even that didn't show up. Here is my new code: http://pastebin.com/BcbUCbgV - AB.java http://pastebin.com/WqiTDczh - MyPlayerListener.java
I found the bug. After drawing if I do BarAPI.setHealth( players[ i ], time ); it does actually work. So there must be something wrong at the drawing with bar instantly