Fix EntityDismountEvent and VehicleExitEvent cancellation

Perhaps "workaround" would be the better term
This commit is contained in:
Zach Brown 2016-04-22 15:45:22 -05:00
parent a6536804fd
commit 4f7b7bb31a
No known key found for this signature in database
GPG Key ID: CC9DA35FC5450B76
5 changed files with 41 additions and 12 deletions

View File

@ -1,9 +1,8 @@
From 32304a72413a8faddc6192b78f7bbc5850810763 Mon Sep 17 00:00:00 2001
From e99524d7eec1240e136ac933dccd3f8ac9e72902 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 01:43:11 -0500
Subject: [PATCH] EntityRegainHealthEvent isFastRegen API
Don't even get me started
diff --git a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
index a7b3517..703520f 100644

View File

@ -1,20 +1,25 @@
From 5c4d7d8d8e6ff1d01202e5de62da63fe66c55c96 Mon Sep 17 00:00:00 2001
From 031f1df60d5934708755d7afe14817d30fdf8b4d Mon Sep 17 00:00:00 2001
From: Nik Gil <nikmanG@users.noreply.github.com>
Date: Thu, 3 Mar 2016 04:04:19 -0600
Subject: [PATCH] Made EntityDismountEvent Cancellable
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 782abd6..c3e6588 100644
index 782abd6..b15c5f6 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1741,7 +1741,9 @@ public abstract class Entity implements ICommandListener {
@@ -1741,7 +1741,14 @@ public abstract class Entity implements ICommandListener {
}
}
// CraftBukkit end
- Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity())); // Spigot
+ // Paper start - make EntityDismountEvent cancellable
+ if (!new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()).callEvent()) return;
+ if (!new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()).callEvent()) {
+ if (entity instanceof EntityPlayer) {
+ ((EntityPlayer) entity).playerConnection.sendPacket(new net.minecraft.server.PacketPlayOutMount(this));
+ }
+ return;
+ }
+ // Paper end
this.passengers.remove(entity);
entity.j = 60;

View File

@ -1,4 +1,4 @@
From 4fd34aff149d7fee35a8e3b18e2e007bb2225d97 Mon Sep 17 00:00:00 2001
From 5f3dd9383f6ea18ea59df19c28d68bea36d87d98 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 8 Mar 2016 23:25:45 -0500
Subject: [PATCH] Disable Scoreboards for non players by default
@ -37,10 +37,10 @@ index b044f33..1758a56 100644
if (scoreboard.addPlayerToTeam(s2, s)) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 5ff5c54..f9626d6 100644
index fc4d72f..14ab2da 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1847,6 +1847,7 @@ public abstract class Entity implements ICommandListener {
@@ -1852,6 +1852,7 @@ public abstract class Entity implements ICommandListener {
}
public ScoreboardTeamBase aO() {

View File

@ -1,4 +1,4 @@
From 113483e5a4e9d1f9f4f0b98b2d80ceb075c323ba Mon Sep 17 00:00:00 2001
From 8a8060df1836f7082b54b4fda091c10e1cefd2d6 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 22 Mar 2016 00:55:23 -0400
Subject: [PATCH] Don't teleport dead entities
@ -7,10 +7,10 @@ Had some issue with this in past, and this is the vanilla logic.
Potentially an old CB change that's no longer needed.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 4a4fe34..49e6661 100644
index 8c26c0e..1bc39f5 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2097,7 +2097,7 @@ public abstract class Entity implements ICommandListener {
@@ -2102,7 +2102,7 @@ public abstract class Entity implements ICommandListener {
}
public Entity teleportTo(Location exit, boolean portal) {

View File

@ -0,0 +1,25 @@
From acbc64e0d3be4b92b05dfb9cac09fd7d2f0f021a Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 15:42:44 -0500
Subject: [PATCH] Fix VehicleExitEvent cancellation
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 8512105..1f59225 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1739,6 +1739,11 @@ public abstract class Entity implements ICommandListener {
CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
+ // Paper - Fix cancellation
+ if (entity instanceof EntityPlayer) {
+ ((EntityPlayer) entity).playerConnection.sendPacket(new net.minecraft.server.PacketPlayOutMount(this));
+ }
+ // Paper end
return;
}
}
--
2.8.0