Java Reference
In-Depth Information
playerTeleports.put(player.getName(), locs);
@Command(aliases = { "back" },
description = "Go back to previous places that you teleported to." ,
permissions = { "" },
toolTip = "/back" )
public void backCommand(MessageReceiver caller, String[] args) {
if (caller instanceof Player) {
Player me = (Player)caller;
Stack <Location> locs = playerTeleports.get(me.getName());
if (locs != null && !locs.empty()) {
Location loc = locs.peek();
while (equalsIsh(loc, me.getLocation()) && locs.size() > 1) {
loc = locs.peek();
} else { "You have not teleported yet." );
As this plugin is using event listening, here are the special things you need
to do:
•At , declare that this plugin implementsListener .
•At , register the plugin for events.
•At add the @HookHandler annotation and declare that this event listener
will listen for TeleportHook events.
Every time a player teleports, the onTeleport function will be called. The first
thing we do is get the correct Player object, which is stored in the event that
was passed in to us. Now we know who we're dealing with.
Next we're looking in the list named isTeleporting to find out whether this player
is someone we are in the middle of teleporting. What's isTeleporting , you ask?
Ah, take a look up at the top of the plugin around , and you'll see two
variables declared to be private static . That means no one else can see them,
and the values will stick around in between this command being run. So here
Search WWH ::

Custom Search