package com.pauldavdesign.mineauz.minigames.commands;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

import com.pauldavdesign.mineauz.minigames.MultiplayerTimer;
import com.pauldavdesign.mineauz.minigames.gametypes.MinigameType;
import com.pauldavdesign.mineauz.minigames.minigame.Minigame;

public class StartCommand implements ICommand{

	@Override
	public String getName() {
		return "start";
	}
	
	@Override
	public String[] getAliases(){
		return null;
	}

	@Override
	public boolean canBeConsole() {
		return true;
	}

	@Override
	public String getDescription() {
		return "Starts a Treasure Hunt Minigame. If the game isn't treasure hunt, it will force start a game begin countdown without waiting for players.";
	}

	@Override
	public String[] getParameters() {
		return null;
	}

	@Override
	public String[] getUsage() {
		return new String[] {"/minigame start <Minigame>"};
	}

	@Override
	public String getPermissionMessage() {
		return "You do not have permission to start a Minigame";
	}

	@Override
	public String getPermission() {
		return "minigame.start";
	}

	@Override
	public boolean onCommand(CommandSender sender, Minigame minigame,
			String label, String[] args) {
		if(args != null){
			Minigame mgm = plugin.mdata.getMinigame(args[0]);
			
			if(mgm != null && mgm.getThTimer() == null && mgm.getType() == MinigameType.TREASURE_HUNT){
				plugin.mdata.startGlobalMinigame(mgm.getName());
				mgm.setEnabled(true);
				mgm.saveMinigame();
			}
			else if(mgm.getType() != MinigameType.TREASURE_HUNT && mgm.getType() != MinigameType.SINGLEPLAYER && mgm.hasPlayers()){
				mgm.setMpTimer(new MultiplayerTimer(mgm));
				mgm.getMpTimer().setPlayerWaitTime(0);
				mgm.getMpTimer().startTimer();
			}
			else if(mgm.getThTimer() != null){
				sender.sendMessage(ChatColor.RED + mgm.getName() + " is already running!");
			}
			else{
				sender.sendMessage(ChatColor.RED + "No Treasure Hunt or Multiplayer Minigame found by the name " + args[0]);
			}
			return true;
		}
		return false;
	}

}

@@ -1610,16 +1610,51 @@
 ers())%7B%0A
+%09%09%09%09if(mgm.getMpTimer() == null)%7B%0A%09
 %09%09%09%09mgm.
@@ -1688,24 +1688,25 @@
 imer(mgm));%0A
+%09
 %09%09%09%09mgm.getM
@@ -1736,16 +1736,17 @@
 ime(0);%0A
+%09
 %09%09%09%09mgm.
@@ -1768,24 +1768,121 @@
 artTimer();%0A
+%09%09%09%09%7D%0A%09%09%09%09else%0A%09%09%09%09%09sender.sendMessage(ChatColor.RED + mgm.getName() + %22 has already started.%22);%0A
 %09%09%09%7D%0A%09%09%09else

Check to make sure the game hasn't already started.