How to get Essentials' API

Discussion in 'Plugin Development' started by tovd1234, Aug 18, 2015.

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

    tovd1234

    Hello, I'm creating a plugin to display your Essentials warps in a GUI. But I don't know how to import Essentials' API. I see it on GitHub but can't download it. So if ajnyone could help me out it would be much appreciated :)'

    Thanks, Tim
     
  2. Offline

    benzimmer123

    I believe it's already linked into the actual Essentials plugin?
     
  3. Offline

    mythbusterma

    @tovd1234

    Just use the jarfile of the plugin.
     
    tovd1234 likes this.
  4. Offline

    greeves12

    Import the .jar file into your plugin, then search up the essentials API
     
  5. Offline

    nj2miami

    I have created this exact plugin already so I will give you the nuts and bolt of it to save you some time.

    You need the Essentials.jar in your project.

    You can then simply grab all of the warps Essentials know by using:
    Warps w = new Warps(Bukkit.getServer(), Bukkit.getPluginManager().getPlugin("Essentials").getDataFolder());

    Iterate over the list your choice of way:
    for(String s : w.getList())

    For instance, you could load all the warps when your server starts and then you can simply display them in a GUI. When you display the GUI, you could also iterate over the list to only display the ones a player has permissions for or display them all and just let Essentials handle the permission check when they click one.

    Simply name the items in your GUI the name of the warp and you can then easily just run the following when a player clicks an inventory item (InventoryClickEvent):
    Bukkit.dispatchCommand(p, "warp " + ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));

    The above simply sends the command as the player /warp NAME and allows Essentials to handle the permission side of things for you.

    As I said above, you could do some per-warp permission checks when you build the GUI for the player but if you do not care that the player sees all of the warps then simply doing what I said will be the far easiest way.
     
    Synapz likes this.
Thread Status:
Not open for further replies.

Share This Page