API help? Like world edit api?

Discussion in 'Plugin Development' started by JBoss925, Apr 11, 2014.

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

    JBoss925

    Hey guys it's JBoss925. I'm sure this is a very stupid question but I'm a very stupid person so this fits. Anyway I've become interested in making an apis for my friends to use because a few of my plugins are very complex and I'd rather not have to explain a ton of packet stuff and things they don't understand. I'd rather make methods they can use to edit and add things. Now, the problem I am having is I cannot use a jar I made as an api. I've done an ABSOLUTE TON OF GOOGLING and exactly 0% of it helped. Anyway, I would like to know if there is a special way to export a jar or reference a jar to be used as an api. Like world edit. Is there any specific way? Do I need maven or gradle? Thanks for all the help. :D

    -JBoss925
     
  2. Offline

    mazentheamazin

    JBoss925
    You'll just add it to your project the same way you do with Bukkit
     
  3. Offline

    JBoss925

    I did but it isn't working. I exported it as a jar with dependencies, gave it my main and that was it. Am I to format is a specific way?
     
  4. Offline

    Blah1

    God i hate posts that start with "this is a stupid question" or "im stupid" or "my english is bad."
    Just tell us what you need help with! This is an accepting community.

    As for your question, you will have to import that jar to your project folder and have that plugin on your server. Depending on what IDE you're using the process will be different.
     
  5. Offline

    JBoss925

    Ok mazentheamazin Blah1 I did an example thing of what I want to do and went to the output in the libraries of my project and got this:
    Code:
      // IntelliJ API Decompiler stub source generated from a class file
      // Implementation of methods is not available
     
    package me.JBoss925.com;
     
    public class api extends org.bukkit.plugin.java.JavaPlugin {
        public static org.bukkit.event.player.AsyncPlayerChatEvent chat;
        public static org.bukkit.event.player.PlayerJoinEvent join;
        public static org.bukkit.event.player.PlayerInteractEvent pie;
     
        public api() { /* compiled code */ }
     
        public void setKilled(org.bukkit.entity.Player victim, boolean killed) { /* compiled code */ }
     
        public void openInventory(org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory) { /* compiled code */ }
     
        public void closeInventory(org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory) { /* compiled code */ }
     
        public void tellPlayer(org.bukkit.entity.Player receiver, java.lang.String message) { /* compiled code */ }
     
        public void replaceCurseWords(boolean allowed) { /* compiled code */ }
     
        public void addPotion(org.bukkit.potion.PotionEffectType potionEffectType, org.bukkit.entity.Player player, java.lang.Integer time, java.lang.Integer level) { /* compiled code */ }
     
        public void playerAddUUIDList(org.bukkit.entity.Player player, java.util.List list) { /* compiled code */ }
     
        public void playerAddUUIDList(org.bukkit.entity.Player player, java.util.ArrayList arrayList) { /* compiled code */ }
     
        public void performCommand(org.bukkit.entity.Player player, java.lang.String command) { /* compiled code */ }
     
        public void playerJoinMessage(java.lang.String message, boolean enabled) { /* compiled code */ }
     
        public void playerSetFire(org.bukkit.entity.Player victim, java.lang.Integer ticksIfEnabled, boolean enabled) { /* compiled code */ }
    }
    Notice the method implementation unavailable. I'll do a bit more googling. Thanks for your help tho.

    I do. Please see my last post. And very sorry about that I'm stupid thing. I feel like it's so simple and I sound arrogant if i don't put it. I won't put it next time.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    mazentheamazin

    JBoss925
    In your API class, you need to make a method where you're able to get an instance of the class, since all the methods are not static.
     
  7. Offline

    JBoss925

    OH MY GOD I DIDN'T MAKE THEM STATIC, DID I? OEWNGIOJ:DKLS FIDHPFJ WFMN<B. Thank you. I will try that and see if it works.

    EDIT: LOL that smiley face wasn't intentional.
     
  8. Offline

    mazentheamazin

    JBoss925
    By the way, remember that your class' name are nouns, not verbs
     
  9. Offline

    JBoss925

    What are you talking about?

    This didn't work. I decided to import it as well. Also didn't work. It makes no sense.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  10. Offline

    mazentheamazin

    JBoss925
    For example, when I create a class, I do not do exampleclass, I make it Exampleclass, I just capitalize the first letter.
     
  11. Offline

    Gater12

    JBoss925
    Conventions for class names. That would probably be more of a variable name. Conventions should be used to avoid confusion between class names and variables.
     
  12. Offline

    JBoss925

    Oh I got it. Also, mazentheamazin any nsight on this? It's driving me insane. Do I put it in like a normal plugin but in the libraries section? It makes NO SENSE AND I'M LITERALLY FUCKING DYING.
     
  13. Offline

    Gater12

    JBoss925
    ? Just put it in like a plugin usually. However you can also include the jar into your project...
     
  14. Offline

    JBoss925

    It's not working that way. Let me explain, I have it and it just has a bunch of methods in it. Then I export it to a jar and reference it in my libraries like bukkit. Then I go to type a method in my api and it doesn't recognize it.
     
  15. Offline

    xTigerRebornx

    JBoss925 When you say it doesn't recognize it, are you saying that your IDE doesn't recognize it, or something else?
     
  16. Offline

    JBoss925

    My IDEA usually suggests the methods when typing. First off, it didn't do that and then when I typed out the full method it was red and gave me an error.
     
  17. Offline

    xTigerRebornx

  18. Offline

    JBoss925

    lemme check brb

    I just tried something and it worked. I did import static me.JBoss925.com.api.*; and it imported all the methods. I don't know how to make it do it automatically like bukkit though.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  19. Offline

    xTigerRebornx

    JBoss925 Whatever plugin is using your plugin as a "Library", they need to add your plugin as a dependancy
     
Thread Status:
Not open for further replies.

Share This Page