Solved My Own API

Discussion in 'Plugin Development' started by tkuiyeager1, Oct 8, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    tkuiyeager1

    Hey,
    i want to create my own plugin API so other plugins can use him, but i dont know how to do it, can someone teach me how to make an API or send a tutorial?
     
  2. Offline

    Zombie_Striker

  3. Offline

    tkuiyeager1

  4. Offline

    DoggyCode™

    You create public static methods with contents which other plugins can access. For example:

    Code:
    public static String isRiding(Player p){
            String positive = ChatColor.GREEN + "True";
            String negative = ChatColor.RED + "False";
            if(p.getVehicle() instanceof Horse || p.getVehicle() instanceof Pig || p.getVehicle() instanceof Spider || p.getVehicle() instanceof EnderDragon){
                return positive;
            }
            return negative;
        }
    Now if people add your jar to their plugin, they can call this method by importing from your packages and using for example:
    Code:
    Player#sendMessage("Player-Riding-Status: "+(String)ClassName.isRiding(Player#)); //don't need to cast, just did to to show that it's a String.
    Note: server using your plugin must have your API installed.

    So an API is basically tons of methods to make stuff easier for others.
     
    bwfcwalshy likes this.
  5. @tkuiyeager1 An api is basically methods. Look at Bukkit, they have a class and that has a bunch of methods to return stuff and do other things.
     
  6. Offline

    Zombie_Striker

  7. Offline

    tkuiyeager1

    thanks, but what is this should be:
    Code:
    public class <APINAME> extends ??????
     
  8. Offline

    DoggyCode™

    Your API should just be like a normal Bukkit plugin, just with methods. And their plugin using your API don't have to extend anything (besides the normal).
     
  9. @tkuiyeager1 It doesn't need to extend anything. You can make a class that others extend or implement but you don't need to to make methods.
     
  10. Offline

    tkuiyeager1

    Ok Thanks
     
Thread Status:
Not open for further replies.

Share This Page