From 274a363a974983444f140ef30086c1fa57dcc3d6 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 14 Dec 2014 20:49:38 -0600 Subject: [PATCH] Avoid trap in Spigot for light levels outside max height --- src/main/java/org/dynmap/bukkit/BukkitWorld.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/dynmap/bukkit/BukkitWorld.java b/src/main/java/org/dynmap/bukkit/BukkitWorld.java index d83b956f..485b88d1 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitWorld.java +++ b/src/main/java/org/dynmap/bukkit/BukkitWorld.java @@ -11,6 +11,7 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; import org.dynmap.DynmapChunk; @@ -124,7 +125,10 @@ public class BukkitWorld extends DynmapWorld { @Override public int getLightLevel(int x, int y, int z) { if(world != null) { - return world.getBlockAt(x, y, z).getLightLevel(); + if ((y >= 0) && (y < this.worldheight)) { + return world.getBlockAt(x, y, z).getLightLevel(); + } + return 0; } else { return -1; @@ -149,7 +153,12 @@ public class BukkitWorld extends DynmapWorld { @Override public int getSkyLightLevel(int x, int y, int z) { if(world != null) { - return world.getBlockAt(x, y, z).getLightFromSky(); + if ((y >= 0) && (y < this.worldheight)) { + return world.getBlockAt(x, y, z).getLightFromSky(); + } + else { + return 15; + } } else { return -1;