Refine's TablistAPI | Custom
- Support for Custom Skins along with Dot Skins and Mob Skins
- Supports all spigot and client versions (1.7x to 1.20x).
- Lightweight with no performance overhead.
- Supports hex colors on supported versions.
- Periodically updating footer/header.
- 1.7 clients have a 32 char limit whilst 1.8+ clients have a 48 char limit.
- Easy to use.
You can either shade this repository into your plugin, or run it as a plugin by itself.
- Clone this repository
- Enter the directory:
cd TablistAPI - Build & install with Maven:
mvn clean package install
OR
<repositories>
<repository>
<id>refine-public</id>
<url>https://maven.refinedev.xyz/public-repo</url>
</repository>
</repositories>Next, add TablistAPI to your project's dependencies via Maven
Add this to your pom.xml<dependencies>:
<dependency>
<groupId>xyz.refinedev.api</groupId>
<artifactId>TablistAPI</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>It requires PacketEvents to be shaded in the plugin you are using this with. Please relocate Packet Events according to their guide in their wiki guide
I recommend registering tablist after any other scoreboard related API is registered because those APIs sometimes assign or override the player's scoreboard, which would be problematic here.
You can initiate and register a TablistAdapter using the following code:
importxyz.refinedev.api.tablist.TablistHandler;
importxyz.refinedev.api.tablist.adapter.impl.ExampleAdapter;
importxyz.refinedev.api.skin.SkinAPI;
importcom.github.retrooper.packetevents.PacketEventsAPI;
publicclassExamplePluginextendsJavaPlugin {
privateTablistHandlertablistHandler;
privatePacketEventsAPI<?> packetEvents;
privateSkinAPIskinAPI;
@OverridepublicvoidonEnable() {
//this.packetEvents.init();//this.skinAPI = new SkinAPI(plugin, gson);this.tablistHandler = newTablistHandler(plugin);
this.tablistHandler.init(this.packetEvents);
this.tablistHandler.setupSkinCache(this.skinAPI, true);
this.tablistHandler.registerAdapter(newExampleAdapter(tablist), 20L);
}
publicvoidonDisable() {
//this.skinAPI.unload();
}
}importxyz.refinedev.api.tablist.adapter.TabAdapter;
publicclassTablistAdapterimplementsTabAdapter {
/** * Get the tab header for a player. * * @param player the player * @return string */publicStringgetHeader(Playerplayer) { // String or you can use \n to use multiple linesreturn"Example";
} /** * Get the tab player for a player. * * @param player the player * @return string */publicStringgetFooter(Playerplayer) { // String or you can use \n to use multiple linesreturn"Example";
}
/** * Get the tab lines for a player. * * @param player the player * @return list of entries */publicList<TabEntry> getLines(Playerplayer) { // Tab Entry contains the string, skin, slot and ping of the tablist slotList<TabEntry> entries = newArrayList<>();
List<Player> players = newArrayList<>(Bukkit.getOnlinePlayers());
for ( inti = 0; i < 80; i++ ) {
finalintx = i % 4;
finalinty = i / 4;
if (players.size() <= i) continue;
PlayertabPlayer = players.get(i);
if (tabPlayer == null) continue;
entries.add(newTabEntry(x, y, tabPlayer.getDisplayName(), tabPlayer.spigot().getPing(), Skin.getPlayer(tabPlayer)));
}
returnentries;
}
}We don't plan on working on the API much, so don't expect support for bugs. If you need help with implementation, feel free to ask in our discord.
Feel free to use this API in any project, just give credits. You are not allowed to sell or claim ownership of this code. The code is provided as is and is property of Refine Development.