Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
Benjamín edited this page Dec 22, 2022 · 3 revisions

Adapts

Learn to how to use the library adapts.

The adapts allows you add full support for the Titles and ActionBars at the majory Minecraft versions 1.8.x - 1.16.x.

Also, if you're supporting a version just, can use just the correspond adapt with AdaptManager.adapt(SimpleAdapt adapt), if you need multiple adapts (all for each server version case), can use AdaptModelManager.findAdapt(), that method initialize the adapt correspond for the server version that's running.

If you're using versions higher to 1.16 (+1.17), the AdaptManager isn't required, so the constructors/methods that requires a SimpleAdapt object can be null.

Example:

XTitle.newTitleManager(adaptManager.getAdapt()); // Will be return null because there not an adapt set.

Importment:

private AdaptManager adaptManager;

@Override
public void onEnable() {
    // Initializes the object with a new instance of SimpleAdaptManager object.
    adaptManager = XTitle.newAdaptManager();
    // Setup the correspond adapt for this server version.
    adaptManager.findAdapt();
    // Setup the adapt that requires the server.
    adaptManager.adapt(new AdaptHandler());

    // Returns the current adapt used.
    // NOTE: Will be returns null if there not an adapt set.
    adaptManager.getAdapt();
}

Titles

The TitleManager interface provides multiple methods for manage the titles.

Available Methods:

  • clearTitle(Player player) Resets the current title sent to player.
  • sendTitle(Player player, String title, String subtitle) Sends a title to player without time parameters specified.
  • sendTitle(Player player, int fadeIn, int stay, int fadeOut, String title, String subtitle) Sends a title to player with the specified title times.

So, how to I can use it for reset/send a title to player.

First you need get/create a TitleManager instance. Example:

TitleManager titleManager = XTitle.newTitleManager(adaptManager.getAdapt()); // Returns the current adapt that being used, if there not set a one will be return null.

Now, for send a title just we call to some interface method. Example:

titleManager.sendTitle(player, 20, 60, 20, "Hello!", "This is an example title!");

titleManager.sendTitle(player, "Hello!", "This is an example title!");

titleManager.clearTitle(player);

ActionBars

The same TitleManager interface provide methods for send actionbars to player.

Available Methods:

  • sendActionBar(Player player, String message) Sends an actionbar to player without a specified duration.
  • sendActionBar(JavaPlugin plugin, Player player, String message, long duration) Sends an actionbar with a specified duration (in ticks).

We supose that you already have an TitleManager instance, if not you have, create one or get one.

Okay, for send an actionbar just we call to some interface method. Example:

titleManager.sendActionBar(player, "This is an example actionbar!");

titleManager.sendActionBar(plugin, player, "This is an example actionbar!", 100); // 100 ticks represent 5 seconds.
Clone this wiki locally