Paper/Spigot-Server-Patches/0110-Vehicle-Event-Cancellation-Changes.patch
2018-07-21 16:43:00 -04:00

46 lines
2.1 KiB
Diff

From 173ce5b19ace1cc6316fe318b79cc36ee2c207d5 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 18:20:05 -0500
Subject: [PATCH] Vehicle Event Cancellation Changes
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 31c580de1..16d521dfd 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -93,7 +93,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public boolean j;
public final List<Entity> passengers;
protected int k;
- private Entity ax;
+ private Entity ax;public void setVehicle(Entity entity) { this.ax = entity; } // Paper - OBFHELPER
public boolean attachedToPlayer;
public World world;
public double lastX;
@@ -2123,6 +2123,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
+ entity.setVehicle(this); // Paper - Set the vehicle back for the event
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -2138,7 +2139,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
// CraftBukkit end
- Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity())); // Spigot
+ // Paper start - make EntityDismountEvent cancellable
+ if (!new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()).callEvent()) {
+ return;
+ }
+ entity.setVehicle(null);
+ // Paper end
+
this.passengers.remove(entity);
entity.k = 60;
}
--
2.18.0