mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
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!
This commit is contained in:
parent
d9195b0be3
commit
a9d195552e
2 changed files with 35 additions and 1 deletions
|
@ -13,10 +13,18 @@ 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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,9 +44,18 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
|
|||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
// Paper start
|
||||
if (cancel && !this.isCancellable) {
|
||||
return;
|
||||
}
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public boolean isCancellable() {
|
||||
return this.isCancellable;
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,9 +44,18 @@ public class VehicleExitEvent extends VehicleEvent 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() {
|
||||
|
|
Loading…
Reference in a new issue