Пример #1
0
        static void OnPlayerCommand(Player p, string cmd, string args, CommandData data)
        {
            if (cmd.CaselessEq("skin") && Hacks.CanUseHacks(p))
            {
                var splitArgs = args.Trim().Length == 0 ? new string[] { } : args.SplitSpaces();
                if (splitArgs.Length == 0)
                {
                    // check if we should use default skin
                    var storedModel = new StoredCustomModel(p.Model);
                    if (storedModel.Exists())
                    {
                        storedModel.LoadFromFile();

                        if (
                            !storedModel.usesHumanSkin &&
                            storedModel.defaultSkin != null
                            )
                        {
                            Debug("Setting {0} to defaultSkin {1}", p.name, storedModel.defaultSkin);
                            Command.Find("Skin").Use(
                                p,
                                "-own " + storedModel.defaultSkin,
                                data
                                );
                            p.cancelcommand = true;
                        }
                    }
                    else if (splitArgs.Length > 0)
                    {
                        var last = splitArgs[splitArgs.Length - 1];
                        MemoizedGetSkinType.Invalidate(last);
                    }
                }
            }
        }
Пример #2
0
        static void DoTP(Player p, string message)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("%WYou can't teleport to spawners because hacks are disabled in {0}", p.level.ColoredName);
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to teleport to."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S to teleport to.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            Command.Find("tp").Use(p, "-precise " + (int)(spawner.x * 32) + " " + (int)(spawner.y * 32) + " " + (int)(spawner.z * 32));
        }
Пример #3
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();

            string[] parts = message.SplitSpaces();
            Vec3S32  pos;

            pos.X = p.Pos.BlockX;
            pos.Y = (p.Pos.Y - 32) / 32;
            pos.Z = p.Pos.BlockZ;

            switch (parts.Length)
            {
            case 1:
                if (message == "")
                {
                    break;
                }

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

            case 3:
                if (!CommandParser.GetCoords(p, parts, 0, ref pos))
                {
                    return;
                }
                break;

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

            default:
                p.Message("Invalid number of parameters"); return;
            }
            if (!CommandParser.IsBlockAllowed(p, "place ", block))
            {
                return;
            }

            pos = p.level.ClampPos(pos);
            p.SendBlockchange((ushort)pos.X, (ushort)pos.Y, (ushort)pos.Z, block);
            //string blockName = Block.GetName(p, block);
            //p.Message("{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
        }
Пример #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);
        }