Fixed compass teleporting twice on cliff edges

This commit is contained in:
TomyLobo 2011-11-16 16:54:05 +01:00
parent 927cab001e
commit 13f36757c2

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -86,6 +87,8 @@ public class WorldEditPlayerListener extends PlayerListener {
} }
} }
private boolean ignoreLeftClickAir = false;
/** /**
* Called when a player interacts * Called when a player interacts
* *
@ -110,13 +113,29 @@ public class WorldEditPlayerListener extends PlayerListener {
if (we.handleArmSwing(player)) { if (we.handleArmSwing(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
if (!ignoreLeftClickAir) {
final int taskId = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() {
ignoreLeftClickAir = false;
}}, 2);
if (taskId != -1) {
ignoreLeftClickAir = true;
}
}
break; break;
} }
case LEFT_CLICK_AIR: case LEFT_CLICK_AIR:
if (ignoreLeftClickAir) {
break;
}
if (we.handleArmSwing(player)) { if (we.handleArmSwing(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
case RIGHT_CLICK_BLOCK: { case RIGHT_CLICK_BLOCK: {