Also unsit player on teleport event
This commit is contained in:
parent
03c683af03
commit
ef9f272a57
@ -83,7 +83,7 @@ public class Chairs extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
if (sit.containsKey(player.getName())) {
|
||||
unSitPlayer(player, true);
|
||||
unSitPlayer(player, false, true);
|
||||
}
|
||||
}
|
||||
if (ignoreList != null) {
|
||||
@ -175,14 +175,14 @@ public class Chairs extends JavaPlugin {
|
||||
arrow.setPassenger(player);
|
||||
return arrow;
|
||||
}
|
||||
protected void unSitPlayer(final Player player, boolean playerleft)
|
||||
protected void unSitPlayer(final Player player, boolean restoreposition, boolean correctnmspostion)
|
||||
{
|
||||
final Entity arrow = sit.get(player.getName());
|
||||
sit.remove(player.getName());
|
||||
player.eject();
|
||||
arrow.remove();
|
||||
final Location tploc = sitstopteleportloc.get(player.getName());
|
||||
if (!playerleft)
|
||||
if (restoreposition)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
||||
{
|
||||
@ -193,6 +193,8 @@ public class Chairs extends JavaPlugin {
|
||||
}
|
||||
},1);
|
||||
} else
|
||||
{
|
||||
if (correctnmspostion)
|
||||
{
|
||||
try {
|
||||
Method getHandleMethod = player.getClass().getDeclaredMethod("getHandle");
|
||||
@ -212,6 +214,7 @@ public class Chairs extends JavaPlugin {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
sitblock.remove(sitblockbr.get(player.getName()));
|
||||
sitblockbr.remove(player.getName());
|
||||
sitstopteleportloc.remove(player.getName());
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
public class TryUnsitEventListener implements Listener {
|
||||
@ -27,7 +28,17 @@ public class TryUnsitEventListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.sit.containsKey(player.getName()))
|
||||
{
|
||||
plugin.unSitPlayer(player,true);
|
||||
plugin.unSitPlayer(player, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.sit.containsKey(player.getName()))
|
||||
{
|
||||
plugin.unSitPlayer(player, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,7 @@ public class TryUnsitEventListener implements Listener {
|
||||
Player player = event.getEntity();
|
||||
if (plugin.sit.containsKey(player.getName()))
|
||||
{
|
||||
plugin.unSitPlayer(player,true);
|
||||
plugin.unSitPlayer(player, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +70,7 @@ public class TryUnsitEventListener implements Listener {
|
||||
public void run()
|
||||
{
|
||||
queueUnsit.remove(player.getName());
|
||||
plugin.unSitPlayer(player, false);
|
||||
plugin.unSitPlayer(player, true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -74,7 +85,7 @@ public class TryUnsitEventListener implements Listener {
|
||||
if (plugin.sitblock.containsKey(b))
|
||||
{
|
||||
Player player = Bukkit.getPlayerExact(plugin.sitblock.get(b));
|
||||
plugin.unSitPlayer(player,false);
|
||||
plugin.unSitPlayer(player, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user