Merge pull request #9 from Techcable/cancellable-EntityDismountEvent

Make EntityDismountEvent Cancellable
This commit is contained in:
Zach Brown 2016-02-03 03:09:18 -06:00
commit a3fce6a8a0
2 changed files with 111 additions and 0 deletions

View file

@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nik Gil <nikmanG@users.noreply.github.com>
Date: Mon, 1 Feb 2016 23:36:31 -0700
Subject: [PATCH] Made EntityDismountEvent Cancellable
diff --git a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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 @@ import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
+// PaperSpigot start
+import org.bukkit.event.Cancellable;
+// PaperSpigot end
+
/**
* Called when an entity stops riding another entity.
*
*/
-public class EntityDismountEvent extends EntityEvent
+public class EntityDismountEvent extends EntityEvent implements Cancellable // PaperSpigot - implement Cancellable
{
private static final HandlerList handlers = new HandlerList();
@@ -0,0 +0,0 @@ public class EntityDismountEvent extends EntityEvent
{
return handlers;
}
+
+ // PaperSpigot start - implement Cancellable methods
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+ // PaperSpigot end
}
--

View file

@ -0,0 +1,66 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nik Gil <nikmanG@users.noreply.github.com>
Date: Mon, 1 Feb 2016 23:47:24 -0700
Subject: [PATCH] Made EntityDismountEvent Cancellable
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.plugin.PluginManager;
// CraftBukkit end
+// PaperSpigot start
+import org.spigotmc.event.entity.EntityDismountEvent;
+// PaperSpigot end
+
public abstract class Entity implements ICommandListener {
// CraftBukkit start
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
}
}
// CraftBukkit end
- pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
+ // PaperSpigot start - make EntityDismountEvent cancellable
+ EntityDismountEvent dismountEvent = new EntityDismountEvent(this.getBukkitEntity(), this.vehicle.getBukkitEntity()); // Spigot
+ pluginManager.callEvent(dismountEvent);
+ if (dismountEvent.isCancelled()) return;
+ // PaperSpigot end
this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null;
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -0,0 +0,0 @@ import org.bukkit.event.vehicle.VehicleExitEvent;
import co.aikar.timings.SpigotTimings; // Spigot
+// PaperSpigot start
+import org.bukkit.Bukkit;
+import org.spigotmc.event.entity.EntityDismountEvent;
+// PaperSpigot end
+
public abstract class EntityLiving extends Entity {
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
}
}
// CraftBukkit end
- org.bukkit.Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
-
+ // PaperSpigot start - make dismountEvent cancellable
+ EntityDismountEvent dismountEvent = new EntityDismountEvent(this.getBukkitEntity(), this.vehicle.getBukkitEntity()); // Spigot
+ Bukkit.getPluginManager().callEvent(dismountEvent);
+ if (dismountEvent.isCancelled()) return;
+ // PaperSpigot end
+
if (!this.world.isClientSide) {
this.q(this.vehicle);
}
--