From 85508db9b2edfd16f91c0aeb8303c1650db6908b Mon Sep 17 00:00:00 2001 From: Shevchik Date: Tue, 7 Jan 2014 03:34:16 +0400 Subject: [PATCH] Fix player quit properly --- src/com/cnaude/chairs/PlayerSitData.java | 25 +++--------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/com/cnaude/chairs/PlayerSitData.java b/src/com/cnaude/chairs/PlayerSitData.java index bfd14ac..2a81900 100644 --- a/src/com/cnaude/chairs/PlayerSitData.java +++ b/src/com/cnaude/chairs/PlayerSitData.java @@ -116,7 +116,7 @@ public class PlayerSitData { arrow.setPassenger(player); return arrow; } - protected void unSitPlayer(final Player player, boolean restoreposition, boolean correctnmspostion) + protected void unSitPlayer(final Player player, boolean restoreposition, boolean correctleaveposition) { final Entity arrow = sit.get(player.getName()); sit.remove(player.getName()); @@ -133,28 +133,9 @@ public class PlayerSitData { player.setSneaking(false); } },1); - } else + } else if (correctleaveposition) { - if (correctnmspostion) - { - try { - Method getHandleMethod = player.getClass().getDeclaredMethod("getHandle"); - getHandleMethod.setAccessible(true); - Object nmsPlayer = getHandleMethod.invoke(player); - Class entityClass = nmsPlayer.getClass().getSuperclass().getSuperclass().getSuperclass(); - Field locXField = entityClass.getDeclaredField("locX"); - locXField.setAccessible(true); - locXField.set(nmsPlayer, tploc.getX()); - Field locYField = entityClass.getDeclaredField("locY"); - locYField.setAccessible(true); - locYField.set(nmsPlayer, tploc.getY()); - Field locZField = entityClass.getDeclaredField("locZ"); - locZField.setAccessible(true); - locZField.set(nmsPlayer, tploc.getZ()); - } catch (Exception e) { - e.printStackTrace(); - } - } + player.teleport(tploc); } sitblock.remove(sitblockbr.get(player.getName())); sitblockbr.remove(player.getName());