Add a NPE check to getVehicle

This commit is contained in:
fullwall 2018-03-02 00:39:05 +08:00
parent d14119bc38
commit bf13181bd1
4 changed files with 13 additions and 2 deletions

View File

@ -505,6 +505,9 @@ public class NMSImpl implements NMSBridge {
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null) {
return null;
}
Entity e = handle.getVehicle();
return (e == handle || e == null) ? null : e.getBukkitEntity();
}

View File

@ -547,6 +547,9 @@ public class NMSImpl implements NMSBridge {
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null) {
return null;
}
Entity e = handle.getVehicle();
return (e == handle || e == null) ? null : e.getBukkitEntity();
}

View File

@ -84,9 +84,10 @@ public class OcelotController extends MobEntityController {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
}
@Override
protected SoundEffect d(DamageSource damagesource) {
@ -188,9 +189,10 @@ public class OcelotController extends MobEntityController {
@Override
public void M() {
super.M();
if (npc != null)
if (npc != null) {
npc.update();
}
}
@Override
public boolean m_() {

View File

@ -551,6 +551,9 @@ public class NMSImpl implements NMSBridge {
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null) {
return null;
}
Entity e = handle.getVehicle();
return (e == handle || e == null) ? null : e.getBukkitEntity();
}