Handling stuff

Discussion in 'Resources' started by Jaker232, Feb 23, 2012.

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

    Jaker232

    You may have hit a dead end one time that you have no clue what to do other than write your own class with methods that can return a value. Methods that return a value together in a set is called an 'Application Programming Interface', which Bukkit is a perfect example of one. I'll explain to you what it means and give you an example, and how to set it up.

    1. What it means
    You have heard of the term 'Application Programming Interface' before, or for short, 'API' and have no clue what it means. I'll explain down here.

    An application programming interface (API) is a source code-based specification intended to be used as an interface by software components to communicate with each other. An API may include specifications for routines, data structures, object classes, and variables. It can also set the value which I will explain further down. You may be asking yourself "Why is this so important?". The answer, it's important because you can hook into any plugin with an API. Take for instance, PermissionEx. This permission plugin has an API of its own. Think of this has a line:

    Code:java
    1.  
    2. PermissionsManager pm = PermissionsEx.getPermissionManager();
    3.  


    The following syntax creates a new PermissionsManager instance by getting the Permission Manager in the PermissionsEx class. The line above returns a warning for 'pm' because it is never used.

    Warning: Many people do not realize before working with another Plugin's API, they have to download it and import it to their build path as well follow the manual instructions to setting up. For your sake of hours of research, I'll show you the defaults.
    1. If your plugin requires 'x' plugin to work, you would type in plugin.yml [depend:[x]]. 'x' is the name of the plugin. If it does not depend, but is optional, put [softdepend:[x]].
    2. Do some checking if your plugin is required and disable your plugin if the depended plugin is void, or invalid. Optionally, you can check to see if the plugin you little depend on that is optional, you can print that it has found the plugin and full benefits are possible.
    ---END of WARNING---
    2. Examples
    Alright, so you know what the term Application Programming Interface or called as API mean, seen one in PermissionsEx, and you want to implement into your useful plugin. I am currently as of this time of typing, working on a plugin that relies on it's API to simplify life and everything. I will show you how to do that.
    2.1: Returning values

    You want to return a value of a String, an Integer, or a Boolean in a method of the class. You would primarily decide the one you want. For this section, I'll show you a String one from my auction plugin.
    2.1.2: String value method

    Code:java
    1.  
    2. public String getOwnerOfAuctionID(final int historyNum) {
    3. if(ownerDB.containsKey(historyNum)) {
    4. return ownerDB.get(historyNum);
    5. } else {
    6. return null;
    7. }
    8. }
    9.  

    Line 1-> It creates a method with String and the action with the argument historyNum.
    Line 3-> It returns a string value. ownerDB is a Map to show the auction number ID, then get the value.
    Line 5-> If the ID is invalid, return "null".
    2.2: Setting values
    You now know how to get the String value, but what about setting it? I'll show you how to do this. Fetch this code.
    2.2.1: String setting method
    Code:java
    1.  
    2. public void setOwnerOfAuctionID(final int historyNum, final String name) {
    3. if(ownerDB.containsKey(historyNum)) {
    4. ownerDB.remove(historyNum);
    5. ownerDB.put(historyNum, name);
    6. }
    7. }
    8.  

    (The code above is psuedocode, don't expect it to work.)
    Line 1-> Creates a new method with 2 syntaxes.
    --END OF 2.2.1--
    Thank you for reading my longest tutorial ever.
     
  2. Offline

    ZNickq

    That definition is wrong in many, many ways...

    I'd really love to see those "many people"...



    Those are not real APIs, they're just methods...big difference!


    No it's not, it's Java...



    To be honest, it's probably the best tutorial you've ever done, but that isn't exactly a high place :p


    Bottom line, you didn't really explain what an API is correctly, those are just individual methods...
    And i'm not saying this to be mean, but you'll just confuse people if they read your "tutorial" and learn false stuff from it, which is mostly the case :/
     
  3. Offline

    Jaker232

    Just stop criticizing me on my work.
     
  4. Offline

    ZNickq

    Criticizing is exactly what you need right now, the resource section is made to help people, explaining wrong things to them is not helping them in any way :| you need to understand that :p
     
  5. Offline

    Jaker232

    I'm doing what's right. Stop going and putting your dirty dirt fingerprints on all threads I make and try to make me look bad, because you are one person I hate the most.
     
  6. Offline

    ZNickq

    :(
     
  7. Offline

    Jaker232

    You caused me to be veto'd off the Freedomcraft Team, which I have seem, has collapsed because I was missing. HA.
     
  8. Offline

    Gravity Retired Staff

    If you write a tutorial, there is no sense in yelling at people who help you make corrections, if that didn't happen all the tutorials section would be a giant stinking pile of lies. Peer reviews are executed by anyone who writes any kind of documentation (or code, for that matter) and it is definitely something you should accept..
     
    billofbong and Score_Under like this.
  9. Offline

    Boreeas

    Fact: You were giving incorrect information
    Fact: You are ignoring criticism
    Fact: You are bringing personal quarrels in a public forum.

    Stop. Just stop.
     
  10. Offline

    DrAgonmoray

    lol. JusticeCraft has never had better development before. :p
    While ZNickq perhaps didn't take the best approach to criticizing you (and perhaps I'm not either), you are still spreading BAD information. Go do some research and actually learn what you're talking about before you start teaching trying to teach!

    Edit: Now includes 50% less meanness.
     
  11. Offline

    Kaikz

    Most certainly not what you described.
     
  12. Offline

    Jaker232

    I know what it is. I'm writing one now.
    It's my own definition.

    Now, get off my thread before I call a moderator here to clean up your dirt.
     
  13. Offline

    DrAgonmoray

    And there lays the problem.
     
  14. Offline

    Jaker232

    Just stop trolling and go delete your posts.
    Stop trashing me.
     
  15. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    You rang?

    The only thing I'd be cleaning up is your poor attitude today, and possibly cleaning the first post if it contains poor definitions like your API definition. We don't want users misunderstanding how things work due to this or any poorly phrased topic.


    That said, everyone can stop taking aggressive stances. Just offer advice on how to fix things. :)
     
    ZNickq likes this.
  16. Offline

    Jaker232

    You can go blame the other trolls.
     
  17. Offline

    Kaikz

    Why? You're digging your own hole. We've merely corrected your mistakes and pointed out where you can improve.

    You'll get nothing but hate, if you carry on acting like this. /wooden spoon
     
    DrAgonmoray likes this.
  18. Offline

    Gravity Retired Staff

    There might be some attitude here but if you were to just accept the help and stop being so defensive your tutorials would end up a lot better, your threads would not be covered in trolling, and everyone would be happy. Hooray.
     
  19. Offline

    Jaker232

    Alright. I get it.
    I have updated the definition. You happy now?


    I know. I'm doing that now.
     
  20. Offline

    Gravity Retired Staff

    Sweet. High-five.
    Thank you for writing a tutorial up ;) took me a while to learn this but I know it will come in useful for new developers.
     
  21. Offline

    Kaikz

    Now you're thinking with portals properly.
     
  22. Offline

    Jaker232

    I'm getting disinterested in Portal, not to be offtopic. I'm grown an addiction to Team Fortress 2.
     
  23. Offline

    DrAgonmoray

    I haven't played tf2 in foreeeever.
    Add me on steam or i'll find you.
     
  24. Offline

    Jaker232

    Fine :/ PM me your ID.
     
  25. Offline

    DrAgonmoray

Thread Status:
Not open for further replies.

Share This Page