package com.censoredsoftware.demigods.command;

import com.censoredsoftware.demigods.helper.WrappedCommand;
import com.censoredsoftware.demigods.language.Symbol;
import com.censoredsoftware.demigods.player.DCharacter;
import com.censoredsoftware.demigods.player.DPlayer;
import com.censoredsoftware.demigods.structure.Structure;
import com.censoredsoftware.demigods.structure.global.Altar;
import com.google.common.collect.Sets;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;

import java.util.Set;

public class DevelopmentCommands extends WrappedCommand
{
	public DevelopmentCommands()
	{
		super(false);
	}

	@Override
	public Set<String> getCommands()
	{
		return Sets.newHashSet("test1", "test2", "test3", "hspawn", "nearestaltar", "obelisk");
	}

	@Override
	public boolean processCommand(CommandSender sender, Command command, String[] args)
	{
		if(command.getName().equalsIgnoreCase("test1")) return test1(sender, args);
		else if(command.getName().equalsIgnoreCase("test2")) return test2(sender, args);
		else if(command.getName().equalsIgnoreCase("test3")) return test3(sender, args);
		else if(command.getName().equalsIgnoreCase("hspawn")) return hspawn(sender);
		else if(command.getName().equalsIgnoreCase("nearestaltar")) return nearestAltar(sender);
		else if(command.getName().equalsIgnoreCase("obelisk")) return obelisk(sender, args);
		return false;
	}

	private static boolean test1(CommandSender sender, final String[] args)
	{
		Player player = (Player) sender;

		for(Symbol symbol : Symbol.values())
			player.sendMessage(symbol.name() + ": " + symbol);

		return true;
	}

	private static boolean test2(CommandSender sender, final String[] args)
	{
		Player player = (Player) sender;

		for(DCharacter character : DCharacter.Util.loadAll())
			character.getMeta().resetSkills();

		// if(Demigods.ERROR_NOISE) Errors.triggerError(ChatColor.GREEN + player.getName(), new ColoredStringBuilder().gray(" " + Unicodes.getRightwardArrow() + " ").red("Test error.").build());

		return true;
	}

	private static boolean test3(CommandSender sender, final String[] args)
	{
		Player player = (Player) sender;

		DCharacter character = DPlayer.Util.getPlayer(player).getCurrent();

		if(character == null)
		{
			player.sendMessage(ChatColor.RED + "You are mortal, we do not track mortals.");
			return true;
		}

		player.sendMessage("# of " + character.getAlliance() + "s Online: " + DCharacter.Util.getOnlineCharactersWithAlliance(character.getAlliance()).size());
		player.sendMessage("# of Enemies Online: " + DCharacter.Util.getOnlineCharactersWithoutAlliance(character.getAlliance()).size());

		return true;
	}

	private static boolean hspawn(CommandSender sender)
	{
		Player player = (Player) sender;

		// This SHOULD happen automatically, but bukkit doesn't do this, so we need to.

		if(player.isInsideVehicle() && player.getVehicle() instanceof Horse)
		{
			Horse horse = (Horse) player.getVehicle();
			horse.eject();
			horse.teleport(player.getWorld().getSpawnLocation());
			horse.setPassenger(player);
			player.sendMessage(ChatColor.YELLOW + "Teleported to spawn...");
		}

		return true;
	}

	private static boolean nearestAltar(CommandSender sender)
	{
		Player player = (Player) sender;

		if(Altar.Util.isAltarNearby(player.getLocation()))
		{
			Structure save = Altar.Util.getAltarNearby(player.getLocation());
			player.teleport(save.getReferenceLocation().clone().add(2.0, 1.5, 0));
			player.sendMessage(ChatColor.YELLOW + "Nearest Altar found.");
		}
		else player.sendMessage(ChatColor.YELLOW + "There is no alter nearby.");

		return true;
	}

	private static boolean obelisk(CommandSender sender, final String[] args)
	{
		Player player = (Player) sender;

		DCharacter character = DPlayer.Util.getPlayer(player).getCurrent();

		return true;
	}
}

@@ -82,29 +82,21 @@
 ods.
-helper.WrappedCommand
+battle.Battle
 ;%0Aim
@@ -134,23 +134,29 @@
 ods.
-language.Symbol
+helper.WrappedCommand
 ;%0Aim
@@ -1609,92 +1609,66 @@
 for(
-Symbol symbol : Symbol.values())%0A%09%09%09player.sendMessage(symbol.name() + %22: %22 + symbol
+Battle battle : Battle.Util.getAllActive())%0A%09%09%09battle.end(
 );%0A%0A

Add this again.