Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +01:00
0976d52bbd
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Please note that this build includes changes to meet upstreams requirements for nullability annotations. While we aim for a level of accuracy, these might not be 100% correct, if there are any issues, please speak to us on discord, or open an issue on the tracker to discuss. Bukkit Changes: 9a6a1de3 Remove nullability annotations from enum constructors 3f0591ea SPIGOT-2540: Add nullability annotations to entire Bukkit API CraftBukkit Changes:8d8475fc
SPIGOT-4666: Force parameter in HumanEntity#sleep8b1588e2
Fix ExplosionPrimeEvent#setFire not working with EnderCrystals39a287b7
Don't ignore newlines in PlayerListHeader/Footer Spigot Changes: cf694d87 Add nullability annotations
113 Zeilen
4.1 KiB
Diff
113 Zeilen
4.1 KiB
Diff
From 4e2017501e66dc245fbf331a39e74e195f1ca38a 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 69c9e499a..f0c0bae56 100644
|
|
--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
|
@@ -13,10 +13,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(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
|
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited, boolean isCancellable) { // Paper
|
|
super(vehicle);
|
|
this.exited = exited;
|
|
+ // Paper start
|
|
+ this.isCancellable = isCancellable;
|
|
+ }
|
|
+
|
|
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
|
+ this(vehicle, exited, true);
|
|
+ // Paper end
|
|
}
|
|
|
|
/**
|
|
@@ -34,9 +42,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
|
|
+ }
|
|
+
|
|
@NotNull
|
|
@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
|
|
index a473b2c6e..a5b4aed52 100644
|
|
--- a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
|
+++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
|
@@ -16,11 +16,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(@NotNull Entity what, @NotNull Entity dismounted)
|
|
{
|
|
+ // Paper start
|
|
+ this(what, dismounted, true);
|
|
+ }
|
|
+
|
|
+ public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable)
|
|
+ {
|
|
+ // Paper end
|
|
super( what );
|
|
this.dismounted = dismounted;
|
|
+ this.isCancellable = isCancellable; // Paper
|
|
}
|
|
|
|
@NotNull
|
|
@@ -38,9 +47,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
|
|
+ }
|
|
+
|
|
@NotNull
|
|
@Override
|
|
public HandlerList getHandlers()
|
|
--
|
|
2.21.0
|
|
|