Added the Client property.

The `Client` property gets data from the array `Terraria.Netplay.Clients`.
This commit is contained in:
AkjaHAsLk1IALk0MasH 2023-05-14 09:14:43 +07:00
parent 6d4682ed7e
commit c047b0e87d

View file

@ -988,7 +988,7 @@ namespace TShockAPI
get get
{ {
return RealPlayer return RealPlayer
&& (Netplay.Clients[Index] != null && Netplay.Clients[Index].IsActive && !Netplay.Clients[Index].PendingTermination); && (Client != null && Client.IsActive && !Client.PendingTermination);
} }
} }
@ -1005,8 +1005,8 @@ namespace TShockAPI
/// </summary> /// </summary>
public int State public int State
{ {
get { return Netplay.Clients[Index].State; } get { return Client.State; }
set { Netplay.Clients[Index].State = value; } set { Client.State = value; }
} }
/// <summary> /// <summary>
@ -1014,7 +1014,7 @@ namespace TShockAPI
/// </summary> /// </summary>
public string UUID public string UUID
{ {
get { return RealPlayer ? Netplay.Clients[Index].ClientUUID : ""; } get { return RealPlayer ? Client.ClientUUID : ""; }
} }
/// <summary> /// <summary>
@ -1026,8 +1026,8 @@ namespace TShockAPI
{ {
if (string.IsNullOrEmpty(CacheIP)) if (string.IsNullOrEmpty(CacheIP))
return return
CacheIP = RealPlayer ? (Netplay.Clients[Index].Socket.IsConnected() CacheIP = RealPlayer ? (Client.Socket.IsConnected()
? TShock.Utils.GetRealIP(Netplay.Clients[Index].Socket.GetRemoteAddress().ToString()) ? TShock.Utils.GetRealIP(Client.Socket.GetRemoteAddress().ToString())
: "") : "")
: "127.0.0.1"; : "127.0.0.1";
else else
@ -1110,6 +1110,11 @@ namespace TShockAPI
} }
/// <summary>
/// Player RemoteClient.
/// </summary>
public RemoteClient Client => Netplay.Clients[Index];
/// <summary> /// <summary>
/// Gets the Terraria Player object associated with the player. /// Gets the Terraria Player object associated with the player.
/// </summary> /// </summary>
@ -2071,7 +2076,7 @@ namespace TShockAPI
if (!RealPlayer || !ConnectionAlive) if (!RealPlayer || !ConnectionAlive)
return; return;
Netplay.Clients[Index].Socket.AsyncSend(data, 0, data.Length, Netplay.Clients[Index].ServerWriteCallBack); Client.Socket.AsyncSend(data, 0, data.Length, Client.ServerWriteCallBack);
} }
/// <summary> /// <summary>