package me.otisdiver.otisarena;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import me.otisdiver.otisarena.task.EndGame;

public class Commander implements CommandExecutor {

    private static final String noAccessMessage = ChatColor.DARK_RED + "Access denied!";
    
    private OtisArena main;
    
    /** Handles plugin commands.
     * 
     * @param main instance of JavaPlugin
     */
    public Commander(OtisArena main) {
        this.main = main;
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String cmd, String[] args) {
        if (cmd.equalsIgnoreCase("endgame")) {
            if (!sender.hasPermission("gameadmin")) {
                sender.sendMessage(noAccessMessage);
                return true;
            }
            if (args.length != 1) return false;
            
            String arg = args[0].toLowerCase();
            if (arg.equals("no")) {
                new EndGame(main, false);
                Bukkit.getServer().shutdown();
            }
            else if (args.equals("yes")) {
                new EndGame(main, true);
            }
            
            else return false;
            return true;
        }
        return false;
    }

}

@@ -56,37 +56,8 @@
 it;%0A
-import org.bukkit.ChatColor;%0A
 impo
@@ -272,98 +272,8 @@
 or %7B
-%0A%0A    private static final String noAccessMessage = ChatColor.DARK_RED + %22Access denied!%22;
 %0A   
@@ -648,126 +648,74 @@
     
-if (!sender.hasPermission(%22gameadmin%22)) %7B%0A                sender.sendMessage(noAccessMessage);%0A               
+// not enough args, stop%0A            if (args.length != 1)
  return 
 true
@@ -702,35 +702,36 @@
 th != 1) return 
-tru
+fals
 e;%0A            %7D
@@ -721,33 +721,32 @@
 se;%0A            
-%7D
 %0A            if 
@@ -746,56 +746,65 @@
     
-if (args.length != 1) return false;%0A            
+// start a new game or shut the server down based on args
 %0A   
@@ -1101,74 +1101,234 @@
     
-%0A            else return false;%0A            return true;%0A        %7D
+// not a valid option, stop%0A            else %7B%0A                return false;%0A            %7D%0A            %0A            // haven't stopped yet -%3E success!%0A            return true;%0A        %7D%0A        // not one of our commands, stop
 %0A   

fix /endgame always returning false