Pl3xMap Towny API - silverwolfg11/Pl3xMap-Towny Wiki

Dependencies:

Pl3xMap-Towny uses jitpack.io to host the JAR package.

If you're building a plugin that utilizes the Pl3xMap-Towny API, it is highly recommended you use a build tool such as Maven or Gradle. The Pl3xMap-Towny dependency is the full jar of the plugin and also has two transitive dependencies: Towny, and Pl3xMap.

If you are using maven, add the following to your pom.xml:

<repositories>
    <repository>
         <id>jitpack.io</id>
         <url>https://jitpack.io</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.github.silverwolfg11</groupId>
    <artifactId>Pl3xMap-Towny</artifactId>
    <version>v1.0.0-alpha-3</version>
</dependency>

For gradle, add the following to your build.gradle:

// ...
repositories {
    maven { url 'https://jitpack.io' }
}
// ...
dependencies {
    implementation 'com.github.silverwolfg11:Pl3xMap-Towny:v1.0.0-alpha-3'
}

Events

The plugin has two events available to use: MapReloadEvent and WorldRenderTownEvent.

MapReloadEvent

This event is called when the plugin is reloaded. The event is purely informative to notify other plugins when this plugin is reloaded. One thing this event can be used for is re-adding custom tooltip replacements. Tooltip replacements reset every time the PlexMap-Towny plugin reloads, so your plugin should listen to this event and re-register custom replacements if they exist.

WorldRenderTownEvent

This event is called whenever the plugin renders a town on the map per world. This event is called asynchronously. Two primary uses of this event are either cancelling this event to prevent the town from being rendered in a specific world or modifying the marker options for the town claim. Cancelling the event means that the town claim will not be rendered, the town outpost icons for that world will not be rendered, and the town homeblock icon will not be rendered (if the homeblock is in that world). The marker options for the specific event will only apply to the town area claims and not any of the town icons.

Tooltip Replacements

To register custom tooltip replacements, you will need to use TownyLayerManager#registerReplacement(String key, Function<Town, String> function). To get the current TownyLayerManager, simply call the getLayerManager() method on the Pl3xMap-Towny plugin object. The registerReplacement() method takes in a key which is essentially the text that you want to replace (e.g. "%mayor%"), and a function that is for replacing the text based on the current town being rendered. The replacements are registered for both the click tooltip, and the hover tooltip text.

Some things to keep in mind:

Misc Methods