Mineplex2018-withcommit/Patches/CraftBukkit-Patches/0017-EntityDismountEvent-teleport-crash-fix.patch

138 lines
8.2 KiB
Diff
Raw Normal View History

2016-04-25 02:19:41 +02:00
From b65ae80e1e33609ba8b85c51484d196e57c0a75f Mon Sep 17 00:00:00 2001
2015-11-22 02:44:32 +01:00
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
2016-02-14 23:58:33 +01:00
index 81ca499..2a4f819 100644
2015-11-22 02:44:32 +01:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2016-02-14 23:58:33 +01:00
@@ -1591,7 +1591,11 @@ public abstract class Entity implements ICommandListener {
2015-11-22 02:44:32 +01:00
}
}
// CraftBukkit end
- pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
2016-02-14 23:58:33 +01:00
+ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ); // Spigot
2015-11-22 02:44:32 +01:00
+ pluginManager.callEvent(event); // Spigot
+ if (event.isCancelled() || vehicle != originalVehicle) {
+ return;
2016-02-14 23:58:33 +01:00
+ }
2015-11-22 02:44:32 +01:00
this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null;
}
2016-02-14 23:58:33 +01:00
@@ -1599,44 +1603,44 @@ public abstract class Entity implements ICommandListener {
2015-11-22 02:44:32 +01:00
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;
2016-02-14 23:58:33 +01:00
+ org.spigotmc.event.entity.EntityDismountEvent exitEvent1 = null;
2015-11-22 02:44:32 +01:00
if (this.vehicle != null) {
- exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
2016-02-14 23:58:33 +01:00
- pluginManager.callEvent(exitEvent);
+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle)) {
2015-11-22 02:44:32 +01:00
+ exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
2016-02-14 23:58:33 +01:00
+ pluginManager.callEvent(exitEvent);
2015-11-22 02:44:32 +01:00
+
2016-02-14 23:58:33 +01:00
+ if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
+ return;
+ }
+ }
+ exitEvent1 = new org.spigotmc.event.entity.EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity);
2015-11-22 02:44:32 +01:00
+ pluginManager.callEvent(exitEvent1);
2016-02-14 23:58:33 +01:00
- if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
2015-11-22 02:44:32 +01:00
+ if (exitEvent1.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
2016-02-14 23:58:33 +01:00
return;
}
2015-11-22 02:44:32 +01:00
}
- 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
2016-02-14 23:58:33 +01:00
index f75b0b1..19fc521 100644
2015-11-22 02:44:32 +01:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2016-02-14 23:58:33 +01:00
@@ -1725,6 +1725,13 @@ public abstract class EntityLiving extends Entity {
2015-11-22 02:44:32 +01:00
return;
}
}
+
2016-02-14 23:58:33 +01:00
+ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
2015-11-22 02:44:32 +01:00
+ getBukkitEntity().getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || vehicle != originalVehicle) {
+ return;
+ }
// CraftBukkit end
2016-02-14 23:58:33 +01:00
org.bukkit.Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
2015-11-22 02:44:32 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
2016-02-14 23:58:33 +01:00
index efbf1a8..ad53590 100644
2015-11-22 02:44:32 +01:00
--- 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;
2016-02-14 23:58:33 +01:00
@@ -233,6 +234,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
2015-11-22 02:44:32 +01:00
// If this entity is riding another entity, we must dismount before teleporting.
entity.mount(null);
2016-02-14 23:58:33 +01:00
+ if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ())) {
2015-11-22 02:44:32 +01:00
+ Thread.dumpStack();
+ return false;
+ }
2016-02-14 23:58:33 +01:00
2015-11-22 02:44:32 +01:00
// Spigot start
if (!location.getWorld().equals(getWorld())) {
--
2016-04-25 02:19:41 +02:00
2.7.4
2015-11-22 02:44:32 +01:00