diff options
author | zml2008 <zach@zachsthings.com> | 2012-03-10 21:56:55 -0800 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-15 00:33:55 -0400 |
commit | 868eaf571cb168a8b2f2e128bb5eba6ed4505206 (patch) | |
tree | c018cafaa4ceab260875c3097e5f5b5f275c6e02 | |
parent | 2a4167d8a5a70ecc0585cb761dfb0067020bc90d (diff) | |
download | craftbukkit-868eaf571cb168a8b2f2e128bb5eba6ed4505206.tar craftbukkit-868eaf571cb168a8b2f2e128bb5eba6ed4505206.tar.gz craftbukkit-868eaf571cb168a8b2f2e128bb5eba6ed4505206.tar.lz craftbukkit-868eaf571cb168a8b2f2e128bb5eba6ed4505206.tar.xz craftbukkit-868eaf571cb168a8b2f2e128bb5eba6ed4505206.zip |
[Bleeding] Call a LAVA BlockIgniteEvent in another place in BlockStationary. Fixes BUKKIT-970
Also adds CraftEventFactory.callEvent(Event), which returns the event called. Currently only used for n.m.s.BlockStationary's lava
BlockIgniteEvent calls.
-rw-r--r-- | src/main/java/net/minecraft/server/BlockStationary.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 6 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java index d4f276c9..bbf87e01 100644 --- a/src/main/java/net/minecraft/server/BlockStationary.java +++ b/src/main/java/net/minecraft/server/BlockStationary.java @@ -56,12 +56,8 @@ public class BlockStationary extends BlockFluids { if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) { // CraftBukkit start - prevent lava putting something on fire. org.bukkit.block.Block block = bworld.getBlockAt(i, j, k); - if (block.getTypeId() != Block.FIRE.id) { - BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) { continue; } } @@ -83,6 +79,15 @@ public class BlockStationary extends BlockFluids { i = i1 + random.nextInt(3) - 1; k = j1 + random.nextInt(3) - 1; if (world.isEmpty(i, j + 1, k) && this.j(world, i, j, k)) { + // CraftBukkit start - prevent lava putting something on fire. + org.bukkit.block.Block block = bworld.getBlockAt(i, j + 1, k); + if (block.getTypeId() != Block.FIRE.id) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) { + continue; + } + } + // CraftBukkit end + world.setTypeId(i, j + 1, k, Block.FIRE.id); } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index d6550e81..66dbef78 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -47,6 +47,7 @@ import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.Event; import org.bukkit.event.block.*; import org.bukkit.event.entity.*; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -72,6 +73,11 @@ public class CraftEventFactory { return distanceFromSpawn > spawnSize; } + public static <T extends Event> T callEvent(T event) { + Bukkit.getServer().getPluginManager().callEvent(event); + return event; + } + /** * Block place methods */ |