本文整理汇总了C#中fCraft.Command类的典型用法代码示例。如果您正苦于以下问题:C# Command类的具体用法?C# Command怎么用?C# Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于fCraft命名空间,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrollHandler
static void TrollHandler(Player player, Command cmd)
{
string Name = cmd.Next();
if (Name == null)
{
player.Message("Player not found. Please specify valid name.");
return;
}
if (!Player.IsValidName(Name))
return;
Player target = Server.FindPlayerOrPrintMatches(player, Name, true, true);
if (target == null)
return;
string options = cmd.Next();
if (options == null)
{
CdTroll.PrintUsage(player);
return;
}
string Message = cmd.NextAll();
if (Message.Length < 1 && options.ToLower() != "leave")
{
player.Message("&WError: Please enter a message for {0}.", target.ClassyName);
return;
}
switch (options.ToLower())
{
case "pm":
if (player.Can(Permission.UseColorCodes) && Message.Contains("%"))
{
Message = Color.ReplacePercentCodes(Message);
}
Server.Players.Message("&Pfrom {0}: {1}",
target.Name, Message);
break;
case "ac":
Chat.SendAdmin(target, Message);
break;
case "st":
case "staff":
Chat.SendStaff(target, Message);
break;
case "i":
case "impersonate":
case "msg":
case "message":
case "m":
Server.Message("{0}&S&F: {1}",
target.ClassyName, Message);
break;
case "leave":
case "disconnect":
case "gtfo":
Server.Players.Message("&SPlayer {0}&S left the server.",
target.ClassyName);
break;
default: player.Message("Invalid option. Please choose st, ac, pm, message or leave");
break;
}
}
示例2: BRB
internal static void BRB(Player player, Command cmd)
{
StreamReader streamReader = new StreamReader("plugins/brbMessage.txt");
string message = streamReader.ReadToEnd();
streamReader.Close();
string msg = cmd.NextAll().Trim();
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}
if (msg.Length > 0)
{
Server.Message("{0}&S &EWill Brb &9({1})",
player.ClassyName, msg);
player.IsAway = true;
return;
}
else
{
Server.Players.Message("&S{0} &EWill Brb &9(" + message + ")", player.ClassyName);
player.IsAway = true;
}
}
示例3: CModeWater
internal static void CModeWater(Player player, Command cmd)
{
if (!player.Can(Permissions.ControlPhysics))
{
player.NoAccessMessage(Permissions.ControlPhysics);
return;
}
string blockpar = cmd.Next();
string wmt = "";
int BlockAddr = -1;
try { BlockAddr = Convert.ToInt32(blockpar); }
catch
{
player.Message("Incorrect parameter!"); return;
}
if (BlockAddr < 3 && BlockAddr >= 0)
{
player.world.map.modeWater = BlockAddr;
switch (BlockAddr)
{
case 0: wmt = "'none'"; break;
case 1: wmt = "'infinite'"; break;
case 2: wmt = "'finite'"; break;
}
player.Message("Water mode set to " + wmt + ".");
}
}
示例4: DoZone
void DoZone( Player player, Command cmd ) {
if( !player.Can( Permissions.SetSpawn ) ) {
world.NoAccessMessage( player );
return;
}
string name = cmd.Next();
if( name == null ) {
player.Message( "No zone name specified. See " + Color.Help + "/help zone" );
return;
}
if( !Player.IsValidName( name ) ) {
player.Message( "\"" + name + "\" is not a valid zone name" );
return;
}
Zone zone = new Zone();
zone.name = name;
string property = cmd.Next();
if( property == null ) {
player.Message( "No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone" );
return;
}
PlayerClass minRank = world.classes.ParseClass( property );
if( minRank != null ) {
zone.buildRank = minRank.rank;
player.tag = zone;
player.marksExpected = 2;
player.marks.Clear();
player.markCount = 0;
player.selectionCallback = MakeZone;
}
}
示例5: SetParametrization
public static void SetParametrization(Player p, Command cmd)
{
string strFunc = cmd.Next();
if (string.IsNullOrWhiteSpace(strFunc))
{
p.Message("Error: empty parametrization expression");
return;
}
if (strFunc.Length < 3)
{
p.Message("Error: expression is too short (should be like x=f(t,u,v))");
return;
}
strFunc = strFunc.ToLower();
try
{
string coordVar = SimpleParser.PreparseAssignment(ref strFunc);
CheckCoordVar(coordVar);
Expression expression = SimpleParser.Parse(strFunc, new string[] { "t", "u", "v" });
p.Message("Expression parsed as " + coordVar + "=" + expression.Print());
GetPlayerParametrizationCoordsStorage(p)[VarNameToIdx(coordVar[0])] = expression;
}
catch (Exception e)
{
p.Message("Error: "+e.Message);
}
}
示例6: PayHandler
static void PayHandler(Player player, Command cmd)
{
string targetName = cmd.Next();
string money = cmd.Next();
int amount;
if (money == null)
{
player.Message("&ePlease select the amount of bits you wish to send.");
return;
}
Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
if (target == null)
{
player.Message("&ePlease select a player to pay bits towards.");
return;
}
if (!int.TryParse(money, out amount))
{
player.Message("&ePlease select from a whole number.");
return;
}
PayHandler(player, new Command("/economy pay " + target + " " + money));
}
示例7: StaffChat
internal static void StaffChat( Player player, Command cmd ) {
if( player.Info.IsMuted ) {
player.MutedMessage();
return;
}
if( DateTime.UtcNow < player.Info.MutedUntil ) {
player.Message( "You are muted for another {0:0} seconds.",
player.Info.MutedUntil.Subtract( DateTime.UtcNow ).TotalSeconds );
return;
}
Player[] plist = Server.PlayerList;
if( plist.Length > 0 ) player.Info.LinesWritten++;
string message = cmd.NextAll();
if( message != null && message.Trim().Length > 0 ) {
message = message.Trim();
if( player.Can( Permission.UseColorCodes ) && message.Contains( "%" ) ) {
message = Color.ReplacePercentCodes( message );
}
for( int i = 0; i < plist.Length; i++ ) {
if( (plist[i].Can( Permission.ReadStaffChat ) || plist[i] == player) && !plist[i].IsIgnoring( player.Info ) ) {
plist[i].Message( "{0}(staff){1}{0}: {2}", Color.PM, player.GetClassyName(), message );
}
}
}
}
示例8: FuncDrawOperation
protected FuncDrawOperation(Player player, Command cmd)
: base(player)
{
string strFunc = cmd.Next();
if (string.IsNullOrWhiteSpace(strFunc))
{
player.Message("&WEmpty function expression");
return;
}
if (strFunc.Length < 3)
{
player.Message("&WExpression is too short (should be like z=f(x,y))");
return;
}
strFunc = strFunc.ToLower();
_vaxis = GetAxis(SimpleParser.PreparseAssignment(ref strFunc));
_expression = SimpleParser.Parse(strFunc, GetVarArray(_vaxis));
Player.Message("Expression parsed as "+_expression.Print());
string scalingStr=cmd.Next();
_scaler = new Scaler(scalingStr);
}
示例9: Paint
void Paint( Player player, Command cmd ) {
player.replaceMode = !player.replaceMode;
if( player.replaceMode ){
player.Message( "Replacement mode: ON" );
} else {
player.Message( "Replacement mode: OFF" );
}
}
示例10: Call
public bool Call( Player player, Command cmd, bool raiseEvent ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
if( raiseEvent && CommandManager.RaiseCommandCallingEvent( cmd, this, player ) ) return false;
Handler( player, cmd );
if( raiseEvent ) CommandManager.RaiseCommandCalledEvent( cmd, this, player );
return true;
}
示例11: CancelDraw
internal static void CancelDraw( Player player, Command command )
{
if( player.marksExpected > 0 ) {
player.marksExpected = 0;
} else {
player.Message( "There is currently nothing to cancel." );
}
}
示例12: Compass
void Compass( Player player, Command cmd ) {
int offset = (int)(player.pos.r / 255f * 64f) + 32;
string name = cmd.Next();
if( name != null ) {
Player target = world.FindPlayer( name );
if( target != null ) {
player.Message( "Coordinates of player \"" + target.name + "\":" );
offset = (int)(target.pos.r / 255f * 64f) + 32;
} else {
world.NoPlayerMessage( player, name );
return;
}
}
player.Message( Color.Silver, String.Format( "({0},{1},{2}) - {3}[{4}{5}{6}{3}{7}]",
player.pos.x / 32,
player.pos.y / 32,
player.pos.h / 32,
Color.White,
compass.Substring( offset - 12, 11 ),
Color.Red,
compass.Substring( offset - 1, 3 ),
compass.Substring( offset + 2, 11 ) ) );
}
示例13: user
public bool IsConfirmed; // whether this command has been confirmed by the user (with /ok)
public Command( Command other ) {
if( other == null ) throw new ArgumentNullException( "other" );
offset = other.offset;
Message = other.Message;
Name = other.Name;
IsConfirmed = other.IsConfirmed;
}
示例14: DumpStats
internal static void DumpStats( Player player, Command cmd ) {
string fileName = cmd.Next();
if( fileName == null ) {
cdDumpStats.PrintUsage( player );
return;
}
if( !Paths.Contains( Paths.WorkingPath, fileName ) ) {
player.UnsafePathMessage();
return;
}
if( Paths.IsProtectedFileName( Path.GetFileName( fileName ) ) ) {
player.Message( "You may not use this file." );
return;
}
if( Path.HasExtension( fileName ) &&
!Path.GetExtension( fileName ).Equals( ".txt", StringComparison.OrdinalIgnoreCase ) ) {
player.Message( "Stats filename must end with .txt" );
return;
}
if( File.Exists( fileName ) && !cmd.IsConfirmed ) {
player.AskForConfirmation( cmd, "File \"{0}\" already exists. Overwrite?", Path.GetFileName( fileName ) );
return;
}
if( !Paths.TestFile( "dumpstats file", fileName, false, true, false ) ) {
player.Message( "Cannot create specified file. See log for details." );
return;
}
PlayerInfo[] infos;
using( FileStream fs = File.Create( fileName ) ) {
using( StreamWriter writer = new StreamWriter( fs ) ) {
infos = PlayerDB.GetPlayerListCopy();
if( infos.Length == 0 ) {
writer.WriteLine( "{0} (0 players)", "(TOTAL)" );
writer.WriteLine();
} else {
DumpPlayerGroupStats( writer, infos, "(TOTAL)" );
}
foreach( Rank rank in RankManager.Ranks ) {
infos = PlayerDB.GetPlayerListCopy( rank );
if( infos.Length == 0 ) {
writer.WriteLine( "{0} (0 players)", rank.Name );
writer.WriteLine();
} else {
DumpPlayerGroupStats( writer, infos, rank.Name );
}
}
}
}
player.Message( "Stats saved to \"{0}\"", Path.GetFileName( fileName ) );
}
示例15: Colors
internal static void Colors( Player player, Command cmd ) {
StringBuilder sb = new StringBuilder( "List of colors: " );
foreach( var color in Color.ColorNames ) {
sb.AppendFormat( "&{0}%{0} {1} ", color.Key, color.Value );
}
player.Message( sb.ToString() );
}