Sobki

Untitled

Feb 25th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. package com.Sobki.korra.SandBlast;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.block.Block;
  8. import org.bukkit.entity.Entity;
  9. import org.bukkit.entity.LivingEntity;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.util.Vector;
  12.  
  13. import com.projectkorra.projectkorra.GeneralMethods;
  14. import com.projectkorra.projectkorra.ProjectKorra;
  15. import com.projectkorra.projectkorra.ability.AddonAbility;
  16. import com.projectkorra.projectkorra.ability.SandAbility;
  17. import com.projectkorra.projectkorra.configuration.ConfigManager;
  18. import com.projectkorra.projectkorra.util.DamageHandler;
  19. import com.projectkorra.projectkorra.util.ParticleEffect;
  20. import com.projectkorra.projectkorra.util.ParticleEffect.BlockData;
  21. import com.projectkorra.projectkorra.util.TempBlock;
  22.  
  23. public class SandBlast extends SandAbility implements AddonAbility {
  24.  
  25. // Configurable variables
  26. private long cooldown;
  27. private double range;
  28. private double speed;
  29. private double damage;
  30.  
  31. // Instance related variables
  32. private Location origin;
  33. private Location location;
  34. private Vector direction;
  35.  
  36. public SandBlast(Player player) {
  37. super(player);
  38.  
  39. if (!bPlayer.canBend(this)) {
  40. return;
  41. }
  42.  
  43. setFields();
  44. start();
  45. }
  46.  
  47. public void setFields() {
  48. this.cooldown = ConfigManager.getConfig().getLong("ExtraAbilities.Sobki.SandBlast.Cooldown");
  49. this.range = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Range");
  50. this.speed = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Speed");
  51. this.damage = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Damage");
  52. this.origin = player.getLocation().clone().add(0, 1, 0);
  53. this.location = origin.clone();
  54. this.direction = player.getLocation().getDirection();
  55. }
  56.  
  57. @Override
  58. public void progress() {
  59. if (!bPlayer.canBendIgnoreBinds(this)) {
  60. remove();
  61. return;
  62. }
  63. if (origin.distance(location) > range) {
  64. remove();
  65. bPlayer.addCooldown(this);
  66. return;
  67. }
  68.  
  69. location.add(direction.multiply(speed));
  70. ParticleEffect.BLOCK_CRACK.display(new BlockData(Material.SAND, (byte) 0), 0.2F, 0.2F, 0.2F, 0, 8, location, 32);
  71. ParticleEffect.BLOCK_CRACK.display(new BlockData(Material.SAND, (byte) 1), 0.2F, 0.2F, 0.2F, 0, 8, location, 32);
  72. if (new Random().nextInt(6) == 0) {
  73. playSandBendingSound(location);
  74. }
  75.  
  76. for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 1.5)) {
  77. if (entity instanceof LivingEntity && entity.getUniqueId() != player.getUniqueId()) {
  78. DamageHandler.damageEntity(entity, damage, this);
  79. }
  80. }
  81.  
  82. for (Block block : GeneralMethods.getBlocksAroundPoint(location, 1)) {
  83. if (!block.getType().isTransparent()) {
  84. if (!isEarthbendable(player, block)) {
  85. remove();
  86. return;
  87. }
  88.  
  89. TempBlock tempBlock = new TempBlock(block, Material.AIR, (byte) 0);
  90. tempBlock.setRevertTime(5000);
  91. }
  92.  
  93. }
  94. }
  95.  
  96. @Override
  97. public long getCooldown() {
  98. return cooldown;
  99. }
  100.  
  101. @Override
  102. public Location getLocation() {
  103. return null;
  104. }
  105.  
  106. @Override
  107. public String getName() {
  108. return "SandBlast";
  109. }
  110.  
  111. @Override
  112. public String getDescription() {
  113. return "SandBlast is an ability for sandbenders allowing them to shoot small sand bullets rapidly.";
  114. }
  115.  
  116. @Override
  117. public String getInstructions() {
  118. return "Left click to shoot a shot.";
  119. }
  120.  
  121. @Override
  122. public boolean isHarmlessAbility() {
  123. return false;
  124. }
  125.  
  126. @Override
  127. public boolean isSneakAbility() {
  128. return false;
  129. }
  130.  
  131. @Override
  132. public String getAuthor() {
  133. return "Sobki";
  134. }
  135.  
  136. @Override
  137. public String getVersion() {
  138. return "v1.0";
  139. }
  140.  
  141. @Override
  142. public void load() {
  143. ProjectKorra.plugin.getServer().getPluginManager().registerEvents(new SandBlastListener(), ProjectKorra.plugin);
  144. ProjectKorra.log.info(getName() + " " + getVersion() + " by " + getAuthor() + " loaded!");
  145.  
  146. ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Cooldown", 2000);
  147. ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Range", 30);
  148. ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Speed", 1);
  149. ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Damage", 10);
  150. ConfigManager.defaultConfig.save();
  151. }
  152.  
  153. @Override
  154. public void stop() {
  155.  
  156. }
  157.  
  158. }
Add Comment
Please, Sign In to add comment