Setup
The API is in our repository: repo.incredibleplugins.com
Javadoc
The Javadoc can be found here: repo.incredibleplugins.com
API Usage Explained
First, include the API in your build file. Example snippets for your build file can be found here: Maven, Gradle, SBT
You can also download the API file from there, if you want to add it to your libraries manually.
The API is accessible through an implementation of the LandsIntegration interface. It is recommended to bind this instance to a variable of a singleton class, if possible.
LandsIntegration api = LandsIntegration.of(plugin);Common Use-Cases
Checking Role-Flag States for Players Using
LandWorldto check flag states has the benefit that it also checks wilderness flags. Some use cases might not intent that. In this case you can useLandsIntegration#getArea(location)and check the flag state of the area instead.LandWorld world = api.getWorld(world); if (world != null) { // Lands is enabled in this world if (world.hasFlag(api.getLandPlayer(player), location, material, Flags.BLOCK_BREAK, false)) { // the player is allowed to break blocks with the given material at the given location } else { // the player isn't allowed to break this block in wilderness or a claimed land at this position } }Checking Natural-Flag States
LandWorlddoes check wilderness and claimed lands if applicable. If you want to limit the check to claimed land, useLandsIntegration#getArea(location)instead of getting the world.LandWorld world = api.getWorld(world); if (world != null) { // Lands is enabled in this world if (world.hasNaturalFlag(location, Flags.MONSTER_SPAWN)) { // monsters are allowed to spawn at this location } else { // they aren't allowed to spawn at this location } }Registering custom Flags This one is simple as well. Just use the factory methods of the needed flag type's interface:
RoleFlag.of(...),NaturalFlag.of(...)etc. Please note that flags need to registered after Lands was loaded, but before Lands enables. You can ensure that, by using this method in youronLoadmethod of your plugins main class:LandsIntegration#onLoadRoleFlag flag = RoleFlag.of(api, FlagTarget.PLAYER, RoleFlagCategory.ACTION, "flag_name");It is recommended to set further attributes:
flag.setDisplayName("Name") .setIcon(itemstack) .setDescription(description);
Last updated