Paper/Spigot-API-Patches/0168-Support-cancellation-supression-of-EntityDismount-Ve.patch
Zach Brown 23a0b8c7bb
Update upstream CB
--- work/CraftBukkit
Submodule work/CraftBukkit e4183e70..f489f0f7:
  > SPIGOT-4494: Remove fix for SPIGOT-3864, better handled by SPIGOT-3879 fix
2018-11-21 21:49:47 -05:00

113 lines
4.0 KiB
Diff

From 9cc1d43c347c163357f283529d7fd0a9cefb5474 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 18 Nov 2018 15:53:43 +0000
Subject: [PATCH] Support cancellation supression of EntityDismount/VehicleExit
events"
Entities must be dismounted before teleportation in order to avoid
multiple issues in the server with regards to teleportation, shamefully,
too many plugins rely on the events firing, which means that not firing
these events caues more issues than it solves;
In order to counteract this, Entity dismount/exit vehicle events have
been modified to supress cancellation (and has a method to allow plugins
to check if this has been set), noting that cancellation will be silently
surpressed given that plugins are not expecting this event to not be cancellable.
This is a far from ideal scenario, however: given the current state of this
event and other alternatives causing issues elsewhere, I believe that
this is going to be the best soultion all around.
Improvements/suggestions welcome!
diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
index 364451b5..b3269db2 100644
--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
+++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
@@ -12,10 +12,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final LivingEntity exited;
+ private final boolean isCancellable; // Paper
- public VehicleExitEvent(final Vehicle vehicle, final LivingEntity exited) {
+ public VehicleExitEvent(Vehicle vehicle, LivingEntity exited, boolean isCancellable) { // Paper
super(vehicle);
this.exited = exited;
+ // Paper start
+ this.isCancellable = isCancellable;
+ }
+
+ public VehicleExitEvent(final Vehicle vehicle, final LivingEntity exited) {
+ this(vehicle, exited, true);
+ // Paper end
}
/**
@@ -32,9 +40,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
}
public void setCancelled(boolean cancel) {
+ // Paper start
+ if (cancel && !isCancellable) {
+ return;
+ }
this.cancelled = cancel;
}
+ public boolean isCancellable() {
+ return isCancellable;
+ // paper end
+ }
+
@Override
public HandlerList getHandlers() {
return handlers;
diff --git a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
index 4110d3bb..555899ef 100644
--- a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
+++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
@@ -15,11 +15,20 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Entity dismounted;
+ private final boolean isCancellable; // Paper
public EntityDismountEvent(Entity what, Entity dismounted)
{
+ // Paper start
+ this(what, dismounted, true);
+ }
+
+ public EntityDismountEvent(Entity what, Entity dismounted, boolean isCancellable)
+ {
+ // Paper end
super( what );
this.dismounted = dismounted;
+ this.isCancellable = isCancellable; // Paper
}
public Entity getDismounted()
@@ -36,9 +45,18 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable
@Override
public void setCancelled(boolean cancel)
{
+ // Paper start
+ if (cancel && !isCancellable) {
+ return;
+ }
this.cancelled = cancel;
}
+ public boolean isCancellable() {
+ return isCancellable;
+ // Paper end
+ }
+
@Override
public HandlerList getHandlers()
{
--
2.19.1