Skip to content
Leaf26 edited this page Oct 29, 2021 · 9 revisions

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

  • RandomSelectPlayerEvent
  • RandomSelectQueueEvent
  • LoadChunksPlayerEvent
  • LoadChunksQueueEvent
  • RandomPreTeleportEvent
  • RandomTeleportEvent
  • TeleportCancelEvent
  • TeleportCommandSuccessEvent

Getting a region by name

TeleportRegion teleportRegion = RTP.getRegion(String regionName)

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

Adding Location Checks

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

Adding Sub-Commands

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

Clone this wiki locally