本文整理汇总了C#中fCraft.CommandReader.NextAll方法的典型用法代码示例。如果您正苦于以下问题:C# CommandReader.NextAll方法的具体用法?C# CommandReader.NextAll怎么用?C# CommandReader.NextAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.CommandReader
的用法示例。
在下文中一共展示了CommandReader.NextAll方法的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: 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 );
}
}
}
示例3: 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;
}
}
示例4: 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 );
}
示例5: 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 );
}
}
}
示例6: 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." );
}
}
示例7: WorldSetHandler
static void WorldSetHandler( Player player, CommandReader cmd ) {
string worldName = cmd.Next();
string varName = cmd.Next();
string value = cmd.NextAll();
if( worldName == null || varName == null ) {
CdWorldSet.PrintUsage( player );
return;
}
World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
if( world == null ) return;
switch( varName.ToLower() ) {
case "hide":
case "hidden":
if( String.IsNullOrEmpty( value ) ) {
player.Message( "World {0}&S is current {1}hidden.",
world.ClassyName,
world.IsHidden ? "" : "NOT " );
} else if( value.Equals( "on", StringComparison.OrdinalIgnoreCase ) ||
value.Equals( "true", StringComparison.OrdinalIgnoreCase ) ||
value == "1" ) {
if( world.IsHidden ) {
player.Message( "World {0}&S is already hidden.", world.ClassyName );
} else {
player.Message( "World {0}&S is now hidden.", world.ClassyName );
world.IsHidden = true;
WorldManager.SaveWorldList();
}
} else if( value.Equals( "off", StringComparison.OrdinalIgnoreCase ) ||
value.Equals( "false", StringComparison.OrdinalIgnoreCase ) ||
value == "0" ) {
if( world.IsHidden ) {
player.Message( "World {0}&S is no longer hidden.", world.ClassyName );
world.IsHidden = false;
WorldManager.SaveWorldList();
} else {
player.Message( "World {0}&S is not hidden.", world.ClassyName );
}
} else {
CdWorldSet.PrintUsage( player );
}
break;
case "backup":
case "backups":
TimeSpan backupInterval;
string oldDescription = world.BackupSettingDescription;
if( String.IsNullOrEmpty( value ) ) {
player.Message( GetBackupSettingsString( world ) );
return;
} else if( value.Equals( "off", StringComparison.OrdinalIgnoreCase ) ||
value.StartsWith( "disable", StringComparison.OrdinalIgnoreCase ) ) {
// Disable backups on the world
if( world.BackupEnabledState == YesNoAuto.No ) {
MessageSameBackupSettings( player, world );
return;
} else {
world.BackupEnabledState = YesNoAuto.No;
}
} else if( value.Equals( "default", StringComparison.OrdinalIgnoreCase ) ||
value.Equals( "auto", StringComparison.OrdinalIgnoreCase ) ) {
// Set world to use default settings
if( world.BackupEnabledState == YesNoAuto.Auto ) {
MessageSameBackupSettings( player, world );
return;
} else {
world.BackupEnabledState = YesNoAuto.Auto;
}
} else if( value.TryParseMiniTimeSpan( out backupInterval ) ) {
if( backupInterval == TimeSpan.Zero ) {
// Set world's backup interval to 0, which is equivalent to disabled
if( world.BackupEnabledState == YesNoAuto.No ) {
MessageSameBackupSettings( player, world );
return;
} else {
world.BackupEnabledState = YesNoAuto.No;
}
} else if( world.BackupEnabledState != YesNoAuto.Yes ||
world.BackupInterval != backupInterval ) {
// Alter world's backup interval
world.BackupInterval = backupInterval;
} else {
MessageSameBackupSettings( player, world );
return;
}
} else {
CdWorldSet.PrintUsage( player );
return;
}
player.Message( "Backup setting for world {0}&S changed from \"{1}\" to \"{2}\"",
world.ClassyName, oldDescription, world.BackupSettingDescription );
WorldManager.SaveWorldList();
break;
case "description":
//.........这里部分代码省略.........
示例8: SignAddHandler
static void SignAddHandler(Player player, CommandReader cmd)
{
World playerWorld = player.World;
if (playerWorld == null) PlayerOpException.ThrowNoWorld(player);
string givenZoneName = "Sign_" + cmd.Next();
if (givenZoneName == null || !cmd.HasNext)
{
CdSignAdd.PrintUsage(player);
return;
}
if (!player.Info.Rank.AllowSecurityCircumvention)
{
SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
switch (buildCheck)
{
case SecurityCheckResult.BlackListed:
player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
playerWorld.ClassyName);
return;
case SecurityCheckResult.RankTooLow:
player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
playerWorld.ClassyName);
return;
}
}
Zone newZone = new Zone();
ZoneCollection zoneCollection = player.WorldMap.Zones;
if (!canManageSpecialZone(givenZoneName.ToLower(), player)) {
return;
}
// Adding an ordinary, rank-restricted zone.
if (!World.IsValidName(givenZoneName))
{
player.Message("\"{0}\" is not a valid Sign/Zone name", givenZoneName);
return;
}
if (zoneCollection.Contains(givenZoneName))
{
player.Message("A Sign/Zone with this name already exists.");
return;
}
newZone.Name = givenZoneName;
Rank minRank = RankManager.HighestRank;
if (cmd.HasNext)
{
newZone.Sign = cmd.NextAll();
if (newZone.Sign.Length == 0)
{
CdSignAdd.PrintUsage(player);
return;
}
else
{
if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
File.WriteAllText("./Signs/" + player.World.Name + "/" + newZone.Name + ".txt", cmd.NextAll().Replace("%n", "/n"));
player.Message("&SMessage for sign {0}&S is: {1}", newZone.ClassyName, newZone.Sign);
newZone.Sign = null;
}
}
newZone.Controller.MinRank = minRank;
player.SelectionStart(1, SignAddCallback, newZone, CdSignAdd.Permissions);
player.Message("SignAdd: Creating sign {0}&S. Click or &H/Mark&S 1 block.",
newZone.ClassyName);
}
示例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: UnbanHandler
static void UnbanHandler( Player player, CommandReader cmd ) {
string targetName = cmd.Next();
if( targetName == null ) {
CdUnban.PrintUsage( player );
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName, false );
if( target == null ) return;
string reason = cmd.NextAll();
try {
target.Unban( player, reason, true, true );
} catch( PlayerOpException ex ) {
player.Message( ex.MessageColored );
}
}
示例11: KickHandler
static void KickHandler( Player player, CommandReader cmd ) {
string name = cmd.Next();
if( name == null ) {
player.Message( "Usage: &H/Kick PlayerName [Message]" );
return;
}
// find the target
Player target = Server.FindPlayerOrPrintMatches( player, name, false, false, true );
if( target == null ) return;
string reason = cmd.NextAll();
DateTime previousKickDate = target.Info.LastKickDate;
string previousKickedBy = target.Info.LastKickByClassy;
string previousKickReason = target.Info.LastKickReason;
// do the kick
try {
Player targetPlayer = target;
target.Kick( player, reason, LeaveReason.Kick, true, true, true );
WarnIfOtherPlayersOnIP( player, target.Info, targetPlayer );
} catch( PlayerOpException ex ) {
player.Message( ex.MessageColored );
if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
FreezeIfAllowed( player, target.Info );
}
return;
}
// warn player if target has been kicked before
if( target.Info.TimesKicked > 1 ) {
player.Message( "Warning: {0}&S has been kicked {1} times before.",
target.ClassyName, target.Info.TimesKicked - 1 );
if( previousKickDate != DateTime.MinValue ) {
player.Message( "Most recent kick was {0} ago, by {1}",
DateTime.UtcNow.Subtract( previousKickDate ).ToMiniString(),
previousKickedBy );
}
if( !String.IsNullOrEmpty( previousKickReason ) ) {
player.Message( "Most recent kick reason was: {0}",
previousKickReason );
}
}
}
示例12: SetInfoHandler
static void SetInfoHandler( Player player, CommandReader cmd ) {
string targetName = cmd.Next();
string propertyName = cmd.Next();
string valName = cmd.NextAll();
if( targetName == null || propertyName == null ) {
CdSetInfo.PrintUsage( player );
return;
}
PlayerInfo info = PlayerDB.FindByPartialNameOrPrintMatches( player, targetName );
if( info == null ) return;
switch( propertyName.ToLower() ) {
case "banreason":
if( valName.Length == 0 ) valName = null;
if( SetPlayerInfoField( player, "BanReason", info, info.BanReason, valName ) ) {
info.BanReason = valName;
}
break;
case "displayedname":
string oldDisplayedName = info.DisplayedName;
if( valName.Length == 0 ) valName = null;
if( valName == info.DisplayedName ) {
if( valName == null ) {
player.Message( "SetInfo: DisplayedName for {0} is not set.",
info.Name );
} else {
player.Message( "SetInfo: DisplayedName for {0} is already set to \"{1}&S\"",
info.Name,
valName );
}
break;
}
info.DisplayedName = valName;
if( oldDisplayedName == null ) {
player.Message( "SetInfo: DisplayedName for {0} set to \"{1}&S\"",
info.Name,
valName );
} else if( valName == null ) {
player.Message( "SetInfo: DisplayedName for {0} was reset (was \"{1}&S\")",
info.Name,
oldDisplayedName );
} else {
player.Message( "SetInfo: DisplayedName for {0} changed from \"{1}&S\" to \"{2}&S\"",
info.Name,
oldDisplayedName,
valName );
}
break;
case "kickreason":
if( valName.Length == 0 ) valName = null;
if( SetPlayerInfoField( player, "KickReason", info, info.LastKickReason, valName ) ) {
info.LastKickReason = valName;
}
break;
case "name":
if( valName.Equals( info.Name, StringComparison.OrdinalIgnoreCase ) ) {
player.Message( "SetInfo: You may change capitalization of player's real name. " +
"If you'd like to make other changes to the way player's name is displayed, " +
"use &H/SetInfo <Name> DisplayedName <NewName>" );
break;
}
string oldName = info.Name;
if( oldName != valName ) {
info.Name = valName;
player.Message( "Name capitalization changed from \"{0}\" to \"{1}\"",
oldName, valName );
} else {
player.Message( "Name capitalization is already \"{0}\"", oldName );
}
break;
case "previousrank":
Rank newPreviousRank;
if( valName.Length > 0 ) {
newPreviousRank = RankManager.FindRank( valName );
if( newPreviousRank == null ) {
player.MessageNoRank( valName );
break;
}
} else {
newPreviousRank = null;
}
Rank oldPreviousRank = info.PreviousRank;
if( newPreviousRank == oldPreviousRank ) {
if( newPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
info.ClassyName );
} else {
player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
info.ClassyName,
newPreviousRank.ClassyName );
}
//.........这里部分代码省略.........
示例13: ZoneEditHandler
static void ZoneEditHandler( Player player, CommandReader cmd ) {
if( player.World == null ) PlayerOpException.ThrowNoWorld( player );
bool changesWereMade = false;
string zoneName = cmd.Next();
if( zoneName == null ) {
player.Message( "No zone name specified. See &H/Help ZEdit" );
return;
}
Zone zone = player.WorldMap.Zones.Find( zoneName );
if( zone == null ) {
player.MessageNoZone( zoneName );
return;
}
if (!canManageSpecialZone(zone.Name.ToLower(), player)) {
return;
}
if (zone.Name.ToLower().StartsWith("command_")) {
if (player.Info.Rank != RankManager.HighestRank) {
player.Message("You cannot affect command zones.");
return;
}
}
//player.Message(cmd.RawMessage);
//player.Message(cmd.RawMessage.Substring(cmd.Offset));
if (cmd.RawMessage.Substring(cmd.Offset + 1).StartsWith("#"))
{
zone.Sign = cmd.NextAll().Substring(1);
if (zone.Sign.Length == 0 || zone.Sign == null)
{
if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
if (File.Exists("./Signs/" + player.World.Name + "/" + zone.Name + ".txt")) File.Delete("./Signs/" + player.World.Name + "/" + zone.Name + ".txt");
player.Message("&SSign Text for zone {0}&S was removed.", zone.ClassyName);
zone.Sign = null;
}
else
{
if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
File.WriteAllText("./Signs/" + player.World.Name + "/" + zone.Name + ".txt", cmd.NextAll().Substring(1).Replace("%n", "/n"));
player.Message("&SSign Text for zone {0}&S changed to {1}", zone.ClassyName, zone.Sign);
zone.Sign = null;
}
return;
}
string nextToken;
while( (nextToken = cmd.Next()) != null ) {
// Clear whitelist
if( nextToken.Equals( "-*" ) ) {
PlayerInfo[] oldWhitelist = zone.Controller.ExceptionList.Included;
if( oldWhitelist.Length > 0 ) {
zone.Controller.ResetIncludedList();
player.Message( "Whitelist of zone {0}&S cleared: {1}",
zone.ClassyName, oldWhitelist.JoinToClassyString() );
Logger.Log( LogType.UserActivity,
"{0} {1} &scleared whitelist of zone {2} on world {3}: {4}",
player.Info.Rank.Name, player.Name, zone.Name, player.World.Name,
oldWhitelist.JoinToString( pi => pi.Name ) );
} else {
player.Message( "Whitelist of zone {0}&S is empty.",
zone.ClassyName );
}
continue;
}
// Clear blacklist
if( nextToken.Equals( "+*" ) ) {
PlayerInfo[] oldBlacklist = zone.Controller.ExceptionList.Excluded;
if( oldBlacklist.Length > 0 ) {
zone.Controller.ResetExcludedList();
player.Message( "Blacklist of zone {0}&S cleared: {1}",
zone.ClassyName, oldBlacklist.JoinToClassyString() );
Logger.Log( LogType.UserActivity,
"{0} {1} &scleared blacklist of zone {2} on world {3}: {4}",
player.Info.Rank.Name, player.Name, zone.Name, player.World.Name,
oldBlacklist.JoinToString( pi => pi.Name ) );
} else {
player.Message( "Blacklist of zone {0}&S is empty.",
zone.ClassyName );
}
continue;
}
if( nextToken.StartsWith( "+" ) ) {
PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, nextToken.Substring( 1 ), SearchOptions.IncludeSelf );
if( info == null ) return;
// prevent players from whitelisting themselves to bypass protection
if (!player.Info.Rank.AllowSecurityCircumvention && player.Info == info)
{
switch( zone.Controller.CheckDetailed( info ) ) {
case SecurityCheckResult.BlackListed:
player.Message( "You are not allowed to remove yourself from the blacklist of zone {0}",
zone.ClassyName );
continue;
case SecurityCheckResult.RankTooLow:
//.........这里部分代码省略.........
示例14: UnbanIPHandler
static void UnbanIPHandler(Player player, CommandReader cmd)
{
string targetNameOrIP = cmd.Next();
if (targetNameOrIP == null)
{
CdUnbanIP.PrintUsage(player);
return;
}
string reason = cmd.NextAll();
try
{
IPAddress targetAddress;
if (IPAddressUtil.IsIP(targetNameOrIP) && IPAddress.TryParse(targetNameOrIP, out targetAddress))
{
targetAddress.UnbanIP(player, reason, true, true);
}
else
{
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player,
targetNameOrIP,
SearchOptions.ReturnSelfIfOnlyMatch);
if (target == null) return;
if (target == player.Info)
{
player.Message("You cannot &H/UnbanIP&S yourself.");
return;
}
if (target.LastIP.Equals(IPAddress.Any) || target.LastIP.Equals(IPAddress.None))
{
target.Unban(player, reason, true, true);
}
else
{
target.UnbanIP(player, reason, true, true);
}
}
}
catch (PlayerOpException ex)
{
player.Message(ex.MessageColored);
}
}
示例15: SudoHandler
static void SudoHandler(Player player, CommandReader cmd)
{
string ply = cmd.Next();
if (!cmd.HasNext)
{
CdSudo.PrintUsage(player);
return;
}
string sudocmd = cmd.NextAll();
PlayerInfo p = PlayerDB.FindPlayerInfoOrPrintMatches(player, ply, SearchOptions.IncludeSelf);
if (p == null)
{
return;
}
if (p.PlayerObject == null)
{
player.Message("This player is offline!");
return;
}
try {
p.PlayerObject.ParseMessage(sudocmd, false);
player.Message("Forced {0} to type in \"{1}\"", p.Name, sudocmd);
} catch {
player.Message("Cannot use that command with /sudo");
}
}