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

87 lines
1.9 KiB
Java
Raw Normal View History

2014-05-02 06:35:41 +02:00
package nautilus.game.arcade.command;
import java.util.ArrayList;
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);
Plugin.GetGameCreationManager().SetNextGameType(type);
//End Current
if (Plugin.GetGame().GetState() == GameState.Recruit)
{
Plugin.GetGame().SetState(GameState.Dead);
Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " has changed game to " + type.GetName() + ".");
}
else
{
Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " set next game to " + type.GetName() + ".");
}
}
}