Fix Exceptions

This commit is contained in:
MistPhizzle 2014-08-25 16:47:56 -04:00
parent 6453cc9897
commit a11eb336e6

View file

@ -1,7 +1,9 @@
package com.projectkorra.ProjectKorra.airbending; package com.projectkorra.ProjectKorra.airbending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -81,62 +83,70 @@ public class Suffocate {
return; return;
} }
for (Entity entity: targets.keySet()) { try {
if (targets.isEmpty()) { for (Entity entity: targets.keySet()) {
remove(player); if (!targets.keySet().iterator().hasNext()) {
return; remove(player);
} return;
if (isUndead(entity) && !canBeUsedOnUndead) { }
breakSuffocate(entity); if (targets.isEmpty()) {
continue; remove(player);
} return;
}
if (entity.getLocation().getBlock() != null && Methods.isWater(entity.getLocation().getBlock())) { if (isUndead(entity) && !canBeUsedOnUndead) {
breakSuffocate(entity);
continue;
}
if (Methods.isRegionProtectedFromBuild(player, "Suffocate", entity.getLocation())) {
remove(player);
continue;
}
if (entity.getLocation().distance(player.getLocation()) >= range) {
breakSuffocate(entity);
continue;
}
if (Methods.isObstructed(player.getLocation(), entity.getLocation())) {
breakSuffocate(entity);
continue;
}
if (entity instanceof Player) {
if (AvatarState.isAvatarState((Player) entity)) {
breakSuffocate(entity); breakSuffocate(entity);
continue; continue;
} }
}
if (entity.isDead()) { if (entity.getLocation().getBlock() != null && Methods.isWater(entity.getLocation().getBlock())) {
breakSuffocate(entity); breakSuffocate(entity);
continue; continue;
} }
if (entity instanceof Creature) { if (Methods.isRegionProtectedFromBuild(player, "Suffocate", entity.getLocation())) {
((Creature) entity).setTarget(player); remove(player);
} continue;
}
for(Location airsphere : Methods.getCircle(entity.getLocation(), 3, 3, false, true, 0)) { if (entity.getLocation().distance(player.getLocation()) >= range) {
Methods.playAirbendingParticles(airsphere, 1); breakSuffocate(entity);
} continue;
entity.setFallDistance(0); }
new TempPotionEffect((LivingEntity) entity, slow);
new TempPotionEffect((LivingEntity) entity, nausea); if (Methods.isObstructed(player.getLocation(), entity.getLocation())) {
if (System.currentTimeMillis() >= time + warmup) { breakSuffocate(entity);
Methods.damageEntity(player, entity, damage); continue;
entity.teleport(entity); }
if (entity instanceof Player) {
if (AvatarState.isAvatarState((Player) entity)) {
breakSuffocate(entity);
continue;
}
}
if (entity.isDead()) {
breakSuffocate(entity);
continue;
}
if (entity instanceof Creature) {
((Creature) entity).setTarget(player);
}
for(Location airsphere : Methods.getCircle(entity.getLocation(), 3, 3, false, true, 0)) {
Methods.playAirbendingParticles(airsphere, 1);
}
entity.setFallDistance(0);
new TempPotionEffect((LivingEntity) entity, slow);
new TempPotionEffect((LivingEntity) entity, nausea);
if (System.currentTimeMillis() >= time + warmup) {
Methods.damageEntity(player, entity, damage);
entity.teleport(entity);
}
} }
} catch (ConcurrentModificationException e) {
} }
} }