Merge remote branch 'origin' into general-devel
This commit is contained in:
commit
4039327690
11 changed files with 163 additions and 26 deletions
|
|
@ -404,17 +404,23 @@ namespace TShockAPI
|
||||||
User user = TShock.Users.GetUserByName(args.Player.Name);
|
User user = TShock.Users.GetUserByName(args.Player.Name);
|
||||||
string encrPass = "";
|
string encrPass = "";
|
||||||
|
|
||||||
if (args.Parameters.Count == 1)
|
if (args.Parameters.Count == 0)
|
||||||
{
|
{
|
||||||
if (Hooks.PlayerHooks.OnPlayerPreLogin(args.Player, args.Player.Name, args.Parameters[0]))
|
if (Hooks.PlayerHooks.OnPlayerPreLogin(args.Player, args.Player.Name, ""))
|
||||||
return;
|
return;
|
||||||
|
user = TShock.Users.GetUserByName(args.Player.Name);
|
||||||
|
}
|
||||||
|
else if (args.Parameters.Count == 1)
|
||||||
|
{
|
||||||
|
if (Hooks.PlayerHooks.OnPlayerPreLogin(args.Player, args.Player.Name, args.Parameters[0]))
|
||||||
|
return;
|
||||||
user = TShock.Users.GetUserByName(args.Player.Name);
|
user = TShock.Users.GetUserByName(args.Player.Name);
|
||||||
encrPass = TShock.Utils.HashPassword(args.Parameters[0]);
|
encrPass = TShock.Utils.HashPassword(args.Parameters[0]);
|
||||||
}
|
}
|
||||||
else if (args.Parameters.Count == 2 && TShock.Config.AllowLoginAnyUsername)
|
else if (args.Parameters.Count == 2 && TShock.Config.AllowLoginAnyUsername)
|
||||||
{
|
{
|
||||||
if (Hooks.PlayerHooks.OnPlayerPreLogin(args.Player, args.Parameters[0], args.Parameters[1]))
|
if (Hooks.PlayerHooks.OnPlayerPreLogin(args.Player, args.Parameters[0], args.Parameters[1]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
user = TShock.Users.GetUserByName(args.Parameters[0]);
|
user = TShock.Users.GetUserByName(args.Parameters[0]);
|
||||||
encrPass = TShock.Utils.HashPassword(args.Parameters[1]);
|
encrPass = TShock.Utils.HashPassword(args.Parameters[1]);
|
||||||
|
|
@ -426,7 +432,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage(String.Format("Syntax: /login{0} <password>", TShock.Config.AllowLoginAnyUsername ? " [username]" : " "));
|
args.Player.SendErrorMessage(String.Format("Syntax: /login{0} [password]", TShock.Config.AllowLoginAnyUsername ? " [username]" : " "));
|
||||||
args.Player.SendErrorMessage("If you forgot your password, there is no way to recover it.");
|
args.Player.SendErrorMessage("If you forgot your password, there is no way to recover it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -436,7 +442,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("A user by that name does not exist.");
|
args.Player.SendErrorMessage("A user by that name does not exist.");
|
||||||
}
|
}
|
||||||
else if (user.Password.ToUpper() == encrPass.ToUpper())
|
else if (user.Password.ToUpper() == encrPass.ToUpper() || (user.UUID == args.Player.UUID && !TShock.Config.DisableUUIDLogin))
|
||||||
{
|
{
|
||||||
args.Player.PlayerData = TShock.InventoryDB.GetPlayerData(args.Player, TShock.Users.GetUserID(user.Name));
|
args.Player.PlayerData = TShock.InventoryDB.GetPlayerData(args.Player, TShock.Users.GetUserID(user.Name));
|
||||||
|
|
||||||
|
|
@ -489,6 +495,7 @@ namespace TShockAPI
|
||||||
args.Player.LoginHarassed = false;
|
args.Player.LoginHarassed = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
TShock.Users.SetUserUUID(user, args.Player.UUID);
|
||||||
|
|
||||||
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
|
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
|
||||||
}
|
}
|
||||||
|
|
@ -562,6 +569,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. --Why?
|
user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. --Why?
|
||||||
|
user.UUID = args.Player.UUID;
|
||||||
|
|
||||||
if (TShock.Users.GetUserByName(user.Name) == null && user.Name != TSServerPlayer.AccountName) // Cheap way of checking for existance of a user
|
if (TShock.Users.GetUserByName(user.Name) == null && user.Name != TSServerPlayer.AccountName) // Cheap way of checking for existance of a user
|
||||||
{
|
{
|
||||||
|
|
@ -959,7 +967,7 @@ namespace TShockAPI
|
||||||
string reason = args.Parameters.Count > 2
|
string reason = args.Parameters.Count > 2
|
||||||
? String.Join(" ", args.Parameters.GetRange(2, args.Parameters.Count - 2))
|
? String.Join(" ", args.Parameters.GetRange(2, args.Parameters.Count - 2))
|
||||||
: "Manually added IP address ban.";
|
: "Manually added IP address ban.";
|
||||||
TShock.Bans.AddBan(ip, "", reason, false, args.Player.UserAccountName);
|
TShock.Bans.AddBan(ip, "", "", reason, false, args.Player.UserAccountName);
|
||||||
args.Player.SendSuccessMessage(ip + " banned.");
|
args.Player.SendSuccessMessage(ip + " banned.");
|
||||||
return;
|
return;
|
||||||
#endregion Add ip ban
|
#endregion Add ip ban
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
[Description("Enables kicking of banned users by matching their IP Address.")] public bool EnableIPBans = true;
|
[Description("Enables kicking of banned users by matching their IP Address.")] public bool EnableIPBans = true;
|
||||||
|
|
||||||
|
[Description("Enables kicking of banned users by matching their client UUID.")] public bool EnableUUIDBans = true;
|
||||||
|
|
||||||
[Description("Enables kicking of banned users by matching their Character Name.")] public bool EnableBanOnUsernames;
|
[Description("Enables kicking of banned users by matching their Character Name.")] public bool EnableBanOnUsernames;
|
||||||
|
|
||||||
[Description("Selects the default group name to place new registrants under.")] public string
|
[Description("Selects the default group name to place new registrants under.")] public string
|
||||||
|
|
@ -206,6 +208,10 @@ namespace TShockAPI
|
||||||
[Description("Disable users from being able to login with account password when joining.")] public bool
|
[Description("Disable users from being able to login with account password when joining.")] public bool
|
||||||
DisableLoginBeforeJoin;
|
DisableLoginBeforeJoin;
|
||||||
|
|
||||||
|
[Description("Disable users from being able to login with their client UUID.")]
|
||||||
|
public bool
|
||||||
|
DisableUUIDLogin;
|
||||||
|
|
||||||
[Description("Allows users to register any username with /register.")] public bool AllowRegisterAnyUsername;
|
[Description("Allows users to register any username with /register.")] public bool AllowRegisterAnyUsername;
|
||||||
|
|
||||||
[Description("Allows users to login with any username with /login.")] public bool AllowLoginAnyUsername = true;
|
[Description("Allows users to login with any username with /login.")] public bool AllowLoginAnyUsername = true;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ namespace TShockAPI.DB
|
||||||
var table = new SqlTable("Bans",
|
var table = new SqlTable("Bans",
|
||||||
new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
|
new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
|
||||||
new SqlColumn("Name", MySqlDbType.Text),
|
new SqlColumn("Name", MySqlDbType.Text),
|
||||||
|
new SqlColumn("UUID", MySqlDbType.Text),
|
||||||
new SqlColumn("Reason", MySqlDbType.Text),
|
new SqlColumn("Reason", MySqlDbType.Text),
|
||||||
new SqlColumn("BanningUser", MySqlDbType.Text),
|
new SqlColumn("BanningUser", MySqlDbType.Text),
|
||||||
new SqlColumn("Date", MySqlDbType.Text),
|
new SqlColumn("Date", MySqlDbType.Text),
|
||||||
|
|
@ -61,7 +62,7 @@ namespace TShockAPI.DB
|
||||||
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE IP=@0", ip))
|
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE IP=@0", ip))
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
|
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -80,7 +81,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
banlist.Add(new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration")));
|
banlist.Add(new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration")));
|
||||||
}
|
}
|
||||||
return banlist;
|
return banlist;
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +104,24 @@ namespace TShockAPI.DB
|
||||||
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE " + namecol + "=@0", name))
|
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE " + namecol + "=@0", name))
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
|
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban GetBanByUUID(string uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE UUID=@0", uuid))
|
||||||
|
{
|
||||||
|
if (reader.Read())
|
||||||
|
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -120,11 +138,11 @@ namespace TShockAPI.DB
|
||||||
return AddBan(ip, name, reason, false, "", "");
|
return AddBan(ip, name, reason, false, "", "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
public bool AddBan(string ip, string name = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
|
public bool AddBan(string ip, string name = "", string uuid = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return database.Query("INSERT INTO Bans (IP, Name, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5);", ip, name, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
|
return database.Query("INSERT INTO Bans (IP, Name, UUID Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5, @6);", ip, name, uuid, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -181,6 +199,8 @@ namespace TShockAPI.DB
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string UUID { get; set; }
|
||||||
|
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
|
|
||||||
public string BanningUser { get; set; }
|
public string BanningUser { get; set; }
|
||||||
|
|
@ -189,10 +209,11 @@ namespace TShockAPI.DB
|
||||||
|
|
||||||
public string Expiration { get; set; }
|
public string Expiration { get; set; }
|
||||||
|
|
||||||
public Ban(string ip, string name, string reason, string banner, string date, string exp)
|
public Ban(string ip, string name, string uuid, string reason, string banner, string date, string exp)
|
||||||
{
|
{
|
||||||
IP = ip;
|
IP = ip;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
UUID = UUID;
|
||||||
Reason = reason;
|
Reason = reason;
|
||||||
BanningUser = banner;
|
BanningUser = banner;
|
||||||
Date = date;
|
Date = date;
|
||||||
|
|
@ -203,6 +224,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
IP = string.Empty;
|
IP = string.Empty;
|
||||||
Name = string.Empty;
|
Name = string.Empty;
|
||||||
|
UUID = string.Empty;
|
||||||
Reason = string.Empty;
|
Reason = string.Empty;
|
||||||
BanningUser = "";
|
BanningUser = "";
|
||||||
Date = "";
|
Date = "";
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ namespace TShockAPI.DB
|
||||||
new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true},
|
new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true},
|
||||||
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
||||||
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
||||||
|
new SqlColumn("UUID", MySqlDbType.VarChar, 128),
|
||||||
new SqlColumn("Usergroup", MySqlDbType.Text),
|
new SqlColumn("Usergroup", MySqlDbType.Text),
|
||||||
new SqlColumn("Registered", MySqlDbType.Text),
|
new SqlColumn("Registered", MySqlDbType.Text),
|
||||||
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
||||||
|
|
@ -62,8 +63,8 @@ namespace TShockAPI.DB
|
||||||
int ret;
|
int ret;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = database.Query("INSERT INTO Users (Username, Password, UserGroup, Registered) VALUES (@0, @1, @2, @3);", user.Name,
|
ret = database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name,
|
||||||
TShock.Utils.HashPassword(user.Password), user.Group, DateTime.UtcNow.ToString("s"));
|
TShock.Utils.HashPassword(user.Password), user.UUID, user.Group, DateTime.UtcNow.ToString("s"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -116,6 +117,26 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the UUID for a given username
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">User user</param>
|
||||||
|
/// <param name="group">string uuid</param>
|
||||||
|
public void SetUserUUID(User user, string uuid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
database.Query("UPDATE Users SET UUID = @0 WHERE Username = @1;", uuid,
|
||||||
|
user.Name) == 0)
|
||||||
|
throw new UserNotExistException(user.Name);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new UserManagerException("SetUserUUID SQL returned an error", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the group for a given username
|
/// Sets the group for a given username
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -269,6 +290,7 @@ namespace TShockAPI.DB
|
||||||
user.ID = result.Get<int>("ID");
|
user.ID = result.Get<int>("ID");
|
||||||
user.Group = result.Get<string>("Usergroup");
|
user.Group = result.Get<string>("Usergroup");
|
||||||
user.Password = result.Get<string>("Password");
|
user.Password = result.Get<string>("Password");
|
||||||
|
user.UUID = result.Get<string>("UUID");
|
||||||
user.Name = result.Get<string>("Username");
|
user.Name = result.Get<string>("Username");
|
||||||
user.Registered = result.Get<string>("Registered");
|
user.Registered = result.Get<string>("Registered");
|
||||||
user.LastAccessed = result.Get<string>("LastAccessed");
|
user.LastAccessed = result.Get<string>("LastAccessed");
|
||||||
|
|
@ -282,15 +304,17 @@ namespace TShockAPI.DB
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
public string UUID { get; set; }
|
||||||
public string Group { get; set; }
|
public string Group { get; set; }
|
||||||
public string Registered { get; set; }
|
public string Registered { get; set; }
|
||||||
public string LastAccessed { get; set; }
|
public string LastAccessed { get; set; }
|
||||||
public string KnownIps { get; set; }
|
public string KnownIps { get; set; }
|
||||||
|
|
||||||
public User(string name, string pass, string group, string registered, string last, string known)
|
public User(string name, string pass, string uuid, string group, string registered, string last, string known)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Password = pass;
|
Password = pass;
|
||||||
|
UUID = uuid;
|
||||||
Group = group;
|
Group = group;
|
||||||
Registered = registered;
|
Registered = registered;
|
||||||
LastAccessed = last;
|
LastAccessed = last;
|
||||||
|
|
@ -301,6 +325,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
Name = "";
|
Name = "";
|
||||||
Password = "";
|
Password = "";
|
||||||
|
UUID = "";
|
||||||
Group = "";
|
Group = "";
|
||||||
Registered = "";
|
Registered = "";
|
||||||
LastAccessed = "";
|
LastAccessed = "";
|
||||||
|
|
|
||||||
|
|
@ -1396,7 +1396,59 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
var user = TShock.Users.GetUserByName(args.Player.Name);
|
var user = TShock.Users.GetUserByName(args.Player.Name);
|
||||||
|
|
||||||
if (user != null && !TShock.Config.DisableLoginBeforeJoin)
|
if (user != null && !TShock.Config.DisableUUIDLogin)
|
||||||
|
{
|
||||||
|
if(user.UUID == args.Player.UUID)
|
||||||
|
{
|
||||||
|
args.Player.PlayerData = TShock.InventoryDB.GetPlayerData(args.Player, TShock.Users.GetUserID(args.Player.Name));
|
||||||
|
|
||||||
|
if (args.Player.State == 1)
|
||||||
|
args.Player.State = 2;
|
||||||
|
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
|
||||||
|
|
||||||
|
var group = TShock.Utils.GetGroup(user.Group);
|
||||||
|
|
||||||
|
if (TShock.Config.ServerSideInventory)
|
||||||
|
{
|
||||||
|
if (group.HasPermission(Permissions.bypassinventorychecks))
|
||||||
|
{
|
||||||
|
args.Player.IgnoreActionsForClearingTrashCan = false;
|
||||||
|
}
|
||||||
|
else if (!TShock.CheckInventory(args.Player))
|
||||||
|
{
|
||||||
|
args.Player.LoginFailsBySsi = true;
|
||||||
|
args.Player.SendMessage("Login Failed, Please fix the above errors then /login again.", Color.Cyan);
|
||||||
|
args.Player.IgnoreActionsForClearingTrashCan = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.Player.LoginFailsBySsi = false;
|
||||||
|
|
||||||
|
if (group.HasPermission(Permissions.ignorestackhackdetection))
|
||||||
|
args.Player.IgnoreActionsForCheating = "none";
|
||||||
|
|
||||||
|
if (group.HasPermission(Permissions.usebanneditem))
|
||||||
|
args.Player.IgnoreActionsForDisabledArmor = "none";
|
||||||
|
|
||||||
|
args.Player.Group = group;
|
||||||
|
args.Player.tempGroup = null;
|
||||||
|
args.Player.UserAccountName = args.Player.Name;
|
||||||
|
args.Player.UserID = TShock.Users.GetUserID(args.Player.UserAccountName);
|
||||||
|
args.Player.IsLoggedIn = true;
|
||||||
|
args.Player.IgnoreActionsForInventory = "none";
|
||||||
|
|
||||||
|
if (!args.Player.IgnoreActionsForClearingTrashCan)
|
||||||
|
{
|
||||||
|
args.Player.PlayerData.CopyInventory(args.Player);
|
||||||
|
TShock.InventoryDB.InsertPlayerData(args.Player);
|
||||||
|
}
|
||||||
|
args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen);
|
||||||
|
Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + ".");
|
||||||
|
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (user != null && !TShock.Config.DisableLoginBeforeJoin)
|
||||||
{
|
{
|
||||||
args.Player.RequiresPassword = true;
|
args.Player.RequiresPassword = true;
|
||||||
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
|
||||||
|
|
@ -1476,6 +1528,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen);
|
args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen);
|
||||||
Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + ".");
|
Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + ".");
|
||||||
|
TShock.Users.SetUserUUID(user, args.Player.UUID);
|
||||||
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
|
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -2163,6 +2216,11 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pulley > 2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.Player.LastNetPosition == Vector2.Zero)
|
if (args.Player.LastNetPosition == Vector2.Zero)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ namespace TShockAPI.Net
|
||||||
DownedBoss2 = 4,
|
DownedBoss2 = 4,
|
||||||
DownedBoss3 = 8,
|
DownedBoss3 = 8,
|
||||||
HardMode = 16,
|
HardMode = 16,
|
||||||
DownedClown = 32
|
DownedClown = 32,
|
||||||
|
ServerSideCharacter = 64
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|
@ -141,7 +142,7 @@ namespace TShockAPI.Net
|
||||||
stream.WriteByte(HellBackStyle);
|
stream.WriteByte(HellBackStyle);
|
||||||
stream.WriteSingle(WindSpeed);
|
stream.WriteSingle(WindSpeed);
|
||||||
stream.WriteByte(NumberOfClouds);
|
stream.WriteByte(NumberOfClouds);
|
||||||
stream.WriteInt8((byte) BossFlags);
|
stream.WriteInt8((byte)BossFlags);
|
||||||
stream.WriteInt8((byte)BossFlags2);
|
stream.WriteInt8((byte)BossFlags2);
|
||||||
stream.WriteSingle(Rain);
|
stream.WriteSingle(Rain);
|
||||||
stream.WriteBytes(Encoding.UTF8.GetBytes(WorldName));
|
stream.WriteBytes(Encoding.UTF8.GetBytes(WorldName));
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ namespace TShockAPI
|
||||||
return RestMissingParam("password");
|
return RestMissingParam("password");
|
||||||
|
|
||||||
// NOTE: ip can be blank
|
// NOTE: ip can be blank
|
||||||
User user = new User(username, password, group, "", "", "");
|
User user = new User(username, password, "", group, "", "", "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TShock.Users.AddUser(user);
|
TShock.Users.AddUser(user);
|
||||||
|
|
@ -404,7 +404,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TShock.Bans.AddBan(ip, name, parameters["reason"], true, tokenData.Username);
|
TShock.Bans.AddBan(ip, name, "", parameters["reason"], true, tokenData.Username);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -622,7 +622,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
TSPlayer player = (TSPlayer)ret;
|
TSPlayer player = (TSPlayer)ret;
|
||||||
var reason = null == parameters["reason"] ? "Banned via web" : parameters["reason"];
|
var reason = null == parameters["reason"] ? "Banned via web" : parameters["reason"];
|
||||||
TShock.Bans.AddBan(player.IP, player.Name, reason);
|
TShock.Bans.AddBan(player.IP, player.Name, "", reason);
|
||||||
TShock.Utils.ForceKick(player, reason, false, true);
|
TShock.Utils.ForceKick(player, reason, false, true);
|
||||||
return RestResponse("Player " + player.Name + " was banned");
|
return RestResponse("Player " + player.Name + " was banned");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,15 @@ namespace TShockAPI
|
||||||
set { Netplay.serverSock[Index].state = value; }
|
set { Netplay.serverSock[Index].state = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string UUID
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return RealPlayer
|
||||||
|
? Netplay.serverSock[Index].clientUUID
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string IP
|
public string IP
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -495,7 +504,8 @@ namespace TShockAPI
|
||||||
(NPC.downedBoss2 ? BossFlags.DownedBoss2 : BossFlags.None) |
|
(NPC.downedBoss2 ? BossFlags.DownedBoss2 : BossFlags.None) |
|
||||||
(NPC.downedBoss3 ? BossFlags.DownedBoss3 : BossFlags.None) |
|
(NPC.downedBoss3 ? BossFlags.DownedBoss3 : BossFlags.None) |
|
||||||
(Main.hardMode ? BossFlags.HardMode : BossFlags.None) |
|
(Main.hardMode ? BossFlags.HardMode : BossFlags.None) |
|
||||||
(NPC.downedClown ? BossFlags.DownedClown : BossFlags.None),
|
(NPC.downedClown ? BossFlags.DownedClown : BossFlags.None) |
|
||||||
|
(Main.ServerSideCharacter ? BossFlags.ServerSideCharacter : BossFlags.None),
|
||||||
BossFlags2 = (NPC.downedMechBoss1 ? BossFlags2.DownedMechBoss1 : BossFlags2.None) |
|
BossFlags2 = (NPC.downedMechBoss1 ? BossFlags2.DownedMechBoss1 : BossFlags2.None) |
|
||||||
(NPC.downedMechBoss2 ? BossFlags2.DownedMechBoss2 : BossFlags2.None) |
|
(NPC.downedMechBoss2 ? BossFlags2.DownedMechBoss2 : BossFlags2.None) |
|
||||||
(NPC.downedMechBoss3 ? BossFlags2.DownedMechBoss3 : BossFlags2.None) |
|
(NPC.downedMechBoss3 ? BossFlags2.DownedMechBoss3 : BossFlags2.None) |
|
||||||
|
|
|
||||||
|
|
@ -845,6 +845,11 @@ namespace TShockAPI
|
||||||
ban = Bans.GetBanByIp(player.IP);
|
ban = Bans.GetBanByIp(player.IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.EnableUUIDBans && null == ban)
|
||||||
|
{
|
||||||
|
ban = Bans.GetBanByUUID(player.UUID);
|
||||||
|
}
|
||||||
|
|
||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
if (!Utils.HasBanExpired(ban))
|
if (!Utils.HasBanExpired(ban))
|
||||||
|
|
|
||||||
|
|
@ -673,8 +673,9 @@ namespace TShockAPI
|
||||||
if (force || !player.Group.HasPermission(Permissions.immunetoban))
|
if (force || !player.Group.HasPermission(Permissions.immunetoban))
|
||||||
{
|
{
|
||||||
string ip = player.IP;
|
string ip = player.IP;
|
||||||
|
string uuid = player.UUID;
|
||||||
string playerName = player.Name;
|
string playerName = player.Name;
|
||||||
TShock.Bans.AddBan(ip, playerName, reason, false, adminUserName);
|
TShock.Bans.AddBan(ip, playerName, uuid, reason, false, adminUserName);
|
||||||
player.Disconnect(string.Format("Banned: {0}", reason));
|
player.Disconnect(string.Format("Banned: {0}", reason));
|
||||||
Log.ConsoleInfo(string.Format("Banned {0} for : {1}", playerName, reason));
|
Log.ConsoleInfo(string.Format("Banned {0} for : {1}", playerName, reason));
|
||||||
string verb = force ? "force " : "";
|
string verb = force ? "force " : "";
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace UnitTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void AddBanTest()
|
public void AddBanTest()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(Bans.AddBan("127.0.0.1", "BanTest", "Ban Testing"));
|
Assert.IsTrue(Bans.AddBan("127.0.0.1", "BanTest", "BanTest2", "Ban Testing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
@ -62,6 +62,7 @@ namespace UnitTests
|
||||||
{
|
{
|
||||||
Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1"));
|
Assert.IsNotNull(Bans.GetBanByIp("127.0.0.1"));
|
||||||
Assert.IsNotNull(Bans.GetBanByName("BanTest"));
|
Assert.IsNotNull(Bans.GetBanByName("BanTest"));
|
||||||
|
Assert.IsNotNull(Bans.GetBanByUUID("BanTest2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue