Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package src;
- import java.util.concurrent.ConcurrentHashMap;
- import org.bukkit.Location;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.util.Vector;
- import com.projectkorra.projectkorra.GeneralMethods;
- import com.projectkorra.projectkorra.earthbending.EarthMethods;
- import com.projectkorra.projectkorra.util.ParticleEffect;
- public class AuraBlast {
- private static final ConcurrentHashMap<Integer, AuraBlast> instances = new ConcurrentHashMap<Integer, AuraBlast>();
- private Player player;
- private Location blast;
- private Location origin;
- private Vector dir;
- private static int ID = Integer.MIN_VALUE;
- private int id;
- public AuraBlast(Player p) {
- player = p;
- blast = player.getEyeLocation();
- origin = player.getEyeLocation();
- dir = player.getLocation().getDirection().normalize().multiply(1);
- createInstance();
- }
- private void createInstance() {
- id = ID;
- instances.put(id, this);
- if (ID == Integer.MAX_VALUE) {
- ID = Integer.MIN_VALUE;
- }
- ID++;
- }
- public static void repeat() {
- for (int i : instances.keySet()) {
- AuraBlast pb = instances.get(i);
- if (!pb.progress())
- instances.remove(i);
- }
- }
- public boolean progress() {
- blast.add(dir);
- playParticles();
- if (player.isDead() || !player.isOnline()) {
- return false;
- }
- String abil = GeneralMethods.getBoundAbility(player);
- if (abil == null || !abil.equalsIgnoreCase("Aura"))
- return false;
- if (EarthMethods.isTransparentToEarthbending(player, blast.getBlock())) {
- explode();
- return false;
- }
- if (origin.distance(blast) > 25) {
- return false;
- }
- for (Entity entity : GeneralMethods.getEntitiesAroundPoint(blast, 1.5)) {
- if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) {
- explode();
- GeneralMethods.damageEntity(player, entity, 6, "Aura");
- return false;
- }
- }
- return true;
- }
- private void explode() {
- blast.getWorld().createExplosion(blast, 3F, true);
- }
- private void playParticles() {
- ParticleEffect.WITCH_MAGIC.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
- ParticleEffect.EXPLODE.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
- ParticleEffect.CRIT.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
- ParticleEffect.PORTAL.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
- }
- public static void clear() {
- instances.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement