Пример #1
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("You cannot use &T/Descend &Son this map."); return;
            }

            // Move starting position down half a block since players are a little bit above the ground.
            int x = p.Pos.BlockX, y = (p.Pos.Y - 51 - 4) / 32, z = p.Pos.BlockZ;

            if (y > p.level.Height)
            {
                y = p.level.Height;
            }
            y--; // start at block below initially

            int freeY = -1;

            if (p.level.IsValidPos(x, y, z))
            {
                freeY = FindYBelow(p.level, (ushort)x, y, (ushort)z);
            }

            if (freeY == -1)
            {
                p.Message("No free spaces found below you.");
            }
            else
            {
                p.Message("Teleported you down.");
                Position pos = Position.FromFeet(p.Pos.X, freeY * 32, p.Pos.Z);
                p.SendPosition(pos, p.Rot);
            }
        }
Пример #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("You cannot use &T/Ascend %Son this map."); return;
            }
            int x = p.Pos.BlockX, y = p.Pos.BlockY, z = p.Pos.BlockZ;

            if (y < 0)
            {
                y = 0;
            }

            int freeY = -1;

            if (p.level.IsValidPos(x, y, z))
            {
                freeY = FindYAbove(p.level, (ushort)x, (ushort)y, (ushort)z);
            }

            if (freeY == -1)
            {
                p.Message("No free spaces found above you.");
            }
            else
            {
                p.Message("Teleported you up.");
                Position pos = Position.FromFeet(p.Pos.X, freeY * 32, p.Pos.Z);
                p.SendPos(Entities.SelfID, pos, p.Rot);
            }
        }
Пример #3
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 (!GoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}&S to teleport to.", p.level.ColoredName);
                return;
            }
            int matches;

            GoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                               GoodlyEffects.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));
        }
Пример #4
0
        public static bool DetectNoclip(Player p, Position newPos)
        {
            if (p.Game.Referee || Hacks.CanUseHacks(p, p.level))
            {
                return(false);
            }
            if (!p.CheckIfInsideBlock() || p.Game.NoclipLog.AddSpamEntry(5, 1))
            {
                return(false);
            }

            Warn(ref p.Game.LastNoclipWarn, p, "noclip");
            return(false);
        }
Пример #5
0
        internal static void HandleOnJoinedLevel(Player p, Level prevLevel, Level level)
        {
            p.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
            p.prevMsg     = "";
            p.showMBs     = false;
            p.showPortals = false;
            p.ModelBB     = AABB.ModelAABB(p, level); // in case had been using a level-only custom block for their model

            if (!Hacks.CanUseHacks(p, level) && p.isFlying)
            {
                Player.Message(p, "You cannot use /fly on this map.");
                p.isFlying = false;
            }

            if (p.Supports(CpeExt.EnvWeatherType))
            {
                p.Send(Packet.EnvWeatherType((byte)level.Config.Weather));
            }
            if (p.Supports(CpeExt.EnvColors))
            {
                p.SendCurrentEnvColors();
            }
            p.SendCurrentMapAppearance();
            p.SendCurrentBlockPermissions();

            // TODO: unshow old zones here??
            if (p.Supports(CpeExt.SelectionCuboid))
            {
                Zone[] zones = level.Zones.Items;
                foreach (Zone zn in zones)
                {
                    zn.Show(p);
                }
            }

            if (!level.Config.Guns && p.aiming)
            {
                p.aiming = false;
                p.ClearBlockchange();
            }
            if (!p.level.Config.UseBlockDB)
            {
                Player.Message(p, "BlockDB is disabled here, &cyou will not be able to /undo or /redo");
            }
        }
Пример #6
0
        public static bool DetectSpeedhack(Player p, Position newPos, int maxMove)
        {
            if (p.Game.Referee || Hacks.CanUseHacks(p, p.level))
            {
                return(false);
            }
            int  dx = Math.Abs(p.Pos.X - newPos.X), dz = Math.Abs(p.Pos.Z - newPos.Z);
            bool speedhacking = dx >= maxMove || dz >= maxMove;

            if (!speedhacking || p.Game.SpeedhackLog.AddSpamEntry(5, 1))
            {
                return(false);
            }

            Warn(ref p.Game.LastSpeedhackWarn, p, "speedhack");
            p.SendPos(Entities.SelfID, p.Pos, p.Rot);
            return(true);
        }
Пример #7
0
        public static bool DetectSpeedhack(Player p, ushort x, ushort y, ushort z, int maxMove)
        {
            if (p.Game.Referee || Hacks.CanUseHacks(p, p.level))
            {
                return(false);
            }
            int  dx = Math.Abs(p.pos[0] - x), dz = Math.Abs(p.pos[2] - z);
            bool speedhacking = dx >= maxMove || dz >= maxMove;

            if (!speedhacking || p.Game.SpeedhackLog.AddSpamEntry(5, 1))
            {
                return(false);
            }

            Warn(ref p.Game.LastSpeedhackWarn, p, "speedhack");
            p.SendPos(Entities.SelfID, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
            return(true);
        }
Пример #8
0
        public override void Use(Player p, string message)
        {
            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            if (!Hacks.CanUseHacks(p, p.level))
            {
                Player.Message(p, "You cannot use /descend on this map."); return;
            }
            if (p.pos[1] < 51 + 4)
            {
                Player.Message(p, "No free spaces found below you."); return;
            }
            // Move starting position down half a block since players are a little bit above the ground.
            ushort x = (ushort)(p.pos[0] / 32), y = (ushort)((p.pos[1] - 51 - 4) / 32), z = (ushort)(p.pos[2] / 32);

            while (y > 0)
            {
                y--;
                byte block = p.level.GetTile(x, y, z);
                if (!(Block.Convert(block) == Block.air || block == Block.Invalid))
                {
                    continue;
                }
                byte above = p.level.GetTile(x, (ushort)(y + 1), z);
                if (!(Block.Convert(above) == Block.air || above == Block.Invalid))
                {
                    continue;
                }

                byte below = p.level.GetTile(x, (ushort)(y - 1), z);
                if (Solid(Block.Convert(below)))
                {
                    Player.Message(p, "Teleported you down.");
                    p.SendOwnFeetPos(p.pos[0], (ushort)(y * 32), p.pos[2], p.rot[0], p.rot[1]);
                    return;
                }
            }
            Player.Message(p, "No free spaces found below you.");
        }
Пример #9
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!Hacks.CanUseHacks(p)) {
                p.Message("You cannot use &T/Ascend &Son this map."); return;
            }
            int x = p.Pos.FeetBlockCoords.X, y = p.Pos.FeetBlockCoords.Y, z = p.Pos.FeetBlockCoords.Z;
            if (y < 0) y = 0;

            int freeY = -1;
            if (p.level.IsValidPos(x, y, z)) {
                freeY = FindYAbove(p.level, (ushort)x, (ushort)y, (ushort)z);
            }

            if (freeY == -1) {
                p.Message("There are no blocks above to ascend to.");
            } else {
                p.Message("Teleported you up.");
                Position pos = Position.FromFeet(p.Pos.X, freeY * 32, p.Pos.Z);
                p.SendPos(Entities.SelfID, pos, p.Rot);
            }
        }
Пример #10
0
        public override void Use(Player p, string message)
        {
            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            if (!Hacks.CanUseHacks(p, p.level))
            {
                Player.Message(p, "You cannot use /fly on this map.");
                p.isFlying = false; return;
            }

            p.isFlying = !p.isFlying;
            if (!p.isFlying)
            {
                return;
            }
            Player.Message(p, "You are now flying. &cJump!");

            Thread flyThread = new Thread(new ThreadStart(
                                              () => {
                ushort[] oldpos     = new ushort[3];
                List <Vec3U16> last = new List <Vec3U16>(), next = new List <Vec3U16>();
                while (p.isFlying && !p.disconnected)
                {
                    DoFly(p, oldpos, last, next);
                }

                foreach (Vec3U16 cP in last)
                {
                    p.SendBlockchange(cP.X, cP.Y, cP.Z, Block.air);
                }
                Player.Message(p, "Stopped flying");
            }));

            flyThread.Name = "MCG_Fly";
            flyThread.Start();
        }
Пример #11
0
        public override void Use(Player p, string message)
        {
            if (!Hacks.CanUseHacks(p, p.level))
            {
                Player.Message(p, "You cannot use %T/Fly %Son this map.");
                p.isFlying = false; return;
            }

            p.isFlying = !p.isFlying;
            if (!p.isFlying)
            {
                return;
            }

            Player.Message(p, "You are now flying. &cJump!");

            FlyState state = new FlyState();

            state.player = p;
            SchedulerTask task = new SchedulerTask(FlyCallback, state, TimeSpan.Zero, true);

            p.CriticalTasks.Add(task);
        }
Пример #12
0
        public override void Use(Player p, string message)
        {
            if (Player.IsSuper(p))
            {
                MessageInGameOnly(p); return;
            }
            if (!Hacks.CanUseHacks(p, p.level))
            {
                Player.Message(p, "You cannot use /ascend on this map."); return;
            }
            ushort x = (ushort)(p.pos[0] / 32), y = (ushort)(p.pos[1] / 32), z = (ushort)(p.pos[2] / 32);

            while (y < p.level.Height)
            {
                y++;
                byte block = p.level.GetTile(x, y, z);
                if (!(Block.Convert(block) == Block.air || block == Block.Invalid))
                {
                    continue;
                }
                byte above = p.level.GetTile(x, (ushort)(y + 1), z);
                if (!(Block.Convert(above) == Block.air || above == Block.Invalid))
                {
                    continue;
                }

                byte below = p.level.GetTile(x, (ushort)(y - 1), z);
                if (Solid(Block.Convert(below)))
                {
                    Player.Message(p, "Teleported you up.");
                    p.SendOwnFeetPos(p.pos[0], (ushort)(y * 32), p.pos[2], p.rot[0], p.rot[1]);
                    return;
                }
            }
            Player.Message(p, "No free spaces found above you");
        }
Пример #13
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);
        }