commit
9ca7bcabca
40
TrueCraft/Commands/ListCommand.cs
Normal file
40
TrueCraft/Commands/ListCommand.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using TrueCraft.API.Networking;
|
||||
using System.Text;
|
||||
|
||||
namespace TrueCraft.Commands
|
||||
{
|
||||
public class ListCommand : Command
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get { return "list"; }
|
||||
}
|
||||
|
||||
public override string Description
|
||||
{
|
||||
get { return "Lists online players"; }
|
||||
}
|
||||
|
||||
public override void Handle(IRemoteClient client, string alias, string[] arguments)
|
||||
{
|
||||
StringBuilder listMessage = new StringBuilder("Currently connected players: ");
|
||||
foreach (IRemoteClient c in client.Server.Clients)
|
||||
{
|
||||
if (listMessage.Length + c.Username.Length + 2 >= 120)
|
||||
{
|
||||
client.SendMessage(listMessage.ToString());
|
||||
listMessage.Clear();
|
||||
}
|
||||
listMessage.AppendFormat("{0}, ", c.Username);
|
||||
}
|
||||
listMessage.Remove(listMessage.Length - 2, 2);
|
||||
client.SendMessage(listMessage.ToString());
|
||||
}
|
||||
|
||||
public override void Help(IRemoteClient client, string alias, string[] arguments)
|
||||
{
|
||||
client.SendMessage("Correct usage is /" + alias);
|
||||
}
|
||||
}
|
||||
}
|
@ -67,6 +67,7 @@
|
||||
<Compile Include="ServerConfiguration.cs" />
|
||||
<Compile Include="MobManager.cs" />
|
||||
<Compile Include="Rules\OverworldSpawnRules.cs" />
|
||||
<Compile Include="Commands\ListCommand.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user