Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.avatarserv.AirShots;
- import java.util.concurrent.ConcurrentHashMap;
- import org.bukkit.Location;
- import org.bukkit.entity.Player;
- import org.bukkit.util.Vector;
- import com.projectkorra.projectkorra.BendingPlayer;
- import com.projectkorra.projectkorra.GeneralMethods;
- import com.projectkorra.projectkorra.ProjectKorra;
- import com.projectkorra.projectkorra.ability.AddonAbility;
- import com.projectkorra.projectkorra.ability.AirAbility;
- import com.projectkorra.projectkorra.util.ParticleEffect;
- public class AirShots extends AirAbility implements AddonAbility{
- public static final ConcurrentHashMap<Integer, AirShots> users = new ConcurrentHashMap<Integer, AirShots>();
- // --------
- private Location origin;
- private Location track;
- private Vector direction;
- private int rebounds;
- // --------
- public AirShots(Player player) {
- super(player);
- this.origin = player.getEyeLocation();
- this.track = player.getEyeLocation();
- this.direction = player.getLocation().getDirection().normalize().multiply(2.3);
- this.rebounds = 0;
- users.put(player.getEntityId(), this);
- start();
- return;
- }
- // --------
- @Override
- public long getCooldown() {
- return 100;
- }
- @Override
- public Location getLocation() {
- return this.track;
- }
- @Override
- public String getName() {
- return "AirShots";
- }
- @Override
- public boolean isHarmlessAbility() {
- return false;
- }
- @Override
- public boolean isSneakAbility() {
- return false;
- }
- // --------
- @Override
- public void progress() {
- String ability = BendingPlayer.getBendingPlayer(player).getBoundAbilityName();
- if ((ability == null) || !ability.equalsIgnoreCase(getName())){
- remove();
- return;
- }
- if (origin.distance(track) > 60){
- remove();
- return;
- }
- if (player.isDead() || !player.isOnline()){
- remove();
- return;
- }
- if (!isTransparent(track.getBlock())){
- if (rebounds > 9){
- remove();
- return;
- }
- rebound();
- rebounds++;
- return;
- }
- playEffects();
- track.add(direction);
- return;
- }
- public void playEffects(){
- ParticleEffect.EXPLODE.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
- ParticleEffect.CLOUD.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
- ParticleEffect.CRIT_MAGIC.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
- return;
- }
- public void drive(){
- return;
- }
- public void rebound(){
- Vector vector = rotateVectorAroundY(direction, 180);
- vector.setX(-vector.getX());
- vector.setZ(-vector.getZ());
- direction = vector;
- return;
- }
- public static Vector rotateVectorAroundY(Vector vector, double degrees) {
- double rad = Math.toRadians(degrees);
- double currentX = vector.getX();
- double currentZ = vector.getZ();
- double cosine = Math.cos(rad);
- double sine = Math.sin(rad);
- return new Vector((cosine * currentX - sine * currentZ), vector.getY(), (sine * currentX + cosine * currentZ));
- }
- // --------
- @Override
- public void remove(){
- users.remove(player.getEntityId());
- super.remove();
- }
- @Override
- public String getAuthor() {
- return "SkepsonSk";
- }
- @Override
- public String getVersion() {
- return "1.0";
- }
- @Override
- public void load() {
- ProjectKorra.plugin.getServer().getPluginManager().registerEvents(new AirShotsListener(), ProjectKorra.plugin);
- return;
- }
- @Override
- public void stop() {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement