2014-06-18 13:32:17 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Connect : Command
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
public override string CmdName { get { return "connect"; } }
|
|
|
|
|
|
public override string CmdUsage { get { return "connect <server> [account]"; } }
|
|
|
|
|
|
public override string CmdDesc { get { return "cmd.connect.desc"; } }
|
2014-06-18 13:32:17 +02:00
|
|
|
|
|
2020-06-20 15:01:16 +02:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
2014-06-18 13:32:17 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (hasArg(command))
|
|
|
|
|
|
{
|
2014-06-19 19:24:03 +02:00
|
|
|
|
string[] args = getArgs(command);
|
|
|
|
|
|
if (args.Length > 1)
|
|
|
|
|
|
{
|
2015-06-20 22:58:18 +02:00
|
|
|
|
if (!Settings.SetAccount(args[1]))
|
2014-06-19 19:24:03 +02:00
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.connect.unknown", args[1]);
|
2014-06-19 19:24:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-06-20 22:58:18 +02:00
|
|
|
|
if (Settings.SetServerIP(args[0]))
|
2014-06-19 19:24:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
Program.Restart();
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return Translations.Get("cmd.connect.invalid_ip", args[0]);
|
2014-06-18 13:32:17 +02:00
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return GetCmdDescTranslated();
|
2014-06-18 13:32:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|