MineHacker API Docs/Context class
All mods have a Context for their global scope. In addition, you can create a Context object using new Context(), then eval code on it using myContext.eval(source).
Properties
server - The Bukkit.getServer() object. See here for all the goodies.
plugin - The MineHacker JavaPlugin object. Do plugin.logger.info("message") to log in the console.
Context - The Context class. Overrides the one defined in SandboxContext.
File - The MineHacker File class.
Methods
command(name, callback) - Creates a command and invokes callback when a player issues it. In callback the this object is the PlayerCommandPreprocessEvent, and parameters is a space-separated array of parameters.
on(event, [priority = "normal", [ignoreCancelled = true,]] callback) - Registers an event. You can peruse events under the org.bukkit.event packages in the docs. If you surround the event name in quotes, you can omit the package if you want.
mod(jsModName) - Loads a .js file and returns its api variable. You can use the api variable (an empty object by default) to give your mods a mod API. Works on js mod files and folders too. If the specified path is a folder, loads the main.js file in the folder. If the mod does not exist, returns null. You must include the .js extension if it is a .js file.
module(filename) - Same as mod(), except filepaths are relative to the root of the server (craftbukkit.jar directory) and nonexistant files throw an error.
persist(filename, defaultObject) - Returns a persistent object stored in the specified file. JSON is used to encode the object, so you must avoid using circular references. e.g. var store = persist("ModFolder/store.json", {defaultProp:true})
configuration(filename, defaultObject) - Returns a config object stored in the specified file. Once created, the file will not be updated, however it will be reloaded on server reload. JSON is used to encode the object, so you must avoid using circular references. e.g. var config = configuration("ModFolder/config.json", {defaultProp:true})
Comments