package kernitus.plugin.OldCombatMechanics.module;

import kernitus.plugin.OldCombatMechanics.OCMMain;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.projectiles.ProjectileSource;

public class ModuleDisableProjectileRandomness extends Module {

    public ModuleDisableProjectileRandomness(OCMMain plugin){
        super(plugin, "disable-projectile-randomness");
    }

    @EventHandler
    public void onProjectileLaunch(ProjectileLaunchEvent e){
        Projectile projectile = e.getEntity(); //Getting the projectile
        ProjectileSource shooter = projectile.getShooter(); //Getting the shooter
        if(shooter instanceof Player){ //If the shooter was a player
            Player player = (Player) shooter;
            if(!isEnabled(player.getWorld())) return; //If this module is enabled in this world
            debug("Making projectile go straight", player);
            //Here we get a unit vector of the direction the player is looking in and multiply it by the projectile's vector's magnitude
            //We then assign this to the projectile as its new velocity
            projectile.setVelocity(player.getLocation().getDirection().normalize().multiply(projectile.getVelocity().length()));
        }
    }
}
@@ -314,16 +314,145 @@
 ource;%0D%0A
+import org.bukkit.util.Vector;%0D%0A%0D%0A/**%0D%0A * Prevents the noise introduced when shooting with a bow to make arrows go straight.%0D%0A */
 %0D%0Apublic
@@ -772,33 +772,8 @@
 y();
- //Getting the projectile
 %0D%0A  
@@ -833,30 +833,10 @@
 r();
- //Getting the shooter
+%0D%0A
 %0D%0A  
@@ -875,38 +875,8 @@
 er)%7B
- //If the shooter was a player
 %0D%0A  
@@ -977,50 +977,8 @@
 urn;
- //If this module is enabled in this world
 %0D%0A  
@@ -1032,24 +1032,26 @@
 , player);%0D%0A
+%0D%0A
             
@@ -1054,44 +1054,22 @@
     
-//Here we get a unit vector of the d
+Vector playerD
 irec
@@ -1077,196 +1077,128 @@
 ion 
-the
+=
  player
- is looking in and multiply it by the projectile's vector's magnitude%0D%0A            //We then assign this to the projectile as its new velocity%0D%0A            projectile.set
+.getLocation().getDirection().normalize();%0D%0A            // keep original speed%0D%0A            Vector arrow
 Velocity
 (pla
@@ -1197,56 +1197,26 @@
 city
-(
+ = 
 player
-.getLocation().getDirection().normalize()
+Direction
 .mul
@@ -1255,16 +1255,69 @@
 ength())
+;%0D%0A%0D%0A            projectile.setVelocity(arrowVelocity
 );%0D%0A    

Remove unnecessary comments and add javadoc