Advertisement
Guest User

AuraBlast

a guest
Oct 1st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. package src;
  2.  
  3. import java.util.concurrent.ConcurrentHashMap;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.entity.Entity;
  7. import org.bukkit.entity.LivingEntity;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.util.Vector;
  10.  
  11. import com.projectkorra.projectkorra.GeneralMethods;
  12. import com.projectkorra.projectkorra.earthbending.EarthMethods;
  13. import com.projectkorra.projectkorra.util.ParticleEffect;
  14.  
  15. public class AuraBlast {
  16.  
  17. private static final ConcurrentHashMap<Integer, AuraBlast> instances = new ConcurrentHashMap<Integer, AuraBlast>();
  18.  
  19. private Player player;
  20. private Location blast;
  21. private Location origin;
  22. private Vector dir;
  23.  
  24. private static int ID = Integer.MIN_VALUE;
  25. private int id;
  26.  
  27. public AuraBlast(Player p) {
  28. player = p;
  29. blast = player.getEyeLocation();
  30. origin = player.getEyeLocation();
  31. dir = player.getLocation().getDirection().normalize().multiply(1);
  32. createInstance();
  33. }
  34.  
  35. private void createInstance() {
  36. id = ID;
  37. instances.put(id, this);
  38. if (ID == Integer.MAX_VALUE) {
  39. ID = Integer.MIN_VALUE;
  40. }
  41. ID++;
  42.  
  43. }
  44.  
  45. public static void repeat() {
  46. for (int i : instances.keySet()) {
  47. AuraBlast pb = instances.get(i);
  48. if (!pb.progress())
  49. instances.remove(i);
  50. }
  51. }
  52.  
  53. public boolean progress() {
  54. blast.add(dir);
  55. playParticles();
  56. if (player.isDead() || !player.isOnline()) {
  57. return false;
  58. }
  59.  
  60. String abil = GeneralMethods.getBoundAbility(player);
  61. if (abil == null || !abil.equalsIgnoreCase("Aura"))
  62. return false;
  63.  
  64. if (EarthMethods.isTransparentToEarthbending(player, blast.getBlock())) {
  65. explode();
  66. return false;
  67. }
  68.  
  69. if (origin.distance(blast) > 25) {
  70. return false;
  71. }
  72.  
  73. for (Entity entity : GeneralMethods.getEntitiesAroundPoint(blast, 1.5)) {
  74. if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) {
  75. explode();
  76. GeneralMethods.damageEntity(player, entity, 6, "Aura");
  77. return false;
  78. }
  79. }
  80. return true;
  81. }
  82.  
  83. private void explode() {
  84. blast.getWorld().createExplosion(blast, 3F, true);
  85.  
  86. }
  87.  
  88. private void playParticles() {
  89. ParticleEffect.WITCH_MAGIC.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
  90. ParticleEffect.EXPLODE.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
  91. ParticleEffect.CRIT.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
  92. ParticleEffect.PORTAL.display(blast, 0.05F, 0.05F, 0.05F, 0.01F, 2);
  93. }
  94.  
  95. public static void clear() {
  96. instances.clear();
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement