AirBlast fixed a crash causing bug when a user shoots straight down

This commit is contained in:
nathank33 2015-01-18 16:13:49 -08:00
parent d6baea87b9
commit bede932459

View file

@ -1,8 +1,10 @@
package com.projectkorra.ProjectKorra.airbending; package com.projectkorra.ProjectKorra.airbending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -191,7 +193,14 @@ public class AirBlast {
return false; return false;
} }
if (location.distance(origin) > range) { /*
* If a player presses shift and AirBlasts straight down then
* the AirBlast's location gets messed up and reading the distance
* returns Double.NaN. If we don't remove this instance then
* the AirBlast will never be removed.
*/
double dist = location.distance(origin);
if (Double.isNaN(dist) || dist > range) {
instances.remove(id); instances.remove(id);
return false; return false;
} }
@ -255,6 +264,9 @@ public class AirBlast {
if (Commands.invincible.contains(((Player) entity).getName())) return; if (Commands.invincible.contains(((Player) entity).getName())) return;
} }
if(Double.isNaN(velocity.length()))
return;
Methods.setVelocity(entity, velocity); Methods.setVelocity(entity, velocity);
entity.setFallDistance(0); entity.setFallDistance(0);
if (!isUser && entity instanceof Player) { if (!isUser && entity instanceof Player) {