how-to/Hook
Hooking into iPermit is very simple.
- Add iPermit.jar to your classpath (In Eclipse, add as external archive)
- Create a file called 'IPHook.java' in your project
- Use the following as an example hook:
package me.tmk.ipermitchat; import java.io.File; import java.util.List; import me.tmk.ipermit.IPHandler; import me.tmk.ipermit.iPermit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; public class IPHook { //Main iPermit Call. iPermit hookCore = new iPermit(); //Call The File Where All Methods Are Located. IPHandler hook = new IPHandler(hookCore); /* * Used to check if the player has permission. Checks the world the player is in. * If true: Return true. * If false: Return false. Send rejection notification to player. * xPlayer = Player in question * xNode = Node to check * E.G. if(iphook.hasPermission(sender, "derpnode.permission")){ } */ public boolean hasPermission(Player xPlayer, String xNode){ return hook.hasPermission(xPlayer, xNode); } /* * Used to check if the player has permission. Checks the world the player is in. * If true: Return true. * If false: Return false. No rejection notification sent. * xPlayer = Player in question * xNode = Node to check * E.G. if(iphook.checkHasPermission(sender, "derpnode.permission")){ } */ public boolean checkHasPermission(Player xPlayer, String xNode){ return hook.checkHasPermission(xPlayer, xNode); } /* * Used to check if the player is in a certain group. * If true: Return true. * If false: Return false. * xPlayer = Player in question * xGroup = Group to look for * E.G. if(iphook.inGroup(sender, "Admin")){ } */ public boolean inGroup(Player xPlayer, String xGroup){ return hook.inGroup(xPlayer, xGroup); } /* * Returns the groups permissions file for the specified world. * xWorld = World to check files against * E.G. groupConf.save(iphook.groupPermsFile(sender.getWorld().getName())); */ public File groupPermsFile(String xWorld){ return hook.groupPermsFile(xWorld); } /* * Returns the users permissions file for the specified world. * xWorld = World to check files against * E.G. groupConf.save(iphook.userPermsFile(sender.getWorld().getName())); */ public File userPermsFile(String xWorld){ return hook.userPermsFile(xWorld); } /* * Returns the groups permissions configuration for the specified world. * xWorld = World to check files against * E.G. FileConfiguration groupConf = iphook.groupPerms(sender.getWorld().getName()); */ public FileConfiguration groupPerms(String xWorld) { return hook.groupPerms(xWorld); } /* * Returns the users permissions configuration for the specified world. * xWorld = World to check files against * E.G. FileConfiguration userConf = iphook.userPerms(sender.getWorld().getName()); */ public FileConfiguration userPerms(String xWorld) { return hook.userPerms(xWorld); } /* * Used to assign configuration value to a custom file. * Useful for having iPermit specific configurations for your plugin. * xConfig = File to be used as Configuration File * E.G. FileConfiguration ipconfig = iphook.loadConfig(new File(plugin.getDataFolder(), "config.yml")); */ public FileConfiguration loadConfig(File xConfig){ return hook.loadConfig(xConfig); } /* * Returns all String values in a list of values. * xConfig = Configuration File to look in * xPath = Where in the config file is it located * E.G. List<String> userPermissionList = iphook.getValues(userConf, sender.getName().tolowercase() + ".permissions") */ public List<String> getValues(FileConfiguration xConfig, String xPath){ return hook.getValues(xConfig, xPath); } }
How you call these methods are up to you, but that covers all the built in 'API' methods.
Comments