-
Notifications
You must be signed in to change notification settings - Fork 90
API
The BetterRTP API is a fairly powerful tool when it comes to changing and listening to RTP events.
Remember to add BetterRTP
to your plugin.yml
-> softdepend.
BetterRTP does not currently have an online maven repository, so this will need to be installed manually.
Events are implemented right into the Bukkit API. Just use a Listener class and @EventHandler
to listen to these events.
Event | Description |
---|---|
RTP_CancelledEvent | Called when an rtp is cancelled due to a player moving while under a delay |
RTP_CommandEvent | Called everytime a player executes /rtp []
|
RTP_TeleportEvent | Called right when a safe location is found and about to teleport a player |
RTP_TeleportPostEvent | Called after a random teleport |
RTP_TeleportPreEvent | Called before a random teleport |
With BetterRTP, you are able to extend the command library by registering your own sub command.
Lets for example try to add /rtp link
into the list of commands. This can be used by implementing RTPCommand
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
public class LinkCommand implements RTPCommand {
public String getName() {
return "link";
}
@Override
public void execute(CommandSender sendi, String label, String[] args) {
sendi.sendMessage("Link Command!");
}
}
If you would like add a help message when someone executes /rtp help
, have the class also implement RTPCommandHelpable
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
public class LinkCommand implements RTPCommand, RTPCommandHelpable {
public String getName() {
return "link";
}
@Override
public String getHelp() {
return " - &6/%command% link &8| &7Help with linking!";
}
}
Adding commands are nice, but one pet peeve is that the command gets unloaded everytime someone executes /rtp reload
.
So we will need a reload listener and register our commands every time this happens. Which can be detected using the RTP_CommandEvent
event.
Example:
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdReload;
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CommandEvent;
public class ReloadListener implements Listener {
public ReloadListener(Main pl) {
Bukkit.getPluginManager().registerEvents(this, pl);
}
@EventHandler
void reload(RTP_CommandEvent e) {
if (e.getCmd() instanceof CmdReload)
Main.getInstance().load();
}
}
Chat with us on Discord
Have a Suggestion? Make an issue!
Thank you for viewing the Wiki for BetterRTP!
Did this wiki help you out? Please give it a Star so I know it's getting use!
Check out my other plugins!