Allow null weapons for kills

Fixes #742
This commit is contained in:
Brokkonaut
2019-02-14 21:24:09 +01:00
parent 025950a8c4
commit 92de737e4e
2 changed files with 6 additions and 3 deletions

View File

@ -280,7 +280,8 @@ public class Consumer extends Thread {
weapon = ((Player) killer).getInventory().getItemInMainHand(); weapon = ((Player) killer).getInventory().getItemInMainHand();
} }
if (killer instanceof Projectile) { if (killer instanceof Projectile) {
weapon = new ItemStack(itemIDfromProjectileEntity(killer)); Material projectileMaterial = itemIDfromProjectileEntity(killer);
weapon = projectileMaterial == null ? null : new ItemStack(projectileMaterial);
ProjectileSource ps = ((Projectile) killer).getShooter(); ProjectileSource ps = ((Projectile) killer).getShooter();
if (ps == null) { if (ps == null) {
killerActor = Actor.actorFromEntity(killer); killerActor = Actor.actorFromEntity(killer);

View File

@ -43,8 +43,10 @@ public class Kill implements LookupCacheElement {
if (loc != null) { if (loc != null) {
msg.append(" at ").append(loc.getBlockX()).append(":").append(loc.getBlockY()).append(":").append(loc.getBlockZ()); msg.append(" at ").append(loc.getBlockX()).append(":").append(loc.getBlockY()).append(":").append(loc.getBlockZ());
} }
String weaponName = prettyItemName(MaterialConverter.getMaterial(weapon)); if (weapon != 0) {
msg.append(" with " + weaponName); // + ("aeiou".contains(weaponName.substring(0, 1)) ? "an " : "a " ) String weaponName = prettyItemName(MaterialConverter.getMaterial(weapon));
msg.append(" with " + weaponName); // + ("aeiou".contains(weaponName.substring(0, 1)) ? "an " : "a " )
}
return msg.toString(); return msg.toString();
} }