Permalink
Browse files

Fix pvp kills statistics not taking projectile and tameable in account

  • Loading branch information...
1 parent 0ad8550 commit 0143f0bde091295f31d7df1abb2fca253c1c05a6 @aumgn aumgn committed May 1, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/main/java/fr/aumgn/diamondrush/listeners/StatisticsListener.java
@@ -1,8 +1,11 @@
package fr.aumgn.diamondrush.listeners;
+import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile;
+import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -49,6 +52,18 @@ public void onPVPKill(EntityDeathEvent event) {
Entity damagerEntity = ((EntityDamageByEntityEvent) targetEntity.
getLastDamageCause()).getDamager();
+
+ if (damagerEntity instanceof Projectile) {
+ damagerEntity = ((Projectile) damagerEntity).getShooter();
+ }
+
+ if (damagerEntity instanceof Tameable) {
+ AnimalTamer owner = ((Tameable) damagerEntity).getOwner();
+ if (owner instanceof Entity) {
+ damagerEntity = (Entity) owner;
+ }
+ }
+
if (!(damagerEntity instanceof Player)) {
return;
}

0 comments on commit 0143f0b

Please sign in to comment.