Use of NBPAPI
About 179 wordsLess than 1 minute
Get the instance of NBPAPI
Create an new instance of NBPAPI in the main class of your plugin.
public class YourMainClass extends JavaPlugin {
private static NBPAPI nbpapi;
public static NBPAPI getNBPAPI();
@Override
public void onEnable() {
if (getServer.getPluginManager.getPlugin("NoBuildPlus") != null) {
nbpapi = new NBPAPI();
}
}
}NoBuildPlusAPI
NBPAPI.java
public class NBPAPI {
private final String version;
public NBPAPI() {
this.version = "v0.2";
}
/**
* @return version of api
*/
public String getVersion() {
return this.version;
}
/**
* Register extra flags from your own plugin.
* Refresh the flag list after registration
* @param flag the class with implementing p1xel.nobuildplus.Flag
*/
public void registerFlag(Flag flag) {
FlagRegistry.registerFlag(flag);
FlagsManager.defaultFlagList();
}
/**
* Return the bool whether the plugin does protection with flag.
* @param world name of the world
* @param flag object Flag
* @return TRUE means protect, FALSE means no protect.
**/
public boolean canExecute(String world, Flags flag) {
return flag.isEnabled(world);
}
/**
* @return language of files
*/
public String getLang() {
return Config.getLanguage();
}
}Example
If you want to check whether the flag BREAK is enabled in worldName
String world = "worldName";
boolean isEnabled = ExamplePlugin.getAPI().canExecute(world, Flags.break);