Created
December 26, 2010 19:01
-
-
Save nijikokun/755569 to your computer and use it in GitHub Desktop.
Hooking support for plugins, not just iConomy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hooked.java | |
* <br><br> | |
* Controls custom hook information by easily helping you figure out what is what without recieving errors on the matter. | |
* | |
* @author Nijikokun <[email protected]> | |
*/ | |
public class Hooked { | |
public Hooked() { | |
} | |
/** | |
* Silently place a call to the custom hook, does not return any information. | |
* | |
* @param listener | |
* @param args | |
*/ | |
public static void silent(String listener, Object[] args) { | |
etc.getLoader().callCustomHook(listener, args); | |
return; | |
} | |
/** | |
* Publicly call the hook and return any information recieved. | |
* | |
* @param listener | |
* @param args | |
* @return Object | |
*/ | |
public static Object call(String listener, Object[] args) { | |
return etc.getLoader().callCustomHook(listener, args); | |
} | |
/** | |
* Make a public call and return an integer if one exists, if not return 0. | |
* | |
* @param listener | |
* @param args | |
* @return integer, 0 if none was ever returned. | |
*/ | |
public static int getInt(String listener, Object[] args) { | |
Object result = call(listener, args); | |
return (Integer)result; | |
} | |
/** | |
* Make a public call and return a String if one exists, if not return an empty string. | |
* | |
* @param listener | |
* @param args | |
* @return String - Empty if none was ever returned. | |
*/ | |
public static String getString(String listener, Object[] args) { | |
Object result = call(listener, args); | |
return (String)result; | |
} | |
/** | |
* Make a public call and return an boolean if one exists, if not return false. | |
* | |
* @param listener | |
* @param args | |
* @return Boolean - false if none was ever returned. | |
*/ | |
public static boolean getBoolean(String listener, Object[] args) { | |
Object result = call(listener, args); | |
return (Boolean)result; | |
} | |
/** | |
* Make a public call and return an Double if one exists, if not return 0.0. | |
* | |
* @param listener | |
* @param args | |
* @return Double - 0.0 if none was ever returned. | |
*/ | |
public static double getDouble(String listener, Object[] args) { | |
Object result = call(listener, args); | |
return (Double)result; | |
} | |
/** | |
* Make a public call and return an Long if one exists, if not return 0L. | |
* | |
* @param listener | |
* @param args | |
* @return Long - 0L if none was ever returned. | |
*/ | |
public static long getLong(String listener, Object[] args) { | |
Object result = call(listener, args); | |
return (Long)result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then i guess i have to use register, but i didn't get it to work. can you publish a template of an example usage of register?