예제 #1
0
 protected internal static bool CheckRank(Player p, CommandData data, Player target,
                                          string action, bool canAffectOwnRank)
 {
     return(CheckRank(p, data, target.name, target.Rank, action, canAffectOwnRank));
 }
예제 #2
0
        Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data)
        {
            if (!CheckCommand(cmdName))
            {
                return(null);
            }
            Command.Search(ref cmdName, ref cmdArgs);

            byte bindIndex;

            if (byte.TryParse(cmdName, out bindIndex) && bindIndex < CmdBindings.Length)
            {
                if (CmdBindings[bindIndex] == null)
                {
                    Message("No command is bound to: %T/" + cmdName); return(null);
                }

                CmdBindings[bindIndex].Separate(out cmdName, out cmdArgs);
                Command.Search(ref cmdName, ref cmdArgs);
            }

            OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data);
            if (cancelcommand)
            {
                cancelcommand = false; return(null);
            }

            Command command = Command.Find(cmdName);

            if (command == null)
            {
                if (Block.Parse(this, cmdName) != Block.Invalid)
                {
                    cmdArgs = cmdName; cmdName = "mode";
                    command = Command.Find("Mode");
                }
                else
                {
                    Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs);
                    Message("Unknown command \"" + cmdName + "\"."); return(null);
                }
            }

            if (!CanUse(command))
            {
                CommandPerms.Find(command.name).MessageCannotUse(this);
                return(null);
            }

            string reason = Command.GetDisabledReason(command.Enabled);

            if (reason != null)
            {
                Message("Command is disabled as " + reason); return(null);
            }
            if (level != null && level.IsMuseum && !command.museumUsable)
            {
                Message("Cannot use %T/{0} %Swhile in a museum.", command.name); return(null);
            }
            if (frozen && !command.UseableWhenFrozen)
            {
                Message("Cannot use %T/{0} %Swhile frozen.", command.name); return(null);
            }
            return(command);
        }
예제 #3
0
 public virtual void Use(Player p, string message, CommandData data)
 {
     Use(p, message);
 }
예제 #4
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!(p.group.Permission >= LevelPermission.Operator))
            {
                if (!Hacks.CanUseHacks(p))
                {
                    if (data.Context != CommandContext.MessageBlock)
                    {
                        p.Message("%cYou cannot use this command manually when hacks are disabled.");
                        return;
                    }
                }
            }

            BlockID block = p.GetHeldBlock();
            int     x = p.Pos.BlockX, y = (p.Pos.Y - 32) / 32, z = p.Pos.BlockZ;

            try {
                string[] parts = message.Split(' ');
                switch (parts.Length)
                {
                case 1:
                    if (message == "")
                    {
                        break;
                    }

                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }
                    break;

                case 3:
                    x = int.Parse(parts[0]);
                    y = int.Parse(parts[1]);
                    z = int.Parse(parts[2]);
                    break;

                case 4:
                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }

                    x = int.Parse(parts[1]);
                    y = int.Parse(parts[2]);
                    z = int.Parse(parts[3]);
                    break;

                default: Player.Message(p, "Invalid number of parameters"); return;
                }
            } catch {
                p.Message("Invalid parameters"); return;
            }

            if (!CommandParser.IsBlockAllowed(p, "place ", block))
            {
                return;
            }

            x = Clamp(x, p.level.Width);
            y = Clamp(y, p.level.Height);
            z = Clamp(z, p.level.Length);

            p.SendBlockchange((ushort)x, (ushort)y, (ushort)z, block);
            //string blockName = Block.GetName(p, block);
            //Player.Message(p, "{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
        }
예제 #5
0
 public static bool CanSee(CommandData data, Player p, Player target)
 {
     return(p == target || target == null || !target.hidden || data.Rank >= target.hideRank);
 }