本文整理汇总了C#中fCraft.Player.MessageMaxTimeSpan方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessageMaxTimeSpan方法的具体用法?C# Player.MessageMaxTimeSpan怎么用?C# Player.MessageMaxTimeSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.MessageMaxTimeSpan方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UndoPlayerHandler
static void UndoPlayerHandler( Player player, Command cmd )
{
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
if( !BlockDB.IsEnabledGlobally ) {
player.Message( "&WBlockDB is disabled on this server." );
return;
}
if( !playerWorld.BlockDB.IsEnabled ) {
player.Message( "&WBlockDB is disabled in this world." );
return;
}
string name = cmd.Next();
string range = cmd.Next();
if( name == null || range == null ) {
CdUndoPlayer.PrintUsage( player );
return;
}
if( cmd.HasNext ) {
CdUndoPlayer.PrintUsage( player );
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, name );
if( target == null ) return;
if( player.Info != target && !player.Can( Permission.UndoOthersActions, target.Rank ) ) {
player.Message( "You may only undo actions of players ranked {0}&S or lower.",
player.Info.Rank.GetLimit( Permission.UndoOthersActions ).ClassyName );
player.Message( "Player {0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName );
return;
}
int count;
TimeSpan span;
BlockDBEntry[] changes;
if( Int32.TryParse( range, out count ) ) {
if( !cmd.IsConfirmed ) {
player.Message( "Searching for last {0} changes made by {1}&s...",
count, target.ClassyName );
}
changes = playerWorld.BlockDB.Lookup( target, count );
if( changes.Length > 0 && !cmd.IsConfirmed ) {
player.Confirm( cmd, "Undo last {0} changes made by player {1}&S?",
changes.Length, target.ClassyName );
return;
}
} else if( range.TryParseMiniTimespan( out span ) ) {
if( span > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
if( !cmd.IsConfirmed ) {
player.Message( "Searching for changes made by {0}&s in the last {1}...",
target.ClassyName, span.ToMiniString() );
}
changes = playerWorld.BlockDB.Lookup( target, span );
if( changes.Length > 0 && !cmd.IsConfirmed ) {
player.Confirm( cmd, "Undo changes ({0}) made by {1}&S in the last {2}?",
changes.Length, target.ClassyName, span.ToMiniString() );
return;
}
} else {
CdUndoPlayer.PrintUsage( player );
return;
}
if( changes.Length == 0 ) {
player.Message( "UndoPlayer: Found nothing to undo." );
return;
}
BlockChangeContext context = BlockChangeContext.Drawn;
if( player.Info == target ) {
context |= BlockChangeContext.UndoneSelf;
} else {
context |= BlockChangeContext.UndoneOther;
}
int blocks = 0,
blocksDenied = 0;
UndoState undoState = player.DrawBegin( null );
Map map = player.WorldMap;
for( int i = 0; i < changes.Length; i++ ) {
DrawOneBlock( player, map, changes[i].OldBlock,
changes[i].Coord, context,
ref blocks, ref blocksDenied, undoState );
}
Logger.Log( LogType.UserActivity,
"{0} undid {1} blocks changed by player {2} (on world {3})",
player.Name,
blocks,
//.........这里部分代码省略.........
示例2: ParseBlockDBUndoParams
static BlockDBUndoArgs ParseBlockDBUndoParams( Player player, CommandReader cmd, string cmdName, bool not ) {
// check if command's being called by a worldless player (e.g. console)
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
// ensure that BlockDB is enabled
if( !BlockDB.IsEnabledGlobally ) {
player.Message( "&W{0}: BlockDB is disabled on this server.", cmdName );
return null;
}
if( !playerWorld.BlockDB.IsEnabled ) {
player.Message( "&W{0}: BlockDB is disabled in this world.", cmdName );
return null;
}
// parse the first parameter - either numeric or time limit
string range = cmd.Next();
if( range == null ) {
CdUndoPlayer.PrintUsage( player );
return null;
}
int countLimit;
TimeSpan ageLimit = TimeSpan.Zero;
if( !Int32.TryParse( range, out countLimit ) && !range.TryParseMiniTimeSpan( out ageLimit ) ) {
player.Message( "{0}: First parameter should be a number or a timespan.", cmdName );
return null;
}
if( ageLimit > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return null;
}
// parse second and consequent parameters (player names)
HashSet<PlayerInfo> targets = new HashSet<PlayerInfo>();
bool allPlayers = false;
while( true ) {
string name = cmd.Next();
if( name == null ) {
break;
} else if( name == "*" ) {
// all players
if( not ) {
player.Message( "{0}: \"*\" not allowed (cannot undo \"everyone except everyone\")", cmdName );
return null;
}
if( allPlayers ) {
player.Message( "{0}: \"*\" was listed twice.", cmdName );
return null;
}
allPlayers = true;
} else {
// individual player
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, name, SearchOptions.IncludeSelf );
if( target == null ) {
return null;
}
if( targets.Contains( target ) ) {
player.Message( "{0}: Player {1}&S was listed twice.",
target.ClassyName, cmdName );
return null;
}
// make sure player has the permission
if( !not &&
player.Info != target && !player.Can( Permission.UndoAll ) &&
!player.Can( Permission.UndoOthersActions, target.Rank ) ) {
player.Message( "&W{0}: You may only undo actions of players ranked {1}&S or lower.",
cmdName,
player.Info.Rank.GetLimit( Permission.UndoOthersActions ).ClassyName );
player.Message( "Player {0}&S is ranked {1}",
target.ClassyName, target.Rank.ClassyName );
return null;
}
targets.Add( target );
}
}
if( targets.Count == 0 && !allPlayers ) {
player.Message( "{0}: Specify at least one player name, or \"*\" to undo everyone.", cmdName );
return null;
}
if( targets.Count > 0 && allPlayers ) {
player.Message( "{0}: Cannot mix player names and \"*\".", cmdName );
return null;
}
// undoing everyone ('*' in place of player name) requires UndoAll permission
if( ( not || allPlayers ) && !player.Can( Permission.UndoAll ) ) {
player.MessageNoAccess( Permission.UndoAll );
return null;
}
// Queue UndoPlayerCallback to run
return new BlockDBUndoArgs {
Player = player,
AgeLimit = ageLimit,
CountLimit = countLimit,
Area = player.WorldMap.Bounds,
World = playerWorld,
Targets = targets.ToArray(),
Not = not
//.........这里部分代码省略.........
示例3: TimerHandler
static void TimerHandler( Player player, Command cmd ) {
string param = cmd.Next();
// List timers
if( param == null ) {
ChatTimer[] list = ChatTimer.TimerList.OrderBy( timer => timer.TimeLeft ).ToArray();
if( list.Length == 0 ) {
player.Message( "No timers running." );
} else {
player.Message( "There are {0} timers running:", list.Length );
foreach( ChatTimer timer in list ) {
player.Message( " #{0} \"{1}&S\" (started by {2}, {3} left)",
timer.Id, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString() );
}
}
return;
}
// Abort a timer
if( param.Equals( "abort", StringComparison.OrdinalIgnoreCase ) ) {
int timerId;
if( cmd.NextInt( out timerId ) ) {
ChatTimer timer = ChatTimer.FindTimerById( timerId );
if( timer == null || !timer.IsRunning ) {
player.Message( "Given timer (#{0}) does not exist.", timerId );
} else {
timer.Stop();
string abortMsg = String.Format( "&Y(Timer) {0}&Y aborted a timer with {1} left: {2}",
player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message );
Chat.SendSay( player, abortMsg );
}
} else {
CdTimer.PrintUsage( player );
}
return;
}
// Start a timer
if( player.Info.IsMuted ) {
player.MessageMuted();
return;
}
if( player.DetectChatSpam() ) return;
TimeSpan duration;
if( !param.TryParseMiniTimespan( out duration ) ) {
CdTimer.PrintUsage( player );
return;
}
if( duration > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
if( duration < ChatTimer.MinDuration ) {
player.Message( "Timer: Must be at least 1 second." );
return;
}
string sayMessage;
string message = cmd.NextAll();
if( String.IsNullOrEmpty( message ) ) {
sayMessage = String.Format( "&Y(Timer) {0}&Y started a {1} timer",
player.ClassyName,
duration.ToMiniString() );
} else {
sayMessage = String.Format( "&Y(Timer) {0}&Y started a {1} timer: {2}",
player.ClassyName,
duration.ToMiniString(),
message );
}
Chat.SendSay( player, sayMessage );
ChatTimer.Start( duration, message, player.Name );
}
示例4: UndoAreaHandler
static void UndoAreaHandler( Player player, Command cmd )
{
if( !BlockDB.IsEnabledGlobally ) {
player.Message( "&WBlockDB is disabled on this server." );
return;
}
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
if( !playerWorld.BlockDB.IsEnabled ) {
player.Message( "&WBlockDB is disabled in this world." );
return;
}
string name = cmd.Next();
string range = cmd.Next();
if( name == null || range == null ) {
CdUndoArea.PrintUsage( player );
return;
}
if( cmd.HasNext ) {
CdUndoArea.PrintUsage( player );
return;
}
PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, name );
if( target == null ) return;
if( player.Info != target && !player.Can( Permission.UndoOthersActions, target.Rank ) ) {
player.Message( "You may only undo actions of players ranked {0}&S or lower.",
player.Info.Rank.GetLimit( Permission.UndoOthersActions ).ClassyName );
player.Message( "Player {0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName );
return;
}
int count;
TimeSpan span;
if( Int32.TryParse( range, out count ) ) {
UndoAreaCountArgs args = new UndoAreaCountArgs {
Target = target,
World = playerWorld,
MaxBlocks = count
};
player.SelectionStart( 2, UndoAreaCountSelectionCallback, args, Permission.UndoOthersActions );
} else if( range.TryParseMiniTimespan( out span ) ) {
if( span > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
UndoAreaTimeArgs args = new UndoAreaTimeArgs {
Target = target,
Time = span,
World = playerWorld
};
player.SelectionStart( 2, UndoAreaTimeSelectionCallback, args, Permission.UndoOthersActions );
} else {
CdUndoArea.PrintUsage( player );
return;
}
player.MessageNow( "UndoArea: Click 2 blocks or use &H/Mark&S to make a selection." );
}
示例5: RestartHandler
static void RestartHandler( Player player, CommandReader cmd ) {
string delayString = cmd.Next();
TimeSpan delayTime = DefaultShutdownTime;
string reason = "";
if( delayString != null ) {
if( delayString.Equals( "abort", StringComparison.OrdinalIgnoreCase ) ) {
if( Server.CancelShutdown() ) {
Logger.Log( LogType.UserActivity,
"Restart aborted by {0}.", player.Name );
Server.Message( "&WRestart aborted by {0}", player.ClassyName );
} else {
player.MessageNow( "Cannot abort restart - too late." );
}
return;
} else if( !delayString.TryParseMiniTimespan( out delayTime ) ) {
CdShutdown.PrintUsage( player );
return;
}
if( delayTime > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
reason = cmd.NextAll();
}
if( delayTime.TotalMilliseconds > Int32.MaxValue - 1 ) {
player.Message( "Restart: Delay is too long, maximum is {0}",
TimeSpan.FromMilliseconds( Int32.MaxValue - 1 ).ToMiniString() );
return;
}
Server.Message( "&WServer restarting in {0}", delayTime.ToMiniString() );
if( String.IsNullOrEmpty( reason ) ) {
Logger.Log( LogType.UserActivity,
"{0} scheduled a restart ({1} delay).",
player.Name, delayTime.ToCompactString() );
ShutdownParams sp = new ShutdownParams( ShutdownReason.Restarting, delayTime, true, true );
Server.Shutdown( sp, false );
} else {
Server.Message( "&WRestart reason: {0}", reason );
Logger.Log( LogType.UserActivity,
"{0} scheduled a restart ({1} delay). Reason: {2}",
player.Name, delayTime.ToCompactString(), reason );
ShutdownParams sp = new ShutdownParams( ShutdownReason.Restarting, delayTime, true, true, reason, player );
Server.Shutdown( sp, false );
}
}
示例6: BlockDBHandler
//.........这里部分代码省略.........
// sets or resets limit on the age of changes to store
if (db.IsEnabled)
{
string limitString = cmd.Next();
if (limitString == null)
{
if (db.TimeLimit == TimeSpan.Zero)
{
player.Message("BlockDB: There is no time limit for world {0}",
world.ClassyName);
}
else
{
player.Message("BlockDB: Time limit for world {0}&S is {1}",
world.ClassyName, db.TimeLimit.ToMiniString());
}
return;
}
TimeSpan limit;
if (limitString.Equals("none", StringComparison.OrdinalIgnoreCase))
{
limit = TimeSpan.Zero;
}
else if (!limitString.TryParseMiniTimespan(out limit))
{
CdBlockDB.PrintUsage(player);
return;
}
if (limit > DateTimeUtil.MaxTimeSpan)
{
player.MessageMaxTimeSpan();
return;
}
if (!cmd.IsConfirmed && limit != TimeSpan.Zero)
{
player.Confirm(cmd, "BlockDB: Change time limit? Some old data for world {0}&S may be discarded.", world.ClassyName);
}
else
{
if (db.TimeLimit == limit)
{
if (db.TimeLimit == TimeSpan.Zero)
{
player.Message("BlockDB: There is already no time limit for world {0}",
world.ClassyName);
}
else
{
player.Message("BlockDB: Time limit for world {0}&S is already set to {1}",
world.ClassyName, db.TimeLimit.ToMiniString());
}
}
else
{
db.TimeLimit = limit;
WorldManager.SaveWorldList();
if (db.TimeLimit == TimeSpan.Zero)
{
player.Message("BlockDB: Time limit removed for world {0}",
world.ClassyName);
示例7: SetInfoHandler
//.........这里部分代码省略.........
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 );
}
break;
}
info.PreviousRank = newPreviousRank;
if( oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
info.ClassyName,
newPreviousRank.ClassyName );
} else if( newPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
info.ClassyName,
oldPreviousRank.ClassyName );
} else {
player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
info.ClassyName,
oldPreviousRank.ClassyName,
newPreviousRank.ClassyName );
}
break;
case "rankchangetype":
RankChangeType oldType = info.RankChangeType;
try {
info.RankChangeType = (RankChangeType)Enum.Parse( typeof( RankChangeType ), valName, true );
} catch( ArgumentException ) {
player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
String.Join( ", ", Enum.GetNames( typeof( RankChangeType ) ) ) );
break;
}
player.Message( "SetInfo: RankChangeType for {0}&S changed from {1} to {2}",
info.ClassyName,
oldType,
info.RankChangeType );
break;
case "rankreason":
if( valName.Length == 0 ) valName = null;
if( SetPlayerInfoField( player, "RankReason", info, info.RankChangeReason, valName ) ) {
info.RankChangeReason = valName;
}
break;
case "timeskicked":
int oldTimesKicked = info.TimesKicked;
if( ValidateInt( valName, 0, 9999 ) ) {
info.TimesKicked = Int32.Parse( valName );
player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
info.ClassyName,
oldTimesKicked,
info.TimesKicked );
} else {
player.Message( "SetInfo: TimesKicked value out of range (Acceptable value range: 0-9999)" );
}
break;
case "totaltime":
TimeSpan newTotalTime;
TimeSpan oldTotalTime = info.TotalTime;
if( valName.TryParseMiniTimespan( out newTotalTime ) ) {
if( newTotalTime > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
break;
}
info.TotalTime = newTotalTime;
player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
info.ClassyName,
oldTotalTime.ToMiniString(),
oldTotalTime.ToCompactString(),
info.TotalTime.ToMiniString(),
info.TotalTime.ToCompactString() );
} else {
player.Message( "SetInfo: Could not parse value given for TotalTime." );
}
break;
case "unbanreason":
if( valName.Length == 0 ) valName = null;
if( SetPlayerInfoField( player, "UnbanReason", info, info.UnbanReason, valName ) ) {
info.UnbanReason = valName;
}
break;
default:
player.Message( "Only the following properties are editable: " +
"TimesKicked, PreviousRank, TotalTime, RankChangeType, " +
"BanReason, UnbanReason, RankReason, KickReason, DisplayedName" );
return;
}
}
示例8: SetInfoHandler
static void SetInfoHandler( Player player, Command 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.FindPlayerInfoOrPrintMatches( player, targetName );
if( info == null ) return;
switch( propertyName.ToLower() ) {
case "timeskicked":
int oldTimesKicked = info.TimesKicked;
if( ValidateInt( valName, 0, 9999 ) ) {
info.TimesKicked = Int32.Parse( valName );
player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
info.ClassyName,
oldTimesKicked,
info.TimesKicked );
break;
} else {
player.Message( "SetInfo: TimesKicked value acceptible (Acceptible value range: 0-9999)" );
return;
}
case "previousrank":
Rank newPreviousRank;
if( valName.Length > 0 ) {
newPreviousRank = RankManager.FindRank( valName );
if( newPreviousRank == null ) {
player.MessageNoRank( valName );
return;
}
} 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 );
}
return;
}
if( oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
info.ClassyName,
newPreviousRank.ClassyName );
} else if( newPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
info.ClassyName,
oldPreviousRank.ClassyName );
} else {
player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
info.ClassyName,
oldPreviousRank.ClassyName,
newPreviousRank.ClassyName );
}
break;
case "totaltime":
TimeSpan newTotalTime;
TimeSpan oldTotalTime = info.TotalTime;
if( valName.TryParseMiniTimespan( out newTotalTime ) ) {
if( newTotalTime > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
info.TotalTime = newTotalTime;
player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
info.ClassyName,
oldTotalTime.ToMiniString(),
oldTotalTime.ToCompactString(),
info.TotalTime.ToMiniString(),
info.TotalTime.ToCompactString() );
break;
} else {
player.Message( "SetInfo: Could not parse value given for TotalTime." );
return;
}
case "rankchangetype":
RankChangeType oldType = info.RankChangeType;
try {
info.RankChangeType = (RankChangeType)Enum.Parse( typeof( RankChangeType ), valName, true );
} catch( ArgumentException ) {
player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
String.Join( ", ", Enum.GetNames( typeof( RankChangeType ) ) ) );
return;
}
//.........这里部分代码省略.........
示例9: 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.FindPlayerInfoOrPrintMatches( player, targetName, SearchOptions.IncludeSelf );
if( info == null ) return;
switch( propertyName.ToLower() ) {
case "timeskicked":
case "tk":
int oldTimesKicked = info.TimesKicked;
if( ValidateInt( valName, 0, 9999 ) ) {
info.TimesKicked = Int32.Parse( valName );
player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
info.ClassyName,
oldTimesKicked,
info.TimesKicked );
break;
} else {
player.Message( "SetInfo: TimesKicked value out of range (acceptable: 0-9999)" );
return;
}
case "previousrank":
case "pr":
Rank newPreviousRank;
if( valName.Length > 0 ) {
newPreviousRank = RankManager.FindRank( valName );
if( newPreviousRank == null ) {
player.MessageNoRank( valName );
return;
}
} else {
newPreviousRank = null;
}
Rank oldPreviousRank = info.PreviousRank;
if( newPreviousRank == null && oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
info.ClassyName );
return;
} else if( newPreviousRank == oldPreviousRank ) {
player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
info.ClassyName,
newPreviousRank.ClassyName );
return;
}
info.PreviousRank = newPreviousRank;
if( oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
info.ClassyName,
newPreviousRank.ClassyName );
} else if( newPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
info.ClassyName,
oldPreviousRank.ClassyName );
} else {
player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
info.ClassyName,
oldPreviousRank.ClassyName,
newPreviousRank.ClassyName );
}
break;
case "totaltime":
case "tt":
TimeSpan newTotalTime;
TimeSpan oldTotalTime = info.TotalTime;
if( valName.TryParseMiniTimeSpan( out newTotalTime ) ) {
if( newTotalTime > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
info.TotalTime = newTotalTime;
player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
info.ClassyName,
oldTotalTime.ToMiniString(),
oldTotalTime.ToCompactString(),
info.TotalTime.ToMiniString(),
info.TotalTime.ToCompactString() );
break;
} else {
player.Message( "SetInfo: Could not parse value given for TotalTime." );
return;
}
case "rankchangetype":
case "rct":
RankChangeType oldType = info.RankChangeType;
RankChangeType newType;
if(!EnumUtil.TryParse(valName, out newType, true)){
player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
//.........这里部分代码省略.........
示例10: 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.FindPlayerInfoOrPrintMatches(player, targetName, SearchOptions.IncludeSelf);
if( info == null ) return;
switch( propertyName.ToLower() ) {
case "timeskicked":
case "tk":
int oldTimesKicked = info.TimesKicked;
if( ValidateInt( valName, 0, 9999 ) ) {
info.TimesKicked = Int32.Parse( valName );
player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
info.ClassyName,
oldTimesKicked,
info.TimesKicked );
break;
} else {
player.Message( "SetInfo: TimesKicked value out of range (acceptable: 0-9999)" );
return;
}
case "previousrank":
case "pr":
Rank newPreviousRank;
if( valName.Length > 0 ) {
newPreviousRank = RankManager.FindRank( valName );
if( newPreviousRank == null ) {
player.MessageNoRank( valName );
return;
}
} else {
newPreviousRank = null;
}
Rank oldPreviousRank = info.PreviousRank;
if( newPreviousRank == null && oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
info.ClassyName );
return;
} else if( newPreviousRank == oldPreviousRank ) {
player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
info.ClassyName,
newPreviousRank.ClassyName );
return;
}
info.PreviousRank = newPreviousRank;
if( oldPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
info.ClassyName,
newPreviousRank.ClassyName );
} else if( newPreviousRank == null ) {
player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
info.ClassyName,
oldPreviousRank.ClassyName );
} else {
player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
info.ClassyName,
oldPreviousRank.ClassyName,
newPreviousRank.ClassyName );
}
break;
case "totaltime":
case "tt":
TimeSpan newTotalTime;
TimeSpan oldTotalTime = info.TotalTime;
if( valName.TryParseMiniTimespan( out newTotalTime ) ) {
if( newTotalTime > DateTimeUtil.MaxTimeSpan ) {
player.MessageMaxTimeSpan();
return;
}
info.TotalTime = newTotalTime;
player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
info.ClassyName,
oldTotalTime.ToMiniString(),
oldTotalTime.ToCompactString(),
info.TotalTime.ToMiniString(),
info.TotalTime.ToCompactString() );
break;
} else {
player.Message( "SetInfo: Could not parse value given for TotalTime." );
return;
}
case "donatedammount":
case "da":
if (player != Player.Console) {
player.Message("&WYou are not able to Set a players Donated Ammount.");
return;
}
//.........这里部分代码省略.........
示例11: TimerHandler
static void TimerHandler(Player player, CommandReader cmd)
{
string param = cmd.Next();
// List timers
if (param == null)
{
ChatTimer[] list = ChatTimer.TimerList.OrderBy(timer => timer.TimeLeft).ToArray();
if (list.Length == 0)
{
player.Message("No timers running.");
}
else
{
player.Message("There are {0} timers running:", list.Length);
foreach (ChatTimer timer in list)
{
if (timer.Message.Equals(""))
{
player.Message(" #{0} \"&7*CountDown*&s\" (started by {2}, {3} left)",
timer.ID, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
}
else
{
player.Message(" #{0} \"{1}&s\" (started by {2}, {3} left)",
timer.ID, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
}
}
}
return;
}
// Abort a timer
if (param.Equals("abort", StringComparison.OrdinalIgnoreCase))
{
int timerId;
if (cmd.NextInt(out timerId))
{
ChatTimer timer = ChatTimer.FindTimerById(timerId);
if (timer == null || !timer.IsRunning)
{
player.Message("Given timer (#{0}) does not exist.", timerId);
}
else
{
timer.Abort();
string abortMsg = "";
string abortircMsg = "";
if (timer.Message.Equals(""))
{
abortMsg = String.Format("&S{0}&S aborted a &7CountDown&S with {1} left",
player.ClassyName, timer.TimeLeft.ToMiniString());
abortircMsg = String.Format("\u212C&S{0}&S aborted a &7CountDown&S with {1} left",
player.ClassyName, timer.TimeLeft.ToMiniString());
}
else
{
abortMsg = String.Format("&S{0}&S aborted a &7Timer&S with {1} left: &7{2}",
player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
abortircMsg = String.Format( "\u212C&S{0}&S aborted a &7Timer&S with {1} left: \u211C{2}",
player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
}
Server.Players.Message(abortMsg);
IRC.SendChannelMessage(abortircMsg);
}
}
else
{
CdTimer.PrintUsage(player);
}
return;
}
// Start a timer
if (player.Info.IsMuted)
{
player.MessageMuted();
return;
}
if (player.DetectChatSpam()) return;
TimeSpan duration;
if (!param.TryParseMiniTimespan(out duration))
{
CdTimer.PrintUsage(player);
return;
}
if (duration > DateTimeUtil.MaxTimeSpan)
{
player.MessageMaxTimeSpan();
return;
}
if (duration < ChatTimer.MinDuration)
{
player.Message("Timer: Must be at least 1 second.");
return;
}
string sayMessage;
string ircMessage;
string message = cmd.NextAll();
//.........这里部分代码省略.........