Fixed SaveSSI on kick potentially breaking
Added method to save an inventory in SSI to TSPlayer
This commit is contained in:
parent
e821236a04
commit
b8c2c1aded
3 changed files with 28 additions and 3 deletions
|
|
@ -119,6 +119,29 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the player's inventory to SSI
|
||||
/// </summary>
|
||||
/// <returns>bool - True/false if it saved successfully</returns>
|
||||
public bool SaveServerInventory()
|
||||
{
|
||||
if (!TShock.Config.ServerSideInventory)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
PlayerData.CopyInventory(this);
|
||||
TShock.InventoryDB.InsertPlayerData(this);
|
||||
return true;
|
||||
} catch (Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Terraria Player
|
||||
/// </summary>
|
||||
|
|
|
|||
1
TShockAPI/TShock.cs
Executable file → Normal file
1
TShockAPI/TShock.cs
Executable file → Normal file
|
|
@ -77,6 +77,7 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static event Action Initialized;
|
||||
|
||||
public static List<int> TakenPlayerIDs = new List<int>();
|
||||
|
||||
public override Version Version
|
||||
{
|
||||
|
|
|
|||
|
|
@ -574,7 +574,8 @@ namespace TShockAPI
|
|||
/// <param name="reason">string reason</param>
|
||||
/// <param name="force">bool force (default: false)</param>
|
||||
/// <param name="silent">bool silent (default: false)</param>
|
||||
/// <param name="adminUserName">bool silent (default: null)</param>
|
||||
/// <param name="adminUserName">string adminUserName (default: null)</param>
|
||||
/// <param name="saveSSI">bool saveSSI (default: false)</param>
|
||||
public bool Kick(TSPlayer player, string reason, bool force = false, bool silent = false, string adminUserName = null, bool saveSSI = false)
|
||||
{
|
||||
if (!player.ConnectionAlive)
|
||||
|
|
@ -583,8 +584,8 @@ namespace TShockAPI
|
|||
{
|
||||
string playerName = player.Name;
|
||||
player.SilentKickInProgress = silent;
|
||||
if( player.IsLoggedIn && saveSSI)
|
||||
TShock.InventoryDB.InsertPlayerData(player);
|
||||
if (player.IsLoggedIn && saveSSI)
|
||||
player.SaveServerInventory();
|
||||
player.Disconnect(string.Format("Kicked: {0}", reason));
|
||||
Log.ConsoleInfo(string.Format("Kicked {0} for : {1}", playerName, reason));
|
||||
string verb = force ? "force " : "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue