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.
@confuser
Nope. Spigot build 1225 failed. I remove the health bar before re-writing it if that matters. The bar isn't dropping down, nor flickering
@confuser
The SetMessage one with the "float percent"
@rickydaan
I'm currently using build 1225 on most of my servers. The bar timer works as expected without any flickers.
Which method is causing it to flicker?
@confuser
@Confuserr 1196, I think. If I have to update please tell me :)
@rickydaan
Which Spigot build?
Requesting: Spigot support! BUG: The health bar flickers all the time, and can't set health VERSION: Spigot (Must use Spigot due to BungeeCord) 1.7.2 R0.1
PROBLEM (Looked on the forums): Packets (Metadata has to be sent every tick(?))
@Tudedude
You need to register your listeners within onEnable otherwise bukkit won't know about your MyPlayerListener class.
@A5H73Y
Absolutely, I am probably making a terrible nooby mistake, but here is my code on Pastebin, just in case: http://pastebin.com/0KVjLhWu and http://pastebin.com/CbwtCJjQ
@Tudedude
Thats to do with your code, not the plugins API, are you sure you are putting it in a listener class, on the PlayerJoin event..?
@confuser
Okay, I actually knew that, so that was a stupid question for me to ask. What I was trying to ask, was actually more along the lines of this. How would I set the message from a config file? I tried BarAPI.setMessage(getConfig().getString("abMessage"); but it gives me an error asking to create a method for getConfig(). Thank you in advance. EDIT: I extended JavaPlugin and then implemented Listener, and modified the arguments, for player, string but now it won't give me errors, it just won't do anything. When I join the test server, nothing happens.
@minecraftsweat06
Replace this:
with
@Tudedude
This is simply an API. It only offers functionality to display the messages, it won't display anything itself without another plugin telling it to.
How would I make it, so that when a player joins it automatically sets the announcer message for them? Would you have to use a player join event handler, or would it automatically assign it?
@nuno1212sss
Simplest way:
This class is already packaged in Bukkit.
@nuno1212sss
If you are aiming for efficiency, use a StringBuilder instead.
@TheOneMadHawk
100% = 100, the method states percent ;)
Again, it states seconds, not ticks. It decreases every second.
I'm afraid not, but it would be rather simple for you to implement yourself.
@ShadowLAX
xD that's really long and kind of not efficient , why don't you try this, worked for me:
I have a question regarding the method
BarAPI.setMessage(Player player, String message, float percent)
100%=1.0
Which method is the right one to show a full bar?
BarAPI.setMessage(player, message, 100);
or
BarAPI.setMessage(player, message, 1.0);
another question
BarAPI.setMessage(final Player player, String message, int seconds)
does it decrease every second or every tick?
and is it possible to add a method using ticks?
BarAPI.setMessage(final Player player, String message, long ticks)
last question is it possible to add a new method like
BarAPI.setMessage(final Player player, String message, LivingEntity entity)
displaying the living entity's current health (and automatically update it).
For some reason the BarAPI.removeBar(Player player) method is not working like it should (I think?). I use this to remove the bar, but instead of completely removing it from the player's screen it just replaces it with an empty ender dragon bar. I think this is a bug, if not what am I doing wrong? Thanks!
EDIT: I figured out what I was doing wrong. >_<
Can someone give me a simple example on how to make a message show up when a player steps on a pressure plate?
Hmm Need a Little help here :/
http://dev.bukkit.org/paste/9025/
there seems to be a conversion mismatch when trying to display message arguments from cmbset to ALL Currently online players when args[0] is ALL
Anyone Help, i'm relatively new to Java
thanks :)