mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
Add Account Command
This commit is contained in:
62
Command/Command/Cmd/CommandAccount.cs
Normal file
62
Command/Command/Cmd/CommandAccount.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using EggLink.DanhengServer.Data.Custom;
|
||||
using EggLink.DanhengServer.Data;
|
||||
using EggLink.DanhengServer.Internationalization;
|
||||
using EggLink.DanhengServer.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EggLink.DanhengServer.Database.Account;
|
||||
|
||||
namespace EggLink.DanhengServer.Command.Cmd
|
||||
{
|
||||
[CommandInfo("account", "Game.Command.Account.Desc", "Game.Command.Account.Usage", permission: "egglink.manage")]
|
||||
public class CommandAccount : ICommand
|
||||
{
|
||||
[CommandMethod("create")]
|
||||
public void CreateAccount(CommandArg arg)
|
||||
{
|
||||
if (arg.Args.Count < 2)
|
||||
{
|
||||
arg.SendMsg(I18nManager.Translate("Game.Command.Notice.InvalidArguments"));
|
||||
return;
|
||||
}
|
||||
|
||||
string account = arg.Args[1];
|
||||
int uid = 0;
|
||||
|
||||
if (arg.Args.Count > 2)
|
||||
{
|
||||
if (!int.TryParse(arg.Args[2], out uid))
|
||||
{
|
||||
arg.SendMsg(I18nManager.Translate("Game.Command.Notice.InvalidUid"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (AccountData.GetAccountByUserName(account) != null)
|
||||
{
|
||||
arg.SendMsg(string.Format(I18nManager.Translate("Game.Command.Account.DuplicateAccount"), account));
|
||||
return;
|
||||
}
|
||||
|
||||
if (uid != 0 && AccountData.GetAccountByUid(uid) != null)
|
||||
{
|
||||
arg.SendMsg(string.Format(I18nManager.Translate("Game.Command.Account.DuplicateUID"), uid));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AccountHelper.CreateAccount(account, uid);
|
||||
arg.SendMsg(I18nManager.Translate("Game.Command.Account.CreateSuccess", account));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
arg.SendMsg(I18nManager.Translate("Game.Command.Account.CreateError", ex.Message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@ namespace EggLink.DanhengServer.Internationalization.Message
|
||||
public UnlockAllTextCHS UnlockAll { get; } = new();
|
||||
public MailTextCHS Mail { get; } = new();
|
||||
public RaidTextCHS Raid { get; } = new();
|
||||
public AccountTextCHS Account { get; } = new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -363,7 +364,20 @@ namespace EggLink.DanhengServer.Internationalization.Message
|
||||
public string Usage { get; } = "/raid <leave - 离开临时场景>";
|
||||
public string Leaved { get; } = "已离开临时场景!";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// path: Game.Command.Account
|
||||
/// </summary>
|
||||
public class AccountTextCHS
|
||||
{
|
||||
public string Desc { get; } = "创建账号";
|
||||
public string Usage { get; } = "/account create <用户名>";
|
||||
public string InvalidUid { get; } = "无效UID参数! ";
|
||||
public string CreateError { get; } = "出现内部错误 {0} ";
|
||||
public string CreateSuccess { get; } = "新账号 {0} 创建成功!";
|
||||
public string DuplicateAccount { get; } = "账号 {0} 已存在!";
|
||||
public string DuplicateUID { get; } = "UID {0} 已存在!";
|
||||
public string DataError { get; } = "新账号获取失败! {0}!";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user