PrintUsage() публичный Метод

Prints command usage syntax to the given player.
public PrintUsage ( [ player ) : void
player [
Результат void
Пример #1
0
 static void ClearHandler(Player player, Command cmd)
 {
     if (cmd.HasNext)
     {
         CdClear.PrintUsage(player);
         return;
     }
     for (int i = 0; i < LinesToClear; i++)
     {
         player.Message("");
     }
 }
Пример #2
0
        static void RedoHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            if (cmd.HasNext)
            {
                CdRedo.PrintUsage(player);
                return;
            }

            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            UndoState redoState = player.RedoPop();

            if (redoState == null)
            {
                player.MessageNow("There is currently nothing to redo.");
                return;
            }

            string msg = "Redo: ";

            if (redoState.Op != null && !redoState.Op.IsDone)
            {
                redoState.Op.Cancel();
                msg += String.Format("Cancelled {0} (was {1}% done). ",
                                     redoState.Op.Description,
                                     redoState.Op.PercentDone);
            }

            // no need to set player.drawingInProgress here because this is done on the user thread
            Logger.Log(LogType.UserActivity,
                       "Player {0} initiated /Redo affecting {1} blocks (on world {2})",
                       player.Name,
                       redoState.Buffer.Count,
                       playerWorld.Name);

            msg += String.Format("Restoring {0} blocks. Type &H/Undo&S to reverse.",
                                 redoState.Buffer.Count);
            player.MessageNow(msg);

            var op = new UndoDrawOperation(player, redoState, true);

            op.Prepare(new Vector3I[0]);
            op.Begin();
        }
Пример #3
0
        private static void QuitHandler(Player player, Command cmd)
        {
            string Msg = cmd.NextAll();

            if (Msg.Length < 1)
            {
                CdQuit.PrintUsage(player);
                return;
            }
            else
            {
                player.Info.LeaveMsg = "left the server: &C" + Msg;
                player.Message("Your quit message is now set to: {0}", Msg);
            }
        }
Пример #4
0
        static void InfoSwapHandler(Player player, CommandReader cmd)
        {
            string p1Name = cmd.Next();
            string p2Name = cmd.Next();

            if (p1Name == null || p2Name == null)
            {
                CdInfoSwap.PrintUsage(player);
                return;
            }

            PlayerInfo p1 = PlayerDB.FindByPartialNameOrPrintMatches(player, p1Name);

            if (p1 == null)
            {
                return;
            }
            PlayerInfo p2 = PlayerDB.FindByPartialNameOrPrintMatches(player, p2Name);

            if (p2 == null)
            {
                return;
            }

            if (p1 == p2)
            {
                player.Message("InfoSwap: Please specify 2 different players.");
                return;
            }

            if (p1.IsOnline || p2.IsOnline)
            {
                player.Message("InfoSwap: Both players must be offline to swap info.");
                return;
            }

            if (!cmd.IsConfirmed)
            {
                player.Confirm(cmd, "InfoSwap: Swap stats of players {0}&S and {1}&S?", p1.ClassyName, p2.ClassyName);
            }
            else
            {
                PlayerDB.SwapPlayerInfo(p1, p2);
                player.Message("InfoSwap: Stats of {0}&S and {1}&S have been swapped.",
                               p1.ClassyName, p2.ClassyName);
            }
        }
Пример #5
0
        private static void ZoneRemoveHandler(Player player, Command cmd)
        {
            string zoneName = cmd.Next();

            if (zoneName == null)
            {
                CdZoneRemove.PrintUsage(player);
                return;
            }

            ZoneCollection zones = player.WorldMap.Zones;
            Zone           zone  = zones.Find(zoneName);

            if (zone != null)
            {
                if (!player.Info.Rank.AllowSecurityCircumvention)
                {
                    switch (zone.Controller.CheckDetailed(player.Info))
                    {
                    case SecurityCheckResult.BlackListed:
                        player.Message("You are not allowed to remove zone {0}: you are blacklisted.",
                                       zone.ClassyName);
                        return;

                    case SecurityCheckResult.RankTooLow:
                        player.Message("You are not allowed to remove zone {0}.", zone.ClassyName);
                        return;
                    }
                }
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "Remove zone {0}&S?", zone.ClassyName);
                    return;
                }

                if (zones.Remove(zone.Name))
                {
                    player.Message("Zone \"{0}\" removed.", zone.Name);
                }
            }
            else
            {
                player.MessageNoZone(zoneName);
            }
        }
Пример #6
0
        static void IgnoreHandler(Player player, CommandReader cmd)
        {
            string name = cmd.Next();

            if (name != null)
            {
                if (cmd.HasNext)
                {
                    CdIgnore.PrintUsage(player);
                    return;
                }
                PlayerInfo targetInfo = PlayerDB.FindByPartialNameOrPrintMatches(player, name);
                if (targetInfo == null)
                {
                    return;
                }

                if (targetInfo == player.Info)
                {
                    player.MessageNow("You cannot ignore yourself.");
                    return;
                }

                if (player.Ignore(targetInfo))
                {
                    player.MessageNow("You are now ignoring {0}", targetInfo.ClassyName);
                }
                else
                {
                    player.MessageNow("You are already ignoring {0}", targetInfo.ClassyName);
                }
            }
            else
            {
                PlayerInfo[] ignoreList = player.IgnoreList;
                if (ignoreList.Length > 0)
                {
                    player.MessageNow("Ignored players: {0}", ignoreList.JoinToClassyString());
                }
                else
                {
                    player.MessageNow("You are not currently ignoring anyone.");
                }
            }
        }
Пример #7
0
        static void DoNotMarkHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool doNotMark = !player.DisableClickToMark;

            if (cmd.HasNext && !cmd.NextOnOff(out doNotMark))
            {
                CdDoNotMark.PrintUsage(player);
            }
            player.DisableClickToMark = doNotMark;
            if (doNotMark)
            {
                player.Message("Click-to-mark disabled.");
            }
            else
            {
                player.Message("Click-to-mark re-enabled.");
            }
        }
Пример #8
0
        private static void SpringHandler(Player player, Command cmd)        //for /spring
        {
            string revolutions = cmd.Next();
            int    rev;
            bool   parsed = Int32.TryParse(revolutions, out rev); //tries to convert input to int

            if (player.Can(Permission.DrawAdvanced))
            {
                PrepareSpring.SetParametrization(player, new Command("/scp x=(1+0.2*cos(2*pi*v))*sin(2*pi*u)"));
                PrepareSpring.SetParametrization(player, new Command("/scp y=(1+0.2*cos(2*pi*v))*cos(2*pi*u)"));
                PrepareSpring.SetParametrization(player, new Command("/scp z=u+0.2*sin(2*pi*v)"));

                if (revolutions == null || rev == 1)     //if number of revolutions isnt specified, just does 1
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 1 0.005"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 1 0.005"));
                }

                else if (rev > 9 || rev <= 0)        //The greatest number of revolutions without having to adjust the number of iteration steps. I would adjust the number
                {                                    // of iterations per requested number of revolutions, but it would make the spring look like the blocks were placed too sparingly.
                    player.Message("The number of revolutions must be between 1 and 9.");
                    return;
                }

                else if (rev > 1 && rev < 5)         //different amount of iteration steps when different number of revolutions. Makes the springs look more filled in.
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 " + rev + " 0.005"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 " + rev + " 0.005"));
                }

                else if (rev <= 9 && rev >= 5)       //different amount of iteration steps when different number of revolutions. Makes the springs look more filled in.
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 " + rev + " 0.0099"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 " + rev + " 0.0099"));
                }
                StartCmdDraw(player, new Command("/spd uu"));       //uses custom handler as to not display messages to the user
            }
            else
            {
                CdSpring.PrintUsage(player);
            }
        }
Пример #9
0
        private static void UnpossessHandler(Player player, Command cmd)
        {
            string targetName = cmd.Next();

            if (targetName == null)
            {
                CdUnpossess.PrintUsage(player);
                return;
            }
            Player target = Server.FindPlayerOrPrintMatches(player, targetName, true, true);

            if (target == null)
            {
                return;
            }

            if (!player.StopPossessing(target))
            {
                player.Message("You are not currently possessing anyone.");
            }
        }
Пример #10
0
        static void SolidHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool turnSolidOn = (player.GetBind(Block.Stone) != Block.Admincrete);

            if (cmd.HasNext && !cmd.NextOnOff(out turnSolidOn))
            {
                CdSolid.PrintUsage(player);
                return;
            }

            if (turnSolidOn)
            {
                player.Bind(Block.Stone, Block.Admincrete);
                player.Message("Solid: ON. Stone blocks are replaced with admincrete.");
            }
            else
            {
                player.ResetBind(Block.Stone);
                player.Message("Solid: OFF");
            }
        }
Пример #11
0
        static void LavaHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool turnLavaOn = (player.GetBind(Block.Red) != Block.Lava);

            if (cmd.HasNext && !cmd.NextOnOff(out turnLavaOn))
            {
                CdLava.PrintUsage(player);
                return;
            }

            if (turnLavaOn)
            {
                player.Bind(Block.Red, Block.Lava);
                player.Message("Lava: ON. Red blocks are replaced with lava.");
            }
            else
            {
                player.ResetBind(Block.Red);
                player.Message("Lava: OFF");
            }
        }
Пример #12
0
        static void PaintHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool turnPaintOn = (!player.IsPainting);

            if (cmd.HasNext && !cmd.NextOnOff(out turnPaintOn))
            {
                CdPaint.PrintUsage(player);
                return;
            }

            if (turnPaintOn)
            {
                player.IsPainting = true;
                player.Message("Paint mode: ON");
            }
            else
            {
                player.IsPainting = false;
                player.Message("Paint mode: OFF");
            }
        }
Пример #13
0
        static void GrassHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool turnGrassOn = (player.GetBind(Block.Dirt) != Block.Grass);

            if (cmd.HasNext && !cmd.NextOnOff(out turnGrassOn))
            {
                CdGrass.PrintUsage(player);
                return;
            }

            if (turnGrassOn)
            {
                player.Bind(Block.Dirt, Block.Grass);
                player.Message("Grass: ON. Dirt blocks are replaced with grass.");
            }
            else
            {
                player.ResetBind(Block.Dirt);
                player.Message("Grass: OFF");
            }
        }
Пример #14
0
        static void UnignoreHandler(Player player, Command cmd)
        {
            string name = cmd.Next();

            if (name != null)
            {
                if (cmd.HasNext)
                {
                    CdUnignore.PrintUsage(player);
                    return;
                }
                PlayerInfo targetInfo = PlayerDB.FindPlayerInfoOrPrintMatches(player, name);
                if (targetInfo == null)
                {
                    return;
                }

                if (player.Unignore(targetInfo))
                {
                    player.MessageNow("You are no longer ignoring {0}", targetInfo.ClassyName);
                }
                else
                {
                    player.MessageNow("You are not currently ignoring {0}", targetInfo.ClassyName);
                }
            }
            else
            {
                PlayerInfo[] ignoreList = player.IgnoreList;
                if (ignoreList.Length > 0)
                {
                    player.MessageNow("Ignored players: {0}", ignoreList.JoinToClassyString());
                }
                else
                {
                    player.MessageNow("You are not currently ignoring anyone.");
                }
                return;
            }
        }
Пример #15
0
        private static void PossessHandler(Player player, Command cmd)
        {
            string targetName = cmd.Next();

            if (targetName == null)
            {
                CdPossess.PrintUsage(player);
                return;
            }
            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                return;
            }
            if (target.Immortal)
            {
                player.Message("You cannot possess {0}&S, they are immortal", target.ClassyName);
                return;
            }
            if (target == player)
            {
                player.Message("You cannot possess yourself.");
                return;
            }

            if (!player.Can(Permission.Possess, target.Info.Rank))
            {
                player.Message("You may only possess players ranked {0}&S or lower.",
                               player.Info.Rank.GetLimit(Permission.Possess).ClassyName);
                player.Message("{0}&S is ranked {1}",
                               target.ClassyName, target.Info.Rank.ClassyName);
                return;
            }

            if (!player.Possess(target))
            {
                player.Message("Already possessing {0}", target.ClassyName);
            }
        }
Пример #16
0
        static void UnignoreHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            string name = cmd.Next();

            if (name != null)
            {
                if (cmd.HasNext)
                {
                    // too many parameters given
                    CdUnignore.PrintUsage(player);
                    return;
                }
                // A name was given -- let's find the target
                PlayerInfo targetInfo = PlayerDB.FindPlayerInfoOrPrintMatches(player,
                                                                              name,
                                                                              SearchOptions.ReturnSelfIfOnlyMatch);
                if (targetInfo == null)
                {
                    return;
                }
                if (targetInfo == player.Info)
                {
                    player.Message("You cannot &H/Ignore&S (or &H/Unignore&S) yourself.");
                    return;
                }

                if (player.Unignore(targetInfo))
                {
                    player.MessageNow("You are no longer ignoring {0}", targetInfo.ClassyName);
                }
                else
                {
                    player.MessageNow("You are not currently ignoring {0}", targetInfo.ClassyName);
                }
            }
            else
            {
                ListIgnoredPlayers(player);
            }
        }
Пример #17
0
        static void StaticHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            bool turnStaticOn = (!player.IsRepeatingSelection);

            if (cmd.HasNext && !cmd.NextOnOff(out turnStaticOn))
            {
                CdStatic.PrintUsage(player);
                return;
            }

            if (turnStaticOn)
            {
                player.Message("Static: On");
                player.IsRepeatingSelection = true;
            }
            else
            {
                player.Message("Static: Off");
                player.IsRepeatingSelection = false;
                player.SelectionCancel();
            }
        }
Пример #18
0
 static void DeafenHandler([NotNull] Player player, [NotNull] CommandReader cmd)
 {
     if (cmd.HasNext)
     {
         CdDeafen.PrintUsage(player);
         return;
     }
     if (!player.IsDeaf)
     {
         for (int i = 0; i < LinesToClear; i++)
         {
             player.MessageNow("");
         }
         player.MessageNow("Deafened mode: ON");
         player.MessageNow("You will not see ANY messages until you type &H/Deafen&S again.");
         player.IsDeaf = true;
     }
     else
     {
         player.IsDeaf = false;
         player.MessageNow("Deafened mode: OFF");
     }
 }
Пример #19
0
 static void StoreHandler(Player player, Command cmd)
 {
     try
     {
         string option = cmd.Next();
         string item = cmd.Next();
         string field = cmd.Next();
         if (option == null)
         {
             CdStore.PrintUsage(player);
         }
         if (option == "items")
             {
             if (!player.Can(Permission.Economy))
             {
                 player.Message("&cYou do not have permission to use that command!");
                 return;
             }
             if (option == null)
             {
                 player.Message("&ePlease select an option [items/buy]");
                 return;
             }
Пример #20
0
        internal static void PokeHandler(Player player, Command cmd)
        {
            string targetName = cmd.Next();

            if (targetName == null)
            {
                CdPoke.PrintUsage(player);
                return;
            }
            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                return;
            }
            if (target.Immortal)
            {
                player.Message("&SYou failed to poke {0}&S, they are immortal", target.ClassyName);
                return;
            }
            if (target == player)
            {
                player.Message("You cannot poke yourself.");
                return;
            }
            if (!Player.IsValidName(targetName))
            {
                return;
            }
            else
            {
                target.Message("&8You were just poked by {0}",
                               player.ClassyName);
                player.Message("&8Successfully poked {0}", target.ClassyName);
            }
        }
Пример #21
0
        static void MeHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string msg = cmd.NextAll().Trim(' ');

            if (msg.Length > 0)
            {
                Chat.SendMe(player, msg);
            }
            else
            {
                CdMe.PrintUsage(player);
            }
        }
Пример #22
0
        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)
            {
                return;
            }
            if (target == player)
            {
                player.Message("&WYou 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.PlayerSomethingMessage(player, "high fived", target, null);
            target.Message("{0}&S high fived you.", player.ClassyName);
        }
Пример #23
0
        static void BindHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            if (!cmd.HasNext)
            {
                player.Message("All bindings have been reset.");
                player.ResetAllBinds();
                return;
            }

            Block originalBlock;

            if (!cmd.NextBlock(player, false, out originalBlock))
            {
                return;
            }

            if (!cmd.HasNext)
            {
                if (player.GetBind(originalBlock) != originalBlock)
                {
                    player.Message("{0} is no longer bound to {1}",
                                   originalBlock,
                                   player.GetBind(originalBlock));
                    player.ResetBind(originalBlock);
                }
                else
                {
                    player.Message("{0} is not bound to anything.",
                                   originalBlock);
                }
                return;
            }

            Block replacementBlock;

            if (!cmd.NextBlock(player, false, out replacementBlock))
            {
                return;
            }

            if (cmd.HasNext)
            {
                CdBind.PrintUsage(player);
                return;
            }

            Permission permission = Permission.Build;

            switch (replacementBlock)
            {
            case Block.Grass:
                permission = Permission.PlaceGrass;
                break;

            case Block.Admincrete:
                permission = Permission.PlaceAdmincrete;
                break;

            case Block.Water:
                permission = Permission.PlaceWater;
                break;

            case Block.Lava:
                permission = Permission.PlaceLava;
                break;
            }
            if (player.Can(permission))
            {
                player.Bind(originalBlock, replacementBlock);
                player.Message("{0} is now replaced with {1}", originalBlock, replacementBlock);
            }
            else
            {
                player.Message("&WYou do not have {0} permission.", permission);
            }
        }
Пример #24
0
        static void EconomyHandler(Player player, Command cmd)
        {
            try
            {
                string option = cmd.Next();
                string targetName = cmd.Next();
                string amount = cmd.Next();
                int amountnum;
                if (option == null)
                {
                    CdEconomy.PrintUsage(player);
                }
                if (option == "give")
                {
                    if (!player.Can(Permission.ManageEconomy))
                    {
                        player.Message("&cYou do not have permission to use that command!");
                        return;
                    }
                    if (targetName == null)
                    {
                        player.Message("&ePlease type in a player's name to give coins to.");
                        return;
                    }
                    Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

                    if (target == null)
                    {
                        return;
                    }
                    else
                    {
                        if (!int.TryParse(amount, out amountnum))
                        {
                            player.Message("&eThe amount must be a number without any decimals!");
                            return;
                        }
                        if (cmd.IsConfirmed)
                        {
                            //actually give the player the money
                            int tNewMoney = target.Info.Money + amountnum;

                            if (amountnum == 1)
                            {
                                player.Message("&eYou have given {0} &C{1} &ecoin.", target.ClassyName, amountnum);
                                target.Message("&e{0} &ehas given you {1} &ecoin.", player.ClassyName, amountnum);
                                Server.Players.Except(target).Except(player).Message("&e{0} &ewas given {1} &ecoin by {2}&e.", target.ClassyName, amountnum, player.ClassyName);
                            }
                            else
                            {
                                player.Message("&eYou have given {0} &C{1} &ecoins.", target.ClassyName, amountnum);
                                target.Message("&e{0} &ehas given you {1} &ecoins.", player.ClassyName, amountnum);
                                Server.Players.Except(target).Except(player).Message("&e{0} &ewas given {1} &ecoins by {2}&e.", target.ClassyName, amountnum, player.ClassyName);
                            }

                            target.Info.Money = tNewMoney;
                            return;
                        }
                        else
                        {
                            if (amountnum == 1) {
                            player.Confirm(cmd, "&eAre you sure you want to give {0} &C{1} &ecoin?", target.ClassyName, amountnum);
                            return;
                        }
                        else {
                            player.Confirm(cmd, "&eAre you sure you want to give {0} &C{1} &ecoins?", target.ClassyName, amountnum);
                            return;
                        }
                        }

                    }
                }
                if (option == "take")
                {
                    if (!player.Can(Permission.ManageEconomy))
                    {
                        player.Message("&cYou do not have permission to use that command.");
                        return;
                    }
                    if (targetName == null)
                    {
                        player.Message("&ePlease type in a player's name to take coins away from.");
                        return;
                    }
                    Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

                    if (target == null)
                    {
                        return;
                    }
                    else
                    {
                        if (!int.TryParse(amount, out amountnum))
                        {
                            player.Message("&eThe amount must be a number!");
                            return;
                        }

                        if (cmd.IsConfirmed)
                        {
                            if (amountnum > target.Info.Money)
                            {
                                player.Message("{0}&e doesn't have that many coins!", target.ClassyName);
                                return;
                            }
                            else
                            {
                                //actually give the player the money
                                int tNewMoney = target.Info.Money - amountnum;
                                if (amountnum == 1)
                                {
                                    player.Message("&eYou have taken &c{1}&e coin from {0}.", target.ClassyName, amountnum);
                                    target.Message("&e{0} &ehas taken {1} &ecoin from you.", player.ClassyName, amountnum);
                                    Server.Players.Except(target).Except(player).Message("&e{0} &etook {1} &ecoin from {2}&e.", player.ClassyName, amountnum, target.ClassyName);
                                }
                                else
                                {
                                    player.Message("&eYou have taken &c{1}&e coins from {0}.", target.ClassyName, amountnum);
                                    target.Message("&e{0} &ehas taken {1} &ecoins from you.", player.ClassyName, amountnum);
                                    Server.Players.Except(target).Except(player).Message("&e{0} &etook {1} &ecoins from {2}&e.", player.ClassyName, amountnum, target.ClassyName);
                                }
                                target.Info.Money = tNewMoney;
                                return;
                            }
                        }
                        else
                        {
                            player.Confirm(cmd, "&eAre you sure you want to take &c{1} &ecoins from {0}?", target.ClassyName, amountnum);
                            return;
                        }

                    }


                }
                if (option == "pay")
                {
                    //lotsa idiot proofing in this one ^.^

                    if (targetName == null)
                    {
                        player.Message("&ePlease type in a player's name to pay.");
                        return;
                    }
                    Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
                    if (target == player)
                    {
                        player.Message("You cannot pay youself.");
                        return;
                    }

                    if (target == null)
                    {
                        return;
                    }
                    else
                    {
                        if (!int.TryParse(amount, out amountnum))
                        {
                            player.Message("&eThe amount must be a number!");
                            return;
                        }

                        if (cmd.IsConfirmed)
                        {
                            if (amountnum > player.Info.Money)
                            {
                                player.Message("You don't have enough coins!");
                                return;
                            }
                            else
                            {
                                //show him da monai
                                int pNewMoney = player.Info.Money - amountnum;
                                int tNewMoney = target.Info.Money + amountnum;
                                if (amountnum == 1)
                                {
                                    player.Message("&eYou have paid &C{1}&e coin to {0}.", target.ClassyName, amountnum);
                                    target.Message("&e{0} &ehas paid you {1} &ecoin.", player.ClassyName, amountnum);
                                    Server.Players.Except(target).Except(player).Message("&e{0} &ewas paid {1} &ecoin from {2}&e.", target.ClassyName, amountnum, player.ClassyName);
                                }
                                else
                                {
                                    player.Message("&eYou have paid &C{1}&e coins to {0}.", target.ClassyName, amountnum);
                                    target.Message("&e{0} &ehas paid you {1} &ecoins.", player.ClassyName, amountnum);
                                    Server.Players.Except(target).Except(player).Message("&e{0} &ewas paid {1} &ecoins from {2}&e.", target.ClassyName, amountnum, player.ClassyName);
                                }
                                player.Info.Money = pNewMoney;
                                target.Info.Money = tNewMoney;
                                return;
                            }
                        }
                        else
                        {
                            player.Confirm(cmd, "&eAre you sure you want to pay {0}&e {1} &ecoins? Type /ok to continue.", target.ClassyName, amountnum);
                            return;
                        }


                    }
                }


                else if (option == "show")
                {

                    if (targetName == null)
                    {
                        player.Message("&ePlease type in a player's name to see how many coins they have.");
                        return;
                    }
                    Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

                    if (target == null)
                    {
                        return;
                    }
                    else
                    {
                        //actually show how much money that person has
                        player.Message("&e{0} has &C{1} &ecoins!", target.ClassyName, target.Info.Money);
                    }

                }
                else
                {
                    player.Message("&eOptions are &a/Economy pay&e, &a/Economy take&e, &a/Economy give&e, and &a/Economy show&e.");
                    return;
                }
            }
            catch (ArgumentNullException)
            {
                CdEconomy.PrintUsage(player);
            }
        }
Пример #25
0
        static void MirrorHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            CopyState originalInfo = player.GetCopyState();

            if (originalInfo == null)
            {
                player.MessageNow("Nothing to flip! Copy something first.");
                return;
            }

            // clone to avoid messing up any paste-in-progress
            CopyState info = new CopyState(originalInfo);

            bool flipX = false,
                 flipY = false,
                 flipH = false;
            string axis;

            while ((axis = cmd.Next()) != null)
            {
                foreach (char c in axis.ToLower())
                {
                    if (c == 'x')
                    {
                        flipX = true;
                    }
                    if (c == 'y')
                    {
                        flipY = true;
                    }
                    if (c == 'z')
                    {
                        flipH = true;
                    }
                }
            }

            if (!flipX && !flipY && !flipH)
            {
                CdMirror.PrintUsage(player);
                return;
            }

            Block block;

            if (flipX)
            {
                int left  = 0;
                int right = info.Bounds.Width - 1;
                while (left < right)
                {
                    for (int y = info.Bounds.Length - 1; y >= 0; y--)
                    {
                        for (int z = info.Bounds.Height - 1; z >= 0; z--)
                        {
                            block = info.Blocks[left, y, z];
                            info.Blocks[left, y, z]  = info.Blocks[right, y, z];
                            info.Blocks[right, y, z] = block;
                        }
                    }
                    left++;
                    right--;
                }
            }

            if (flipY)
            {
                int left  = 0;
                int right = info.Bounds.Length - 1;
                while (left < right)
                {
                    for (int x = info.Bounds.Width - 1; x >= 0; x--)
                    {
                        for (int z = info.Bounds.Height - 1; z >= 0; z--)
                        {
                            block = info.Blocks[x, left, z];
                            info.Blocks[x, left, z]  = info.Blocks[x, right, z];
                            info.Blocks[x, right, z] = block;
                        }
                    }
                    left++;
                    right--;
                }
            }

            if (flipH)
            {
                int left  = 0;
                int right = info.Bounds.Height - 1;
                while (left < right)
                {
                    for (int x = info.Bounds.Width - 1; x >= 0; x--)
                    {
                        for (int y = info.Bounds.Length - 1; y >= 0; y--)
                        {
                            block = info.Blocks[x, y, left];
                            info.Blocks[x, y, left]  = info.Blocks[x, y, right];
                            info.Blocks[x, y, right] = block;
                        }
                    }
                    left++;
                    right--;
                }
            }

            if (flipX)
            {
                if (flipY)
                {
                    if (flipH)
                    {
                        player.Message("Flipped copy along all axes.");
                    }
                    else
                    {
                        player.Message("Flipped copy along X (east/west) and Y (north/south) axes.");
                    }
                }
                else
                {
                    if (flipH)
                    {
                        player.Message("Flipped copy along X (east/west) and Z (vertical) axes.");
                    }
                    else
                    {
                        player.Message("Flipped copy along X (east/west) axis.");
                    }
                }
            }
            else
            {
                if (flipY)
                {
                    if (flipH)
                    {
                        player.Message("Flipped copy along Y (north/south) and Z (vertical) axes.");
                    }
                    else
                    {
                        player.Message("Flipped copy along Y (north/south) axis.");
                    }
                }
                else
                {
                    player.Message("Flipped copy along Z (vertical) axis.");
                }
            }

            player.SetCopyState(info);
        }
Пример #26
0
        static void RotateHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            CopyState originalInfo = player.GetCopyState();

            if (originalInfo == null)
            {
                player.MessageNow("Nothing to rotate! Copy something first.");
                return;
            }

            int degrees;

            if (!cmd.NextInt(out degrees) || (degrees != 90 && degrees != -90 && degrees != 180 && degrees != 270))
            {
                CdRotate.PrintUsage(player);
                return;
            }

            string axisName = cmd.Next();
            Axis   axis     = Axis.Z;

            if (axisName != null)
            {
                switch (axisName.ToLower())
                {
                case "x":
                    axis = Axis.X;
                    break;

                case "y":
                    axis = Axis.Y;
                    break;

                case "z":
                case "h":
                    axis = Axis.Z;
                    break;

                default:
                    CdRotate.PrintUsage(player);
                    return;
                }
            }

            // allocate the new buffer
            Block[,,] oldBuffer = originalInfo.Blocks;
            Block[,,] newBuffer;

            if (degrees == 180)
            {
                newBuffer = new Block[oldBuffer.GetLength(0), oldBuffer.GetLength(1), oldBuffer.GetLength(2)];
            }
            else if (axis == Axis.X)
            {
                newBuffer = new Block[oldBuffer.GetLength(0), oldBuffer.GetLength(2), oldBuffer.GetLength(1)];
            }
            else if (axis == Axis.Y)
            {
                newBuffer = new Block[oldBuffer.GetLength(2), oldBuffer.GetLength(1), oldBuffer.GetLength(0)];
            }
            else
            {
                // axis == Axis.Z
                newBuffer = new Block[oldBuffer.GetLength(1), oldBuffer.GetLength(0), oldBuffer.GetLength(2)];
            }

            // clone to avoid messing up any paste-in-progress
            CopyState info = new CopyState(originalInfo, newBuffer);

            // construct the rotation matrix
            int[,] matrix =
            {
                { 1, 0, 0 },
                { 0, 1, 0 },
                { 0, 0, 1 }
            };

            int a,
                b;

            switch (axis)
            {
            case Axis.X:
                a = 1;
                b = 2;
                break;

            case Axis.Y:
                a = 0;
                b = 2;
                break;

            default:
                a = 0;
                b = 1;
                break;
            }

            switch (degrees)
            {
            case 90:
                matrix[a, a] = 0;
                matrix[b, b] = 0;
                matrix[a, b] = -1;
                matrix[b, a] = 1;
                break;

            case 180:
                matrix[a, a] = -1;
                matrix[b, b] = -1;
                break;

            case -90:
            case 270:
                matrix[a, a] = 0;
                matrix[b, b] = 0;
                matrix[a, b] = 1;
                matrix[b, a] = -1;
                break;
            }

            // apply the rotation matrix
            for (int x = oldBuffer.GetLength(0) - 1; x >= 0; x--)
            {
                for (int y = oldBuffer.GetLength(1) - 1; y >= 0; y--)
                {
                    for (int z = oldBuffer.GetLength(2) - 1; z >= 0; z--)
                    {
                        int nx = (matrix[0, 0] < 0 ? oldBuffer.GetLength(0) - 1 - x : (matrix[0, 0] > 0 ? x : 0)) +
                                 (matrix[0, 1] < 0 ? oldBuffer.GetLength(1) - 1 - y : (matrix[0, 1] > 0 ? y : 0)) +
                                 (matrix[0, 2] < 0 ? oldBuffer.GetLength(2) - 1 - z : (matrix[0, 2] > 0 ? z : 0));
                        int ny = (matrix[1, 0] < 0 ? oldBuffer.GetLength(0) - 1 - x : (matrix[1, 0] > 0 ? x : 0)) +
                                 (matrix[1, 1] < 0 ? oldBuffer.GetLength(1) - 1 - y : (matrix[1, 1] > 0 ? y : 0)) +
                                 (matrix[1, 2] < 0 ? oldBuffer.GetLength(2) - 1 - z : (matrix[1, 2] > 0 ? z : 0));
                        int nz = (matrix[2, 0] < 0 ? oldBuffer.GetLength(0) - 1 - x : (matrix[2, 0] > 0 ? x : 0)) +
                                 (matrix[2, 1] < 0 ? oldBuffer.GetLength(1) - 1 - y : (matrix[2, 1] > 0 ? y : 0)) +
                                 (matrix[2, 2] < 0 ? oldBuffer.GetLength(2) - 1 - z : (matrix[2, 2] > 0 ? z : 0));
                        newBuffer[nx, ny, nz] = oldBuffer[x, y, z];
                    }
                }
            }

            player.Message("Rotated copy (slot {0}) by {1} degrees around {2} axis.",
                           info.Slot + 1,
                           degrees,
                           axis);
            player.SetCopyState(info);
        }
Пример #27
0
        static void ZoneRenameHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            // make sure that both parameters are given
            string oldName = cmd.Next();
            string newName = cmd.Next();

            if (oldName == null || newName == null)
            {
                CdZoneRename.PrintUsage(player);
                return;
            }

            // make sure that the new name is valid
            if (!World.IsValidName(newName))
            {
                player.Message("\"{0}\" is not a valid zone name", newName);
                return;
            }

            // find the old zone
            var  zones   = player.WorldMap.Zones;
            Zone oldZone = zones.Find(oldName);

            if (oldZone == null)
            {
                player.MessageNoZone(oldName);
                return;
            }

            // Check if a zone with "newName" name already exists
            Zone newZone = zones.FindExact(newName);

            if (newZone != null && newZone != oldZone)
            {
                player.Message("A zone with the name \"{0}\" already exists.", newName);
                return;
            }

            // check if any change is needed
            string fullOldName = oldZone.Name;

            if (fullOldName == newName)
            {
                player.Message("The zone is already named \"{0}\"", fullOldName);
                return;
            }

            // actually rename the zone
            zones.Rename(oldZone, newName);

            // announce the rename
            playerWorld.Players.Message("&SZone \"{0}\" was renamed to \"{1}&S\" by {2}",
                                        fullOldName, oldZone.ClassyName, player.ClassyName);
            Logger.Log(LogType.UserActivity,
                       "Player {0} renamed zone \"{1}\" to \"{2}\" on world {3}",
                       player.Name, fullOldName, newName, playerWorld.Name);
        }
Пример #28
0
        static void ZoneRemoveHandler(Player player, CommandReader cmd)
        {
            if (player.World == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string zoneName = cmd.Next();

            if (zoneName == null || cmd.HasNext)
            {
                CdZoneRemove.PrintUsage(player);
                return;
            }

            if (zoneName == "*")
            {
                if (!cmd.IsConfirmed)
                {
                    Logger.Log(LogType.UserActivity,
                               "ZRemove: Asked {0} to confirm removing all zones on world {1}",
                               player.Name, player.World.Name);
                    player.Confirm(cmd,
                                   "&WRemove ALL zones on this world ({0}&W)? This cannot be undone.&S",
                                   player.World.ClassyName);
                    return;
                }
                player.WorldMap.Zones.Clear();
                Logger.Log(LogType.UserActivity,
                           "Player {0} removed all zones on world {1}",
                           player.Name, player.World.Name);
                Server.Message("Player {0}&S removed all zones on world {1}",
                               player.ClassyName, player.World.ClassyName);
                return;
            }

            ZoneCollection zones = player.WorldMap.Zones;
            Zone           zone  = zones.Find(zoneName);

            if (zone != null)
            {
                if (!player.Info.Rank.AllowSecurityCircumvention)
                {
                    switch (zone.Controller.CheckDetailed(player.Info))
                    {
                    case SecurityCheckResult.BlackListed:
                        player.Message("You are not allowed to remove zone {0}: you are blacklisted.", zone.ClassyName);
                        return;

                    case SecurityCheckResult.RankTooLow:
                        player.Message("You are not allowed to remove zone {0}.", zone.ClassyName);
                        return;
                    }
                }
                if (!cmd.IsConfirmed)
                {
                    Logger.Log(LogType.UserActivity,
                               "ZRemove: Asked {0} to confirm removing zone {1} from world {2}",
                               player.Name, zone.Name, player.World.Name);
                    player.Confirm(cmd, "Remove zone {0}&S?", zone.ClassyName);
                    return;
                }

                if (zones.Remove(zone.Name))
                {
                    Logger.Log(LogType.UserActivity,
                               "Player {0} removed zone {1} from world {2}",
                               player.Name, zone.Name, player.World.Name);
                    player.Message("Zone \"{0}\" removed.", zone.Name);
                }
            }
            else
            {
                player.MessageNoZone(zoneName);
            }
        }
Пример #29
0
        static void TimerHandler([NotNull] Player player, [NotNull] 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)
                    {
                        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.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.IsNullOrWhiteSpace(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);
        }
Пример #30
0
        static void ZoneAddHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string givenZoneName = cmd.Next();

            if (givenZoneName == null)
            {
                CdZoneAdd.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 (givenZoneName.StartsWith("+"))
            {
                // personal zone (/ZAdd +Name)
                givenZoneName = givenZoneName.Substring(1);

                // Find the target player
                PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, givenZoneName);
                if (info == null)
                {
                    return;
                }

                // Make sure that the name is not taken already.
                // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2")
                newZone.Name = info.Name;
                for (int i = 2; zoneCollection.Contains(newZone.Name); i++)
                {
                    newZone.Name = givenZoneName + i;
                }

                newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                newZone.Controller.Include(info);
                player.Message("ZoneAdd: Creating a {0}+&S zone for player {1}&S. Click or &H/Mark&S 2 blocks.",
                               newZone.Controller.MinRank.ClassyName, info.ClassyName);
                player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
            }
            else
            {
                // Adding an ordinary, rank-restricted zone.
                if (!World.IsValidName(givenZoneName))
                {
                    player.Message("\"{0}\" is not a valid zone name", givenZoneName);
                    return;
                }

                if (zoneCollection.Contains(givenZoneName))
                {
                    player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit.");
                    return;
                }

                newZone.Name = givenZoneName;

                string rankName = cmd.Next();
                if (rankName == null)
                {
                    player.Message("No rank was specified. See &H/Help zone");
                    return;
                }

                Rank minRank = RankManager.FindRank(rankName);
                if (minRank == null)
                {
                    player.MessageNoRank(rankName);
                    return;
                }

                string name;
                while ((name = cmd.Next()) != null)
                {
                    if (name.Length < 1)
                    {
                        CdZoneAdd.PrintUsage(player);
                        return;
                    }
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    if (name.StartsWith("+"))
                    {
                        newZone.Controller.Include(info);
                    }
                    else if (name.StartsWith("-"))
                    {
                        newZone.Controller.Exclude(info);
                    }
                }

                newZone.Controller.MinRank = minRank;
                player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
                player.Message("ZoneAdd: Creating zone {0}&S. Click or &H/Mark&S 2 blocks.",
                               newZone.ClassyName);
            }
        }