Implement logic to store the data of a player when they join, and allow for a command to be run that will upload that data in place of their existing SSC data.
This commit is contained in:
parent
156df47777
commit
f1ce158efd
4 changed files with 39 additions and 12 deletions
|
|
@ -298,6 +298,11 @@ namespace TShockAPI
|
|||
{
|
||||
HelpText = "Saves all serverside characters."
|
||||
});
|
||||
add(new Command(Permissions.uploaddata, UploadJoinData, "uploadssc")
|
||||
{
|
||||
HelpText = "Upload the account information when you joined the server as your Server Side Character data.",
|
||||
AllowServer = false
|
||||
});
|
||||
add(new Command(Permissions.settempgroup, TempGroup, "tempgroup")
|
||||
{
|
||||
HelpText = "Temporarily sets another player's group."
|
||||
|
|
@ -1691,6 +1696,18 @@ namespace TShockAPI
|
|||
args.Player.SendSuccessMessage("SSC of player \"{0}\" has been overriden.", matchedPlayer.Name);
|
||||
}
|
||||
|
||||
private static void UploadJoinData(CommandArgs args)
|
||||
{
|
||||
if (TShock.CharacterDB.InsertSpecificPlayerData(args.Player, args.Player.DataWhenJoined)) {
|
||||
args.Player.DataWhenJoined.RestoreCharacter(args.Player);
|
||||
args.Player.SendSuccessMessage("Your Join Data has been uploaded to the server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendErrorMessage("Failed to upload your data, please find an admin.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ForceHalloween(CommandArgs args)
|
||||
{
|
||||
TShock.Config.ForceHalloween = !TShock.Config.ForceHalloween;
|
||||
|
|
|
|||
|
|
@ -1506,6 +1506,8 @@ namespace TShockAPI
|
|||
private static bool HandleConnecting(GetDataHandlerArgs args)
|
||||
{
|
||||
var user = TShock.Users.GetUserByName(args.Player.Name);
|
||||
args.Player.DataWhenJoined = new PlayerData(args.Player);
|
||||
args.Player.DataWhenJoined.CopyCharacter(args.Player);
|
||||
|
||||
if (user != null && !TShock.Config.DisableUUIDLogin)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ namespace TShockAPI
|
|||
[Description("User can save all the players SSI state.")]
|
||||
public static readonly string savessc = "tshock.admin.savessi";
|
||||
|
||||
[Description("User can upload their joined character data as SSC data.")]
|
||||
public static readonly string uploaddata = "tshock.ssc.upload";
|
||||
|
||||
[Description("User can elevate other users' groups temporarily.")]
|
||||
public static readonly string settempgroup = "tshock.admin.tempgroup";
|
||||
|
||||
|
|
|
|||
|
|
@ -591,6 +591,11 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This contains the character data a player has when they join the server.
|
||||
/// </summary>
|
||||
public PlayerData DataWhenJoined { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the player's storage contains the given key.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue