Skip to content
Leaf26 edited this page Dec 29, 2022 · 9 revisions

Reference as a Maven Dependency

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>

Custom Events

RTP uses a number of custom spigot events, allowing other plugins to listen in.

  • PlayerQueuePopEvent - when a player is selected for teleportation
  • PlayerQueuePushEvent - when a player begins waiting for a new location to generate
  • PostLoadChunksEvent - after chunk preload task
  • PostSetupTeleportEvent - after selection tasks
  • PostTeleportEvent - after teleportation task
  • PreLoadChunksEvent - before chunk preload task
  • PreSetupTeleportEvent - before selection task
  • PreTeleportEvent - before teleportation task
  • RandomSelectQueueEvent - when the plugin prepares a location asynchronously
  • TeleportCancelEvent - when a player cancels teleportation
  • TeleportCommandFailEvent - when a teleport command fails
  • TeleportCommandSuccessEvent - when a teleport command succeeds

Doing stuff on event

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(PostTeleportEvent 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);

Getting a region by name

You may want to reference or modify a specific region.

Region region = RTP.selectionAPI.getRegion(String regionName)

Adding Location Checks

This plugin keeps a list of method handles for location checking. You can also add arbitrary location checks from various plugins.

Checks can be added by calling Region.addGlobalRegionVerifier() with an appropriate function.

Adding Sub-Commands

If you want to add or replace a sub-command with its own permission, commands, and parameters, you can create custom commands using an included command API, like this:

RTP.baseCommand.addSubCommand(command);

As of 2.0.0, parameter decoding is automated. Reference this package or BukkitTreeCommand for implementing a new subcommand

Clone this wiki locally