Extra NPE check

This commit is contained in:
fullwall 2020-06-27 15:17:29 +08:00
parent 99c7155a7a
commit 1505ccfeca
8 changed files with 44 additions and 15 deletions

View File

@ -367,12 +367,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -386,12 +386,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -390,12 +390,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -412,12 +412,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -448,12 +448,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -455,12 +455,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -461,12 +461,16 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override
public List<org.bukkit.entity.Entity> getPassengers(org.bukkit.entity.Entity entity) {
return Lists.transform(NMSImpl.getHandle(entity).passengers, new Function<Entity, org.bukkit.entity.Entity>() {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null || handle.passengers == null)
return Lists.newArrayList();
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
@Override
public org.bukkit.entity.Entity apply(Entity input) {
return input.getBukkitEntity();

View File

@ -320,7 +320,8 @@ public class NMSImpl implements NMSBridge {
@Override
public NPC getNPC(org.bukkit.entity.Entity entity) {
return getHandle(entity) instanceof NPCHolder ? ((NPCHolder) getHandle(entity)).getNPC() : null;
Entity handle = getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}
@Override