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