Extensive API

Aug 4, 2015
Extensive API
  • Extensive API

    Plugin wiki




    EXTENSIVE API CAN BE FOUND HERE!


    Hello. This is my attempt on a wiki, as this is the first I've ever done, basically this wiki is for this plugin. It's a API that deals with a lot of 1.8 features, and also has some other useful stuff thrown into the mix. In this Wiki, I will be teaching you how to use the API, developer or not. And hopefully you can make some plugins!

    I will update this every time a new feature comes out, with 1.9 on the way, you can expect some.

    I will show you how to use certain parts of the API & give examples for each, we will be starting with the Action Bar, this is how you send one:

    Code (Java):

    This will send a action  bar to the player, with a configurable message.
    ActionBar.sendActionBar(player, message);
     


    Now, if you wanted to message a player with an action bar when they join, you would need something like this.

    Code (Java):

    public class Join extends JavaPlugin implements Listener {
        public void onJoin(PlayerJoinEvent e) { // Creating the event (when a player joins)
            Player p = e.getPlayer(); // Creating the player variable, used to get who joined.
            // now we execute some code
            ActionBar.sendActionBar(p.getPlayer(), ChatColor.RED + "Welcome, " + p.getPlayer().getName());
            // p.getPlayer() is getting the player, so we know whom to send it to.
            // ChatColor.RED translates to &c, "Welcome, " is just some text.
            // p.getPlayer().getName() gets the player, then gets their name.
           // What it will look like in game: "&cWelcome Username!"
        }
     


    Now, let's move on to the Title, this one is a bit trickier, but is very useful in many cases.
    Code (Java):

    // Send a PLAYER a title with integers, regarding the fade in, stay timings, and fade outs.
    // Also along with a cool title and subtitle of course?
    Title.sendTitle(player, fadeIn, stay, fadeOut, title, subtitle);
    Title.sendFullTitle(player, fadeIn, stay, fadeOut, title, subtitle);
    Title.sendSubtitle(player, fadeIn, stay, fadeOut, message);
     


    Okay, now that you've learned the methods, let's send an actual title when a player joins.

    Code (Java):

        public void titleJoin(PlayerJoinEvent e) { // Creating the event (when a player joins)
            Player Player = e.getPlayer(); // Creating the player variable, used to get who joined.
            // now we execute some code
            // note, all timings in minecraft are handled through ticks
            // 20 ticks = 1 second
            Title.sendTitle(Player.getPlayer(), 30, 50, 30, ChatColor.RED + Player.getPlayer().getName(), ChatColor.GOLD + "Welcome to my server!");
            // Player.getPlayer(), once again, gets the player
            // 30 = fadeIn, aka, the amount of time it takes to fade in.
            // 50 = the stay time, how long the title will stay up
            // 30 = fadeOut, the time it takes to fade out of your screen
        }
     


    Alright, I'm gonna stop explaining the player variable as it is very simple to understand. Let's move on, next we have the tab header & footer.

    I found this image with a quick google search, it is not mine.
    [​IMG]

    Neato. Let's manipulate it, you can very simply do so, and it's unique for each player, or you can set it for everyone.
    This example is different, as we are setting it to a command, instead of a onJoin event.


    Code (Java):

    Quite straight forward.
    Title.sendTabTitle(player, header, footer);
     

    Alright, let me show you an example, when a player types the command /hf, it will execute this code:

    // If you have ever made a plugin, this should be straight forward to, if not, click here.
    Code (Java):

        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
           if (cmd.getName().equalsIgnoreCase("hf" )) {
               Player p = (Player)sender;
               if (sender instanceof Player){
                   Title.sendTabTitle(p.getPlayer(), ChatColor.BLUE + "Title", ChatColor.YELLOW + "Footer");
                   return true;
               }
           }
        return false;
        }
     
    Okay, I will update this with more content when I think of more content to add. This is a very easy method, it's changing a user's name.

    Code (Java):

    NameTag.setTag(player, tag, setFor);
     

    Here's a little example:


    Code (Java):

    // When a user joins, if they are OP, they're name will be in &4
         public void playerjoin(PlayerJoinEvent e){
             Player p = e.getPlayer();
             if(p.isOp()){
                 for(Player players : Bukkit.getOnlinePlayers()){
                     NameTagAPI.setTag(p, ChatColor.RED+ p.getPlayer().getName(), players);
                 }
         }
     

    Now, this one is tricky, but in many cases it has deemed to be very useful. It's the BossBar.

    Code (Java):

                   Bar.getBossBar(player) // check a player's boss bar
                   Bar.getHealth(player) // check the boss bar's health of a player
                   Bar.setMessage(player, message); // set the message of a player's boss bar
                   Bar.setMessage(player, message, percentage); // set the message but with a % of health
                   Bar.setMessage(player, message, percentage, timeout); // set the message with a % of health but with a timeout
                   Bar.setMessage(player, message, percentage, timeout, minHealth); // same as above, just with a minimal health
     

    I made a onJoin method for when a user joins.


    Code (Java):

        public void titleJoin(PlayerJoinEvent e) { // Creating the event (when a player joins)
            Player Player = e.getPlayer(); // Creating the player variable, used to get who joined.
            // now we execute some code
            Bar.setMessage(Player.getPlayer(), ChatColor.AQUA + "Thanks for reading this wiki!");
            // Sets the message of a player's boss bar (the dragon follows until boss bar is removed)
            // It says in &b: "Thanks for reading this wiki"
            }

    }
     
    ADDED IN V.2:
    Play records with a line of code, here is how you do it!:
    Full list of records here.
    Code (Java):

    // Replace "RECORD" with the record you want to play.
    // Send a record:
    Record.RECORD.play(Player p);

    //  Broadcast a record to everyone:
    Record.RECORD.playToAll();

    // Stop playing a record:
    Record.RECORD.stop(Player p);

    // Stop the broadcast:
    And you can always broadcast the stop, like this:
    Record.RECORD.stopAll();
     
    Alright, now that I've showed you how to use my API, here's a few things you CAN'T forget.
    Make sure in your plugin.yml you reference this as a depended source, like this:
    Code (YML):

    depend: [ExtensiveAPI]
     
    Next, if you use it in a plugin and release it anywhere, make sure you reference your user's to THIS (resource post) page. If you don't & it is listed as a depend, it simply will not function. We wouldn't want that, plus it draws more attention to my API, and thus, puts more plugins using my API into the community.

    Thank you, if you would like to see more content, suggest some, or simply just give a nice review, leave a rating on my resource, it means a lot, and this plugin, and all my plugins are community driven, which means the more support the more happy I become & continue to make plugins!

    If you would like to check out more of my totally radical plugins, click the link HERE.

    And that is all, thank you everyone.
  • Loading...
  • Loading...