2014-05-02 06:35:41 +02:00
|
|
|
package nautilus.game.arcade.command;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2014-11-14 01:22:00 +01:00
|
|
|
import java.util.List;
|
2014-05-02 06:35:41 +02:00
|
|
|
|
2014-11-14 01:22:00 +01:00
|
|
|
import org.bukkit.command.CommandSender;
|
2014-05-02 06:35:41 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
|
|
|
import nautilus.game.arcade.GameType;
|
|
|
|
import nautilus.game.arcade.game.Game.GameState;
|
|
|
|
import mineplex.core.command.CommandBase;
|
|
|
|
import mineplex.core.common.Rank;
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
|
|
|
|
public class SetCommand extends CommandBase<ArcadeManager>
|
2014-08-22 09:05:14 +02:00
|
|
|
{
|
2014-05-02 06:35:41 +02:00
|
|
|
public SetCommand(ArcadeManager plugin)
|
|
|
|
{
|
2015-02-06 04:16:10 +01:00
|
|
|
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPLEAD}, "set");
|
2014-05-02 06:35:41 +02:00
|
|
|
}
|
2014-08-22 09:05:14 +02:00
|
|
|
|
|
|
|
@Override
|
2014-05-02 06:35:41 +02:00
|
|
|
public void Execute(Player caller, String[] args)
|
2014-08-22 09:05:14 +02:00
|
|
|
{
|
2014-05-02 06:35:41 +02:00
|
|
|
if (Plugin.GetGame() == null)
|
|
|
|
return;
|
2014-08-22 09:05:14 +02:00
|
|
|
|
2014-05-02 06:35:41 +02:00
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
caller.sendMessage("/game set <GameType> (Map)");
|
2014-08-22 09:05:14 +02:00
|
|
|
return;
|
2014-05-02 06:35:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String game = args[0].toLowerCase();
|
|
|
|
|
|
|
|
if (args.length > 1)
|
|
|
|
Plugin.GetGameCreationManager().MapPref = args[1];
|
|
|
|
|
|
|
|
//Parse Game
|
|
|
|
ArrayList<GameType> matches = new ArrayList<GameType>();
|
|
|
|
for (GameType type : GameType.values())
|
|
|
|
{
|
|
|
|
if (type.toString().toLowerCase().equals(game))
|
|
|
|
{
|
|
|
|
matches.clear();
|
|
|
|
matches.add(type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type.toString().toLowerCase().contains(game))
|
|
|
|
{
|
|
|
|
matches.add(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (matches.size() == 0)
|
|
|
|
{
|
|
|
|
caller.sendMessage("No results for: " + game);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (matches.size() > 1)
|
|
|
|
{
|
|
|
|
caller.sendMessage("Matched multiple games;");
|
|
|
|
for (GameType cur : matches)
|
|
|
|
caller.sendMessage(cur.toString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameType type = matches.get(0);
|
2014-12-17 03:37:14 +01:00
|
|
|
Plugin.GetGame().setGame(type, caller, true);
|
2014-05-02 06:35:41 +02:00
|
|
|
}
|
2014-11-14 01:22:00 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
|
|
|
{
|
|
|
|
String lastArg = args[args.length - 1];
|
|
|
|
|
|
|
|
return getMatches(lastArg, GameType.values());
|
|
|
|
}
|
2014-05-02 06:35:41 +02:00
|
|
|
}
|