Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Sobki.korra.SandBlast;
- import java.util.Random;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- 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.ProjectKorra;
- import com.projectkorra.projectkorra.ability.AddonAbility;
- import com.projectkorra.projectkorra.ability.SandAbility;
- import com.projectkorra.projectkorra.configuration.ConfigManager;
- import com.projectkorra.projectkorra.util.DamageHandler;
- import com.projectkorra.projectkorra.util.ParticleEffect;
- import com.projectkorra.projectkorra.util.ParticleEffect.BlockData;
- import com.projectkorra.projectkorra.util.TempBlock;
- public class SandBlast extends SandAbility implements AddonAbility {
- // Configurable variables
- private long cooldown;
- private double range;
- private double speed;
- private double damage;
- // Instance related variables
- private Location origin;
- private Location location;
- private Vector direction;
- public SandBlast(Player player) {
- super(player);
- if (!bPlayer.canBend(this)) {
- return;
- }
- setFields();
- start();
- }
- public void setFields() {
- this.cooldown = ConfigManager.getConfig().getLong("ExtraAbilities.Sobki.SandBlast.Cooldown");
- this.range = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Range");
- this.speed = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Speed");
- this.damage = ConfigManager.getConfig().getDouble("ExtraAbilities.Sobki.SandBlast.Damage");
- this.origin = player.getLocation().clone().add(0, 1, 0);
- this.location = origin.clone();
- this.direction = player.getLocation().getDirection();
- }
- @Override
- public void progress() {
- if (!bPlayer.canBendIgnoreBinds(this)) {
- remove();
- return;
- }
- if (origin.distance(location) > range) {
- remove();
- bPlayer.addCooldown(this);
- return;
- }
- location.add(direction.multiply(speed));
- ParticleEffect.BLOCK_CRACK.display(new BlockData(Material.SAND, (byte) 0), 0.2F, 0.2F, 0.2F, 0, 8, location, 32);
- ParticleEffect.BLOCK_CRACK.display(new BlockData(Material.SAND, (byte) 1), 0.2F, 0.2F, 0.2F, 0, 8, location, 32);
- if (new Random().nextInt(6) == 0) {
- playSandBendingSound(location);
- }
- for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 1.5)) {
- if (entity instanceof LivingEntity && entity.getUniqueId() != player.getUniqueId()) {
- DamageHandler.damageEntity(entity, damage, this);
- }
- }
- for (Block block : GeneralMethods.getBlocksAroundPoint(location, 1)) {
- if (!block.getType().isTransparent()) {
- if (!isEarthbendable(player, block)) {
- remove();
- return;
- }
- TempBlock tempBlock = new TempBlock(block, Material.AIR, (byte) 0);
- tempBlock.setRevertTime(5000);
- }
- }
- }
- @Override
- public long getCooldown() {
- return cooldown;
- }
- @Override
- public Location getLocation() {
- return null;
- }
- @Override
- public String getName() {
- return "SandBlast";
- }
- @Override
- public String getDescription() {
- return "SandBlast is an ability for sandbenders allowing them to shoot small sand bullets rapidly.";
- }
- @Override
- public String getInstructions() {
- return "Left click to shoot a shot.";
- }
- @Override
- public boolean isHarmlessAbility() {
- return false;
- }
- @Override
- public boolean isSneakAbility() {
- return false;
- }
- @Override
- public String getAuthor() {
- return "Sobki";
- }
- @Override
- public String getVersion() {
- return "v1.0";
- }
- @Override
- public void load() {
- ProjectKorra.plugin.getServer().getPluginManager().registerEvents(new SandBlastListener(), ProjectKorra.plugin);
- ProjectKorra.log.info(getName() + " " + getVersion() + " by " + getAuthor() + " loaded!");
- ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Cooldown", 2000);
- ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Range", 30);
- ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Speed", 1);
- ConfigManager.getConfig().addDefault("ExtraAbilities.Sobki.SandBlast.Damage", 10);
- ConfigManager.defaultConfig.save();
- }
- @Override
- public void stop() {
- }
- }
Add Comment
Please, Sign In to add comment