Developers

TabAPI - Developers

banner

main listeners dev faq change download

How to use


Simply download TabAPI then add it to your class path. You are now ready to start coding with the TabAPI!

There are a few static methods that will allow you full control of the Tab Menu

TabAPI.setTabString(Plugin, Player, vertloc, horizloc, ping);

- Set the string to be shown on the tab menu. HorizLoc and vertLoc are 0 based (ie (0,0) would be top left). Player is the player receiving this tabstring - use str + TabAPI.nextNull() to ensure the string is unique if there is a chance that it will be the same as another tab.

TabAPI.setPriority(Plugin, player, int);

- Sets the priority of this plugin. The plugin with highest priority will be displayed on the players tab list. Priorities are as follows.

  • -2 = no longer active, remove
  • -1 = background, only show if nothing else is there
  • 0 = normal
  • 1 = high
  • 2 = highest, always show

If you no longer want this tab to show for the player, send -2 to this method

TabAPI.disableTabForPlayer(Player);

resets this players tab to normal, assuming that this plugin holds highest priority NOT IMPLEMENTED

TabAPI.updatePlayer(Player);

- updates a players tab list. Must be called for changes to the tab list to take effect.

Examples

Example 1

Lets say you want your tab list to look something like this. This is a ingame scoreboard so you probably want your priority set to 1 or 2

012
0playeralive: 4dead: 5
1kills2
2deaths1

Your code might look something like

public void playerJoin(Player p){ //add player to the game, set their priority here
  TabAPI.setPriority(plugin, p, 2);
  TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
//other code
}

public void updateTab(Player p){ //update the tab for a player
  TabAPI.setTabString(plugin, p, 0, 0, "players");
  TabAPI.setTabString(plugin, p, 0, 1, "alive"+a);
  TabAPI.setTabString(plugin, p,0, 2,"dead"+d);

  TabAPI.setTabString(plugin, p,1, 0,"kills");
  TabAPI.setTabString(plugin, p, 1,1, playerkills);
  TabAPI.setTabString(plugin, p, 2,0, "deaths");
  TabAPI.setTabString(plugin, p, 1,1, playerdeaths);

  TabAPI.updatePlayer(p);

}

public void removePlayer(Player p){ //player died or left, return priority
  TabAPI.setPriority(plugin, p, -2); //-2 means this plugin isn't using the tab anymore, dont show
  TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
                                   
//other code

}

PlayerJoinEvent

There will be cases where you want to register a tab for a player when they login. The problem is the login/join events are fired before the player actually is on the server and will cause errors along the lines of cannot send packet, player isn't online etc. an easy workaround to this is to schedule a task to register the tab shortly after the player is online.

	public void PlayerJoin(PlayerJoinEvent e){
		final Player p = e.getPlayer();
		TabAPI.setPriority(plugin, p, 0);
		Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
			public void run(){
				updateTabList(p);
			}
		}, 3);
	}