1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package net.minecraft.server;
import java.util.Iterator;
import java.util.List;
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
private EnumMobType a;
protected BlockPressurePlateBinary(String s, Material material, EnumMobType enummobtype) {
super(s, material);
this.a = enummobtype;
}
protected int d(int i) {
return i > 0 ? 1 : 0;
}
protected int c(int i) {
return i == 1 ? 15 : 0;
}
protected int e(World world, int i, int j, int k) {
List list = null;
if (this.a == EnumMobType.EVERYTHING) {
list = world.getEntities((Entity) null, this.a(i, j, k));
}
if (this.a == EnumMobType.MOBS) {
list = world.a(EntityLiving.class, this.a(i, j, k));
}
if (this.a == EnumMobType.PLAYERS) {
list = world.a(EntityHuman.class, this.a(i, j, k));
}
if (list != null && !list.isEmpty()) {
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
// CraftBukkit start - Call interact event when turning on a pressure plate
if (this.c(world.getData(i, j, k)) == 0) {
org.bukkit.World bworld = world.getWorld();
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
org.bukkit.event.Cancellable cancellable;
if (entity instanceof EntityHuman) {
cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
} else {
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(i, j, k));
manager.callEvent((EntityInteractEvent) cancellable);
}
// We only want to block turning the plate on if all events are cancelled
if (cancellable.isCancelled()) {
continue;
}
}
// CraftBukkit end
if (!entity.az()) {
return 15;
}
}
}
return 0;
}
}
|