/*
 * Copyright  2014 - 2017 | Wurst-Imperium | All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package tk.wurst_client.features.mods;

import net.minecraft.entity.Entity;
import tk.wurst_client.events.listeners.UpdateListener;
import tk.wurst_client.features.Feature;
import tk.wurst_client.settings.CheckboxSetting;
import tk.wurst_client.settings.SliderSetting;
import tk.wurst_client.settings.SliderSetting.ValueDisplay;
import tk.wurst_client.utils.EntityUtils;
import tk.wurst_client.utils.EntityUtils.TargetSettings;
import tk.wurst_client.utils.PlayerUtils;
import tk.wurst_client.utils.RotationUtils;

@Mod.Info(
	description = "Slower Killaura that bypasses any AntiCheat plugins.\n"
		+ "Not required on normal NoCheat+ servers!",
	name = "KillauraLegit",
	tags = "LegitAura, killaura legit, kill aura legit, legit aura",
	help = "Mods/KillauraLegit")
@Mod.Bypasses
public class KillauraLegitMod extends Mod implements UpdateListener
{
	public CheckboxSetting useKillaura =
		new CheckboxSetting("Use Killaura settings", true)
		{
			@Override
			public void update()
			{
				if(isChecked())
				{
					KillauraMod killaura = wurst.mods.killauraMod;
					useCooldown.lock(killaura.useCooldown.isChecked());
					speed.lockToValue(killaura.speed.getValue());
					range.lockToValue(killaura.range.getValue());
					fov.lockToValue(killaura.fov.getValue());
				}else
				{
					useCooldown.unlock();
					speed.unlock();
					range.unlock();
					fov.unlock();
				}
			};
		};
	public CheckboxSetting useCooldown =
		new CheckboxSetting("Use Attack Cooldown as Speed", true)
		{
			@Override
			public void update()
			{
				speed.setDisabled(isChecked());
			};
		};
	public SliderSetting speed =
		new SliderSetting("Speed", 12, 0.1, 12, 0.1, ValueDisplay.DECIMAL);
	public SliderSetting range =
		new SliderSetting("Range", 4.25, 1, 4.25, 0.05, ValueDisplay.DECIMAL);
	public SliderSetting fov =
		new SliderSetting("FOV", 360, 30, 360, 10, ValueDisplay.DEGREES);
	
	private TargetSettings targetSettings = new TargetSettings()
	{
		@Override
		public float getRange()
		{
			return range.getValueF();
		}
		
		@Override
		public float getFOV()
		{
			return fov.getValueF();
		}
	};
	
	@Override
	public void initSettings()
	{
		settings.add(useKillaura);
		settings.add(useCooldown);
		settings.add(speed);
		settings.add(range);
		settings.add(fov);
	}
	
	@Override
	public Feature[] getSeeAlso()
	{
		return new Feature[]{wurst.special.targetSpf, wurst.mods.killauraMod,
			wurst.mods.multiAuraMod, wurst.mods.clickAuraMod,
			wurst.mods.triggerBotMod};
	}
	
	@Override
	public void onEnable()
	{
		// TODO: Clean up this mess!
		if(wurst.mods.killauraMod.isEnabled())
			wurst.mods.killauraMod.setEnabled(false);
		if(wurst.mods.multiAuraMod.isEnabled())
			wurst.mods.multiAuraMod.setEnabled(false);
		if(wurst.mods.clickAuraMod.isEnabled())
			wurst.mods.clickAuraMod.setEnabled(false);
		if(wurst.mods.tpAuraMod.isEnabled())
			wurst.mods.tpAuraMod.setEnabled(false);
		if(wurst.mods.triggerBotMod.isEnabled())
			wurst.mods.triggerBotMod.setEnabled(false);
		wurst.events.add(UpdateListener.class, this);
	}
	
	@Override
	public void onDisable()
	{
		wurst.events.remove(UpdateListener.class, this);
	}
	
	@Override
	public void onUpdate()
	{
		// update timer
		updateMS();
		
		// check timer / cooldown
		if(useCooldown.isChecked() ? mc.player.getCooledAttackStrength(0F) < 1F
			: !hasTimePassedS(speed.getValueF()))
			return;
		
		// set entity
		Entity entity = EntityUtils.getBestEntityToAttack(targetSettings);
		
		// check if entity was found
		if(entity == null)
			return;
		
		// face entity
		if(!RotationUtils.faceEntityClient(entity))
			return;
		
		// Criticals
		if(wurst.mods.criticalsMod.isActive() && mc.player.onGround)
			mc.player.jump();
		
		// attack entity
		mc.playerController.attackEntity(mc.player, entity);
		PlayerUtils.swingArmClient();
		
		// reset timer
		updateLastMS();
	}
}

@@ -1653,25 +1653,24 @@
 ;%0A%09%09%09%09%7D%0A%09%09%09%7D
-;
 %0A%09%09%7D;%0A%09publi
@@ -1847,17 +1847,16 @@
 ));%0A%09%09%09%7D
-;
 %0A%09%09%7D;%0A%09p
@@ -2798,76 +2798,32 @@
 %09// 
-TODO: Clean up this mess!%0A%09%09if(wurst.mods.killauraMod.isEnabled())%0A%09
+disable other killauras%0A
 %09%09wu
@@ -2866,51 +2866,8 @@
 e);%0A
-%09%09if(wurst.mods.multiAuraMod.isEnabled())%0A%09
 %09%09wu
@@ -2911,51 +2911,8 @@
 e);%0A
-%09%09if(wurst.mods.clickAuraMod.isEnabled())%0A%09
 %09%09wu
@@ -2956,48 +2956,8 @@
 e);%0A
-%09%09if(wurst.mods.tpAuraMod.isEnabled())%0A%09
 %09%09wu
@@ -2998,52 +2998,8 @@
 e);%0A
-%09%09if(wurst.mods.triggerBotMod.isEnabled())%0A%09
 %09%09wu
@@ -3032,32 +3032,35 @@
 Enabled(false);%0A
+%09%09%0A
 %09%09wurst.events.a

Clean up KillauraLegitMod