Compare commits

..

3 Commits

Author SHA1 Message Date
Mike Primm 96673f0fb3 More protection against exceptions for blocks at top of world 2012-05-23 08:13:47 -05:00
Mike Primm fc451fd002 Prevent traps by stupid mods that think BlockBreak events are good to send without blocks.... 2012-05-22 23:53:29 -05:00
Mike Primm 2f1b1789fd Bump to 0.40 2012-05-20 18:45:40 -05:00
3 changed files with 34 additions and 11 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>dynmap</artifactId>
<version>0.39</version>
<version>0.40</version>
<name>dynmap</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -216,7 +216,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
@SuppressWarnings("unused")
@EventHandler(priority=EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent evt) {
if(evt.isCancelled()) return;
Block b = evt.getBlock();
if(b == null) return; /* Work around for stupid mods.... */
Location l = b.getLocation();
core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().getId(),
BukkitWorld.normalizeWorldName(l.getWorld().getName()), l.getBlockX(), l.getBlockY(), l.getBlockZ());
@@ -228,6 +230,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
@SuppressWarnings("unused")
@EventHandler(priority=EventPriority.MONITOR)
public void onSignChange(SignChangeEvent evt) {
if(evt.isCancelled()) return;
Block b = evt.getBlock();
Location l = b.getLocation();
String[] lines = evt.getLines(); /* Note: changes to this change event - intentional */
@@ -842,7 +845,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
public void onBlockBreak(BlockBreakEvent event) {
if(event.isCancelled())
return;
Location loc = event.getBlock().getLocation();
Block b = event.getBlock();
if(b == null) return; /* Stupid mod workaround */
Location loc = b.getLocation();
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
@@ -101,16 +101,21 @@ public class NewMapChunkCache implements MapChunkCache {
exceptions++;
}
laststep = BlockStep.Y_MINUS;
typeid = blkdata = -1;
if((y >= 0) && (y < worldheight))
typeid = blkdata = -1;
else
typeid = blkdata = 0;
}
public final int getBlockTypeID() {
if(typeid < 0)
if(typeid < 0) {
typeid = snap.getBlockTypeId(bx, y, bz);
}
return typeid;
}
public final int getBlockData() {
if(blkdata < 0)
if(blkdata < 0) {
blkdata = snap.getBlockData(bx, y, bz);
}
return blkdata;
}
public int getBlockSkyLight() {
@@ -353,6 +358,8 @@ public class NewMapChunkCache implements MapChunkCache {
* Step current position in given direction
*/
public final void stepPosition(BlockStep step) {
typeid = -1;
blkdata = -1;
switch(step.ordinal()) {
case 0:
x++;
@@ -372,6 +379,9 @@ public class NewMapChunkCache implements MapChunkCache {
break;
case 1:
y++;
if(y >= worldheight) {
typeid = blkdata = 0;
}
break;
case 2:
z++;
@@ -407,6 +417,9 @@ public class NewMapChunkCache implements MapChunkCache {
break;
case 4:
y--;
if(y < 0) {
typeid = blkdata = 0;
}
break;
case 5:
z--;
@@ -426,8 +439,6 @@ public class NewMapChunkCache implements MapChunkCache {
break;
}
laststep = step;
typeid = -1;
blkdata = -1;
}
/**
* Unstep current position to previous position
@@ -449,8 +460,12 @@ public class NewMapChunkCache implements MapChunkCache {
else
laststep = BlockStep.Y_MINUS;
this.y = y;
typeid = -1;
blkdata = -1;
if((y < 0) || (y >= worldheight)) {
typeid = blkdata = 0;
}
else {
typeid = blkdata = -1;
}
}
public final int getX() {
return x;
@@ -493,9 +508,12 @@ public class NewMapChunkCache implements MapChunkCache {
}
@Override
public final boolean isEmptySection() {
if(isSectionNotEmpty[chunkindex] == null)
try {
return !isSectionNotEmpty[chunkindex][y >> 4];
} catch (Exception x) {
initSectionData(chunkindex);
return !isSectionNotEmpty[chunkindex][y >> 4];
return !isSectionNotEmpty[chunkindex][y >> 4];
}
}
}