From 2638e2c1c8599fc39b2497b63243139c960d0f57 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Sat, 14 Dec 2013 21:54:49 +0400 Subject: [PATCH] Do not player try to unsit before unsit is actually finished --- src/com/cnaude/chairs/EventListener.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/com/cnaude/chairs/EventListener.java b/src/com/cnaude/chairs/EventListener.java index 950ad6d..fa7ec61 100644 --- a/src/com/cnaude/chairs/EventListener.java +++ b/src/com/cnaude/chairs/EventListener.java @@ -1,5 +1,7 @@ package com.cnaude.chairs; +import java.util.HashSet; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -40,6 +42,7 @@ public class EventListener implements Listener { } } + private HashSet queueUnsit = new HashSet(); @EventHandler(priority=EventPriority.LOWEST) public void onExitVehicle(VehicleExitEvent e) { @@ -49,13 +52,18 @@ public class EventListener implements Listener { if (plugin.sit.containsKey(player.getName())) { e.setCancelled(true); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() + if (!queueUnsit.contains(player.getName())) { - public void run() + queueUnsit.add(player.getName()); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - plugin.unSitPlayer(player, false); - } - }); + public void run() + { + queueUnsit.remove(player.getName()); + plugin.unSitPlayer(player, false); + } + }); + } } } }