✏️
PlayerListDeluxe
  • Introduction
  • Troubleshoot
  • Configuration
    • Understanding the Config Element
    • Tablist Handlers
    • Sorting Feature
    • Migrating from PlayerListPlus
  • FAKE PLAYER
    • Managing Fake Player
    • Fake Player Placeholder
  • HOW TO
    • Where to put Handler?
    • How to add/remove column
    • Create Staff/VIP Handler
    • Prevent Same Player Showing in 2 Handler
    • Sort Player By Name and Etc
    • List of Player that in Same or in A World
    • Condition Tutorial
  • PLACEHOLDER
    • Using Placeholder From PlaceholderAPI
    • Custom Placeholders
  • API
    • Creating Complex Placeholder
    • Creating Parameterized Placeholder
    • Creating Simple Placeholder
    • Managing your own Tablist
    • Events
    • Skin Toolkit
Powered by GitBook
On this page
  • Introduction
  • Disabling PlayerListDeluxe's Tablist
  • Showing Tablist to Player
  • Set the Tablist Layout
  • Set the Tablist Header Footer
  • Updating the Tablist Line

Was this helpful?

  1. API

Managing your own Tablist

Introduction

You will manage your own Tablist, overriding the original PlayerListDeluxe's tablist.

Disabling PlayerListDeluxe's Tablist

public class ExampleListener implements Listener {

    @EventHandler
    public void event(TablistShowEvent e) {
        if (e.getTablist().getPlugin() == PlayerListPlugin.getPlugin()) {
            e.setCancelled(true);
            // this will cancel tablist show event for PlayerListDeluxe plugin
        }
    }
    
}

Showing Tablist to Player

public class Example extends JavaPlugin {

    public void showToPlayer(Player p) {
        if (getTablist(p) != null) return;
        Tablist tablist = new Tablist(p, this);
        // start the tablist task
        tablist.start();
        // store them into Player's metadata
        Metadata.setMetadata(p, "MyTablist", tablist);
    }
    
    public Tablist getTablist(Player p) {
        // get from stored data
        return Metadata.getMetadata(p, "MyTablist");
    }
    
}

Set the Tablist Layout


    public void prepareLayout(Tablist tablist) {
        TablistLayout layout = new TablistLayout(/* size */ 40);
        // create new line
        LineData line = new LineData.Builder().text("Line 1");
        layout.setLine(0, line);
        tablist.setLayout(layout);
    }
    

Set the Tablist Header Footer

    
    public void prepareHeaderFooter(Tablist tablist) {
        DisplayData header = new DisplayData("This is header");
        DisplayData footer = new DisplayData("This is footer");
        TablistDisplay display = new TablistDisplay(
            new DisplayData[] { header },
            new DisplayData[] { footer }
        );
        tablist.setDisplay(display);
    }
    
    public void manuallySetHeaderFooter(Tablist tablist) {
        tablist.setHeader("This is header");
        tablist.setFooter("This is footer");
        // OR
        tablist.setHeaderFooter("This is header", "This is footer");
    }
    

Updating the Tablist Line


    public void updateTablist(Tablist tablist) {
        TablistLine line = tablist.getLine(0);
        // this will update your tablist automatically
        line.setText("This is the first line");
    }
    
PreviousCreating Simple PlaceholderNextEvents

Last updated 5 years ago

Was this helpful?