diff --git a/Spigot-API-Patches/Support-cancellation-supression-of-EntityDismount-Ve.patch b/Spigot-API-Patches/Support-cancellation-supression-of-EntityDismount-Ve.patch new file mode 100644 index 000000000..6a279de2b --- /dev/null +++ b/Spigot-API-Patches/Support-cancellation-supression-of-EntityDismount-Ve.patch @@ -0,0 +1,110 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +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 364451b56..b3269db2e 100644 +--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java ++++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java +@@ -0,0 +0,0 @@ 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 + } + + /** +@@ -0,0 +0,0 @@ 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 4110d3bb2..555899efc 100644 +--- a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java ++++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java +@@ -0,0 +0,0 @@ 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() +@@ -0,0 +0,0 @@ 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() + { +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch b/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch index 2132d8fb2..0b6846ca1 100644 --- a/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch +++ b/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch @@ -4,18 +4,23 @@ Date: Thu, 15 Nov 2018 13:38:37 +0000 Subject: [PATCH] force entity dismount during teleportation Entities must be dismounted before teleportation in order to avoid -multiple issues in the server with regards to teleportation, while -we now lose the ability for plugins to monitor this specific case -of entity dismount, the alternative is that we allow a cancellable -event, but silently ignore the cancelled status, which might cause -further issues for plugins tracking state +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; -Given that nobody can be relying on the Cancellable state of those -events during teleportation due to the issues that arise from this, -this is a small trade off +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/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 32b90f30d9..2377175f83 100644 +index 32b90f30d9..78ec842f29 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -25,14 +30,14 @@ index 32b90f30d9..2377175f83 100644 - public void stopRiding() { + // Paper start + public void stopRiding() { stopRiding(false); } -+ public void stopRiding(boolean force) { ++ public void stopRiding(boolean suppressCancellation) { + // Paper end if (this.vehicle != null) { Entity entity = this.vehicle; this.vehicle = null; - if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit -+ if (!entity.removePassenger(this, force)) this.vehicle = entity; // CraftBukkit // Paper ++ if (!entity.removePassenger(this, suppressCancellation)) this.vehicle = entity; // CraftBukkit // Paper } } @@ -43,25 +48,31 @@ index 32b90f30d9..2377175f83 100644 - protected boolean removePassenger(Entity entity) { // CraftBukkit + // Paper start + protected boolean removePassenger(Entity entity) { return removePassenger(entity, false);} -+ protected boolean removePassenger(Entity entity, boolean force) { // CraftBukkit ++ protected boolean removePassenger(Entity entity, boolean suppressCancellation) { // CraftBukkit + // Paper end if (entity.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { -+ if (!force) { // Paper - // CraftBukkit start - CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); - Entity orig = craft == null ? null : craft.getHandle(); @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { + VehicleExitEvent event = new VehicleExitEvent( + (Vehicle) getBukkitEntity(), +- (LivingEntity) entity.getBukkitEntity() ++ (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper + ); + Bukkit.getPluginManager().callEvent(event); + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); +@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + } + // CraftBukkit end + // Spigot start +- org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()); ++ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; - } -+ } // Paper - // Spigot end - this.passengers.remove(entity); - entity.k = 60; diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 4490b63258..4fcbbae7d4 100644 +index 4490b63258..388a20a21f 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -71,26 +82,13 @@ index 4490b63258..4fcbbae7d4 100644 - public void stopRiding() { + // Paper start + public void stopRiding() { stopRiding(false);}; -+ public void stopRiding(boolean force) { ++ public void stopRiding(boolean suppressCancellation) { + // paper end Entity entity = this.getVehicle(); - super.stopRiding(); -+ super.stopRiding(force); // Paper ++ super.stopRiding(suppressCancellation); // Paper Entity entity1 = this.getVehicle(); if (entity1 != entity && this.playerConnection != null) { -diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 73bd0dc4a1..ec52f385eb 100644 ---- a/src/main/java/net/minecraft/server/PlayerList.java -+++ b/src/main/java/net/minecraft/server/PlayerList.java -@@ -0,0 +0,0 @@ public abstract class PlayerList { - } - - public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag, Location location, boolean avoidSuffocation) { -- entityplayer.stopRiding(); // CraftBukkit -+ entityplayer.stopRiding(true); // CraftBukkit // Paper - entityplayer.getWorldServer().getTracker().untrackPlayer(entityplayer); - // entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); // CraftBukkit - entityplayer.getWorldServer().getPlayerChunkMap().removePlayer(entityplayer); -- \ No newline at end of file