create teleportTospawn method in Utils class

This commit is contained in:
DNx5
2015-11-03 03:42:02 +07:00
parent 6d46827936
commit 872856e729
6 changed files with 92 additions and 137 deletions
@@ -12,6 +12,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.zip.GZIPInputStream;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.settings.Spawn;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -297,4 +299,15 @@ public class Utils {
return false;
}
}
public static void teleportToSpawn(Player player) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawn);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
player.teleport(tpEvent.getTo());
}
}
}
}