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";
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace TShockAPI
|
|||
/// The amount of tiles that the player has killed in the last second.
|
||||
/// </summary>
|
||||
public int TileKillThreshold { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The amount of tiles the player has placed in the last second.
|
||||
/// </summary>
|
||||
|
|
@ -113,10 +113,10 @@ namespace TShockAPI
|
|||
/// A system to delay Remembered Position Teleports a few seconds
|
||||
/// </summary>
|
||||
public int RPPending = 0;
|
||||
|
||||
|
||||
public int sX = -1;
|
||||
public int sY = -1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A queue of tiles destroyed by the player for reverting.
|
||||
/// </summary>
|
||||
|
|
@ -145,7 +145,7 @@ namespace TShockAPI
|
|||
/// The player's temporary group. This overrides the user's actual group.
|
||||
/// </summary>
|
||||
public Group tempGroup = null;
|
||||
|
||||
|
||||
public Timer tempGroupTimer;
|
||||
|
||||
private Group group = null;
|
||||
|
|
@ -158,7 +158,7 @@ namespace TShockAPI
|
|||
public int Index { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last time the player changed their team or pvp status.
|
||||
/// The last time the player changed their team or pvp status.
|
||||
/// </summary>
|
||||
public DateTime LastPvPTeamChange;
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ namespace TShockAPI
|
|||
/// <summary>
|
||||
/// A list of command callbacks indexed by the command they need to do.
|
||||
/// </summary>
|
||||
public Dictionary<string, Action<object>> AwaitingResponse;
|
||||
public Dictionary<string, Action<object>> AwaitingResponse;
|
||||
|
||||
public bool AwaitingName { get; set; }
|
||||
|
||||
|
|
@ -332,14 +332,14 @@ namespace TShockAPI
|
|||
/// Spawn protection message cool down.
|
||||
/// </summary>
|
||||
public long SPm = 1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Permission to build message cool down.
|
||||
/// </summary>
|
||||
public long BPm = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The time in ms when the player has logged in.
|
||||
/// The time in ms when the player has logged in.
|
||||
/// </summary>
|
||||
public long LoginMS;
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ namespace TShockAPI
|
|||
/// Contains data stored by plugins
|
||||
/// </summary>
|
||||
protected ConcurrentDictionary<string, object> data = new ConcurrentDictionary<string, object>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Whether the player is a real, human, player on the server.
|
||||
/// </summary>
|
||||
|
|
@ -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>
|
||||
|
|
@ -755,7 +760,7 @@ namespace TShockAPI
|
|||
/// Spawns the player at his spawn point.
|
||||
/// </summary>
|
||||
public void Spawn()
|
||||
{
|
||||
{
|
||||
if (this.sX > 0 && this.sY > 0)
|
||||
{
|
||||
Spawn(this.sX, this.sY);
|
||||
|
|
@ -867,7 +872,7 @@ namespace TShockAPI
|
|||
/// <returns>True or false, depending if the item passed the check or not.</returns>
|
||||
public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0)
|
||||
{
|
||||
if ((TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) &&
|
||||
if ((TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) &&
|
||||
(TShock.Itembans.ItemIsBanned(name, this) || !TShock.Config.AllowAllowedGroupsToSpawnBannedItems))
|
||||
return false;
|
||||
|
||||
|
|
@ -983,7 +988,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message with the specified color.
|
||||
/// Sends a message with the specified color.
|
||||
/// </summary>
|
||||
/// <param name="msg">The message.</param>
|
||||
/// <param name="color">The message color.</param>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue