diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index e08df139..d7cd86af 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -119,6 +119,29 @@ namespace TShockAPI } } + /// + /// Saves the player's inventory to SSI + /// + /// bool - True/false if it saved successfully + 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; + } + + } + /// /// Terraria Player /// diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs old mode 100755 new mode 100644 index c5376ea9..3dd4a32a --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -77,6 +77,7 @@ namespace TShockAPI /// public static event Action Initialized; + public static List TakenPlayerIDs = new List(); public override Version Version { diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 89e27b6f..697ae2f9 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -574,7 +574,8 @@ namespace TShockAPI /// string reason /// bool force (default: false) /// bool silent (default: false) - /// bool silent (default: null) + /// string adminUserName (default: null) + /// bool saveSSI (default: false) 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 " : "";