Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java

83 lines
1.8 KiB
Java
Raw Normal View History

2014-05-02 06:35:41 +02:00
package nautilus.game.arcade.command;
import java.util.ArrayList;
import java.util.List;
2014-05-02 06:35:41 +02: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-05-02 06:35:41 +02:00
public SetCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "set");
2014-05-02 06:35:41 +02:00
}
@Override
2014-05-02 06:35:41 +02:00
public void Execute(Player caller, String[] args)
{
2014-05-02 06:35:41 +02:00
if (Plugin.GetGame() == null)
return;
2014-05-02 06:35:41 +02:00
if (args.length == 0)
{
caller.sendMessage("/game set <GameType> (Map)");
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
}
@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
}