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

German - DerFeliix

Source

GitHub

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.

Frostcast CI

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

WelcomeBar

Parkour

QuickSupport

BossBroadcast

BossMessage

PvPGames Automated

BossEventScheduler

Infernal Mobs

MythicMobs

MultiKill

PlayerBoss

BossAds

Item Lore Stats

BossBarPro

VIPLobby

Battle Of Blocks

BossBroadcaster

SilkSpawners

BarJoin

JoinGlobalMessages

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.

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of Difd9 Difd9 Oct 19, 2014 at 23:44 UTC - 0 likes

    @confuserr perhaps this may be of use... I hear a lot of people say it crashes their servers I have yet to try it https://github.com/mgone2010/BossbarAPI EDIT: Ok although it may help you it only takes 2 seconds to see how unstable the plugin is

    Last edited Oct 19, 2014 by Difd9
  • Avatar of Bars96 Bars96 Oct 19, 2014 at 22:29 UTC - 0 likes

    Bars not shown to players. My code:

    public final class OnlyCore extends JavaPlugin {
    	public static OnlyCore plugin;
    	boolean barapi = false;
    	long time = 0;
    	int mes = 0;
    
    	public void onEnable() {
    		try {
    			loadConfiguration();
    		} catch (IOException e) {
    			getLogger().info("[OnlyCore] Can't load config");
    		}
    
    		setupBarAPI();
    
    		if ((barapi) && (time >= 60L) && (tips.size() > 0)) {
    			getLogger().info("Loaded "+tips.size()+" messages to bar");
    			Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable() {
    				@Override
    				public void run() {
    					int length = tips.size();
    					String msg = ChatColor.translateAlternateColorCodes('&', tips.get(mes));
    					for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    						msg = msg.replace("%p", p.getName());
    						BarAPI.setMessage(p, msg);
    						BarAPI.setHealth(p, (mes/length*100F));
    					}
    
    					if (mes == length) mes = 0;
    					else mes++;
    				}
    			}, 20L, time);
    		}
    	}
    
    	public void onDisable() {
    	}
    
    	public void loadConfiguration() throws IOException {
    		File cfgFile = new File(this.getDataFolder() + File.separator + "config.yml");
    		YamlConfiguration config = YamlConfiguration.loadConfiguration(cfgFile);
    		if (barapi) {
    			tips.addAll(config.getStringList("tips.messages"));
    			time = config.getInt("tips.time") * 20L;
    		}
    	}
    
    	private void setupBarAPI() {
    		if (Bukkit.getServer().getPluginManager().isPluginEnabled("BarAPI")) {
    			barapi = true;
    			getLogger().info("BarAPI found, hooked");
    		}
    	}
    }
    
  • Avatar of Difd9 Difd9 Oct 19, 2014 at 18:00 UTC - 0 likes

    Humm well could you at least post the version on Jenkins

  • Avatar of confuserr confuserr Oct 19, 2014 at 12:00 UTC - 0 likes

    @Difd9: Go

    The wither has smoke and shield effects which I've not been able to completely disable at the moment.

  • Avatar of Difd9 Difd9 Oct 17, 2014 at 16:57 UTC - 0 likes

    @confuserr

    Could you perhaps spawn a invisible wither with no AI at the player to prevent the issue?

    Last edited Oct 17, 2014 by Difd9
  • Avatar of confuserr confuserr Oct 17, 2014 at 11:12 UTC - 0 likes

    @Difd9: Go

    This is not a 'flaw' of my plugin, it's a bug within the minecraft 1.8 client.

  • Avatar of Difd9 Difd9 Oct 16, 2014 at 19:58 UTC - 0 likes

    @confuserr underground the bar doesn't show up for 1.8 clients... this is a flaw of the API not any addons @JonasFranzDEV if you want you could look into writing a plugin for that

  • Avatar of Difd9 Difd9 Oct 15, 2014 at 00:09 UTC - 0 likes

    I found the author has 1.8 builds that fully support 1.8: http://ci.frostcast.net/job/BarAPI/

  • Avatar of JonasFranzDEV JonasFranzDEV Oct 14, 2014 at 11:40 UTC - 0 likes

    @Difd9: Go

    I updated it! Please ignore the exceptions they only come if you use 1.7.x but it works.

    BFAK:90882812,2c4f9f711e49fa8a3d5364f25952709d451240f93b7a7fe45bc28479b115783b

  • Avatar of Difd9 Difd9 Oct 13, 2014 at 21:28 UTC - 0 likes

    @JonasFranzDEV I cant find the version... if its the

    Name Description Size MD5 BarAPI.zip Look on Github for the newest ... 60.8 KiB 187c1cf34bad...

    thing it doesn't work and the console spam is just the same as @confuserr's version

Facts

Date created
Sep 01, 2013
Category
Last update
Apr 19, 2014
Development stage
Release
License
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Curse link
BarAPI
Downloads
314,315
Recent files

Authors