Request for Erik

This commit is contained in:
Zidonuke 2011-12-29 01:56:18 -05:00
parent abbf95f870
commit f360067198
2 changed files with 26 additions and 16 deletions

View file

@ -427,30 +427,37 @@ namespace TShockAPI
{ {
try try
{ {
var user = new User();
if (args.Parameters.Count == 1) if (args.Parameters.Count == 1)
{ {
var user = new User();
user.Name = args.Player.Name; user.Name = args.Player.Name;
user.Password = args.Parameters[0]; user.Password = args.Parameters[0];
user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. }
else if (args.Parameters.Count == 2 && TShock.Config.AllowRegisterAnyUsername)
if (TShock.Users.GetUserByName(user.Name) == null) // Cheap way of checking for existance of a user {
{ user.Name = args.Parameters[0];
args.Player.SendMessage("Account " + user.Name + " has been registered.", Color.Green); user.Password = args.Parameters[1];
args.Player.SendMessage("Your password is " + user.Password);
TShock.Users.AddUser(user);
Log.ConsoleInfo(args.Player.Name + " registered an Account: " + user.Name);
}
else
{
args.Player.SendMessage("Account " + user.Name + " has already been registered.", Color.Green);
Log.ConsoleInfo(args.Player.Name + " failed to register an existing Account: " + user.Name);
}
} }
else else
{ {
args.Player.SendMessage("Invalid syntax! Proper syntax: /register <password>", Color.Red); args.Player.SendMessage("Invalid syntax! Proper syntax: /register <password>", Color.Red);
return;
}
user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB.
if (TShock.Users.GetUserByName(user.Name) == null) // Cheap way of checking for existance of a user
{
args.Player.SendMessage("Account " + user.Name + " has been registered.", Color.Green);
args.Player.SendMessage("Your password is " + user.Password);
TShock.Users.AddUser(user);
Log.ConsoleInfo(args.Player.Name + " registered an Account: " + user.Name);
}
else
{
args.Player.SendMessage("Account " + user.Name + " has already been registered.", Color.Green);
Log.ConsoleInfo(args.Player.Name + " failed to register an existing Account: " + user.Name);
} }
} }
catch (UserManagerException ex) catch (UserManagerException ex)

View file

@ -221,6 +221,9 @@ namespace TShockAPI
[Description("Disable users from being able to login with account password when joining")] [Description("Disable users from being able to login with account password when joining")]
public bool DisableLoginBeforeJoin = false; public bool DisableLoginBeforeJoin = false;
[Description("Allows users to register any username with /register")]
public bool AllowRegisterAnyUsername = false;
public static ConfigFile Read(string path) public static ConfigFile Read(string path)
{ {