本文整理汇总了C#中Server.SendChatToGroup方法的典型用法代码示例。如果您正苦于以下问题:C# Server.SendChatToGroup方法的具体用法?C# Server.SendChatToGroup怎么用?C# Server.SendChatToGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server.SendChatToGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
{
if (parameters.Length != 1)
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help difficulty for more information.");
return;
}
Difficulty value;
int num;
if (int.TryParse(text, out num))
{
if (num < 0 || num > 3)
{
user.SendChat(ChatColors.Red + "Invalid difficulty specified.");
return;
}
value = (Difficulty)num;
}
else
{
if (!Enum.TryParse<Difficulty>(text, true, out value))
{
user.SendChat(ChatColors.Red + "Invalid difficulty specified.");
return;
}
}
//user.World.Difficulty = value; // TODO
server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " sets difficulty of " + user.World.Name + " to " + value.ToString());
}
示例2: Execute
public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
{
if (parameters.Length != 1)
{
user.SendChat(ChatColors.Red + "Invalid parameters. Use /help op for more information.");
return;
}
var groups = server.GetUserGroups(parameters[0]);
if (groups.Contains("server.op"))
{
user.SendChat(ChatColors.Red + "User is already an op.");
return;
}
groups.Add("server.op");
server.SetUserGroups(parameters[0], groups);
server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " adds " + parameters[0] + " to server.op group.");
}
示例3: Execute
public override void Execute(Server server, RemoteClient user, string text, params string[] parameters)
{
if (parameters.Length != 1)
{
user.SendChat(ChatColors.Red + "Invalid parameters. Use /help op for more information.");
return;
}
var groups = server.GetUserGroups(parameters[0]);
if (!groups.Contains("server.op"))
{
user.SendChat(ChatColors.Red + "User is not an op.");
return;
}
groups.Remove("server.op");
server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " removes " + parameters[0] + " from server.op group.");
server.SetUserGroups(parameters[0], groups);
}
示例4: Execute
public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
{
string player = user.Username;
GameMode gameMode;
if (parameters.Length == 0 || parameters.Length > 2)
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
return;
}
int value;
if (int.TryParse(parameters[0], out value))
{
if (value < 0 || value > 2)
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
return;
}
gameMode = (GameMode)value;
}
else
{
if (!Enum.TryParse<GameMode>(parameters[0], true, out gameMode))
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help gamemode for more information.");
return;
}
}
if (parameters.Length == 2)
player = parameters[1];
var client = server.MinecraftServer.GetClient(player);
if (client == null)
{
user.SendChat(ChatColors.Red + player + " is not online."); // TODO: Set it anyway
return;
}
client.Entity.GameMode = gameMode;
server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " sets " + player + " to " + gameMode + " mode.");
}
示例5: Execute
public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
{
string player = user.Username;
int x = (int)user.Entity.Position.X;
int y = (int)user.Entity.Position.Y;
int z = (int)user.Entity.Position.Z;
if (parameters.Length == 1)
player = parameters[0];
else if (parameters.Length == 3)
{
if (!int.TryParse(parameters[0], out x) &&
!int.TryParse(parameters[1], out y) &&
!int.TryParse(parameters[2], out z))
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help spawnpoint for more information.");
return;
}
}
else if (parameters.Length == 4)
{
player = parameters[0];
if (!int.TryParse(parameters[1], out x) &&
!int.TryParse(parameters[2], out y) &&
!int.TryParse(parameters[3], out z))
{
user.SendChat(ChatColors.Red + "Incorrect usage. Use /help spawnpoint for more information.");
return;
}
}
var client = server.MinecraftServer.GetClient(player);
if (player == null)
{
user.SendChat(ChatColors.Red + player + " is not online."); // TODO: Set it anyway
return;
}
client.Entity.SpawnPoint = new Vector3(x, y, z);
server.SendChatToGroup("server.op", user.Username + " set " + player + " spawn point to " + client.Entity.SpawnPoint);
}
示例6: Execute
public override void Execute(Server server, MinecraftClient user, string text, params string[] parameters)
{
bool add = false;
var current = server.MinecraftServer.GetLevel(user).Time;
long? time = null;
if (parameters.Length == 0)
{
user.SendChat("The current time is " + current + ", or " + LongToTimeString(current));
return;
}
if (parameters[0].ToLower() == "day")
time = 0;
else if (parameters[0].ToLower() == "night")
time = 12000;
else if (parameters[0].ToLower() == "noon")
time = 6000;
else if (parameters[0].ToLower() == "midnight")
time = 18000;
else
{
string timeString;
if (parameters[0].ToLower() == "set" && parameters.Length > 1)
timeString = parameters[1];
else if (parameters[0].ToLower() == "add" && parameters.Length > 1)
{
timeString = parameters[1];
add = true;
}
else
timeString = parameters[0];
if (timeString.Contains(":"))
{
try
{
time = TimeStringToLong(timeString);
}
catch { }
}
else
{
long _time;
if (long.TryParse(timeString, out _time))
time = _time;
}
if (add)
time += current;
}
if (time == null)
{
user.SendChat(ChatColors.Red + "Invalid time specified.");
return;
}
time = time.Value % 24000;
server.MinecraftServer.GetLevel(user).Time = time.Value; // TODO: Add event listener in Craft.Net
server.SendChatToGroup("server.op", ChatColors.Gray + user.Username + " set the time in " + user.World.Name +
" to " + time.Value + ", or " + LongToTimeString(time.Value));
}