/*
 * This file is part of PV-Star for Bukkit, licensed under the MIT License (MIT).
 *
 * Copyright (c) JCThePants (www.jcwhatever.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


package com.jcwhatever.pvs.commands.admin.arena;

import com.jcwhatever.nucleus.managed.commands.CommandInfo;
import com.jcwhatever.nucleus.managed.commands.arguments.ICommandArguments;
import com.jcwhatever.nucleus.managed.commands.exceptions.CommandException;
import com.jcwhatever.nucleus.managed.commands.mixins.IExecutableCommand;
import com.jcwhatever.nucleus.managed.language.Localizable;
import com.jcwhatever.pvs.Lang;
import com.jcwhatever.pvs.api.PVStarAPI;
import com.jcwhatever.pvs.api.arena.IArena;
import com.jcwhatever.pvs.api.commands.AbstractPVCommand;

import org.bukkit.command.CommandSender;

@CommandInfo(
        parent="arena",
        command="select",
        staticParams={"arenaName"},
        description="Set an arena as your selected arena.",

        paramDescriptions = {
                "arenaName= The name of the arena to select."})

public class SelectSubCommand extends AbstractPVCommand implements IExecutableCommand {

    @Localizable static final String _SUCCESS =
            "'{0: arena name}' is your selected arena.";

    @Override
    public void execute(CommandSender sender, ICommandArguments args) throws CommandException {

        String arenaName = args.getString("arenaName");

        IArena arena = getArena(sender, arenaName);
        if (arena == null)
            return; // finish

        PVStarAPI.getArenaManager().setSelectedArena(sender, arena);

        tellSuccess(sender, Lang.get(_SUCCESS, arena.getName()));
    }
}

@@ -1586,28 +1586,152 @@
 ged.
-language.Localizable
+commands.mixins.ITabCompletable;%0Aimport com.jcwhatever.nucleus.managed.language.Localizable;%0Aimport com.jcwhatever.nucleus.utils.CollectionUtils
 ;%0Aim
@@ -1903,17 +1903,16 @@
 ommand;%0A
-%0A
 import o
@@ -1945,16 +1945,69 @@
 ender;%0A%0A
+import java.util.Collection;%0Aimport java.util.List;%0A%0A
 @Command
@@ -2309,16 +2309,24 @@
 VCommand
+%0A       
  impleme
@@ -2347,16 +2347,33 @@
 eCommand
+, ITabCompletable
  %7B%0A%0A    
@@ -2818,24 +2818,24 @@
 r, arena);%0A%0A
-
         tell
@@ -2893,11 +2893,459 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void onTabComplete(CommandSender sender, String%5B%5D arguments, Collection%3CString%3E completions) %7B%0A        List%3CIArena%3E arenas = PVStarAPI.getArenaManager().getArenas();%0A        tabCompleteSearch(arguments, arenas, completions, new CollectionUtils.ISearchTextGetter%3CIArena%3E() %7B%0A            @Override%0A            public String getText(IArena element) %7B%0A                return element.getName();%0A            %7D%0A        %7D);%0A    %7D
 %0A%7D%0A

add tab complete to arena select command