From 6583ad4076d6048650029bcf178bf2acde4acd67 Mon Sep 17 00:00:00 2001 From: ced777ric <44529860+ced777ric@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:02:29 +0200 Subject: [PATCH] IsOffline (#207) --- NwPluginAPI/Core/Interfaces/IPlayer.cs | 19 +++++++++++++++++++ NwPluginAPI/Core/OfflinePlayer.cs | 6 ++++++ NwPluginAPI/Core/Player.cs | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/NwPluginAPI/Core/Interfaces/IPlayer.cs b/NwPluginAPI/Core/Interfaces/IPlayer.cs index 12243d6..ae7ee6a 100644 --- a/NwPluginAPI/Core/Interfaces/IPlayer.cs +++ b/NwPluginAPI/Core/Interfaces/IPlayer.cs @@ -5,5 +5,24 @@ namespace PluginAPI.Core.Interfaces /// public interface IPlayer : IEntity { + /// + /// Gets if the player is in the server. + /// + bool IsOffline { get; } + + /// + /// Gets the player's user id. + /// + string UserId { get; } + + /// + /// Gets the player's name. + /// + string Nickname { get; } + + /// + /// Gets the player's ip address. + /// + string IpAddress { get; } } } \ No newline at end of file diff --git a/NwPluginAPI/Core/OfflinePlayer.cs b/NwPluginAPI/Core/OfflinePlayer.cs index 5adae85..8960f13 100644 --- a/NwPluginAPI/Core/OfflinePlayer.cs +++ b/NwPluginAPI/Core/OfflinePlayer.cs @@ -4,6 +4,11 @@ namespace PluginAPI.Core { public class OfflinePlayer : IPlayer { + /// + /// Gets if the player is in the server. + /// + public bool IsOffline { get; } + /// /// Gets the player's user id. /// @@ -27,6 +32,7 @@ public class OfflinePlayer : IPlayer /// The ip address. public OfflinePlayer(string userId, string name = "(no nick)", string ipAddress = "127.0.0.1") { + IsOffline = true; UserId = userId; Nickname = name; IpAddress = ipAddress; diff --git a/NwPluginAPI/Core/Player.cs b/NwPluginAPI/Core/Player.cs index 9c0fae0..47475e0 100644 --- a/NwPluginAPI/Core/Player.cs +++ b/NwPluginAPI/Core/Player.cs @@ -557,6 +557,11 @@ public string DisplayNickname /// public string LogName => IsServer ? "SERVER CONSOLE" : $"{Nickname} ({UserId})"; + /// + /// Gets if the player is in the server. + /// + public bool IsOffline => GameObject == null; + /// /// Gets the player's user id. ///