Resource ActionBar [1.8-1.11]

Discussion in 'Spigot Plugin Development' started by MrGriefer_, Apr 12, 2017.

  1. Hello everyone, recently I have been working on a plugin that contains action bar function. I didn't want to use some big library with a lot of reflection classes, so I made my own small class that can help you to use action bars in your plugin. And this is my first time creating a utility class and my first resource in SpigotMC, so help and suggestions will be appreciated.

    Here is the code: Gist
    Remember to replace "instance" with your class that extends JavaPlugin.
    Color codes are supported.


    To create a new action bar it's as simple as:
    Code (Text):
    ActionBar bar = new ActionBar();
    To send it to a player:
    Code (Text):
    bar.sendActionBar(p, message);
    Send the action bar for a specific amount of time (ticks 20 = 1 second):
    Code (Text):
    bar.sendActionBar(player, "Action Bar Message", duration);
    To send it to all players online:
    Code (Text):
    bar.sendActionBarToAllPlayers("Action Bar Message");
    To send it to all players online for a specific amount of time:
    Code (Text):
    bar.sendActionBarToAllPlayers("Action Bar Message", duration);
    Picture:
    [​IMG]
    Code used in that picture:

    Code (Text):
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
                return false;
            }
       
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("test")) {
                ActionBar bar = new ActionBar();
                bar.sendActionBar(p, "&cR&6A&eI&aN&bB&dO&5W &f:)");
                return true;
            }
       
            return true;
        }

    I have tested it on 1.7 it doesn't work! ActionBars didn't existed in 1.7.

    Thanks for reading, hoped this helped you. Enjoy!
     
    #1 MrGriefer_, Apr 12, 2017
    Last edited: Apr 12, 2017
  2. There are already tons of resources like this, but thanks I guess.
     
  3. u should implement the translatealternatercolorcodes into the methods themselves
     
  4. I'm just posting my own version.
     
  5. I will make sure to add that!