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.
AsyncWorldEdit uses this too
Can you make it so the Bar updates more frequently, please? Or eventually make it possible to change the interval between updates?
RemoveBar appears to be broken.
Edit: Error seems to be caused after /reload logging out fixes it.
where can i download it i am making a new server that is going to be awesome but i dont now how to download it here and instal it to the server
Psst, you might want to add SilkSpawners to the list of the plugins.
Will be included in the next release :)
As you've probably hear, Mojang changed their Username system to the UUID system. Will you support this?
Thanks, ~ Nathan
Thank you, it works great! Really easy to use and implement!
Just wanted to say thanks for making it open source!
Really cool! BukkitGames uses it.
Hey, not sure if this is possible, but could you make it so that instead of requiring a Player, you could use a Location
Hello, great API! Very useful and simple to put in! =) I have one small suggestion however. When utilizing your setMessage(player, message, seconds) to count down to the time a given event would occur, I found that there's no way to make the bar start somewhere in the middle. Perhaps this functionality wouldn't have an obvious use at first, so let me paint my scenario.
I have a bar that counts down until a boss mob respawns, however I don't want this bar to show server wide, only in the world of the boss. Therefore, as players enter and leave the world, I add and remove the bar as necessary. HOWEVER, when a player enters the world, there's no way to show that the bar is X percent done AND have it continue to count down.
Therefore I propose you add a new method signature setMessage(player, message, seconds, percent) that would be almost exactly the same as the above except that the initial dragon health would be based on the percent rather than defaulting to full health.
To keep from breaking other plugins, you can keep the old method signature and have it call the new one with a percent at 100.0f, thus retaining the old functionality. Looking at the code, this should be a pretty simple change, and I would make the change myself to add to your github but I can't seem to remember my github login credentials. If I manage to get on github I will make the changes and add it as a new issue.
Thanks for taking the time to consider my suggestion! =)
@uyghti123
I would like that too.
If it's not too much to ask, is there a way you can implement a way to catch what is said in the bar? I'm trying to use it for alot of things, but I'd like it so it doesn't override more important announcements on the BossBar
Example: Killing a player will show who killed you and the hearts the player was on. I also use it for announcing minigames and such, and I'd like it so when a player is killed, it won't override the minigame announcement.
Thanks, uyghti123 :)
@confuser
That's right :) Great API, thanks a lot!
@toropov023
That's pretty much what I've done on Frostcast Hunger Games. Far more efficient than a custom event :)
@confuser
I simply created a Bukkit Scheduler Repeating task that was updating the bar every second (20 ticks) with a time counter outside of it. So when the time counter reach 0 the task would cancel it self and call a specific method. Something like this: pastebin.com/eD8anGW3
@toropov023
I could call a custom event instead?
@victor2748
Yeah, makes sense. Anyways, I just managed to do it a bit differently
@toropov023
Bad idea! what if I want to breadcast a message with the word 'time'? Code it yourself!
sweet