From 8f17ec96f07761bd9434620fcb2d06e743abdb66 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 2 Feb 2013 19:07:05 -0500 Subject: [PATCH] Fixed teleport exploit in regards to Archery bonus XP. --- .../nossr50/skills/archery/ArcheryManager.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 572c01cf6..8e71a5ec8 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -18,10 +18,21 @@ public class ArcheryManager extends SkillManager { public void distanceXpBonus(LivingEntity target) { Player player = mcMMOPlayer.getPlayer(); - Location shooterLocation = player.getEyeLocation(); + Location shooterLocation = player.getLocation(); Location targetLocation = target.getLocation(); + + if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) { + return; + } + double squaredDistance = shooterLocation.distanceSquared(targetLocation); + // Cap distance at 100^2 to prevent teleport exploit. + // TODO: Better way to handle this would be great... + if (squaredDistance > 10000) { + squaredDistance = 10000; + } + int bonusXp = (int) (squaredDistance * Archery.distanceXpModifer); mcMMOPlayer.addXp(SkillType.ARCHERY, bonusXp); }