aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0122-Vehicle-Event-Cancellation-Changes.patch
blob: 1c2c6354af8d68a050365f93d5ff5a7ebf2bfe58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 553d60de49239338485f8c345535b4855e14d276 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 61d2d91c..f82c0546 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -83,7 +83,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
     public boolean i;
     public final List<Entity> passengers;
     protected int j;
-    private Entity au;
+    private Entity au;public void setVehicle(Entity entity) { this.au = entity; } // Paper // OBFHELPER
     public boolean attachedToPlayer;
     public World world;
     public double lastX;
@@ -2025,6 +2025,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
             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) {
@@ -2040,7 +2041,13 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
                 }
             }
             // 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.j = 60;
         }
-- 
2.19.1