Content generated with AI — it may contain mistakes.

ExyliaProtections/ReferencedevUpdated in v1.1.0

API

Ask from another plugin whether a spot is protected, whether a player may build, break or use blocks there, and whether a protection keeps players from flying there.

Page 18 of 252 min read

ProtectionsService answers the questions other plugins ask about land: is this spot inside a protection, may this player build, break or use blocks there, and does that protection stop flight right now.

java
boolean claimed = ExyliaAPI.get(ProtectionsService.class)
        .map(protections -> protections.protectionAt(location).isPresent())
        .orElse(false);
Adding it to your project

The artifact, the repository and the plugin.yml line are the same for every Exylia plugin and live on the public API page. The protections contract arrived in the public API 1.9.0, shipped with ExyliaLib 1.238.0, in the package net.exylia.lib.api.protections.

An empty Optional from ExyliaAPI.get means the server has no ExyliaProtections. The service is registered once the plugin has started and goes away when it disables.

Methods#

MethodWhat it does
Optional<String> protectionAt(Location location)The id of the protection whose land holds that spot, or empty when none covers it.
boolean canBuild(Player player, Location location)Whether the player may place blocks there: the place role permission, as the block listeners decide it. true outside every protection.
boolean canBreak(Player player, Location location)The same for breaking, with the break role permission.
boolean canInteract(Player player, Location location)The same for using a block, answered by the containers role permission.
boolean deniesFlight(Location location)Whether flight must stop at that spot: submodules.raids and effects.no-flight-during-siege are on and the protection there is under siege or raidable. With raids off it always answers false.

All of them read the protections this server has loaded in memory, without touching the database. Right after a restart, before the protections have finished loading, protectionAt finds none, and the three can methods refuse in worlds where land can be protected, except for a player with the bypass.

The three can methods arrived with ExyliaLib 1.432.0 and are what ExyliaLib's build zones ask, so any Exylia plugin that checks whether a player may build at a spot respects protections without code of its own. They give no warning to the player; tell them yourself when you refuse.

The id is an opaque string. Keep it to compare two answers; do not parse it or show it to players.

deniesFlight is what ExyliaSurvivalCore's /fly asks before letting a player fly, and once a second for everybody already flying. Use it the same way for any flight of your own.

What is not there#

The service is read-only and deliberately small. There is no method to create, delete or edit a protection, or to read its members, roles, flags or bank; and the plugin fires no events of its own. Placeholders cover the read-outs most integrations want: see Placeholders.

Something missing on this page? Tell us on Discord