Ensure projectile source exists, fixes #369

This commit is contained in:
HappyPikachu 2018-04-17 11:17:10 -04:00
parent 1d04d263d7
commit 1bac3ed1f3

View File

@ -58,7 +58,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldguard.protection.managers.RegionManager;
@ -465,9 +464,8 @@ public class PlayerListener implements Listener {
if (damager != null) {
if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
ProjectileSource source = projectile.getShooter();
if (source instanceof Entity) {
killMob((Entity)source, evt.getEntity());
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
killMob((Entity)projectile.getShooter(), evt.getEntity());
}
} else if (damager instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) damager;
@ -535,9 +533,8 @@ public class PlayerListener implements Listener {
}
if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
ProjectileSource source = projectile.getShooter();
if (source instanceof Entity) {
killPlayer((Entity)source, evt.getEntity());
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
killPlayer((Entity)projectile.getShooter(), evt.getEntity());
}
} else if (damager instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) damager;