160 lines
8.8 KiB
Diff
160 lines
8.8 KiB
Diff
|
From bc86c3b02f2efa4c1194fc908e8d1ee8723f62c5 Mon Sep 17 00:00:00 2001
|
||
|
From: libraryaddict <libraryaddict115@yahoo.co.nz>
|
||
|
Date: Sun, 22 Nov 2015 14:41:11 +1300
|
||
|
Subject: [PATCH] EntityDismountEvent & teleport crash fix
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||
|
index 81ca499..7165579 100644
|
||
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
||
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||
|
@@ -23,6 +23,8 @@ import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||
|
+import org.spigotmc.event.entity.EntityDismountEvent;
|
||
|
+import org.spigotmc.event.entity.EntityMountEvent;
|
||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||
|
@@ -1591,7 +1593,12 @@ public abstract class Entity implements ICommandListener {
|
||
|
}
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
- pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
|
||
|
+ EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(this.getBukkitEntity(), this.vehicle.getBukkitEntity());
|
||
|
+ pluginManager.callEvent(event); // Spigot
|
||
|
+
|
||
|
+ if (event.isCancelled() || vehicle != originalVehicle) {
|
||
|
+ return;
|
||
|
+ } // Spigot
|
||
|
this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
|
||
|
this.vehicle.passenger = null;
|
||
|
}
|
||
|
@@ -1599,44 +1606,45 @@ public abstract class Entity implements ICommandListener {
|
||
|
this.vehicle = null;
|
||
|
} else {
|
||
|
// CraftBukkit start
|
||
|
- if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
|
||
|
+ if (entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
|
||
|
// It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
|
||
|
VehicleExitEvent exitEvent = null;
|
||
|
+ EntityDismountEvent exitEvent1 = null;
|
||
|
if (this.vehicle != null) {
|
||
|
- exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
|
||
|
+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle))
|
||
|
+ exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
|
||
|
pluginManager.callEvent(exitEvent);
|
||
|
|
||
|
if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
|
||
|
return;
|
||
|
}
|
||
|
+
|
||
|
+ exitEvent1 = new EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity);
|
||
|
+
|
||
|
+ pluginManager.callEvent(exitEvent1);
|
||
|
+
|
||
|
+ if (exitEvent1.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
- VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity);
|
||
|
- pluginManager.callEvent(event);
|
||
|
+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle)) {
|
||
|
+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity);
|
||
|
+ pluginManager.callEvent(event);
|
||
|
|
||
|
- // If a plugin messes with the vehicle or the vehicle's passenger
|
||
|
- if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
|
||
|
- // If we only cancelled the enterevent then we need to put the player in a decent position.
|
||
|
- if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) {
|
||
|
- this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
|
||
|
- this.vehicle.passenger = null;
|
||
|
- this.vehicle = null;
|
||
|
+ // If a plugin messes with the vehicle or the vehicle's passenger
|
||
|
+ if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
|
||
|
+ // If we only cancelled the enterevent then we need to put the player in a decent position.
|
||
|
+ if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) {
|
||
|
+ this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
|
||
|
+ this.vehicle.passenger = null;
|
||
|
+ this.vehicle = null;
|
||
|
+ }
|
||
|
+ return;
|
||
|
}
|
||
|
- return;
|
||
|
}
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
- // Spigot Start
|
||
|
- if ( entity.world.isChunkLoaded( (int) entity.locX >> 4, (int) entity.locZ >> 4, true ) )
|
||
|
- {
|
||
|
- org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent( this.getBukkitEntity(), entity.getBukkitEntity() );
|
||
|
- pluginManager.callEvent( event );
|
||
|
- if ( event.isCancelled() )
|
||
|
- {
|
||
|
- return;
|
||
|
- }
|
||
|
- }
|
||
|
- // Spigot End
|
||
|
|
||
|
if (this.vehicle != null) {
|
||
|
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 b861dbe..96b3905 100644
|
||
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||
|
@@ -21,6 +21,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||
|
+import org.spigotmc.event.entity.EntityDismountEvent;
|
||
|
// CraftBukkit end
|
||
|
|
||
|
import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||
|
@@ -1725,8 +1726,15 @@ public abstract class EntityLiving extends Entity {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
+
|
||
|
+ EntityDismountEvent event = new EntityDismountEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
|
||
|
+ getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||
|
+
|
||
|
+ if (event.isCancelled() || vehicle != originalVehicle) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
// CraftBukkit end
|
||
|
-
|
||
|
+
|
||
|
if (!this.world.isClientSide) {
|
||
|
this.q(this.vehicle);
|
||
|
}
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
index efbf1a8..dbc7b54 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
@@ -1,6 +1,7 @@
|
||
|
package org.bukkit.craftbukkit.entity;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
+import com.google.common.primitives.Doubles;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collection;
|
||
|
import java.util.List;
|
||
|
@@ -234,6 +235,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||
|
// If this entity is riding another entity, we must dismount before teleporting.
|
||
|
entity.mount(null);
|
||
|
|
||
|
+ if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ()))
|
||
|
+ {
|
||
|
+ Thread.dumpStack();
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
// Spigot start
|
||
|
if (!location.getWorld().equals(getWorld())) {
|
||
|
entity.teleportTo(location, cause.equals(TeleportCause.NETHER_PORTAL));
|
||
|
--
|
||
|
1.9.5.msysgit.0
|
||
|
|