2
0
bm01 13 жил өмнө
parent
commit
093f368545

+ 1 - 1
src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java

@@ -929,7 +929,7 @@ public class PlayerProfile
 				if(x.isOnline() && !x.getName().equals(thisplayer.getName()) && Party.getInstance().isPartyLeader(x.getName(), this.getParty()))
 				{
 					//leaderName = x.getName();
-					if(m.getDistance(thisplayer.getLocation(), x.getLocation()) < 25)
+					if(m.isNear(thisplayer.getLocation(), x.getLocation(), 25))
 					{
 						PlayerProfile PartyLeader = Users.getProfile(x);
 						if(PartyLeader.getSkillLevel(skillType) >= this.getSkillLevel(skillType))

+ 12 - 6
src/main/java/com/gmail/nossr50/m.java

@@ -189,13 +189,19 @@ public class m
 		
 		return 1;
 	}
-
-	public static double getDistance(Location loca, Location locb)
-	{
-		return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2)
-				+ Math.pow(loca.getZ() - locb.getZ(), 2));
+	
+	public static boolean isNear(Location first, Location second, int maxDistance) {
+		double relX = first.getX() - second.getX();
+		double relY = first.getY() - second.getY();
+		double relZ = first.getZ() - second.getZ();
+		double dist = relX * relX + relY * relY + relZ * relZ;
+		
+		if (dist < maxDistance * maxDistance)
+			return true;
+		
+		return false;
 	}
-
+	
 	public static boolean abilityBlockCheck(Block block)
 	{
 		switch(block.getType()){

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/Skills.java

@@ -274,7 +274,7 @@ public class Skills
     			player.sendMessage(ability.getAbilityOn());
     			for(Player y : player.getWorld().getPlayers())
 	    		{
-	    			if(y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
+    				if(y != player && m.isNear(player.getLocation(), y.getLocation(), 10))
 	    				y.sendMessage(ability.getAbilityPlayer(player));
 	    		}
     			PP.setSkillDATS(ability, System.currentTimeMillis()+(ticks*1000));