Skip to content

Commit

Permalink
IsOffline (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ced777ric authored Jun 26, 2023
1 parent ec9b4ac commit 6583ad4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NwPluginAPI/Core/Interfaces/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,24 @@ namespace PluginAPI.Core.Interfaces
/// </summary>
public interface IPlayer : IEntity
{
/// <summary>
/// Gets if the player is in the server.
/// </summary>
bool IsOffline { get; }

/// <summary>
/// Gets the player's user id.
/// </summary>
string UserId { get; }

/// <summary>
/// Gets the player's name.
/// </summary>
string Nickname { get; }

/// <summary>
/// Gets the player's ip address.
/// </summary>
string IpAddress { get; }
}
}
6 changes: 6 additions & 0 deletions NwPluginAPI/Core/OfflinePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace PluginAPI.Core
{
public class OfflinePlayer : IPlayer
{
/// <summary>
/// Gets if the player is in the server.
/// </summary>
public bool IsOffline { get; }

/// <summary>
/// Gets the player's user id.
/// </summary>
Expand All @@ -27,6 +32,7 @@ public class OfflinePlayer : IPlayer
/// <param name="ipAddress">The ip address.</param>
public OfflinePlayer(string userId, string name = "(no nick)", string ipAddress = "127.0.0.1")
{
IsOffline = true;
UserId = userId;
Nickname = name;
IpAddress = ipAddress;
Expand Down
5 changes: 5 additions & 0 deletions NwPluginAPI/Core/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ public string DisplayNickname
/// </summary>
public string LogName => IsServer ? "SERVER CONSOLE" : $"{Nickname} ({UserId})";

/// <summary>
/// Gets if the player is in the server.
/// </summary>
public bool IsOffline => GameObject == null;

/// <summary>
/// Gets the player's user id.
/// </summary>
Expand Down

0 comments on commit 6583ad4

Please sign in to comment.