diff options
author | Erik Broes <erikbroes@ripe.net> | 2011-03-02 21:24:19 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@ripe.net> | 2011-03-02 21:27:02 +0100 |
commit | 332b0c2ca93e1556e2464fdbdd12d83fef006001 (patch) | |
tree | 011a49daad501c252e5d7dd936e7adde4810773c /src | |
parent | 34458efd83fe1119448c660924296347ef03c6d6 (diff) | |
download | craftbukkit-332b0c2ca93e1556e2464fdbdd12d83fef006001.tar craftbukkit-332b0c2ca93e1556e2464fdbdd12d83fef006001.tar.gz craftbukkit-332b0c2ca93e1556e2464fdbdd12d83fef006001.tar.lz craftbukkit-332b0c2ca93e1556e2464fdbdd12d83fef006001.tar.xz craftbukkit-332b0c2ca93e1556e2464fdbdd12d83fef006001.zip |
BlockFlowing NPE fix.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockFlowing.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index 70da69ce..4d2de48f 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -2,12 +2,12 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit start import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.event.Event.Type; import org.bukkit.event.block.BlockFromToEvent; -// CraftBukkit end public class BlockFlowing extends BlockFluids { @@ -28,8 +28,11 @@ public class BlockFlowing extends BlockFluids { } public void a(World world, int i, int j, int k, Random random) { - // CraftBukkit - CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); + // CraftBukkit start + CraftWorld cworld = ((WorldServer) world).getWorld(); + CraftServer server = ((WorldServer) world).getServer(); + CraftBlock source = cworld == null ? null : (CraftBlock) cworld.getBlockAt(i, j, k); + // CraftBukkit end int l = this.g(world, i, j, k); byte b0 = 1; @@ -97,7 +100,9 @@ public class BlockFlowing extends BlockFluids { if (this.l(world, i, j - 1, k)) { // CraftBukkit start - send "down" to the server BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.DOWN); - ((WorldServer) world).getServer().getPluginManager().callEvent(event); + if (server != null) { + server.getPluginManager().callEvent(event); + } if (!event.isCancelled()) { if (l >= 8) { @@ -125,7 +130,11 @@ public class BlockFlowing extends BlockFluids { for (BlockFace currentFace: faces) { if (aboolean[index]) { BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace); - ((WorldServer) world).getServer().getPluginManager().callEvent(event); + + if (server != null) { + server.getPluginManager().callEvent(event); + } + if (!event.isCancelled()) { this.g(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1); } |