-
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.4.3</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.4.3</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 implements 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 implements 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);
Get the FakePlayerManager:
FakePlayerManager fakePlayerManager = BungeeTabListPlusAPI.getFakePlayerManager();
Enable disable fake players from the config randomly joining the game:
fakePlayerManager.setRandomJoinLeaveEnabled(true);
fakePlayerManager.setRandomJoinLeaveEnabled(false);
Get all fake players which are displayed in the tab list:
Collection<FakePlayer> onlineFakePlayers = fakePlayerManager.getOnlineFakePlayers();
Add a fake player to the tab list:
ServerInfo server = ...;
FakePlayer fakePlayer = fakePlayerManager.createFakePlayer("Name", server);
fakePlayer.setPing(47);
fakePlayer.setRandomServerSwitchEnabled(true);
fakePlayer.setSkin(BungeeTabListPlusAPI.getSkinForPlayer("Herobrine"));
Remove a fake player from the tab list:
fakePlayerManager.removeFakePlayer(fakePlayer);
If BungeeTabListPlus_SpongeBridge.jar is installed on your Sponge server it provides an API allowing developers register custom placeholders.
-
Add the BungeeTabListPlus dependency to your @Plugin annotation:
@Plugin(id = "your_id", name = "your_name", version = "your_version", dependencies = {@Dependency(id = "bungeetablistplus")})
or if you want your plugin to be able to run without BungeeTabListPlus being installed:
@Plugin(id = "your_id", name = "your_name", version = "your_version", dependencies = {@Dependency(id = "bungeetablistplus", optional = true)})
-
Add a dependency to the BungeeTabListPlus API to your maven project.
<dependency> <groupId>codecrafter47.bungeetablistplus</groupId> <artifactId>bungeetablistplus-sponge-bukkit</artifactId> <version>2.5.0</version> <scope>provided</scope> </dependency>
-
Create a class for your custom variable
import codecrafter47.bungeetablistplus.api.sponge.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 placeholder. You should do this during the POST_INITIALIZATION phase or later.
BungeeTabListPlusSpongeAPI.registerVariable(this, new TestVariable());