Lands Wiki
DiscordHome
For Server Admins
For Server Admins
  • Info
  • Configuration
    • Installation
    • Frequently asked Questions
    • Database
    • Playtime Rewards
    • Leaderboards
    • Roles and their Flags
    • Natural flags
    • Player Personal Settings
    • Wars
    • Levels
    • Regeneration
    • Discord Bot
    • PlaceholderAPI Placeholders
    • Camps
    • GUI Menus
    • Bedrock Forms
    • Messages
    • Translations
    • Events
  • Permissions
    • Recommendation
    • Player Commands
    • Admin Commands
    • Other Permissions
    • Luckperms Context
  • Admin & Moderation
    • Tools
  • Developers
    • Setup
    • Levels
    • Update
Powered by GitBook
On this page
  • Javadoc
  • API Usage explained
Edit on GitHub
  1. Developers

Setup

PreviousToolsNextLevels

Last updated 5 months ago

Javadoc

The JavaDoc can be found here:

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

  1. 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
        }
    }
  2. 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
        }
    }
  3. RoleFlag flag = RoleFlag.of(api, FlagTarget.PLAYER, RoleFlagCategory.ACTION, "flag_name");

    It is recommended to set further attributes:

    flag.setDisplayName("Name")
        .setIcon(itemstack)
        .setDescription(description);

Checking Role-Flag States for Players Using 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 and check the flag state of the area instead.

Checking Natural-Flag States does check wilderness and claimed lands if applicable. If you want to limit the check to claimed land, use instead of getting the world.

Registering your own Flags This one is simple as well. Just use the factory methods of the needed flag type's interface: , 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:

LandWorld
LandsIntegration#getArea(location)
LandWorld
LandsIntegration#getArea(location)
RoleFlag.of(...)
NaturalFlag.of(...)
LandsIntegration#onLoad
JitPack