From 50ecce618e45793bda647f435ebe295a11202555 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Fri, 1 Jun 2012 11:54:05 -0400 Subject: [PATCH] Added some docs on the player class. Also changed Command Callback to use object's instead of CommandArgs to promote generics. The new /test command will simply send the player a success message so that it can be tested on the console without opening the game( I dont have the game at work and didnt want to worldgen so I have no clue if it works as intended[ will be able to fix etc later tonight as I dont expect many people to be working on this before then] ) --- TShockAPI/Commands.cs | 4 +- TShockAPI/TSPlayer.cs | 188 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 181 insertions(+), 11 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f51fcfbd..18b1c4d1 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -322,9 +322,9 @@ namespace TShockAPI private static void TestCallbackCommand(CommandArgs args) { - Action a = (s) => args.Player.Spawn(); + Action a = (s) => { ((CommandArgs)s).Player.SendSuccessMessage("This is your callack"); }; args.Player.AddResponse( "yes", a); - args.Player.SendInfoMessage( "Type yes to spawn." ); + args.Player.SendInfoMessage( "Type /yes to get called back." ); } #region Account commands diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 4e8a3c3e..fec2675b 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -27,62 +27,232 @@ namespace TShockAPI { public class TSPlayer { + /// + /// This represents the server as a player. + /// public static readonly TSServerPlayer Server = new TSServerPlayer(); + + /// + /// This player represents all the players. + /// public static readonly TSPlayer All = new TSPlayer("All"); + + /// + /// The amount of tiles that the player has killed in the last second. + /// public int TileKillThreshold { get; set; } - public int TilePlaceThreshold { get; set; } + + /// + /// The amount of tiles the player has placed in the last second. + /// + public int TilePlaceThreshold { get; set; } + + /// + /// The amount of liquid( in tiles ) that the player has placed in the last second. + /// public int TileLiquidThreshold { get; set; } + + /// + /// The number of projectiles created by the player in the last second. + /// public int ProjectileThreshold { get; set; } + + /// + /// A queue of tiles destroyed by the player for reverting. + /// public Dictionary TilesDestroyed { get; protected set; } + + /// + /// A queue of tiles placed by the player for reverting. + /// public Dictionary TilesCreated { get; protected set; } + public int FirstMaxHP { get; set; } + public int FirstMaxMP { get; set; } + + /// + /// The player's group. + /// public Group Group { get; set; } + public bool ReceivedInfo { get; set; } + + /// + /// The players index in the player array( Main.players[] ). + /// public int Index { get; protected set; } + + /// + /// The last time the player changed their team or pvp status. + /// public DateTime LastPvpChange; + + /// + /// Temp points for use in regions and other plugins. + /// public Point[] TempPoints = new Point[2]; + + /// + /// Whether the player is waiting to place/break a tile to set as a temp point. + /// public int AwaitingTempPoint { get; set; } - public Dictionary> AwaitingResponse; + + /// + /// A list of command callbacks indexed by the command they need to do. + /// + public Dictionary> AwaitingResponse; + public bool AwaitingName { get; set; } + + /// + /// The last time a player broke a grief check. + /// public DateTime LastThreat { get; set; } + + /// + /// Not used, can be removed. + /// public DateTime LastTileChangeNotify { get; set; } + public bool InitSpawn; + + /// + /// Whether the player should see logs. + /// public bool DisplayLogs = true; + public Vector2 oldSpawn = Vector2.Zero; + + /// + /// The last player that the player whispered with( to or from ). + /// public TSPlayer LastWhisper; + + /// + /// The number of unsuccessful login attempts. + /// public int LoginAttempts { get; set; } + public Vector2 TeleportCoords = new Vector2(-1, -1); + public Vector2 LastNetPosition = Vector2.Zero; + + /// + /// The player's login name. + /// public string UserAccountName { get; set; } + + /// + /// Unused can be removed. + /// public bool HasBeenSpammedWithBuildMessage; + + /// + /// Whether the player is logged in or not. + /// public bool IsLoggedIn; + + /// + /// The player's user id( from the db ). + /// public int UserID = -1; + + /// + /// Whether the player has been nagged about logging in. + /// public bool HasBeenNaggedAboutLoggingIn; - public bool TPAllow = true; + + public bool TPAllow = true; + + /// + /// Whether the player is muted or not. + /// public bool mute; + public bool TpLock; + private Player FakePlayer; + public bool RequestedSection; + + /// + /// The last time the player died. + /// public DateTime LastDeath { get; set; } + + /// + /// Whether the player is dead or not. + /// public bool Dead; + public string Country = "??"; + + /// + /// The players difficulty( normal[softcore], mediumcore, hardcore ). + /// public int Difficulty; + private string CacheIP; + public string IgnoreActionsForInventory = "none"; + public string IgnoreActionsForCheating = "none"; + public string IgnoreActionsForDisabledArmor = "none"; + public bool IgnoreActionsForClearingTrashCan; + + /// + /// The player's server side inventory data. + /// public PlayerData PlayerData; + + /// + /// Whether the player needs to specify a password upon connection( either server or user account ). + /// public bool RequiresPassword; + public bool SilentKickInProgress; + + /// + /// A list of points where ice tiles have been placed. + /// public List IceTiles; - public long RPm = 1; - public long WPm = 1; - public long SPm = 1; - public long BPm = 1; + + /// + /// Unused, can be removed. + /// + public long RPm = 1; + + /// + /// World protection message cool down. + /// + public long WPm = 1; + + /// + /// Spawn protection message cool down. + /// + public long SPm = 1; + + /// + /// Permission to build message cool down. + /// + public long BPm = 1; + + /// + /// The time in ms when the player has logged in. + /// public long LoginMS; + + /// + /// Whether the player has been harrassed about logging in due to server side inventory or forced login. + /// public bool LoginHarassed = false; + + /// + /// Whether the player is a real, human, player on the server. + /// public bool RealPlayer { get { return Index >= 0 && Index < Main.maxNetPlayers && Main.player[Index] != null; } @@ -213,7 +383,7 @@ namespace TShockAPI Index = index; Group = new Group(TShock.Config.DefaultGuestGroupName); IceTiles = new List(); - AwaitingResponse = new Dictionary>(); + AwaitingResponse = new Dictionary>(); } protected TSPlayer(String playerName) @@ -525,7 +695,7 @@ namespace TShockAPI return TShock.SendBytes(Netplay.serverSock[Index], data); } - public void AddResponse( string name, Action callback) + public void AddResponse( string name, Action callback) { if( AwaitingResponse.ContainsKey(name)) {