Class ActionBar


  • public final class ActionBar
    extends Object
    A reflection API for action bars in Minecraft. Fully optimized - Supports 1.8.8+ and above. Requires ReflectionUtils. Messages are not colorized by default.

    Action bars are text messages that appear above the player's hotbar Note that this is different than the text appeared when switching between items. Those messages show the item's name and are different from action bars. The only natural way of displaying action bars is when mounting.

    Action bars cannot fade or stay like titles. For static Action bars you'll need to send the packet every 2 seconds (40 ticks) for it to stay on the screen without fading.

    PacketPlayOutTitle: https://wiki.vg/Protocol#Title

    Version:
    3.1.0
    Author:
    Crypto Morin
    See Also:
    ReflectionUtils
    • Method Detail

      • sendPlayersActionBar

        public static void sendPlayersActionBar​(@Nullable
                                                String message)
        Sends an action bar all the online players.
        Parameters:
        message - the message to send.
        Since:
        1.0.0
        See Also:
        sendActionBar(Player, String)
      • clearActionBar

        public static void clearActionBar​(@Nonnull
                                          org.bukkit.entity.Player player)
        Clear the action bar by sending an empty message.
        Parameters:
        player - the player to send the action bar to.
        Since:
        2.1.1
        See Also:
        sendActionBar(Player, String)
      • clearPlayersActionBar

        public static void clearPlayersActionBar()
        Clear the action bar by sending an empty message to all the online players.
        Since:
        2.1.1
        See Also:
        clearActionBar(Player player)
      • sendActionBarWhile

        public static void sendActionBarWhile​(@Nonnull
                                              org.bukkit.plugin.java.JavaPlugin plugin,
                                              @Nonnull
                                              org.bukkit.entity.Player player,
                                              @Nullable
                                              String message,
                                              @Nonnull
                                              Callable<Boolean> callable)
        Sends an action bar to a player for a specific amount of ticks. Plugin instance should be changed in this method for the schedulers.

        If the caller returns true, the action bar will continue. If the caller returns false, action bar will not be sent anymore.

        Parameters:
        plugin - the plugin handling the message scheduler.
        player - the player to send the action bar to.
        message - the message to send. The message will not be updated.
        callable - the condition for the action bar to continue.
        Since:
        1.0.0
        See Also:
        sendActionBar(JavaPlugin, Player, String, long)
      • sendActionBarWhile

        public static void sendActionBarWhile​(@Nonnull
                                              org.bukkit.plugin.java.JavaPlugin plugin,
                                              @Nonnull
                                              org.bukkit.entity.Player player,
                                              @Nullable
                                              Callable<String> message,
                                              @Nonnull
                                              Callable<Boolean> callable)
        Sends an action bar to a player for a specific amount of ticks.

        If the caller returns true, the action bar will continue. If the caller returns false, action bar will not be sent anymore.

        Parameters:
        plugin - the plugin handling the message scheduler.
        player - the player to send the action bar to.
        message - the message to send. The message will be updated.
        callable - the condition for the action bar to continue.
        Since:
        1.0.0
        See Also:
        sendActionBarWhile(JavaPlugin, Player, String, Callable)
      • sendActionBar

        public static void sendActionBar​(@Nonnull
                                         org.bukkit.plugin.java.JavaPlugin plugin,
                                         @Nonnull
                                         org.bukkit.entity.Player player,
                                         @Nullable
                                         String message,
                                         long duration)
        Sends an action bar to a player for a specific amount of ticks.
        Parameters:
        plugin - the plugin handling the message scheduler.
        player - the player to send the action bar to.
        message - the message to send.
        duration - the duration to keep the action bar in ticks.
        Since:
        1.0.0
        See Also:
        sendActionBarWhile(JavaPlugin, Player, String, Callable)