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 PermissionsManager pm = PermissionsEx.getPermissionManager(); 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. 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]]. 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 public String getOwnerOfAuctionID(final int historyNum) {if(ownerDB.containsKey(historyNum)) {return ownerDB.get(historyNum);} else {return null;}} 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 public void setOwnerOfAuctionID(final int historyNum, final String name) {if(ownerDB.containsKey(historyNum)) {ownerDB.remove(historyNum);ownerDB.put(historyNum, name);}} (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.
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 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 :/
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
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.
You caused me to be veto'd off the Freedomcraft Team, which I have seem, has collapsed because I was missing. HA.
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..
Fact: You were giving incorrect information Fact: You are ignoring criticism Fact: You are bringing personal quarrels in a public forum. Stop. Just stop.
lol. JusticeCraft has never had better development before. 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.
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.
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.
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
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.
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.