本文整理汇总了C#中fCraft.CommandReader类的典型用法代码示例。如果您正苦于以下问题:C# CommandReader类的具体用法?C# CommandReader怎么用?C# CommandReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandReader类属于fCraft命名空间,在下文中一共展示了CommandReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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 );
}
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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");
}
}
示例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 );
}
}
示例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;
}
示例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);
}
示例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 );
}
示例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 );
}
示例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 );
}
}
}
示例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());
}