Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.56 KB | None | 0 0
  1. package pl.avatarserv.AirShots;
  2.  
  3. import java.util.concurrent.ConcurrentHashMap;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.util.Vector;
  8.  
  9. import com.projectkorra.projectkorra.BendingPlayer;
  10. import com.projectkorra.projectkorra.GeneralMethods;
  11. import com.projectkorra.projectkorra.ProjectKorra;
  12. import com.projectkorra.projectkorra.ability.AddonAbility;
  13. import com.projectkorra.projectkorra.ability.AirAbility;
  14. import com.projectkorra.projectkorra.util.ParticleEffect;
  15.  
  16. public class AirShots extends AirAbility implements AddonAbility{
  17.  
  18.     public static final ConcurrentHashMap<Integer, AirShots> users = new ConcurrentHashMap<Integer, AirShots>();
  19.    
  20.     // --------
  21.    
  22.     private Location origin;
  23.    
  24.     private Location track;
  25.     private Vector direction;
  26.    
  27.     private int rebounds;
  28.    
  29.     // --------
  30.    
  31.     public AirShots(Player player) {
  32.        
  33.         super(player);
  34.        
  35.         this.origin = player.getEyeLocation();
  36.        
  37.         this.track = player.getEyeLocation();
  38.         this.direction = player.getLocation().getDirection().normalize().multiply(2.3);
  39.        
  40.         this.rebounds = 0;
  41.        
  42.         users.put(player.getEntityId(), this);
  43.        
  44.         start();
  45.        
  46.         return;
  47.        
  48.     }
  49.  
  50.     // --------
  51.    
  52.     @Override
  53.     public long getCooldown() {
  54.         return 100;
  55.     }
  56.  
  57.     @Override
  58.     public Location getLocation() {
  59.         return this.track;
  60.     }
  61.  
  62.     @Override
  63.     public String getName() {
  64.         return "AirShots";
  65.     }
  66.  
  67.     @Override
  68.     public boolean isHarmlessAbility() {
  69.         return false;
  70.     }
  71.  
  72.     @Override
  73.     public boolean isSneakAbility() {
  74.         return false;
  75.     }
  76.  
  77.     // --------
  78.    
  79.     @Override
  80.     public void progress() {
  81.        
  82.         String ability = BendingPlayer.getBendingPlayer(player).getBoundAbilityName();
  83.        
  84.         if ((ability == null) || !ability.equalsIgnoreCase(getName())){
  85.             remove();
  86.             return;
  87.         }
  88.        
  89.         if (origin.distance(track) > 60){
  90.             remove();
  91.             return;
  92.         }
  93.        
  94.         if (player.isDead() || !player.isOnline()){
  95.             remove();
  96.             return;
  97.         }
  98.        
  99.         if (!isTransparent(track.getBlock())){
  100.            
  101.             if (rebounds > 9){
  102.                
  103.                 remove();
  104.                 return;
  105.                
  106.             }
  107.            
  108.             rebound();
  109.             rebounds++;
  110.            
  111.             return;
  112.         }
  113.        
  114.         playEffects();
  115.         track.add(direction);
  116.        
  117.         return;
  118.        
  119.     }
  120.  
  121.     public void playEffects(){
  122.        
  123.         ParticleEffect.EXPLODE.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
  124.         ParticleEffect.CLOUD.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
  125.         ParticleEffect.CRIT_MAGIC.display(track, 0.05F, 0.05F, 0.05F, 0F, 40);
  126.  
  127.         return;
  128.        
  129.     }
  130.  
  131.     public void drive(){
  132.        
  133.         return;
  134.        
  135.     }
  136.    
  137.     public void rebound(){
  138.  
  139.         Vector vector = rotateVectorAroundY(direction, 180);
  140.         vector.setX(-vector.getX());
  141.         vector.setZ(-vector.getZ());
  142.        
  143.         direction = vector;
  144.        
  145.         return;
  146.        
  147.     }
  148.    
  149.     public static Vector rotateVectorAroundY(Vector vector, double degrees) {
  150.        
  151.         double rad = Math.toRadians(degrees);
  152.  
  153.         double currentX = vector.getX();
  154.         double currentZ = vector.getZ();
  155.  
  156.         double cosine = Math.cos(rad);
  157.         double sine = Math.sin(rad);
  158.  
  159.         return new Vector((cosine * currentX - sine * currentZ), vector.getY(), (sine * currentX + cosine * currentZ));
  160.     }
  161.    
  162.     // --------
  163.    
  164.     @Override
  165.     public void remove(){
  166.    
  167.         users.remove(player.getEntityId());
  168.         super.remove();
  169.    
  170.     }
  171.    
  172.     @Override
  173.     public String getAuthor() {
  174.         return "SkepsonSk";
  175.     }
  176.  
  177.     @Override
  178.     public String getVersion() {
  179.         return "1.0";
  180.     }
  181.  
  182.     @Override
  183.     public void load() {
  184.        
  185.         ProjectKorra.plugin.getServer().getPluginManager().registerEvents(new AirShotsListener(), ProjectKorra.plugin);
  186.        
  187.         return;
  188.        
  189.     }
  190.  
  191.     @Override
  192.     public void stop() {
  193.         // TODO Auto-generated method stub
  194.        
  195.     }
  196.  
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement