本文整理汇总了C#中fCraft.Player.MessagePrefixed方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessagePrefixed方法的具体用法?C# Player.MessagePrefixed怎么用?C# Player.MessagePrefixed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.MessagePrefixed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BanInfoHandler
//.........这里部分代码省略.........
} else {
player.Message( "Player {0}&S is &CBANNED&S (but their IP is not).", info.ClassyName );
}
break;
case BanStatus.IPBanExempt:
if( ipBan != null ) {
player.Message( "Player {0}&S is exempt from an existing IP ban.", info.ClassyName );
} else {
player.Message( "Player {0}&S is exempt from IP bans.", info.ClassyName );
}
break;
case BanStatus.NotBanned:
if( ipBan != null ) {
player.Message( "Player {0}&s is not banned, but their IP is.", info.ClassyName );
} else {
player.Message( "Player {0}&s is not banned.", info.ClassyName );
}
break;
}
if( info.BanDate != DateTime.MinValue ) {
player.Message( " Last ban by {0}&S on {1:dd MMM yyyy} ({2} ago).",
info.BannedByClassy,
info.BanDate,
info.TimeSinceBan.ToMiniString() );
if( info.BanReason != null ) {
player.Message( " Last ban reason: {0}", info.BanReason );
}
} else {
player.Message( "No past bans on record." );
}
if( info.UnbanDate != DateTime.MinValue && !info.IsBanned ) {
player.Message( " Unbanned by {0}&S on {1:dd MMM yyyy} ({2} ago).",
info.UnbannedByClassy,
info.UnbanDate,
info.TimeSinceUnban.ToMiniString() );
if( info.UnbanReason != null ) {
player.Message( " Last unban reason: {0}", info.UnbanReason );
}
}
if( info.BanDate != DateTime.MinValue ) {
TimeSpan banDuration;
if( info.IsBanned ) {
banDuration = info.TimeSinceBan;
player.Message( " Ban duration: {0} so far",
banDuration.ToMiniString() );
} else {
banDuration = info.UnbanDate.Subtract( info.BanDate );
player.Message( " Previous ban's duration: {0}",
banDuration.ToMiniString() );
}
}
}
// Show alts
if( !address.Equals( IPAddress.None ) ) {
List<PlayerInfo> altNames = new List<PlayerInfo>();
int bannedAltCount = 0;
foreach( PlayerInfo playerFromSameIP in PlayerDB.FindPlayers( address ) ) {
if( playerFromSameIP == info ) continue;
altNames.Add( playerFromSameIP );
if( playerFromSameIP.IsBanned ) {
bannedAltCount++;
}
}
if( altNames.Count > 0 ) {
altNames.Sort( new PlayerInfoComparer( player ) );
if( altNames.Count > MaxAltsToPrint ) {
if( bannedAltCount > 0 ) {
player.MessagePrefixed( "&S ",
"&S Over {0} accounts ({1} banned) on IP: {2} &Setc",
MaxAltsToPrint,
bannedAltCount,
altNames.Take( 15 ).ToArray().JoinToClassyString() );
} else {
player.MessagePrefixed( "&S ",
"&S Over {0} accounts on IP: {1} &Setc",
MaxAltsToPrint,
altNames.Take( 15 ).ToArray().JoinToClassyString() );
}
} else {
if( bannedAltCount > 0 ) {
player.MessagePrefixed( "&S ",
"&S {0} accounts ({1} banned) on IP: {2}",
altNames.Count,
bannedAltCount,
altNames.ToArray().JoinToClassyString() );
} else {
player.MessagePrefixed( "&S ",
"&S {0} accounts on IP: {1}",
altNames.Count,
altNames.ToArray().JoinToClassyString() );
}
}
}
}
}
示例2: PlayersHandler
static void PlayersHandler( Player player, CommandReader cmd ) {
string param = cmd.Next();
Player[] players;
string worldName = null;
string qualifier;
int offset = 0;
if( param == null || Int32.TryParse( param, out offset ) ) {
// No world name given; Start with a list of all players.
players = Server.Players;
qualifier = "online";
if( cmd.HasNext ) {
CdPlayers.PrintUsage( player );
return;
}
} else {
// Try to find the world
World world = WorldManager.FindWorldOrPrintMatches( player, param );
if( world == null ) return;
worldName = param;
// If found, grab its player list
players = world.Players;
qualifier = String.Format( "in world {0}&S", world.ClassyName );
if( cmd.HasNext && !cmd.NextInt( out offset ) ) {
CdPlayers.PrintUsage( player );
return;
}
}
if( players.Length > 0 ) {
// Filter out hidden players, and sort
Player[] visiblePlayers = players.Where( player.CanSee )
.OrderBy( p => p, PlayerListSorter.Instance )
.ToArray();
if( visiblePlayers.Length == 0 ) {
player.Message( "There are no players {0}", qualifier );
} else if( visiblePlayers.Length <= PlayersPerPage || player.IsSuper ) {
player.MessagePrefixed( "&S ", "&SThere are {0} players {1}: {2}",
visiblePlayers.Length, qualifier, visiblePlayers.JoinToClassyString() );
} else {
if( offset >= visiblePlayers.Length ) {
offset = Math.Max( 0, visiblePlayers.Length - PlayersPerPage );
}
Player[] playersPart = visiblePlayers.Skip( offset ).Take( PlayersPerPage ).ToArray();
player.MessagePrefixed( "&S ", "&SPlayers {0}: {1}",
qualifier, playersPart.JoinToClassyString() );
if( offset + playersPart.Length < visiblePlayers.Length ) {
player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Players {3}{1}",
offset + 1, offset + playersPart.Length,
visiblePlayers.Length,
(worldName == null ? "" : worldName + " ") );
} else {
player.Message( "Showing players {0}-{1} (out of {2}).",
offset + 1, offset + playersPart.Length,
visiblePlayers.Length );
}
}
} else {
player.Message( "There are no players {0}", qualifier );
}
}
示例3: HelpHandler
static void HelpHandler( Player player, CommandReader cmd ) {
string commandName = cmd.Next();
if( commandName != null ) {
CommandDescriptor descriptor = CommandManager.GetDescriptor( commandName, true );
if( descriptor == null ) {
player.Message( "Unknown command: \"{0}\"", commandName );
return;
}
string sectionName = cmd.Next();
if( sectionName != null ) {
string sectionHelp;
if( descriptor.HelpSections != null &&
descriptor.HelpSections.TryGetValue( sectionName.ToLower(), out sectionHelp ) ) {
player.MessagePrefixed( HelpPrefix, sectionHelp );
} else {
player.Message( "No help found for \"{0}\"", sectionName );
}
} else {
StringBuilder sb = new StringBuilder( Color.Help );
sb.Append( descriptor.Usage )
.Append( "\n&S" );
if( descriptor.Aliases != null ) {
sb.AppendFormat( "Aliases: &H{0}\n&S", descriptor.Aliases.JoinToString() );
}
if( String.IsNullOrEmpty( descriptor.Help ) ) {
sb.Append( "No help is available for this command." );
} else {
sb.Append( descriptor.Help );
}
if( descriptor.Permissions != null && descriptor.Permissions.Length > 0 ) {
Rank minRank = descriptor.MinRank;
if( minRank == null ) {
sb.Append( "\nNot available to any rank" );
} else {
sb.AppendFormat( "\nAvailable to {0}&S+", minRank.ClassyName );
}
sb.AppendFormat( " (permissions: {0})", descriptor.Permissions.JoinToString() );
} else {
sb.Append( "\nAvailable to players of all ranks." );
}
player.MessagePrefixed( HelpPrefix, sb.ToString() );
}
} else {
player.Message( " To see a list of all commands, write &H/Commands" );
player.Message( " To see detailed help for a command, write &H/Help Command" );
if( player != Player.Console ) {
player.Message( " To see your stats, write &H/Info" );
}
player.Message( " To list available worlds, write &H/Worlds" );
player.Message( " To join a world, write &H/Join WorldName" );
player.Message( " To send private messages, write &[email protected] Message" );
}
}
示例4: CommandsHandler
static void CommandsHandler( Player player, CommandReader cmd ) {
string param = cmd.Next();
if( cmd.HasNext ) {
CdCommands.PrintUsage( player );
return;
}
CommandDescriptor[] cd;
CommandCategory category;
string prefix;
if( param == null ) {
prefix = "Available commands";
cd = CommandManager.GetCommands( player.Info.Rank, false );
} else if( param.StartsWith( "@" ) ) {
string rankName = param.Substring( 1 );
Rank rank = RankManager.FindRank( rankName );
if( rank == null ) {
player.MessageNoRank( rankName );
return;
} else {
prefix = String.Format( "Commands available to {0}&S", rank.ClassyName );
cd = CommandManager.GetCommands( rank, false );
}
} else if( param.Equals( "all", StringComparison.OrdinalIgnoreCase ) ) {
prefix = "All commands";
cd = CommandManager.GetCommands();
} else if( param.Equals( "hidden", StringComparison.OrdinalIgnoreCase ) ) {
prefix = "Hidden commands";
cd = CommandManager.GetCommands( true );
} else if( EnumUtil.TryParse( param, out category, true ) ) {
prefix = String.Format( "{0} commands", category );
cd = CommandManager.GetCommands( category, false );
} else {
CdCommands.PrintUsage( player );
return;
}
player.MessagePrefixed( "&S ", "{0}: {1}", prefix, cd.JoinToClassyString() );
}
示例5: WorldsHandler
static void WorldsHandler(Player player, Command cmd)
{
string param = cmd.Next();
World[] worlds;
string listName;
string extraParam;
int offset = 0;
if (param == null || Int32.TryParse(param, out offset))
{
listName = "available worlds";
extraParam = "";
worlds = WorldManager.Worlds.Where(w => !w.IsRealm).Where(player.CanSee).ToArray();
}
else
{
switch (Char.ToLower(param[0]))
{
case 'a':
listName = "worlds";
extraParam = "all ";
worlds = WorldManager.Worlds;
break;
case 'h':
listName = "hidden worlds";
extraParam = "hidden ";
worlds = WorldManager.Worlds.Where(w => !player.CanSee(w)).ToArray();
break;
case 'r':
listName = "Available Realms";
extraParam = "realms";
worlds = WorldManager.Worlds.Where(w => w.IsRealm).ToArray();
break;
case 'p':
listName = "populated worlds";
extraParam = "populated ";
worlds = WorldManager.Worlds.Where(w => w.Players.Any(player.CanSee)).ToArray();
break;
case '@':
if (param.Length == 1)
{
CdWorlds.PrintUsage(player);
return;
}
string rankName = param.Substring(1);
Rank rank = RankManager.FindRank(rankName);
if (rank == null)
{
player.MessageNoRank(rankName);
return;
}
listName = String.Format("worlds where {0}&S+ can build", rank.ClassyName);
extraParam = "@" + rank.Name + " ";
worlds = WorldManager.Worlds.Where(w => (w.BuildSecurity.MinRank <= rank) && player.CanSee(w))
.ToArray();
break;
default:
CdWorlds.PrintUsage(player);
return;
}
if (cmd.HasNext && !cmd.NextInt(out offset))
{
CdWorlds.PrintUsage(player);
return;
}
}
if (worlds.Length == 0)
{
player.Message("There are no {0}.", listName);
}
else if (worlds.Length <= WorldNamesPerPage || player.IsSuper)
{
player.MessagePrefixed("&S ", "&SThere are {0} {1}: {2}",
worlds.Length, listName, worlds.JoinToClassyString());
}
else
{
if (offset >= worlds.Length)
{
offset = Math.Max(0, worlds.Length - WorldNamesPerPage);
}
World[] worldsPart = worlds.Skip(offset).Take(WorldNamesPerPage).ToArray();
player.MessagePrefixed("&S ", "&S{0}: {1}",
listName.UppercaseFirst(), worldsPart.JoinToClassyString());
if (offset + worldsPart.Length < worlds.Length)
{
player.Message("Showing {0}-{1} (out of {2}). Next: &H/Worlds {3}{1}",
offset + 1, offset + worldsPart.Length, worlds.Length, extraParam);
}
else
{
player.Message("Showing worlds {0}-{1} (out of {2}).",
offset + 1, offset + worldsPart.Length, worlds.Length);
}
//.........这里部分代码省略.........
示例6: HelpHandler
internal static void HelpHandler( Player player, Command cmd ) {
string commandName = cmd.Next();
if( commandName == "commands" ) {
CdCommands.Call( player, cmd, false );
} else if( commandName != null ) {
CommandDescriptor descriptor = CommandManager.GetDescriptor( commandName, true );
if( descriptor == null ) {
player.Message( "Unknown command: \"{0}\"", commandName );
return;
}
string sectionName = cmd.Next();
if( sectionName != null ) {
string sectionHelp;
if( descriptor.HelpSections != null && descriptor.HelpSections.TryGetValue( sectionName.ToLower(), out sectionHelp ) ) {
player.MessagePrefixed( HelpPrefix, sectionHelp );
} else {
player.Message( "No help found for \"{0}\"", sectionName );
}
} else {
StringBuilder sb = new StringBuilder( Color.Help );
sb.Append( descriptor.Usage ).Append( '\n' );
if( descriptor.Aliases != null ) {
sb.Append( "Aliases: &H" );
sb.Append( descriptor.Aliases.JoinToString() );
sb.Append( "\n&S" );
}
if( String.IsNullOrEmpty( descriptor.Help ) ) {
sb.Append( "No help is available for this command." );
} else {
sb.Append( descriptor.Help );
}
player.MessagePrefixed( HelpPrefix, sb.ToString() );
if( descriptor.Permissions != null && descriptor.Permissions.Length > 0 ) {
player.MessageNoAccess( descriptor );
}
}
} else {
player.Message( " To see a list of all commands, write &H/Commands" );
player.Message( " To see detailed help for a command, write &H/Help Command" );
if( player != Player.Console ) {
player.Message( " To see your stats, write &H/Info" );
}
player.Message( " To list available worlds, write &H/Worlds" );
player.Message( " To join a world, write &H/Join WorldName" );
player.Message( " To send private messages, write &[email protected] Message" );
}
}
示例7: Worlds
internal static void Worlds( Player player, Command cmd ) {
string param = cmd.Next();
bool listVisible = true,
listHidden = false,
listAllLoaded = false;
if( !String.IsNullOrEmpty( param ) ) {
switch( Char.ToLower( param[0] ) ) {
case 'a':
listHidden = true;
break;
case 'h':
listVisible = false;
listHidden = true;
break;
case 'l':
listAllLoaded = true;
listVisible = false;
listHidden = false;
break;
default:
cdWorlds.PrintUsage( player );
return;
}
}
StringBuilder sb = new StringBuilder();
bool first = true;
int count = 0;
World[] worldListCache = WorldManager.WorldList;
foreach( World world in worldListCache ) {
bool visible = player.CanJoin( world ) && !world.IsHidden;
if( (world.IsLoaded && listAllLoaded) || (visible && listVisible) || (!visible && listHidden) ) {
if( !first ) {
sb.Append( ", " );
}
sb.Append( world.GetClassyName() );
count++;
first = false;
}
}
if( listAllLoaded ) {
player.MessagePrefixed( "&S ", "There are " + count + " loaded worlds: " + sb );
} else if( listVisible && !listHidden ) {
player.MessagePrefixed( "&S ", "There are " + count + " available worlds: " + sb );
} else if( !listVisible ) {
player.MessagePrefixed( "&S ", "There are " + count + " hidden worlds: " + sb );
} else {
player.MessagePrefixed( "&S ", "There are " + count + " worlds total: " + sb );
}
}
示例8: CommandsHandler
internal static void CommandsHandler( Player player, Command cmd )
{
string param = cmd.Next();
CommandDescriptor[] cd;
CommandCategory category;
if (param == null)
{
player.Message("&SFor &aBuilding &Scommands, type &a/Commands building" +
"\n&SFor &fChat &Scommands, type &a/Commands chat" +
"\n&SFor &fInfo &Scommands, type &a/Commands info" +
"\n&SFor &3Moderation &scommands, type &a/Commands moderation" +
"\n&SFor &9World &Scommands, type &a/Commands world" +
"\n&SFor &bZone &Scommands, type &a/Commands zone" +
(CommandManager.GetCommands(CommandCategory.Math, false).Length > 0
? "\n&SFor &cFunction drawing &Scommands, type &a/Commands math"
: "") +
(CommandManager.GetCommands(CommandCategory.Fun, false).Length > 0
? "\n&SFor &dFun &Scommands, type &a/Commands fun"
: ""));
return;
}
string prefix;
if( param == null ) {
prefix = "Available commands";
cd = CommandManager.GetCommands( player.Info.Rank, false );
} else if( param.StartsWith( "@" ) ) {
string rankName = param.Substring( 1 );
Rank rank = RankManager.FindRank( rankName );
if( rank == null ) {
player.Message( "Unknown rank: {0}", rankName );
return;
} else {
prefix = String.Format( "Commands available to {0}&S", rank.ClassyName );
cd = CommandManager.GetCommands( rank, false );
}
} else if( param.Equals( "all", StringComparison.OrdinalIgnoreCase ) ) {
prefix = "All commands";
cd = CommandManager.GetCommands();
} else if( param.Equals( "hidden", StringComparison.OrdinalIgnoreCase ) ) {
prefix = "Hidden commands";
cd = CommandManager.GetCommands( true );
} else if( EnumUtil.TryParse( param, out category, true ) ) {
prefix = String.Format( "{0} commands", category );
cd = CommandManager.GetCommands( category, false );
} else {
CdCommands.PrintUsage( player );
return;
}
player.MessagePrefixed( "&S ", "{0}: {1}", prefix, cd.JoinToClassyString() );
}
示例9: InfoHandler
//.........这里部分代码省略.........
player.Message( " IP is &CBANNED&S, but account is exempt." );
} else {
player.Message( " IP is not banned, and account is exempt." );
}
break;
case BanStatus.NotBanned:
if( ipBan != null ) {
if( String.IsNullOrEmpty( ipBan.BanReason ) ) {
player.Message( " IP is &CBANNED" );
} else {
player.Message( " IP is &CBANNED&S ({0}&S)", ipBan.BanReason );
}
}
break;
}
if( !info.LastIP.Equals( IPAddress.None ) ) {
// Show alts
List<PlayerInfo> altNames = new List<PlayerInfo>();
int bannedAltCount = 0;
foreach( PlayerInfo playerFromSameIP in PlayerDB.FindPlayers( info.LastIP ) ) {
if( playerFromSameIP == info ) continue;
altNames.Add( playerFromSameIP );
if( playerFromSameIP.IsBanned ) {
bannedAltCount++;
}
}
if( altNames.Count > 0 ) {
altNames.Sort( new PlayerInfoComparer( player ) );
if( altNames.Count > MaxAltsToPrint ) {
if( bannedAltCount > 0 ) {
player.MessagePrefixed( "&S ",
"&S Over {0} accounts ({1} banned) on IP: {2} &Setc",
MaxAltsToPrint,
bannedAltCount,
altNames.Take( 15 ).ToArray().JoinToClassyString() );
} else {
player.MessagePrefixed( "&S ",
"&S Over {0} accounts on IP: {1} &Setc",
MaxAltsToPrint,
altNames.Take( 15 ).ToArray().JoinToClassyString() );
}
} else {
if( bannedAltCount > 0 ) {
player.MessagePrefixed( "&S ",
"&S {0} accounts ({1} banned) on IP: {2}",
altNames.Count,
bannedAltCount,
altNames.ToArray().JoinToClassyString() );
} else {
player.MessagePrefixed( "&S ",
"&S {0} accounts on IP: {1}",
altNames.Count,
altNames.ToArray().JoinToClassyString() );
}
}
}
}
// Stats
if (info.BlocksDrawn > 0)
{
示例10: LPRHandler
static void LPRHandler(Player player, CommandReader cmd)
{
string name = cmd.Next();
PlayerInfo[] infos;
Rank rank = RankManager.FindRank(player.Info.Rank.Name);
if (name != null)
{
rank = RankManager.FindRank(name);
if (rank == null)
{
player.MessageNoRank(name);
return;
}
}
infos = PlayerDB.PlayerInfoList.Where(info => info.PreviousRank == rank).OrderBy(c => c.TimeSinceRankChange).ToArray();
int offset;
if (!cmd.NextInt(out offset)) offset = 0;
if (offset >= infos.Count())
{
offset = Math.Max(0, infos.Count() - PlayersPerPage);
}
var playersPart = infos.Skip(offset).Take(10).ToArray();
player.MessagePrefixed("&S ", "&SPlayers who previously had rank ({1}&s): {0}", playersPart.JoinToString((r => String.Format("&n{0}&S (Had current rank ({2}&s) for: {1})", r.ClassyName, r.TimeSinceRankChange.ToMiniString(), r.Rank.ClassyName))), rank.ClassyName);
player.Message("Showing players {0}-{1} (out of {2}).", offset + 1, offset + playersPart.Length, infos.Count());
}
示例11: CommandsHandler
private static void CommandsHandler(Player player, CommandReader cmd) {
string param = cmd.Next();
CommandDescriptor[] cd;
CommandCategory category;
string prefix;
if (param == null) {
player.Message("&sCommand Categories:");
player.Message("&h /cmds Building");
player.Message("&h /cmds Chat");
player.Message("&h /cmds Info");
player.Message("&h /cmds Maintenance");
player.Message("&h /cmds Moderation");
player.Message("&h /cmds World");
player.Message("&h /cmds New");
player.Message("&h /cmds All");
return;
}
Array items = CommandManager.GetCommands(player.Info.Rank, false);
string output = "";
if (param.StartsWith("*") && param.EndsWith("*")) {
foreach (CommandDescriptor item in items) {
if (item.Name.ToLower().Contains(param.ToLower().Trim('*'))) {
output += item.MinRank.Color + item.Name + "&s, ";
}
}
player.Message("&sCommands containing \"{0}\":", param.Trim('*'));
if (output.EndsWith(", ")) {
player.Message(output.Remove(output.Length - 2) + ".");
} else {
player.Message("There are no commands containing \"{0}\"", param.Trim('*'));
}
return;
} else if (param.EndsWith("*")) {
foreach (CommandDescriptor item in items) {
if (item.Name.ToLower().StartsWith(param.ToLower().Trim('*'))) {
output += item.MinRank.Color + item.Name + "&s, ";
}
}
player.Message("&sCommands starting with \"{0}\":", param.Trim('*'));
if (output.EndsWith(", ")) {
player.Message(output.Remove(output.Length - 2) + ".");
} else {
player.Message("There are no commands starting with \"{0}\"", param.Trim('*'));
}
return;
} else if (param.StartsWith("*")) {
foreach (CommandDescriptor item in items) {
if (item.Name.ToLower().EndsWith(param.ToLower().Trim('*'))) {
output += item.MinRank.Color + item.Name + "&s, ";
}
}
player.Message("&sCommands ending with \"{0}\":", param.Trim('*'));
if (output.EndsWith(", ")) {
player.Message(output.Remove(output.Length - 2) + ".");
} else {
player.Message("There are no commands ending with \"{0}\"", param.Trim('*'));
}
return;
} else if (param.StartsWith("@")) {
string rankName = param.Substring(1);
Rank rank = RankManager.FindRank(rankName);
if (rank == null) {
player.MessageNoRank(rankName);
return;
}
prefix = String.Format("Commands available to {0}&S", rank.ClassyName);
cd = CommandManager.GetCommands(rank, false);
} else if (param.Equals("all", StringComparison.OrdinalIgnoreCase)) {
prefix = "All commands";
cd = CommandManager.GetCommands();
} else if (param.Equals("hidden", StringComparison.OrdinalIgnoreCase)) {
prefix = "Hidden commands";
cd = CommandManager.GetCommands(true);
} else if (EnumUtil.TryComplete(param, out category, true)) {
prefix = String.Format("{0} commands", category);
cd = CommandManager.GetCommands(category, false);
} else {
CdCommands.PrintUsage(player);
return;
}
player.MessagePrefixed("&S ", "{0}: {1}", prefix, cd.JoinToClassyString());
}
示例12: PrintHelpSection
/// <summary> Prints a command HelpSection syntax to the given player.
/// If that fails, it will print the usage instead </summary>
public void PrintHelpSection(Player player, string sectionName)
{
string sectionHelp;
if (HelpSections != null && HelpSections.TryGetValue(sectionName.ToLower(), out sectionHelp))
{
player.MessagePrefixed("&S ", sectionHelp);
}
else
{
PrintUsage(player); //if sectionName was incorrect
}
}
示例13: CommandsHandler
internal static void CommandsHandler(Player player, Command cmd)
{
string param = cmd.Next();
CommandDescriptor[] cd;
if (param == null)
{
player.Message("&SCommands Available:\n" +
"&SFor &aBuilding &Scommands, type &a/Commands building" +
"\n&SFor &fChat &Scommands, type &a/Commands chat" +
"\n&SFor &fInfo &Scommands, type &a/Commands info" +
"\n&SFor &3Moderation &scommands, type &a/Commands moderation" +
"\n&SFor &9World &Scommands, type &a/Commands world" +
"\n&SFor &bZone &Scommands, type &a/Commands zone");
}
else if (param.StartsWith("@"))
{
string rankName = param.Substring(1);
Rank rank = RankManager.FindRank(rankName);
if (rank == null)
{
player.Message("Unknown rank: {0}", rankName);
return;
}
else
{
player.Message("List of commands available to {0}&S:", rank.ClassyName);
cd = CommandManager.GetCommands(rank, true);
player.MessagePrefixed("&S ", "&S " + cd.JoinToClassyString());
}
}
else if (param.Equals("all", StringComparison.OrdinalIgnoreCase))
{
player.Message("List of ALL commands:");
cd = CommandManager.GetCommands();
player.MessagePrefixed("&S ", "&S " + cd.JoinToClassyString());
}
else if (param.Equals("hidden", StringComparison.OrdinalIgnoreCase))
{
player.Message("List of hidden commands:");
cd = CommandManager.GetCommands(true);
player.MessagePrefixed("&S ", "&S " + cd.JoinToClassyString());
}
else if (Enum.GetNames(typeof(CommandCategory)).Contains(param, StringComparer.OrdinalIgnoreCase))
{
CommandCategory category = (CommandCategory)Enum.Parse(typeof(CommandCategory), param, true);
player.Message("List of {0} commands:", category);
cd = CommandManager.GetCommands(category, false);
player.MessagePrefixed("&S ", "&S " + cd.JoinToClassyString());
}
else
{
CdCommands.PrintUsage(player);
return;
}
}
示例14: Commands
internal static void Commands( Player player, Command cmd ) {
string param = cmd.Next();
CommandDescriptor[] cd;
if( param == null ) {
player.Message( "List of available commands:" );
cd = CommandManager.GetCommands( false );
} else if( param.StartsWith( "@" ) ) {
string rankName = param.Substring( 1 );
Rank rank = RankManager.FindRank( rankName );
if( rank == null ) {
player.Message( "Unknown rank: {0}", rankName );
return;
} else {
player.Message( "List of commands available to {0}&S:", rank.GetClassyName() );
cd = CommandManager.GetCommands( rank, true );
}
} else if( param.Equals( "all", StringComparison.OrdinalIgnoreCase ) ) {
player.Message( "List of ALL commands:" );
cd = CommandManager.GetCommands();
} else if( param.Equals( "hidden", StringComparison.OrdinalIgnoreCase ) ) {
player.Message( "List of hidden commands:" );
cd = CommandManager.GetCommands( true );
} else if( Enum.GetNames( typeof( CommandCategory ) ).Contains( param, StringComparer.OrdinalIgnoreCase ) ) {
CommandCategory category = (CommandCategory)Enum.Parse( typeof( CommandCategory ), param, true );
player.Message( "List of {0} commands:", category );
cd = CommandManager.GetCommands( category, false );
} else if( Enum.GetNames( typeof( Permission ) ).Contains( param, StringComparer.OrdinalIgnoreCase ) ) {
Permission permission = (Permission)Enum.Parse( typeof( Permission ), param, true );
player.Message( "List of commands that need {0} permission:", permission );
cd = CommandManager.GetCommands( permission, true );
} else {
cdCommands.PrintUsage( player );
return;
}
string[] commandNames = cd.Select( desc => desc.Name ).ToArray();
player.MessagePrefixed( "&S ", "&S " + String.Join( ", ", commandNames ) );
}
示例15: Help
internal static void Help( Player player, Command cmd ) {
string commandName = cmd.Next();
if( commandName == "commands" ) {
cdCommands.Handler( player, cmd );
} else if( commandName != null ) {
CommandDescriptor descriptor = CommandManager.GetDescriptor( commandName );
if( descriptor == null ) {
player.Message( "Unknown command: \"{0}\"", commandName );
return;
}
StringBuilder sb = new StringBuilder( Color.Help );
sb.Append( descriptor.Usage ).Append( "&N" );
if( descriptor.Aliases != null ) {
sb.Append( "Aliases: &H" );
sb.Append( descriptor.Aliases.JoinToString( "&S, &H" ) );
sb.Append( "&N" );
}
if( descriptor.HelpHandler != null ) {
sb.Append( descriptor.HelpHandler( player ) );
} else if( descriptor.Help != null ) {
sb.Append( descriptor.Help );
} else {
sb.Append( "No help is available for this command." );
}
player.MessagePrefixed( HelpPrefix, sb.ToString() );
if( descriptor.Permissions != null && descriptor.Permissions.Length > 0 ) {
player.NoAccessMessage( descriptor.Permissions );
}
} else {
player.Message( "To see a list of all commands, write &H/help commands" );
player.Message( "To see detailed help for a command, write &H/help CommandName" );
if( player != Player.Console ) {
player.Message( "To see your stats, write &H/info" );
}
player.Message( "To list available worlds, write &H/worlds" );
player.Message( "To send private messages, write &[email protected] Message" );
player.Message( "To message all players of a rank, write &[email protected]@Rank Message" );
}
}