From c047b0e87d5309b503c9d0beb91797a81dafe38f Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 14 May 2023 09:14:43 +0700
Subject: [PATCH] Added the `Client` property.
The `Client` property gets data from the array `Terraria.Netplay.Clients`.
---
TShockAPI/TSPlayer.cs | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index f6ece337..10b2e760 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -988,7 +988,7 @@ namespace TShockAPI
get
{
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
///
public int State
{
- get { return Netplay.Clients[Index].State; }
- set { Netplay.Clients[Index].State = value; }
+ get { return Client.State; }
+ set { Client.State = value; }
}
///
@@ -1014,7 +1014,7 @@ namespace TShockAPI
///
public string UUID
{
- get { return RealPlayer ? Netplay.Clients[Index].ClientUUID : ""; }
+ get { return RealPlayer ? Client.ClientUUID : ""; }
}
///
@@ -1026,8 +1026,8 @@ namespace TShockAPI
{
if (string.IsNullOrEmpty(CacheIP))
return
- CacheIP = RealPlayer ? (Netplay.Clients[Index].Socket.IsConnected()
- ? TShock.Utils.GetRealIP(Netplay.Clients[Index].Socket.GetRemoteAddress().ToString())
+ CacheIP = RealPlayer ? (Client.Socket.IsConnected()
+ ? TShock.Utils.GetRealIP(Client.Socket.GetRemoteAddress().ToString())
: "")
: "127.0.0.1";
else
@@ -1110,6 +1110,11 @@ namespace TShockAPI
}
+ ///
+ /// Player RemoteClient.
+ ///
+ public RemoteClient Client => Netplay.Clients[Index];
+
///
/// Gets the Terraria Player object associated with the player.
///
@@ -2071,7 +2076,7 @@ namespace TShockAPI
if (!RealPlayer || !ConnectionAlive)
return;
- Netplay.Clients[Index].Socket.AsyncSend(data, 0, data.Length, Netplay.Clients[Index].ServerWriteCallBack);
+ Client.Socket.AsyncSend(data, 0, data.Length, Client.ServerWriteCallBack);
}
///