Setup
Javadoc
The JavaDoc can be found here: JitPack
API Usage explained
Include the API using Gradle:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly "com.github.angeschossen:LandsAPI:version"
}
Replace version
with the version that you want to use.
Include the API using Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>version</version>
<scope>provided</scope>
</dependency>
</dependencies>
Replace version
with the version that you want to use.
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 LandWorld to check flag states has the benefit that it also checks wilderness flags. Some use cases might not intent that. In this case you can use LandsIntegration#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 LandWorld does check wilderness and claimed lands if applicable. If you want to limit the check to claimed land, use LandsIntegration#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 your own 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 your
onLoad
method 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