本文整理汇总了C#中fCraft.CommandReader类的典型用法代码示例。如果您正苦于以下问题:C# CommandReader类的具体用法?C# CommandReader怎么用?C# CommandReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandReader类属于fCraft命名空间,在下文中一共展示了CommandReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SayHandler
static void SayHandler(Player player, CommandReader cmd)
{
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}
if (player.DetectChatSpam()) return;
if (player.Can(Permission.Say))
{
string msg = cmd.NextAll().Trim();
if (msg.Length > 0)
{
Chat.SendSay(player, msg);
}
else
{
CdSay.PrintUsage(player);
}
}
else
{
player.MessageNoAccess(Permission.Say);
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:27,代码来源:ChatCommands.cs
示例2: SetParamIteration
public static void SetParamIteration(Player p, CommandReader cmd)
{
string strParam = cmd.Next();
if (string.IsNullOrWhiteSpace(strParam))
{
p.Message("Error: missing param variable name");
return;
}
strParam = strParam.ToLower();
try
{
CheckParamVar(strParam);
double from = ReadDoubleParam(cmd, "lower bound");
double to = ReadDoubleParam(cmd, "upper bound");
double step = ReadDoubleParam(cmd, "step");
if (step == 0 ||
(to - from)/step < 0)
throw new ArgumentException("wrong iteration bounds/step combination");
p.Message("Iteration for " + strParam + " from " + from + " to " + to + " with step " + step + ". " +
((to - from)/step + 1) + " steps.");
GetPlayerParametrizationParamsStorage(p)[VarNameToIdx(strParam[0])] = new double[] {from, to, step};
}
catch (Exception e)
{
p.Message("Error: " + e.Message);
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:33,代码来源:PrepareParametrizedManifold.cs
示例3: BanHandler
static void BanHandler( Player player, CommandReader cmd ) {
string targetName = cmd.Next();
if( targetName == null ) {
CdBan.PrintUsage( player );
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player,
targetName,
SearchOptions.ReturnSelfIfOnlyMatch );
if( target == null ) return;
if( target == player.Info ) {
player.Message( "You cannot &H/Ban&S yourself." );
return;
}
string reason = cmd.NextAll();
try {
Player targetPlayer = target.PlayerObject;
target.Ban( player, reason, true, true );
WarnIfOtherPlayersOnIP( player, target, targetPlayer );
} catch( PlayerOpException ex ) {
player.Message( ex.MessageColored );
if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
FreezeIfAllowed( player, target );
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:26,代码来源:ModerationCommands.cs
示例4: SetParametrization
public static void SetParametrization(Player p, CommandReader 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);
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:32,代码来源:PrepareParametrizedManifold.cs
示例5: BumHandler
static void BumHandler(Player player, CommandReader cmd)
{
string newModeName = cmd.Next();
if (newModeName == null)
{
player.Message("&sBytes Sent: {0} Per Second: {1:0.0}", player.BytesSent, player.BytesSentRate);
player.Message("&sBytes Received: {0} Per Second: {1:0.0}", player.BytesReceived, player.BytesReceivedRate);
player.Message("&sBandwidth mode: {0}",player.BandwidthUseMode);
return;
}
else if (player.Can(Permission.EditPlayerDB))
{
var newMode = (BandwidthUseMode)Enum.Parse(typeof(BandwidthUseMode), newModeName, true);
player.Message("&sBandwidth mode: {0} --> {1}", player.BandwidthUseMode, newMode.ToString());
player.BandwidthUseMode = newMode;
player.Info.BandwidthUseMode = newMode;
return;
}
else
{
player.Message("You need {0}&s to change your BandwidthUseMode", RankManager.GetMinRankWithAnyPermission(Permission.EditPlayerDB).ClassyName);
return;
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:28,代码来源:InfoCommands.cs
示例6: FuncDrawOperation
protected FuncDrawOperation(Player player, CommandReader 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);
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:25,代码来源:FuncDrawOperation.cs
示例7: TrollHandler
private static void TrollHandler( Player player, CommandReader cmd ) {
string Name = cmd.Next();
if ( Name == null ) {
player.Message( "Player not found. Please specify valid name." );
return;
}
if ( !Player.IsValidPlayerName( Name ) )
return;
Player target = Server.FindPlayerOrPrintMatches( player, Name, SearchOptions.Default );
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 = Chat.ReplacePercentColorCodes( Message, false );
}
Server.Players.Message( "&Pfrom {0}: {1}",
target.Name, 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;
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:56,代码来源:TrollPlugin.cs
示例8: ModelHandler
private static void ModelHandler(Player player, CommandReader cmd) {
PlayerInfo otherPlayer = InfoCommands.FindPlayerInfo(player, cmd, cmd.Next() ?? player.Name);
if (otherPlayer == null) return;
if (!player.IsStaff && otherPlayer != player.Info) {
Rank staffRank = RankManager.GetMinRankWithAnyPermission(Permission.ReadStaffChat);
if (staffRank != null) {
player.Message("You must be {0}&s+ to change another players Model", staffRank.ClassyName);
} else {
player.Message("No ranks have the ReadStaffChat permission so no one can change other players Model, yell at the owner.");
}
return;
}
if (otherPlayer.Rank.Index < player.Info.Rank.Index) {
player.Message("Cannot change the Model of someone higher rank than you.");
return;
}
if (otherPlayer == null) {
player.Message("Your current Model: &f" + player.Info.Mob);
return;
}
string model = cmd.Next();
if (string.IsNullOrEmpty(model)) {
player.Message("Current Model for {0}: &f{1}", otherPlayer.Name, otherPlayer.Mob);
return;
}
if (otherPlayer.IsOnline && otherPlayer.Rank.Index >= player.Info.Rank.Index) {
if (!validEntities.Contains(model.ToLower())) {
Block block;
if (Map.GetBlockByName(model, false, out block)) {
model = block.GetHashCode().ToString();
} else {
player.Message("Model not valid, see &h/Help Model&s.");
return;
}
}
if (otherPlayer.Mob.ToLower() == model.ToLower()) {
player.Message("&f{0}&s's model is already set to &f{1}", otherPlayer.Name, model);
return;
}
if (otherPlayer.IsOnline) {
otherPlayer.PlayerObject.Message("&f{0}&shanged your model from &f{1} &sto &f{2}", (otherPlayer.PlayerObject == player ? "&sC" : player.Name + " &sc"), otherPlayer.Mob, model);
}
if (otherPlayer.PlayerObject != player) {
player.Message("&sChanged model of &f{0} &sfrom &f{1} &sto &f{2}", otherPlayer.Name, otherPlayer.Mob, model);
}
otherPlayer.oldMob = otherPlayer.Mob;
otherPlayer.Mob = model;
} else {
player.Message("Player not found/online or lower rank than you");
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:52,代码来源:CpeCommands.cs
示例9: StaffHandler
static void StaffHandler( Player player, CommandReader cmd ) {
if( player.Info.IsMuted ) {
player.MessageMuted();
return;
}
if( player.DetectChatSpam() ) return;
string message = cmd.NextAll().Trim( ' ' );
if( message.Length > 0 ) {
Chat.SendStaff( player, message );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:13,代码来源:ChatCommands.cs
示例10: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
MapGeneratorParameters newParams;
if( themeName != null ) {
newParams = CreateParameters( themeName );
if( newParams == null ) {
player.Message( "SetGen: \"{0}\" is not a recognized flat theme name. Available themes are: {1}",
themeName, Presets.JoinToString() );
return null;
}
} else {
newParams = CreateDefaultParameters();
}
return newParams;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:15,代码来源:FlatMapGen.cs
示例11: InequalityDrawOperation
public InequalityDrawOperation(Player player, CommandReader cmd)
: base(player)
{
string strFunc = cmd.Next();
if (string.IsNullOrWhiteSpace(strFunc))
throw new ArgumentException("empty inequality expression");
if (strFunc.Length < 3)
throw new ArgumentException("expression is too short (should be like f(x,y,z)>g(x,y,z))");
strFunc = strFunc.ToLower();
_expression = SimpleParser.Parse(strFunc, new string[] { "x", "y", "z" });
if (!_expression.IsInEquality())
throw new ArgumentException("the expression given is not an inequality (should be like f(x,y,z)>g(x,y,z))");
player.Message("Expression parsed as " + _expression.Print());
string scalingStr = cmd.Next();
_scaler = new Scaler(scalingStr);
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:19,代码来源:InequalityDrawOperation.cs
示例12: MassRankHandler
static void MassRankHandler( Player player, CommandReader cmd ) {
string fromRankName = cmd.Next();
string toRankName = cmd.Next();
string reason = cmd.NextAll();
if( fromRankName == null || toRankName == null ) {
CdMassRank.PrintUsage( player );
return;
}
Rank fromRank = RankManager.FindRank( fromRankName );
if( fromRank == null ) {
player.MessageNoRank( fromRankName );
return;
}
Rank toRank = RankManager.FindRank( toRankName );
if( toRank == null ) {
player.MessageNoRank( toRankName );
return;
}
if( fromRank == toRank ) {
player.Message( "Ranks must be different" );
return;
}
int playerCount;
using( PlayerDB.GetReadLock() ) {
playerCount = PlayerDB.List.Count( t => t.Rank == fromRank );
}
string verb = (fromRank > toRank ? "demot" : "promot");
if( !cmd.IsConfirmed ) {
player.Confirm( cmd, "MassRank: {0}e {1} players?", verb.UppercaseFirst(), playerCount );
return;
}
player.Message( "MassRank: {0}ing {1} players...",
verb, playerCount );
int affected = PlayerDB.MassRankChange( player, fromRank, toRank, reason );
player.Message( "MassRank: done, {0} records affected.", affected );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:43,代码来源:MaintenanceCommands.cs
示例13: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
if( themeName == null ) {
return CreateDefaultParameters();
}
MapGenTheme theme;
RealisticMapGenTerrainType terrainType;
string templateName = cmd.Next();
if( templateName == null ) {
player.Message( "SetGen: Realistic MapGen requires both a theme and a terrainType. " +
"See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details" );
return null;
}
// parse theme
bool swapThemeAndTemplate;
if( EnumUtil.TryParse( themeName, out theme, true ) ) {
swapThemeAndTemplate = false;
} else if( EnumUtil.TryParse( templateName, out theme, true ) ) {
swapThemeAndTemplate = true;
} else {
player.Message( "SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
themeName,
Enum.GetNames( typeof( MapGenTheme ) ).JoinToString() );
return null;
}
// parse terrainType
if( swapThemeAndTemplate && !EnumUtil.TryParse( themeName, out terrainType, true ) ) {
MessageTemplateList( themeName, player );
return null;
} else if( !EnumUtil.TryParse( templateName, out terrainType, true ) ) {
MessageTemplateList( templateName, player );
return null;
}
// TODO: optional parameters for preset customization
return CreateParameters( terrainType, theme );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:43,代码来源:RealisticMapGen.cs
示例14: BanHandler
static void BanHandler( Player player, CommandReader cmd ) {
string targetName = cmd.Next();
if( targetName == null ) {
CdBan.PrintUsage( player );
return;
}
PlayerInfo target = PlayerDB.FindByPartialNameOrPrintMatches( player, targetName );
if( target == null ) return;
string reason = cmd.NextAll();
try {
Player targetPlayer = target.PlayerObject;
target.Ban( player, reason, true, true );
WarnIfOtherPlayersOnIP( player, target, targetPlayer );
} catch( PlayerOpException ex ) {
player.Message( ex.MessageColored );
if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
FreezeIfAllowed( player, target );
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:20,代码来源:ModerationCommands.cs
示例15: ManifoldDrawOperation
public ManifoldDrawOperation(Player p, CommandReader cmd) : base (p)
{
_expressions = PrepareParametrizedManifold.GetPlayerParametrizationCoordsStorage(p);
if (null == _expressions[0])
throw new InvalidExpressionException("x is undefined");
if (null == _expressions[1])
throw new InvalidExpressionException("y is undefined");
if (null == _expressions[2])
throw new InvalidExpressionException("z is undefined");
_paramIterations = PrepareParametrizedManifold.GetPlayerParametrizationParamsStorage(p);
if (null==_paramIterations[0] && null==_paramIterations[1] && null==_paramIterations[2])
throw new InvalidExpressionException("all parametrization variables are undefined");
if (GetNumOfSteps(0) * GetNumOfSteps(1) * GetNumOfSteps(2) > MaxIterationSteps)
throw new InvalidExpressionException("too many iteration steps (over " + MaxIterationSteps + ")");
_scaler=new Scaler(cmd.Next());
p.Message("Going to draw the following parametrization:\nx=" + _expressions[0].Print()+
"\ny=" + _expressions[1].Print() + "\nz=" + _expressions[2].Print());
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:22,代码来源:ManifoldDrawOperation.cs
示例16: ReplyHandler
static void ReplyHandler( Player player, CommandReader cmd ) {
string messageText = cmd.NextAll();
if( messageText.Length == 0 ) {
player.Message( "Reply: No message to send!" );
return;
}
string targetName = player.lastPrivateMessageSender;
if( targetName != null ) {
Player targetPlayer = Server.FindPlayerExact( player,
targetName,
SearchOptions.IncludeHidden );
if( targetPlayer != null ) {
if( player.CanSee( targetPlayer ) ) {
if( targetPlayer.IsDeaf ) {
player.Message( "Cannot PM {0}&S: they are currently deaf.", targetPlayer.ClassyName );
} else if( targetPlayer.IsIgnoring( player.Info ) ) {
player.Message( "&WCannot PM {0}&W: you are ignored.", targetPlayer.ClassyName );
} else {
Chat.SendPM( player, targetPlayer, messageText );
player.MessageNow( "&Pto {0}: {1}", targetPlayer.Name, messageText );
}
} else {
player.Message( "Reply: Cannot send message; player {0}&S is offline.",
PlayerDB.FindExactClassyName( targetName ) );
if( targetPlayer.CanHear( player ) ) {
Chat.SendPM( player, targetPlayer, messageText );
player.Info.DecrementMessageWritten();
}
}
} else {
player.Message( "Reply: Cannot send message; player {0}&S is offline.",
PlayerDB.FindExactClassyName( targetName ) );
}
} else {
player.Message( "Reply: You have not sent any messages yet." );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:38,代码来源:ChatCommands.cs
示例17: EqualityDrawOperation
public EqualityDrawOperation(Player player, CommandReader cmd)
: base(player)
{
string strFunc = cmd.Next();
if (string.IsNullOrWhiteSpace(strFunc))
{
player.Message("empty equality expression");
return;
}
if (strFunc.Length < 3)
{
player.Message("expression is too short (should be like f(x,y,z)=g(x,y,z))");
return;
}
strFunc = strFunc.ToLower();
_expression = SimpleParser.ParseAsEquality(strFunc, new string[] { "x", "y", "z" });
player.Message("Expression parsed as " + _expression.Print());
string scalingStr = cmd.Next();
_scaler = new Scaler(scalingStr);
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:23,代码来源:EqualityDrawOperation.cs
示例18: CopyHandler
static void CopyHandler( Player player, CommandReader cmd ) {
if( cmd.HasNext ) {
CdCopy.PrintUsage( player );
return;
}
player.SelectionStart( 2, CopyCallback, null, CdCopy.Permissions );
player.MessageNow( "Copy: Click or &H/Mark&S 2 blocks." );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:BuildingCommands.cs
示例19: CopySlotHandler
static void CopySlotHandler( Player player, CommandReader cmd ) {
int slotNumber;
if( cmd.NextInt( out slotNumber ) ) {
if( cmd.HasNext ) {
CdCopySlot.PrintUsage( player );
return;
}
if( slotNumber < 1 || slotNumber > player.Info.Rank.CopySlots ) {
player.Message( "CopySlot: Select a number between 1 and {0}", player.Info.Rank.CopySlots );
} else {
player.CopySlot = slotNumber - 1;
CopyState info = player.GetCopyState();
if( info == null ) {
player.Message( "Selected copy slot {0} (unused).", slotNumber );
} else {
player.Message( "Selected copy slot {0}: {1} blocks from {2}, {3} old.",
slotNumber, info.Blocks.Length,
info.OriginWorld, DateTime.UtcNow.Subtract( info.CopyTime ).ToMiniString() );
}
}
} else {
CopyState[] slots = player.CopyStates;
player.Message( "Using {0} of {1} slots. Selected slot: {2}",
slots.Count( info => info != null ), player.Info.Rank.CopySlots, player.CopySlot + 1 );
for( int i = 0; i < slots.Length; i++ ) {
if( slots[i] != null ) {
player.Message( " {0}: {1} blocks from {2}, {3} old",
i + 1, slots[i].Blocks.Length,
slots[i].OriginWorld,
DateTime.UtcNow.Subtract( slots[i].CopyTime ).ToMiniString() );
}
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:34,代码来源:BuildingCommands.cs
示例20: RedoHandler
static void RedoHandler( Player player, CommandReader cmd ) {
if( cmd.HasNext ) {
CdRedo.PrintUsage( player );
return;
}
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
UndoState redoState = player.RedoPop();
if( redoState == null ) {
player.MessageNow( "There is currently nothing to redo." );
return;
}
string msg = "Redo: ";
if( redoState.Op != null && !redoState.Op.IsDone ) {
redoState.Op.Cancel();
msg += String.Format( "Cancelled {0} (was {1}% done). ",
redoState.Op.Description,
redoState.Op.PercentDone );
}
// no need to set player.drawingInProgress here because this is done on the user thread
Logger.Log( LogType.UserActivity,
"Player {0} initiated /Redo affecting {1} blocks (on world {2})",
player.Name,
redoState.Buffer.Count,
playerWorld.Name );
msg += String.Format( "Restoring {0} blocks. Type &H/Undo&S to reverse.",
redoState.Buffer.Count );
player.MessageNow( msg );
var op = new UndoDrawOperation( player, redoState, true );
op.Prepare( new Vector3I[0] );
op.Begin();
}
开发者ID:fragmer,项目名称:fCraft,代码行数:38,代码来源:BuildingCommands.cs
注:本文中的fCraft.CommandReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论