2020-04-02 23:07:06 +02:00
|
|
|
From 8410be584674d595e9083950b84c74e5f880383b Mon Sep 17 00:00:00 2001
|
2018-11-18 16:39:28 +01:00
|
|
|
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
|
2020-04-02 23:07:06 +02:00
|
|
|
index 963b9ead4..a976c32de 100644
|
2018-11-18 16:39:28 +01:00
|
|
|
--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -13,10 +13,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
|
2018-11-18 16:39:28 +01:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
private boolean cancelled;
|
|
|
|
private final LivingEntity exited;
|
|
|
|
+ private final boolean isCancellable; // Paper
|
|
|
|
|
2019-03-20 01:28:15 +01:00
|
|
|
- public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
|
|
|
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited, boolean isCancellable) { // Paper
|
2018-11-18 16:39:28 +01:00
|
|
|
super(vehicle);
|
|
|
|
this.exited = exited;
|
|
|
|
+ // Paper start
|
|
|
|
+ this.isCancellable = isCancellable;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
2018-11-18 16:39:28 +01:00
|
|
|
+ this(vehicle, exited, true);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -36,9 +44,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
|
2018-11-18 16:39:28 +01:00
|
|
|
|
2019-05-06 04:58:04 +02:00
|
|
|
@Override
|
2018-11-18 16:39:28 +01:00
|
|
|
public void setCancelled(boolean cancel) {
|
|
|
|
+ // Paper start
|
|
|
|
+ if (cancel && !isCancellable) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
this.cancelled = cancel;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public boolean isCancellable() {
|
|
|
|
+ return isCancellable;
|
|
|
|
+ // paper end
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
@NotNull
|
2018-11-18 16:39:28 +01:00
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
diff --git a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
2020-04-02 23:07:06 +02:00
|
|
|
index 00d8ec81b..a7632c8f5 100644
|
2018-11-18 16:39:28 +01:00
|
|
|
--- a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
2020-01-28 20:43:57 +01:00
|
|
|
@@ -14,10 +14,19 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
|
2018-11-18 16:39:28 +01:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
private boolean cancelled;
|
|
|
|
private final Entity dismounted;
|
|
|
|
+ private final boolean isCancellable; // Paper
|
|
|
|
|
2020-01-28 20:43:57 +01:00
|
|
|
public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted) {
|
|
|
|
- super(what);
|
2018-11-18 16:39:28 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ this(what, dismounted, true);
|
|
|
|
+ }
|
|
|
|
+
|
2020-01-28 20:43:57 +01:00
|
|
|
+
|
|
|
|
+ public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable) {
|
2018-11-18 16:39:28 +01:00
|
|
|
+ // Paper end
|
2020-01-28 20:43:57 +01:00
|
|
|
+ super( what );
|
2018-11-18 16:39:28 +01:00
|
|
|
this.dismounted = dismounted;
|
|
|
|
+ this.isCancellable = isCancellable; // Paper
|
|
|
|
}
|
|
|
|
|
2019-03-20 01:28:15 +01:00
|
|
|
@NotNull
|
2020-01-28 20:43:57 +01:00
|
|
|
@@ -32,9 +41,18 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
|
|
|
|
|
2018-11-18 16:39:28 +01:00
|
|
|
@Override
|
2020-01-28 20:43:57 +01:00
|
|
|
public void setCancelled(boolean cancel) {
|
2018-11-18 16:39:28 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ if (cancel && !isCancellable) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
this.cancelled = cancel;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public boolean isCancellable() {
|
|
|
|
+ return isCancellable;
|
|
|
|
+ // Paper end
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
@NotNull
|
2018-11-18 16:39:28 +01:00
|
|
|
@Override
|
2020-01-28 20:43:57 +01:00
|
|
|
public HandlerList getHandlers() {
|
2018-11-18 16:39:28 +01:00
|
|
|
--
|
2020-04-02 23:07:06 +02:00
|
|
|
2.25.1
|
2018-11-18 16:39:28 +01:00
|
|
|
|