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

102 lines
2.4 KiB
Java
Raw Normal View History

2014-05-02 06:35:41 +02:00
package nautilus.game.arcade.command;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
2015-03-12 02:14:49 +01:00
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
2014-05-02 06:35:41 +02:00
public class SetCommand extends CommandBase<ArcadeManager>
{
2014-05-02 06:35:41 +02:00
public SetCommand(ArcadeManager plugin)
{
2015-07-23 16:29:42 +02:00
super(plugin, Rank.ADMIN, new Rank[] {Rank.MAPLEAD, Rank.JNR_DEV}, "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;
if (args == null || args.length == 0)
2014-05-02 06:35:41 +02:00
{
caller.sendMessage(F.help("/game set <GameType> (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN));
return;
2014-05-02 06:35:41 +02:00
}
String game = args[0].toLowerCase();
if (args.length >= 2)
2015-03-12 02:14:49 +01:00
{
String map = "";
String source = "";
if(args.length == 3)
{
Plugin.GetGameCreationManager().MapSource = args[1];
Plugin.GetGameCreationManager().MapPref = args[2];
source = args[1];
map = args[2];
}
else
{
Plugin.GetGameCreationManager().MapSource = args[0];
Plugin.GetGameCreationManager().MapPref = args[1];
source = args[0];
map = args[1];
}
UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map);
2015-03-12 02:14:49 +01:00
}
2014-05-02 06:35:41 +02:00
//Parse Game
ArrayList<GameType> matches = new ArrayList<>();
2014-05-02 06:35:41 +02:00
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
}