forked from ss13remake/ss13remake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
spoogemonster
committed
Jul 25, 2013
1 parent
1ac3098
commit 39e8e3e
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using SS13.IoC; | ||
using ServerInterfaces.Player; | ||
|
||
namespace ServerServices.ServerConsole.Commands | ||
{ | ||
public class ListPlayers : ConsoleCommand | ||
{ | ||
public override string Command | ||
{ | ||
get { return "listplayers"; } | ||
} | ||
|
||
public override string Description | ||
{ | ||
get { return "Lists all players currently connected"; } | ||
} | ||
|
||
public override string Help | ||
{ | ||
get { return "Usage: listplayers"; } | ||
} | ||
|
||
public override void Execute(params string[] args) | ||
{ | ||
var players = IoCManager.Resolve<IPlayerManager>().GetAllPlayers(); | ||
Console.ForegroundColor = ConsoleColor.Yellow; | ||
Console.WriteLine("Current Players:\n"); | ||
Console.ForegroundColor = ConsoleColor.White; | ||
Console.WriteLine("{0, 20}{1,16}{2,12}{3, 14}{4,9}", "Player Name", "IP Address", "Status", "Playing Time", "Ping"); | ||
foreach(var p in players) | ||
{ | ||
Console.Write("{0, 20}", p.name); | ||
Console.WriteLine("{0,16}{1,12}{2,14}{3,9}", | ||
p.connectedClient.RemoteEndPoint.Address, | ||
p.status.ToString(), | ||
(DateTime.Now - p.ConnectedTime).ToString(@"hh\:mm\:ss"), | ||
Math.Round(p.connectedClient.AverageRoundtripTime * 1000, 2) + "ms"); | ||
} | ||
} | ||
} | ||
} |