<commit_before>package com.martinjonsson01.sqsmoothcraft.missile;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Sign;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.util.Vector;

import com.ginger_walnut.sqsmoothcraft.SQSmoothCraft;

public class MissileListener implements Listener {
	
	Location currentLoc = null;
	Location targetLoc = null;
	
	@EventHandler
	public void onPlayerInteract(PlayerInteractEvent e) {
		
		if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
			return;
		
		if (e.getClickedBlock().getState() instanceof Sign) {
			
			Sign s = (Sign) e.getClickedBlock().getState();
			if (s.getLine(0).equalsIgnoreCase("[hsmissile]")) {
				if (MissileDetection.detectLauncher(s.getBlock())) {
					s.setLine(0, "");
					s.setLine(1, ChatColor.LIGHT_PURPLE + "[" + ChatColor.GOLD + "Missile" + ChatColor.LIGHT_PURPLE + "]");
					s.setLine(2, ChatColor.LIGHT_PURPLE + "[" + ChatColor.RED + "Heat Seeking" + ChatColor.LIGHT_PURPLE + "]");
					s.setLine(3, "");
					s.update();
					return;
				}
			}
			
			if (s.getLine(1).equals(ChatColor.LIGHT_PURPLE + "[" + ChatColor.GOLD + "Missile" + ChatColor.LIGHT_PURPLE + "]")
					&& s.getLine(2).equals(ChatColor.LIGHT_PURPLE + "[" + ChatColor.RED + "Heat Seeking" + ChatColor.LIGHT_PURPLE + "]")) {
				
				Block ammoDispenserBlock = MissileDetection.getAmmoDispenser(s.getBlock());
				Dispenser ammoDispenser = (Dispenser) ammoDispenserBlock.getState();
				Inventory dispenserInv = ammoDispenser.getInventory();
				
				//Checks if the dispenser of the missile launcher has ammo, if so, then it launches the missile fireball thingy
				if (dispenserInv.containsAtLeast(Missile.missileAmmo(), 1)) {
					
					dispenserInv.removeItem(Missile.missileAmmo()); //Removes one missile ammo from dispenser
					
					Fireball fireball = (Fireball) ammoDispenserBlock.getLocation().getWorld().spawnEntity(MissileDetection.inFrontOfDispenser(s.getBlock()).getLocation(), EntityType.FIREBALL);
					
					fireball.setBounce(false);
					fireball.setShooter(e.getPlayer());
					fireball.getLocation().getYaw();
					fireball.getLocation().getPitch();
					Player p = e.getPlayer();
					
					Bukkit.getScheduler().scheduleSyncRepeatingTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						@Override
						public void run() {
							currentLoc = fireball.getLocation();
							targetLoc = p.getLocation();
							Vector vector = targetLoc.toVector().normalize().subtract(currentLoc.toVector().normalize());
							vector = vector.multiply(.5f);
							fireball.setDirection(vector);
							//fireball.setVelocity(vector);
							
							
						}
					}, 21*2, 5); //21*2 because the this one needs to fire off after the one below does VVV
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						
						@Override
						public void run() {
							
							fireball.setVelocity(new Vector(0, 0, 0));
							fireball.setDirection(new Vector(0, 0, 0));
							
						}
						
					}, 20*2);
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						
						@Override
						public void run() {
							
							if(!fireball.isDead()){
								e.getPlayer().sendMessage(ChatColor.RED + "The fuel of your heat seeking missile ran out.");
							}
							fireball.remove();
						}
						<commit_msg>SQSMoothCraft - Really, really small change<commit_after>package com.martinjonsson01.sqsmoothcraft.missile;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Sign;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.util.Vector;

import com.ginger_walnut.sqsmoothcraft.SQSmoothCraft;

public class MissileListener implements Listener {
	
	Location currentLoc = null;
	Location targetLoc = null;
	
	@EventHandler
	public void onPlayerInteract(PlayerInteractEvent e) {
		
		if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
			return;
		
		if (e.getClickedBlock().getState() instanceof Sign) {
			
			Sign s = (Sign) e.getClickedBlock().getState();
			if (s.getLine(0).equalsIgnoreCase("[hsmissile]")) {
				if (MissileDetection.detectLauncher(s.getBlock())) {
					s.setLine(0, "");
					s.setLine(1, ChatColor.LIGHT_PURPLE + "[" + ChatColor.GOLD + "Missile" + ChatColor.LIGHT_PURPLE + "]");
					s.setLine(2, ChatColor.LIGHT_PURPLE + "[" + ChatColor.RED + "Heat Seeking" + ChatColor.LIGHT_PURPLE + "]");
					s.setLine(3, "");
					s.update();
					return;
				}
			}
			
			if (s.getLine(1).equals(ChatColor.LIGHT_PURPLE + "[" + ChatColor.GOLD + "Missile" + ChatColor.LIGHT_PURPLE + "]")
					&& s.getLine(2).equals(ChatColor.LIGHT_PURPLE + "[" + ChatColor.RED + "Heat Seeking" + ChatColor.LIGHT_PURPLE + "]")) {
				
				Block ammoDispenserBlock = MissileDetection.getAmmoDispenser(s.getBlock());
				Dispenser ammoDispenser = (Dispenser) ammoDispenserBlock.getState();
				Inventory dispenserInv = ammoDispenser.getInventory();
				
				//Checks if the dispenser of the missile launcher has ammo, if so, then it launches the missile fireball thingy
				if (dispenserInv.containsAtLeast(Missile.missileAmmo(), 1)) {
					
					dispenserInv.removeItem(Missile.missileAmmo()); //Removes one missile ammo from dispenser
					
					Fireball fireball = (Fireball) ammoDispenserBlock.getLocation().getWorld().spawnEntity(MissileDetection.inFrontOfDispenser(s.getBlock()).getLocation(), EntityType.FIREBALL);
					
					fireball.setBounce(false);
					fireball.setShooter(e.getPlayer());
					fireball.getLocation().getYaw();
					fireball.getLocation().getPitch();
					Player p = e.getPlayer();
					
					Bukkit.getScheduler().scheduleSyncRepeatingTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						@Override
						public void run() {
							currentLoc = fireball.getLocation();
							targetLoc = p.getLocation();
							Vector vector = targetLoc.toVector().normalize().subtract(currentLoc.toVector().normalize());
							vector = vector.multiply(.5f);
							fireball.setDirection(vector);
							fireball.setVelocity(fireball.getDirection());
							
							
						}
					}, 21*2, 5); //21*2 because the this one needs to fire off after the one below does VVV
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						
						@Override
						public void run() {
							
							fireball.setVelocity(new Vector(0, 0, 0));
							fireball.setDirection(new Vector(0, 0, 0));
							
						}
						
					}, 20*2);
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SQSmoothCraft.getPluginMain(), new Runnable(){
						
						@Override
						public void run() {
							
							if(!fireball.isDead()){
								e.getPlayer().sendMessage(ChatColor.RED + "The fuel of your heat seeking missile ran out.");
							}
							fireball.remove();
						}
						
{'fraction_non_alphanumeric': 0.1289511969316228, 'fraction_numerical': 0.007141912445443725, 'mean_word_length': 3.5173237753882916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2772963', 'n_tokens_mistral': 3253, 'n_tokens_neox': 2478, 'n_words': 428}