当前位置: 首页>>代码示例>>C#>>正文


C# Player.MessageNoPlayer方法代码示例

本文整理汇总了C#中fCraft.Player.MessageNoPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessageNoPlayer方法的具体用法?C# Player.MessageNoPlayer怎么用?C# Player.MessageNoPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fCraft.Player的用法示例。


在下文中一共展示了Player.MessageNoPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UndoAllHandler

 public static void UndoAllHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         CdUndoAll.PrintUsage(player);
     }
     PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     UndoPlayerHandler2(player, new Command("/undox " + target.Name + " 10000000"));
 }
开发者ID:Eeyle,项目名称:LegendCraftSource,代码行数:15,代码来源:BuildingCommands.cs

示例2: Tempban

        static void Tempban(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string timeString = cmd.Next();
            TimeSpan duration;
            try{
                if (String.IsNullOrEmpty(targetName) || String.IsNullOrEmpty(timeString) ||
                !timeString.TryParseMiniTimespan(out duration) || duration <= TimeSpan.Zero)
                {
                    CdTempBan.PrintUsage(player);
                    return;
                }
            }catch (OverflowException){
                player.Message("TempBan: Given duration is too long.");
                return;
            }

            // find the target
            PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);

            if (target == null){
                player.MessageNoPlayer(targetName);
                return;
            };

            if (target.Name == player.Name){
                player.Message("Trying to T-Ban yourself? Fail!");
                return;
            }

            // check permissions
            if (!player.Can(Permission.BanIP, target.Rank)){
                player.Message("You can only Temp-Ban players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit(Permission.BanIP).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName);
                return;
            }

            // do the banning
            if (target.Tempban(player.Name, duration)){
                string reason = cmd.NextAll();
                try{
                    Player targetPlayer = target.PlayerObject;
                    target.Ban(player, "You were Banned for " + timeString, false, true);
                    Server.TempBans.Add(targetPlayer);
                }
                catch (PlayerOpException ex){
                    player.Message(ex.MessageColored);
                }
                Scheduler.NewTask(t => Untempban(player, target)).RunOnce(duration);
                Server.Message("&SPlayer {0}&S was Banned by {1}&S for {2}",
                                target.ClassyName, player.ClassyName, duration.ToMiniString());
                if (reason.Length > 0) Server.Message("&Wreason: {0}", reason);
                Logger.Log(LogType.UserActivity, "Player {0} was Banned by {1} for {2}",
                            target.Name, player.Name, duration.ToMiniString());
            }else{
                player.Message("Player {0}&S is already Banned by {1}&S for {2:0} more.",
                                target.ClassyName,
                                target.BannedBy,
                                target.BannedUntil.Subtract(DateTime.UtcNow).ToMiniString());
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:62,代码来源:ModerationCommands.cs

示例3: RankHandler

        public static void RankHandler( Player player, Command cmd )
        {
            string name = cmd.Next();
            string newRankName = cmd.Next();

            // Check arguments
            if( name == null || newRankName == null ) {
                CdRank.PrintUsage( player );
                player.Message( "See &H/Ranks&S for list of ranks." );
                return;
            }

            // Parse rank name
            Rank newRank = RankManager.FindRank( newRankName );
            if( newRank == null ) {
                player.MessageNoRank( newRankName );
                return;
            }

            // Parse player name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }
            PlayerInfo targetInfo = PlayerDB.FindPlayerInfoExact( name );

            if( targetInfo == null ) {
                if( !player.Can( Permission.EditPlayerDB ) ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                if( !Player.IsValidName( name ) ) {
                    player.MessageInvalidPlayerName( name );
                    CdRank.PrintUsage( player );
                    return;
                }
                if( cmd.IsConfirmed ) {
                    if( newRank > RankManager.DefaultRank ) {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                    } else {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Demoted );
                    }
                } else {
                    player.Confirm( cmd,
                                    "Warning: Player \"{0}\" is not in the database (possible typo). Type the full name or",
                                    name );
                    return;
                }
            }

            try {
                player.LastUsedPlayerName = targetInfo.Name;

                //reset temprank values
                if (targetInfo.isTempRanked)
                {
                    targetInfo.isTempRanked = false;
                    targetInfo.tempRankTime = TimeSpan.FromSeconds(0);
                }
                targetInfo.ChangeRank( player, newRank, cmd.NextAll(), true, true, false );
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:68,代码来源:ModerationCommands.cs

示例4: Warn

        internal static void Warn(Player player, Command cmd)
        {
            string name = cmd.Next();

            if (name == null)
            {
                player.Message("No player specified.");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(name);
                return;
            }

            if (player.Can(Permission.Warn, target.Info.Rank))
            {
                target.Info.IsHidden = false;
                if (target.Info.Warn(player.Name))
                {
                    Server.Message("{0}&S has been warned by {1}",
                                      target.ClassyName, player.ClassyName);
                    Scheduler.NewTask(t => target.Info.UnWarn()).RunOnce(TimeSpan.FromMinutes(15));
                }
                else
                {
                    try
                    {
                        Player targetPlayer = target;
                        target.Kick(player, "Auto Kick (2 warnings or more)", LeaveReason.Kick, true, true, true);
                    }
                    catch (PlayerOpException ex)
                    {
                        player.Message(ex.MessageColored);
                        if (ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired)
                            return;
                    }
                }
            }
            else
            {
                player.Message("You can only warn players ranked {0}&S or lower",
                                player.Info.Rank.GetLimit(Permission.Warn).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:49,代码来源:ModerationCommands.cs

示例5: SetClickHandler

 private static void SetClickHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (String.IsNullOrEmpty(targetName))
     {
         CdSetClickDistance.PrintUsage(player);
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (!target.ClassiCube)
     {
         player.Message("Click distance can only be changed for people playing on ClassiCube");
         return;
     }
     string number = cmd.Next();
     if (number == "normal")
     {
         target.Send(PacketWriter.MakeSetClickDistance(160));
         player.Message("Player {0}&s's click distance was set to normal.", target.ClassyName);
         target.hasCustomClickDistance = false;
         return;
     }
     int distance;
     if (String.IsNullOrEmpty(number) || !Int32.TryParse(number, out distance))
     {
         CdSetClickDistance.PrintUsage(player);
         return;
     }
     if (distance > 20 || distance < 1)
     {
         player.Message("Accepted values are between 1 and 20!");
         return;
     }
     int adjustedDistance = (32 * distance);
     target.Send(PacketWriter.MakeSetClickDistance(adjustedDistance));
     target.hasCustomClickDistance = true;
     player.Message("Player {0}&s's click distance was set to {1} blocks.", target.ClassyName, distance);
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:43,代码来源:ModerationCommands.cs

示例6: TeleportHandler

        static void TeleportHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                CdTeleport.PrintUsage( player );
                return;
            }

            if( cmd.Next() != null ) {
                cmd.Rewind();
                int x, y, z;
                if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {

                    if( x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024 ) {
                        player.Message( "Coordinates are outside the valid range!" );

                    } else {
                        player.TeleportTo( new Position {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        } );
                    }
                } else {
                    CdTeleport.PrintUsage( player );
                }

            } else {
                if( name == "-" ) {
                    if( player.LastUsedPlayerName != null ) {
                        name = player.LastUsedPlayerName;
                    } else {
                        player.Message( "Cannot repeat player name: you haven't used any names yet." );
                        return;
                    }
                }
                Player[] matches = Server.FindPlayers( player, name, false, true, true );
                if( matches.Length == 1 ) {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if( targetWorld == null ) PlayerOpException.ThrowNoWorld( target );

                    if( targetWorld == player.World ) {
                        player.TeleportTo( target.Position );

                    } else {
                        switch( targetWorld.AccessSecurity.CheckDetailed( player.Info ) ) {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if( targetWorld.IsFull ) {
                                    player.Message( "Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName );
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld( targetWorld, WorldChangeReason.Tp, target.Position );
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message( "Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName );
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message( "Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName );
                                break;
                        }
                    }

                } else if( matches.Length > 1 ) {
                    player.MessageManyMatches( "player", matches );

                } else {
                    player.MessageNoPlayer( name );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:81,代码来源:ModerationCommands.cs

示例7: High5

        internal static void High5(Player player, Command cmd)
        {
            string targetName = cmd.Next();

            if (targetName == null)
            {
                cdHigh5.PrintUsage(player);
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(targetName);
                return;
            }
            if (target == player)
            {
                player.Message("You cannot high five yourself.");
                return;
            }
            else
            {
                if (target.IsOnline)
                {
                    Server.Players.Message("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName);
                    target.Message("{0}&S high fived you.", player.ClassyName);
                }
                else
                {
                    player.Message("Player {0}&S is not online.", target.ClassyName);
                }
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:35,代码来源:ChatCommands.cs

示例8: BrofistHandler

 static void BrofistHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         player.Message("Enter a playername.");
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player)
     {
         Server.Players.CanSee(target).Except(target).Message("{1}&S just tried to &8Brofist &Sthemsleves...", target.ClassyName, player.ClassyName);
         IRC.PlayerSomethingMessage(player, "brofisted", target, null);
         player.Message("&SYou just tried to &8Brofist &Syourself... That's sad...");
         return;
     }
     Server.Players.CanSee(target).Except(target).Message("{1}&S gave {0}&S a &8Brofist&S.", target.ClassyName, player.ClassyName);
     IRC.PlayerSomethingMessage(player, "brofisted", target, null);
     target.Message("{0}&S's fist met yours for a &8Brofist&S.", player.ClassyName);
 }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:25,代码来源:ChatCommands.cs

示例9: RealmAccess

        internal static void RealmAccess(Player player, Command cmd, string worldName, string name)
        {
            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("Error.");
                }
                else
                {
                    player.Message(player.World.AccessSecurity.GetDescription(player.World, "realm", "accessed"));
                }
                return;
            }

            // Find a realm by name
            World realm = WorldManager.FindWorldOrPrintMatches(player, worldName);
            if (realm == null) return;

            if (name == null)
            {
                player.Message(realm.AccessSecurity.GetDescription(realm, "realm", "accessed"));
                return;
            }
            if (realm == WorldManager.MainWorld)
            {
                player.Message("The main realm cannot have access restrictions.");
                return;
            }

            bool changesWereMade = false;
            do
            {
                if (name.Length < 2) continue;
                // Whitelisting individuals
                if (name.StartsWith("+"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;

                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    // prevent players from whitelisting themselves to bypass protection

                    if (realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.Allowed)
                    {
                        player.Message("{0}&S is already allowed to access {1}&S (by rank)",
                                        info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player) target = null; // to avoid duplicate messages

                    switch (realm.AccessSecurity.Include(info))
                    {
                        case PermissionOverride.Deny:
                            if (realm.AccessSecurity.Check(info))
                            {
                                player.Message("{0}&S is unbanned from Realm {1}",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You are now unbanned from Realm {0}&S (removed from blacklist by {1}&S).",
                                                    realm.ClassyName, player.ClassyName);
                                }
                            }
                            else
                            {
                                player.Message("{0}&S was unbanned from Realm {1}&S. " +
                                                "Player is still NOT allowed to join (by rank).",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You were Unbanned from Realm {0}&S by {1}&S. " +
                                                    "You are still NOT allowed to join (by rank).",
                                                    player.ClassyName, realm.ClassyName);
                                }
                            }
                            Logger.Log(LogType.UserActivity, "{0} removed {1} from the access blacklist of {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.None:
                            player.Message("{0}&S is now allowed to access {1}",
                                            info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You can now access realm {0}&S (whitelisted by {1}&S).",
                                                realm.ClassyName, player.ClassyName);
//.........这里部分代码省略.........
开发者ID:727021,项目名称:800craft,代码行数:101,代码来源:RealmHandler.cs

示例10: TPHandler2


//.........这里部分代码省略.........

            if (cmd.Next() != null)
            {
                cmd.Rewind();
                int x, y, z;
                if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z))
                {

                    if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024)
                    {
                        player.Message("Coordinates are outside the valid range!");

                    }
                    else
                    {
                        player.TeleportTo(new Position
                        {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        });
                    }
                }
                else
                {
                    return;
                }

            }
            else
            {
                Player[] matches = Server.FindPlayers(player, name, true);
                if (matches.Length == 1)
                {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if (targetWorld == null) PlayerOpException.ThrowNoWorld(target);

                    if (targetWorld == player.World)
                    {
                        player.TeleportTo(target.Position);

                    }
                    else
                    {
                        switch (targetWorld.AccessSecurity.CheckDetailed(player.Info))
                        {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if (targetWorld.IsFull)
                                {
                                    player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName);
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message("Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName);
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message("Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName);
                                break;
                            // TODO: case PermissionType.RankTooHigh:
                        }
                    }

                }
                else if (matches.Length > 1)
                {
                    player.MessageManyMatches("player", matches);

                }
                else
                {
                    // Try to guess if player typed "/TP" instead of "/Join"
                    World[] worlds = WorldManager.FindWorlds(player, name);

                    if (worlds.Length == 1)
                    {
                        player.LastUsedWorldName = worlds[0].Name;
                        player.StopSpectating();
                        player.ParseMessage("/Join " + worlds[0].Name, false);
                    }
                    else
                    {
                        player.MessageNoPlayer(name);
                    }
                }
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:101,代码来源:ModerationCommands.cs

示例11: Give

 internal static void Give(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         player.Message("&WPlease insert a playername");
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player)
     {
         player.Message("&WYou cannot give yourself something.");
         return;
     }
     string item = cmd.Next();
     if (item == null)
     {
         player.Message("&WPlease insert an item.");
         return;
     }
     string itemnumber = cmd.Next();
     if (itemnumber == null)
     {
         player.Message("&WPlease insert the item number.");
         return;
     }
     else
     {
         Server.Players.CanSee(target).Message("{0} &egave {1} &e{2} {3}.", player.ClassyName, target.ClassyName, itemnumber, item);
     }
 }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:36,代码来源:ChatCommands.cs

示例12: High5Handler

 internal static void High5Handler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null){
         cdHigh5.PrintUsage(player);
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null){
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player) {
         player.Message("You cannot high five yourself.");
         return;
     }
     Server.Players.CanSee(target).Except(target).Message("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName);
     IRC.IRCAnnounceCustom(String.Format("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName));
     target.Message("{0}&S high fived you.", player.ClassyName);
 }
开发者ID:Bedrok,项目名称:800craft,代码行数:20,代码来源:ChatCommands.cs

示例13: SetSpawnHandler

        static void SetSpawnHandler(Player player, Command cmd)
        {
            string playerName = cmd.Next();
            if (playerName == null)
            {
                player.World.Map.Spawn = player.Position;
                player.TeleportTo(player.World.Map.Spawn);
                player.Send(PacketWriter.MakeAddEntity(255, player.ListName, player.Position));
                player.Message("New spawn point saved.");
                Logger.Log(LogType.UserActivity, "{0} changed the spawned point.",
                            player.Name);

            }
            else if (player.Can(Permission.Bring))
            {
                Player[] infos = player.World.FindPlayers(player, playerName);
                if (infos.Length == 1)
                {
                    Player target = infos[0];
                    if (player.Can(Permission.Bring, target.Info.Rank))
                    {
                        target.Send(PacketWriter.MakeAddEntity(255, target.ListName, player.Position));
                    }
                    else
                    {
                        player.Message("You can only set spawn of players ranked {0}&S or lower.",
                                        player.Info.Rank.GetLimit(Permission.Bring).ClassyName);
                        player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                    }

                }
                else if (infos.Length > 0)
                {
                    player.MessageManyMatches("player", infos);

                }
                else
                {
                    infos = Server.FindPlayers(player, playerName, true);
                    if (infos.Length > 0)
                    {
                        player.Message("You can only set spawn of players on the same world as you.");
                    }
                    else
                    {
                        player.MessageNoPlayer(playerName);
                    }
                }
            }
            else
            {
                player.MessageNoAccess(CdRealm);
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:54,代码来源:WorldCommands.cs

示例14: Tempban

        static void Tempban(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string timeString = cmd.Next();
            TimeSpan duration;

            try
            {
                // validate command parameters
                if (targetName == null || !Player.IsValidName(targetName) ||
                    timeString == null || !timeString.TryParseMiniTimespan(out duration) ||
                    duration <= TimeSpan.Zero)
                {
                    player.Message("Invalid input");
                    return;
                }
            }
            catch (OverflowException)
            {
                player.Message("TempBan: Given duration is too long.");
                return;
            }

            // find the target
            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(targetName);
                return;
            };

            if (target == player)
            {
                player.Message("Trying to T-Ban yourself? Fail!");
                return;
            }

            // check permissions
            if (!player.Can(Permission.BanIP, target.Info.Rank))
            {
                player.Message("You can only Temp-Ban players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit(Permission.BanIP).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                return;
            }

            // do the banning
            if (target.Info.Tempban(player.Name, duration))
            {
                PlayerInfo targets = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);
                if (targets == null) return;
                string reason = cmd.NextAll();
                try
                {
                    Player targetPlayer = targets.PlayerObject;
                    targets.Ban(player, "You were Banned for " + timeString + " Seconds", true, true);

                }
                catch (PlayerOpException ex)
                {
                    player.Message(ex.MessageColored);

                }

                Scheduler.NewTask(t => target.Info.Unban(player, "Tempban Expired", true, true)).RunOnce(duration);
                Server.Message(target,
                                "&SPlayer {0}&S was Banned by {1}&S for {2}",
                                target.ClassyName, player.ClassyName, duration.ToMiniString());
                Logger.Log(LogType.UserActivity, "Player {0} was Banned by {1} for {2}",
                            target.Name, player.Name, duration.ToMiniString());
            }
            else
            {
                player.Message("Player {0}&S is already Banned by {1}&S for {2:0} more.",
                                target.ClassyName,
                                target.Info.MutedBy,
                                target.Info.MutedUntil.Subtract(DateTime.UtcNow).ToMiniString());
            }
        }
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:80,代码来源:ModerationCommands.cs

示例15: RankHandler

        static void RankHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            string newRankName = cmd.Next();

            // Check arguments
            if( name == null || newRankName == null ) {
                CdRank.PrintUsage( player );
                player.Message( "See &H/Ranks&S for list of ranks." );
                return;
            }

            // Parse rank name
            Rank newRank = RankManager.FindRank( newRankName );
            if( newRank == null ) {
                player.MessageNoRank( newRankName );
                return;
            }

            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }
            PlayerInfo targetInfo;

            // Find player by name
            if( name.StartsWith( "!" ) ) {
                name = name.Substring( 1 );
                Player target = Server.FindPlayerExact( player, name, false );
                if( target == null ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                targetInfo = target.Info;
            } else {
                targetInfo = PlayerDB.FindPlayerInfoExact( name );
            }

            // Handle non-existent players
            if( targetInfo == null ) {
                if( !player.Can( Permission.EditPlayerDB ) ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                if( !Player.IsValidName( name ) ) {
                    player.MessageInvalidPlayerName( name );
                    CdRank.PrintUsage( player );
                    return;
                }
                if( cmd.IsConfirmed ) {
                    if( newRank > RankManager.DefaultRank ) {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                    } else {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Demoted );
                    }
                } else {
                    Logger.Log( LogType.UserActivity,
                                "Rank: Asked {0} to confirm adding unrecognized name \"{1}\" to the database.",
                                player.Name, name );
                    player.Confirm( cmd,
                                    "Warning: Player \"{0}\" is not in the database (possible typo). Type the full name or",
                                    name );
                    return;
                }
            }

            try {
                player.LastUsedPlayerName = targetInfo.Name;
                targetInfo.ChangeRank( player, newRank, cmd.NextAll(), true, true, false );
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:76,代码来源:ModerationCommands.cs


注:本文中的fCraft.Player.MessageNoPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。