Update TeleportUtils
This commit is contained in:
parent
82fade61d5
commit
1c090a5a65
@ -28,6 +28,7 @@ public class TeleportUtils {
|
|||||||
try {//Detect Paper class
|
try {//Detect Paper class
|
||||||
Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
|
Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||||
teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
|
teleportAsyncMethod = Player.class.getMethod("teleportAsync", Location.class);
|
||||||
|
teleportAsyncMethod.setAccessible(true);
|
||||||
// if detected,use teleportAsync()
|
// if detected,use teleportAsync()
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
teleportAsyncMethod = null;
|
teleportAsyncMethod = null;
|
||||||
@ -38,7 +39,6 @@ public class TeleportUtils {
|
|||||||
public static void teleport(Player player, Location location) {
|
public static void teleport(Player player, Location location) {
|
||||||
if (teleportAsyncMethod != null) {
|
if (teleportAsyncMethod != null) {
|
||||||
try {
|
try {
|
||||||
teleportAsyncMethod.setAccessible(true);
|
|
||||||
teleportAsyncMethod.invoke(player, location);
|
teleportAsyncMethod.invoke(player, location);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
player.teleport(location);
|
player.teleport(location);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user