Add workaround for bogus Bukkit piston events (http://leaky.bukkit.org/issues/1227)

This commit is contained in:
Mike Primm 2011-09-12 09:55:55 +08:00 committed by mikeprimm
parent e2746b7cbc
commit 3076b28c24

View File

@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
@ -478,7 +479,12 @@ public class DynmapPlugin extends JavaPlugin {
Block b = event.getBlock();
Location loc = b.getLocation();
mapManager.sscache.invalidateSnapshot(loc);
BlockFace dir = event.getDirection();
BlockFace dir;
try { /* Workaround Bukkit bug = http://leaky.bukkit.org/issues/1227 */
dir = event.getDirection();
} catch (ClassCastException ccx) {
dir = BlockFace.NORTH;
}
if(onpiston) {
mapManager.touchVolume(loc, b.getRelative(dir, 2).getLocation());
}
@ -492,9 +498,17 @@ public class DynmapPlugin extends JavaPlugin {
if(event.isCancelled())
return;
Block b = event.getBlock();
/* Avoid bogus piston events from Bukkit */
if((b.getType() != Material.PISTON_BASE) && (b.getType() != Material.PISTON_STICKY_BASE))
return;
Location loc = b.getLocation();
mapManager.sscache.invalidateSnapshot(loc);
BlockFace dir = event.getDirection();
BlockFace dir;
try { /* Workaround Bukkit bug = http://leaky.bukkit.org/issues/1227 */
dir = event.getDirection();
} catch (ClassCastException ccx) {
dir = BlockFace.NORTH;
}
if(onpiston) {
mapManager.touchVolume(loc, b.getRelative(dir, 1+event.getLength()).getLocation());
}