Skip to content

Addon API

Frank van der Heijden edited this page Feb 10, 2021 · 1 revision

Addon API

Insights has an API to support arbitrary plugins for region limiting. An addon must extend upon the following interface:

Main

public interface InsightsAddon {
    String getPluginName();
    String getAreaName();
    String getVersion();
    Optional<Region> getRegion(Location location);
}

String getPluginName() is basically the plugin name which this addon will take care of, Insights will use this to check on load whether the plugin is enabled and will load the addon if so.
String getAreaName() is the name for the area defined by the addon. This could for example be an island, claim, plot, etc.
String getVersion() The version of the addon.
Optional<Region> getRegion(Location location) This is the interesting stuff. Insights expects an optional region here, empty iff there is no such region at the given location, or a Region interface if an area exists at given location. We will discuss the Region interface below.

Regions

A region is any volume defined by the following interface:

public interface Region {
    String getAddon();
    String getKey();
    List<ChunkPart> toChunkParts();
}

String getAddon() Must be the same as getPluginName() defined in InsightsAddon.
String getKey() Must be an unique key per region (ie unique per claim, island, plot, ...), such that Insights can associate this key to a Region. This value is used internally in Insights, to store caches.
List<ChunkPart> toChunkParts() Is where the interesting stuff happens. This is used when Insights will actually scan the region, and defined per ChunkPart 1. The chunk Insights will scan, and 2. A bounding box within the chunk Insighs will scan. Luckily for you, if the addon only needs to support Cuboids, or a list of Cuboids, you won't need to worry about implementing this yourself.

Insights provides two handy classes for handling cuboid systems (toChunkParts() has been implemented for you): SimpleCuboidRegion which defines a single cuboid region space, and SimpleMultiCuboidRegion which defines a list of cuboid region spaces.

Examples

Many examples of Addons can be found on the organisation page of InsightsPlugin.

Clone this wiki locally