mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Fixed teleport exploit in regards to Archery bonus XP.
This commit is contained in:
		@@ -18,10 +18,21 @@ public class ArcheryManager extends SkillManager {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public void distanceXpBonus(LivingEntity target) {
 | 
					    public void distanceXpBonus(LivingEntity target) {
 | 
				
			||||||
        Player player = mcMMOPlayer.getPlayer();
 | 
					        Player player = mcMMOPlayer.getPlayer();
 | 
				
			||||||
        Location shooterLocation = player.getEyeLocation();
 | 
					        Location shooterLocation = player.getLocation();
 | 
				
			||||||
        Location targetLocation = target.getLocation();
 | 
					        Location targetLocation = target.getLocation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        double squaredDistance = shooterLocation.distanceSquared(targetLocation);
 | 
					        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);
 | 
					        int bonusXp = (int) (squaredDistance * Archery.distanceXpModifer);
 | 
				
			||||||
        mcMMOPlayer.addXp(SkillType.ARCHERY, bonusXp);
 | 
					        mcMMOPlayer.addXp(SkillType.ARCHERY, bonusXp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user