Fire events for tripwire and hooks.

This commit is contained in:
Travis Watkins 2012-08-05 22:52:25 -05:00
parent 982efb8c24
commit e1a4273957
2 changed files with 51 additions and 0 deletions

View File

@ -3,6 +3,11 @@ package net.minecraft.server;
import java.util.List;
import java.util.Random;
// CraftBukkit start
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityInteractEvent;
// CraftBukkit end
public class BlockTripwire extends Block {
public BlockTripwire(int i) {
@ -135,6 +140,39 @@ public class BlockTripwire extends Block {
flag1 = true;
}
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
if (flag != flag1) {
if (flag1) {
for (Object object : list) {
if (object != null) {
org.bukkit.event.Cancellable cancellable;
if (object instanceof EntityHuman) {
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
} else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
manager.callEvent((EntityInteractEvent) cancellable);
} else {
continue;
}
if (cancellable.isCancelled()) {
return;
}
}
}
}
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
manager.callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0;
}
// CraftBukkit end
if (flag1 && !flag) {
l |= 1;
}

View File

@ -2,6 +2,8 @@ package net.minecraft.server;
import java.util.Random;
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class BlockTripwireHook extends Block {
public BlockTripwireHook(int i) {
@ -153,6 +155,17 @@ public class BlockTripwireHook extends Block {
this.a(world, l2, j, k3, flag3, flag4, flag1, flag2);
}
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0);
world.getServer().getPluginManager().callEvent(eventRedstone);
if (eventRedstone.getNewCurrent() > 0) {
return;
}
// CraftBukkit end
this.a(world, i, j, k, flag3, flag4, flag1, flag2);
if (l > 0) {
world.setData(i, j, k, i1);