-
Notifications
You must be signed in to change notification settings - Fork 69
Developers
To get easy access to the required dependencies you should add my maven repository to your project.
<repository>
<id>codecrafter47-repo</id>
<url>http://nexus.codecrafter47.dyndns.eu/content/repositories/public/</url>
</repository>
If BungeeTabListPlus_BukkitBridge.jar is installed on the Bukkit server it provides an API allowing developers register custom variables.
-
Add this to plugin.yml:
depend: ['BungeeTabListPlus']
or if you want your plugin to be able to run without BungeeTabListPlus being installed add this:
softdepend: ['BungeeTabListPlus']
-
Add a dependency to the BungeeTabListPlus API to your maven project.
<dependency> <groupId>codecrafter47.bungeetablistplus</groupId> <artifactId>bungeetablistplus-api-bukkit</artifactId> <version>2.2</version> <scope>provided</scope> </dependency>
-
Create a class for your custom variable
import codecrafter47.bungeetablistplus.api.bukkit.Variable; public class TestVariable extends Variable { public TestVariable() { // name of the variable without { } super("test"); } @Override public String getReplacement(Player player) { // return the replacement for the variable return ...; } }
-
Register your variable in onEnable
BungeeTabListPlusBukkitAPI.registerVariable(this, new TestVariable());
The plugin provides an extensive API on BungeeCord allowing third party plugins to create custom variables as well as set a custom tab list for players.
Add this to bungee.yml (or plugin.yml):
depends: ['BungeeTabListPlus']
or if you only want to hook BungeeTabListPlus optionally use:
softDepends: ['BungeeTabListPlus']
Add a dependency to the BungeeTabListPlus API to your maven project.
<dependency>
<groupId>codecrafter47.bungeetablistplus</groupId>
<artifactId>bungeetablistplus-api-bungee</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
-
Create a class that extends PlaceholderProvider. This example registers a {gamemode} placeholder. A single PlaceholderProvider can register multiple Variables.
import codecrafter47.bungeetablistplus.api.bungee.placeholder.PlaceholderProvider; public class MyPlaceholderProvider extends PlaceholderProvider { @Override public void setup() { bind("gamemode").to(context -> getGamemodeName(context.getPlayer().getGamemode())); } private String getGamemodeName(int gamemode) { switch (gamemode){ case 0: return "survival"; case 1: return "creative"; case 2: return "adventure"; case 3: return "spectator"; default: return "unknown"; } } }
-
Register your PlaceholderProvider in onEnable.
BungeeTabListPlusAPI.registerPlaceholderProvider(new MyPlaceholderProvider());
-
Create a class that extends TabListProvider
import codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI; import codecrafter47.bungeetablistplus.api.bungee.tablist.Slot; import codecrafter47.bungeetablistplus.api.bungee.tablist.TabList; import codecrafter47.bungeetablistplus.api.bungee.tablist.TabListContext; import codecrafter47.bungeetablistplus.api.bungee.tablist.TabListProvider; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.lang.Override; class MyTabListProvider extends TabListProvider{ /** * This method is periodically invoked by BungeeTabListPlus to update the tablist. * <p> * This method must fill the tablist with it's content. It cannot change the size of * the tab list. * <p> * This method will not be invoked concurrently. * * @param player the player who will see the tab list * @param tabList an empty TabList * @param context the TabListContext */ @Override public void fillTabList(ProxiedPlayer player, TabList tabList, TabListContext context) { // set the header tabList.setHeader("&6Hi &5" + player.getDisplayName()); // set a slot tabList.setSlot(0, 0, new Slot("Test")); // set a slot with ping tabList.setSlot(0, 1, new Slot("Test ping", -1)); // set a slot with ping and skin tabList.setSlot(0, 1, new Slot("&7Herobrine skin!", -1, BungeeTabListPlusAPI.getSkinForPlayer("Herobrine"))); // set the ping to use for all slots we haven't filled tabList.setDefaultPing(0); // set the skin to use for all slots we haven't filled tabList.setDefaultSkin(BungeeTabListPlusAPI.getSkinForPlayer("MHF_ArrowRight")); } }
-
Apply your custom tab list to a player
BungeeTabListPlusAPI.setCustomTabList(player, new MyTabListProvider());
To remove the custom tab list from a player use
BungeeTabListPlusAPI.removeCustomTabList(player);