summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java')
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java b/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
index 70855690..8bc708fc 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
@@ -2,6 +2,8 @@ package net.minecraft.server;
import java.util.List;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
private final int a;
@@ -11,7 +13,30 @@ public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
}
protected int e(World world, int i, int j, int k) {
- int l = Math.min(world.a(Entity.class, this.a(i, j, k)).size(), this.a);
+ // CraftBukkit start
+ int l = 0;
+ java.util.Iterator iterator = world.a(Entity.class, this.a(i, j, k)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
+
+ 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(), world.getWorld().getBlockAt(i, j, k));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (!cancellable.isCancelled()) {
+ l++;
+ }
+ }
+
+ l = Math.min(l, this.a);
+ // CraftBukkit end
if (l <= 0) {
return 0;