本文整理汇总了C#中IServer.GetClients方法的典型用法代码示例。如果您正苦于以下问题:C# IServer.GetClients方法的具体用法?C# IServer.GetClients怎么用?C# IServer.GetClients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServer
的用法示例。
在下文中一共展示了IServer.GetClients方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public void Use(IServer server, string commandName, string[] tokens)
{
if (tokens.Length < 1)
{
Help(server);
return;
}
var toKick = server.GetClients();
if (toKick.Any() && tokens[0].ToLower() != "all")
{
foreach (var client1 in toKick.Where(client1 => !client1.GetOwner().CanUseCommand("chraft.kick.exempt")))
{
client1.Kick(tokens.Length > 1 ? tokens[1] : "Kicked");
server.GetLogger().Log(LogLevel.Info, "Kicked " + client1.GetOwner().Name);
}
}
else
{
foreach (IClient t in toKick.Where(t => t.GetOwner().Name.ToLower() == tokens[0].ToLower()).Where(t => !t.GetOwner().CanUseCommand("chraft.kick.exempt")))
{
t.Kick(tokens.Length > 1 ? tokens[1] : "Kicked");
server.GetLogger().Log(LogLevel.Info, "Kicked " + t.GetOwner().Name);
}
}
}
示例2: Use
public void Use(IServer server, string commandName, string[] tokens)
{
if (tokens.Length < 2)
{
Help(server);
return;
}
try
{
server.GetBanSystem().AddToBanList(tokens[0], tokens[1], tokens.Length > 2 ? tokens : null);
}
catch (FormatException ex)
{
server.GetLogger().Log(LogLevel.Info, ex.Message);
return;
}
foreach (var nClient in server.GetClients(tokens[0]).ToList())
{
nClient.Kick(tokens[1]);
}
server.GetLogger().Log(LogLevel.Info, string.Format("{0} has been banned", tokens[0]));
}
示例3: Use
public void Use(IServer server, string commandName, string[] tokens)
{
if (tokens.Length < 1)
{
Help(server);
return;
}
switch (tokens[0].ToLower())
{
case "on":
ChraftConfig.SetWhitelist(true);
foreach (var cl in server.GetClients())
{
if (!cl.GetOwner().CanUseCommand("chraft.whitelist.exempt") &&
server.GetBanSystem().IsOnWhiteList(cl.GetOwner().Name))
{
cl.Kick(ChraftConfig.WhiteListMesasge);
}
}
server.GetLogger().Log(LogLevel.Info, "Whitelist enabled");
break;
case "off":
ChraftConfig.SetWhitelist(false);
server.GetLogger().Log(LogLevel.Info, "Whitelist disabled");
break;
case "add":
if (tokens.Length < 2)
{
Help(server);
return;
}
server.GetBanSystem().AddToWhiteList(tokens[1]);
server.GetLogger().Log(LogLevel.Info, tokens[1] + " added to Whitelist");
break;
case "remove":
if (tokens.Length < 2)
{
Help(server);
return;
}
server.GetBanSystem().RemoveFromWhiteList(tokens[1]);
server.GetLogger().Log(LogLevel.Info, tokens[1] + " removed from Whitelist");
break;
case "list":
foreach (var play in server.GetBanSystem().ListWhiteList())
{
server.GetLogger().Log(LogLevel.Info, play);
}
break;
case "message":
if (tokens.Length < 2)
{
Help(server);
return;
}
ChraftConfig.SetWhitelistMessage(tokens[1]);
server.GetLogger().Log(LogLevel.Info, "Whitelist message set");
break;
}
}