diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-10-16 20:59:39 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-10-16 21:05:33 +0100 |
commit | 6f85761f7fc7949b478c0dec44240f93d4b08a02 (patch) | |
tree | 1da56d3d8ca883cfb71e766600f336d39ecbccb2 /EssentialsProtect/src/com/earth2me | |
parent | cf9d79d24c8b33d10585a3fc97bc38554dee6d8b (diff) | |
download | Essentials-6f85761f7fc7949b478c0dec44240f93d4b08a02.tar Essentials-6f85761f7fc7949b478c0dec44240f93d4b08a02.tar.gz Essentials-6f85761f7fc7949b478c0dec44240f93d4b08a02.tar.lz Essentials-6f85761f7fc7949b478c0dec44240f93d4b08a02.tar.xz Essentials-6f85761f7fc7949b478c0dec44240f93d4b08a02.zip |
Extract CommandSender to CommandSource, this should prevent Ess user object leaks.
Diffstat (limited to 'EssentialsProtect/src/com/earth2me')
-rw-r--r-- | EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java index d8657fef5..1336f3e07 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -37,7 +37,12 @@ public class EssentialsProtectEntityListener implements Listener return;
}
- final User user = ess.getUser(target);
+ User user = null;
+ if (target instanceof Player)
+ {
+ user = ess.getUser((Player)target);
+ }
+
final DamageCause cause = event.getCause();
if (event instanceof EntityDamageByBlockEvent)
@@ -69,7 +74,12 @@ public class EssentialsProtectEntityListener implements Listener {
final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
final Entity eAttack = edEvent.getDamager();
- final User attacker = ess.getUser(eAttack);
+
+ User attacker = null;
+ if (eAttack instanceof Player)
+ {
+ attacker = ess.getUser((Player)eAttack);
+ }
//Creeper explode prevention
if (eAttack instanceof Creeper
@@ -126,7 +136,7 @@ public class EssentialsProtectEntityListener implements Listener || (((Projectile)edEvent.getDamager()).getShooter() instanceof Player
&& prot.getSettingBool(ProtectConfig.disable_pvp)
&& (!user.isAuthorized("essentials.protect.pvp")
- || !ess.getUser(((Projectile)edEvent.getDamager()).getShooter()).isAuthorized("essentials.protect.pvp")))))
+ || !ess.getUser((Player)((Projectile)edEvent.getDamager()).getShooter()).isAuthorized("essentials.protect.pvp")))))
{
event.setCancelled(true);
return;
@@ -275,7 +285,7 @@ public class EssentialsProtectEntityListener implements Listener {
return;
}
- final User user = ess.getUser(event.getTarget());
+ final User user = ess.getUser((Player)event.getTarget());
if ((event.getReason() == TargetReason.CLOSEST_PLAYER
|| event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
|| event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
|