-
Notifications
You must be signed in to change notification settings - Fork 10
API
to reference this code in a maven project, add the following to your pom.xml
<dependency>
<groupId>io.github.dailystruggle</groupId>
<artifactId>RTP</artifactId>
<version>INSERT_VERSION</version>
<scope>provided</scope>
</dependency>
RTP uses a number of custom events, allowing other plugins to listen in.
e.g.
- RandomSelectPlayerEvent
- RandomSelectQueueEvent
- LoadChunksPlayerEvent
- LoadChunksQueueEvent
- RandomPreTeleportEvent
- RandomTeleportEvent
- TeleportCancelEvent
- TeleportCommandSuccessEvent
In an event listener, reference any event getters and run necessary code.
public final class OnRandomTeleport implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onRandomTeleport(RandomTeleportEvent event) {
if(configs.config.platformRadius>=0) {
Bukkit.getScheduler().runTask(plugin, ()->makePlatform(event.getTo()));
}
}
}
Highest priority should make this run last, in case the location is modified by another listener. In this case, I want to make a platform later.
and I register the listener normally in my main plugin file
getServer().getPluginManager().registerEvents(new OnRandomTeleport(),this);
You may want to reference or modify a specific region.
TeleportRegion teleportRegion = RTP.getRegion(String regionName)
This plugin keeps a list of method handles for location checking. You can also add arbitrary location checks from various plugins.
Each method takes a location as an input and returns a boolean, as follows:
static boolean check(Location location) { }
Checks can be added by getting a handle to the method and passing it to RTP, as done in https://github.com/DailyStruggle/RTP/blob/main/addons/RTP_Domain/src/main/java/io/github/dailystruggle/rtp_domain/RTP_Domain.java
If you want to add or replace a sub-command with its own permission, commands, and parameters, you can add any CommandExecutor like so:
RTP.setSubCommand("help", "rtp.see", new Help()));
or
SubCommand mySubCommand = new SubCommandImpl("rtp.see", new Help());
mySubCommand.setSubParam("something","rtp.inconspicuous",null);
RTP.setSubCommand("help", mySubCommand);