MakeSetPermission() 정적인 개인적인 메소드

static private MakeSetPermission ( [ player ) : Packet
player [
리턴 Packet
예제 #1
0
        // Change player class
        void ChangeClass(Player player, Command cmd)
        {
            string name         = cmd.Next();
            string newClassName = cmd.Next();

            if (name == null || newClassName == null)
            {
                player.Message("Usage: " + Color.Help + "/user PlayerName ClassName");
                player.Message("To see a list of classes and permissions, use " + Color.Help + "/class");
                return;
            }

            Player target = world.FindPlayer(name);

            if (target == null)
            {
                world.NoPlayerMessage(player, name);
                return;
            }

            PlayerClass newClass = world.classes.FindClass(newClassName);

            if (newClass == null)
            {
                player.Message("Unrecognized player class: " + newClassName);
                return;
            }

            if (target.info.playerClass == newClass)
            {
                player.Message(target.name + "'s class is already " + newClass.color + newClass.name);
                return;
            }

            bool promote = target.info.playerClass.rank < newClass.rank;

            if ((promote && !player.Can(Permissions.Promote)) || !promote && !player.Can(Permissions.Demote))
            {
                world.NoAccessMessage(player);
                return;
            }

            if (promote && !player.info.playerClass.CanPromote(newClass))
            {
                PlayerClass maxRank = player.info.playerClass.maxPromote;
                if (maxRank == null)
                {
                    player.Message("You can only promote players up to " + player.info.playerClass.color + player.info.playerClass.name);
                }
                else
                {
                    player.Message("You can only promote players up to " + maxRank.color + maxRank.name);
                }
                return;
            }
            else if (!promote && !player.info.playerClass.CanDemote(target.info.playerClass))
            {
                PlayerClass maxRank = player.info.playerClass.maxDemote;
                if (maxRank == null)
                {
                    player.Message("You can only demote players that are " + player.info.playerClass.color + player.info.playerClass.name + Color.Sys + " or lower.");
                }
                else
                {
                    player.Message("You can only demote players that are " + maxRank.color + maxRank.name + Color.Sys + " or lower.");
                }
                return;
            }

            if (promote && target.info.playerClass.rank < newClass.rank ||
                target.info.playerClass.rank > newClass.rank)
            {
                world.log.Log("{0} changed the class of {1} from {2} to {3}.", LogType.UserActivity,
                              player.name, target.info.name, target.info.playerClass.name, newClass.name);
                target.info.playerClass     = newClass;
                target.info.classChangeDate = DateTime.Now;
                target.info.classChangedBy  = player.name;

                target.Send(PacketWriter.MakeSetPermission(target));

                if (promote)
                {
                    player.Message("You promoted " + target.name + " to " + newClass.color + newClass.name + ".");
                    target.Message("You have been promoted to " + newClass.color + newClass.name + Color.Sys + " by " + player.name + "!");
                }
                else
                {
                    player.Message("You demoted " + target.name + " to " + newClass.color + newClass.name + ".");
                    target.Message("You have been demoted to " + newClass.color + newClass.name + Color.Sys + " by " + player.name + "!");
                }
                if (world.config.GetBool("ClassPrefixesInList") || world.config.GetBool("ClassColorsInChat"))       // TODO: colors in player names
                {
                    world.UpdatePlayer(target);
                }
                target.mode = BlockPlacementMode.Normal;
            }
            else
            {
                if (promote)
                {
                    player.Message(target.name + " is already same or lower rank than " + newClass.name);
                }
                else
                {
                    player.Message(target.name + " is already same or higher rank than " + newClass.name);
                }
            }
        }