Skip to content

Commit

Permalink
Undo teleport manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarwell committed Apr 5, 2016
1 parent da9ccb4 commit a7c2dd5
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -11,6 +11,8 @@

package de.bmarwell.bukkit.listener;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
Expand All @@ -24,7 +26,18 @@ public class PlayerTeleportListener implements Listener {

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
event.setCancelled(true);
// if this event was cancelled, why bother?
if (event.isCancelled()) {
return;
}

// Undo all teleports manually.
Player teleportedPlayer = event.getPlayer();
Location origin = event.getFrom();
event.getCause();

boolean teleportSuccess = teleportedPlayer.teleport(origin);
// TODO: log teleportSuccess;
}

}

0 comments on commit a7c2dd5

Please sign in to comment.