Skip to content
Permalink
Browse files

Undo teleport manually.

  • Loading branch information...
bmhm committed Apr 5, 2016
1 parent da9ccb4 commit a7c2dd54659f25598863da8a0e026cb83963f3a1
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/main/java/de/bmarwell/bukkit/listener/PlayerTeleportListener.java
@@ -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;
@@ -24,7 +26,18 @@

@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.
You can’t perform that action at this time.