Exemplo n.º 1
0
        private static bool HandlePlayerTeam(GetDataHandlerArgs args)
        {
            byte id = args.Data.ReadInt8();
            byte team = args.Data.ReadInt8();
            if (OnPlayerTeam(id, team))
                return true;

            if (id != args.Player.Index)
            {
                return true;
            }

            args.TPlayer.team = team;

            NetMessage.SendData((int)PacketTypes.PlayerTeam, -1, -1, "", args.Player.Index);

            return true;
        }
Exemplo n.º 2
0
        private static bool HandlePlayerDamage(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();
            var direction = args.Data.ReadInt8();
            var dmg = args.Data.ReadInt16();
            var pvp = args.Data.ReadInt8();
            var crit = args.Data.ReadInt8();

            if (OnPlayerDamage(id, direction, dmg, pvp, crit))
                return true;

            int textlength = (int) (args.Data.Length - args.Data.Position - 1);
            string deathtext = "";
            if (textlength > 0)
            {
                deathtext = Encoding.UTF8.GetString(args.Data.ReadBytes(textlength));
                /*if (!TShock.Utils.ValidString(deathtext))
                {
                    return true;
                }*/
            }

            if (tPulse.Players[id] == null)
                return true;

            if (dmg > tPulse.Config.MaxDamage && !args.Player.Group.HasPermission(Permissions.ignoredamagecap) && id != args.Player.Index)
            {
                args.Player.Disable(String.Format("Player damage exceeded {0}.", tPulse.Config.MaxDamage));
                args.Player.SendData(PacketTypes.PlayerHp, "", id);
                args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
                return true;
            }

            if (!tPulse.Players[id].TPlayer.hostile)
            {
                args.Player.SendData(PacketTypes.PlayerHp, "", id);
                args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
                return true;
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.PlayerHp, "", id);
                args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
                return true;
            }

            if (tPulse.CheckRangePermission(args.Player, tPulse.Players[id].TileX, tPulse.Players[id].TileY, 100))
            {
                args.Player.SendData(PacketTypes.PlayerHp, "", id);
                args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendData(PacketTypes.PlayerHp, "", id);
                args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
                return true;
            }

            return false;
        }
Exemplo n.º 3
0
        private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();
            var direction = args.Data.ReadInt8();
            var dmg = args.Data.ReadInt16();
            var pvp = args.Data.ReadInt8() == 0;
            if (OnKillMe(id, direction, dmg, pvp))
                return true;
            int textlength = (int) (args.Data.Length - args.Data.Position - 1);
            string deathtext = "";
            if (textlength > 0)
            {
                deathtext = Encoding.UTF8.GetString(args.Data.ReadBytes(textlength));
                /*if (!TShock.Utils.ValidString(deathtext))
                {
                    return true;
                }*/
            }

            args.Player.LastDeath = DateTime.Now;
            args.Player.Dead = true;

            return false;
        }
Exemplo n.º 4
0
        private static bool HandlePassword(GetDataHandlerArgs args)
        {
            if (!args.Player.RequiresPassword)
                return true;

            string password = Encoding.UTF8.GetString(args.Data.ReadBytes((int) (args.Data.Length - args.Data.Position - 1)));
            var user = tPulse.Users.GetUserByName(args.Player.Name);
            if (user != null && !tPulse.Config.DisableLoginBeforeJoin)
            {
                string encrPass = Utils.HashPassword(password);
                if (user.Password.ToUpper() == encrPass.ToUpper())
                {
                    args.Player.RequiresPassword = false;
                    args.Player.PlayerData = tPulse.InventoryDB.GetPlayerData(args.Player, tPulse.Users.GetUserID(args.Player.Name));

                    if (args.Player.State == 1)
                        args.Player.State = 2;
                    NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index);

                    var group = tPulse.GetGroup(user.Group);

                    if (tPulse.Config.ServerSideInventory)
                    {
                        if (group.HasPermission(Permissions.bypassinventorychecks))
                        {
                            args.Player.IgnoreActionsForClearingTrashCan = false;
                        }
                        else if (!TPulse.CheckInventory(args.Player))
                        {
                            args.Player.SendMessage("Login Failed, Please fix the above errors then /login again.", Color.Cyan);
                            args.Player.IgnoreActionsForClearingTrashCan = true;
                            return true;
                        }
                    }

                    if (group.HasPermission(Permissions.ignorestackhackdetection))
                        args.Player.IgnoreActionsForCheating = "none";

                    if (group.HasPermission(Permissions.usebanneditem))
                        args.Player.IgnoreActionsForDisabledArmor = "none";

                    args.Player.Group = group;
                    args.Player.UserAccountName = args.Player.Name;
                    args.Player.UserID = tPulse.Users.GetUserID(args.Player.UserAccountName);
                    args.Player.IsLoggedIn = true;
                    args.Player.IgnoreActionsForInventory = "none";

                    if (!args.Player.IgnoreActionsForClearingTrashCan)
                    {
                        args.Player.PlayerData.CopyInventory(args.Player);
                        tPulse.InventoryDB.InsertPlayerData(args.Player);
                    }
                    args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen);
                    Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + ".");
                    //Hooks.PlayerLoginEvent.OnPlayerLogin(args.Player);
                    tPulse.Commands.HandlePlayerLogin(new PlayerLoginEventArgs(args.Player));
                    return true;
                }
                tPulse.PlayerHandle.ForceKick(args.Player, "Invalid user account password.", true);
                return true;
            }
            if (!string.IsNullOrEmpty(tPulse.Config.ServerPassword))
            {
                if (tPulse.Config.ServerPassword == password)
                {
                    args.Player.RequiresPassword = false;
                    if (args.Player.State == 1)
                        args.Player.State = 2;
                    NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index);
                    return true;
                }
                tPulse.PlayerHandle.ForceKick(args.Player, "Incorrect server password", true);
                return true;
            }

            tPulse.PlayerHandle.ForceKick(args.Player, "Bad password attempt", true);
            return true;
        }
Exemplo n.º 5
0
        private static bool HandlePlayerBuff(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();
            var type = args.Data.ReadInt8();
            var time = args.Data.ReadInt16();

            if (OnPlayerBuff(id, type, time))
                return true;

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.PlayerBuff, "", id);
                return true;
            }
            if (!tPulse.Players[id].TPlayer.hostile)
            {
                args.Player.SendData(PacketTypes.PlayerBuff, "", id);
                return true;
            }
            if (tPulse.CheckRangePermission(args.Player, tPulse.Players[id].TileX, tPulse.Players[id].TileY, 50))
            {
                args.Player.SendData(PacketTypes.PlayerBuff, "", id);
                return true;
            }
            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendData(PacketTypes.PlayerBuff, "", id);
                return true;
            }

            if (WhitelistBuffMaxTime[type] > 0 && time <= WhitelistBuffMaxTime[type])
            {
                return false;
            }

            args.Player.SendData(PacketTypes.PlayerBuff, "", id);
            return true;
        }
Exemplo n.º 6
0
        private static bool HandleGetSection(GetDataHandlerArgs args)
        {
            if (args.Player.RequestedSection)
                return true;
            args.Player.RequestedSection = true;
            if (String.IsNullOrEmpty(args.Player.Name))
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Blank name.", true);
                return true;
            }
            if (TPulse.HackedHealth(args.Player) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection))
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "You have hacked health/mana, please use a different character.", true);
                return true;
            }

            if (!args.Player.Group.HasPermission(Permissions.ignorestackhackdetection))
            {
                TPulse.HackedInventory(args.Player);
            }

            if (tPulse.ActivePlayers() + 1 > tPulse.Config.MaxSlots &&
                !args.Player.Group.HasPermission(Permissions.reservedslot))
            {
                tPulse.PlayerHandle.ForceKick(args.Player, tPulse.Config.ServerFullReason, true);
                return true;
            }

            NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);

            if (tPulse.Config.EnableGeoIP && tPulse.Geo != null)
            {
                Log.Info(string.Format("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", args.Player.Name, args.Player.IP,
                                       args.Player.Group.Name, args.Player.Country, tPulse.ActivePlayers(),
                                       tPulse.Config.MaxSlots));
                Utils.Broadcast(string.Format("{0} ({1}) has joined.", args.Player.Name, args.Player.Country), Color.Yellow);
            }
            else
            {
                Log.Info(string.Format("{0} ({1}) from '{2}' group joined. ({3}/{4})", args.Player.Name, args.Player.IP,
                                       args.Player.Group.Name, tPulse.ActivePlayers(), tPulse.Config.MaxSlots));
                Utils.Broadcast(args.Player.Name + " has joined.", Color.Yellow);
            }

            if (tPulse.Config.DisplayIPToAdmins)
                tPulse.SendLogs(string.Format("{0} has joined. IP: {1}", args.Player.Name, args.Player.IP), Color.Blue, tPulse);

            return false;
        }
Exemplo n.º 7
0
        private static bool HandleLiquidSet(GetDataHandlerArgs args)
        {
            int tileX = args.Data.ReadInt32();
            int tileY = args.Data.ReadInt32();
            byte liquid = args.Data.ReadInt8();
            bool lava = args.Data.ReadBoolean();

            if (OnLiquidSet(tileX, tileY, liquid, lava))
                return true;
            if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY)
                return false;

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (args.Player.TileLiquidThreshold >= tPulse.Config.TileLiquidThreshold)
            {
                args.Player.Disable("Reached TileLiquid threshold.");
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (!args.Player.Group.HasPermission(Permissions.ignoreliquidsetdetection))
            {
                args.Player.TileLiquidThreshold++;
            }
            if (liquid != 0)
            {
                int bucket = 0;
                if (args.TPlayer.inventory[args.TPlayer.selectedItem].type == 206)
                {
                    bucket = 1;
                }
                else if (args.TPlayer.inventory[args.TPlayer.selectedItem].type == 207)
                {
                    bucket = 2;
                }

                if (lava && bucket != 2 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                    tPulse.Itembans.ItemIsBanned("Lava Bucket", args.Player))
                {
                    args.Player.Disable("Using banned lava bucket without permissions.");
                    args.Player.SendTileSquare(tileX, tileY);
                    return true;
                }

                if (!lava && bucket != 1 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                    tPulse.Itembans.ItemIsBanned("Water Bucket", args.Player))
                {
                    args.Player.Disable("Using banned water bucket without permissions.");
                    args.Player.SendTileSquare(tileX, tileY);
                    return true;
                }
            }

            if (tPulse.CheckTilePermission(args.Player, tileX, tileY))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (tPulse.CheckRangePermission(args.Player, tileX, tileY, 16))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            return false;
        }
Exemplo n.º 8
0
        private static bool HandleSpawn(GetDataHandlerArgs args)
        {
            var player = args.Data.ReadInt8();
            var spawnx = args.Data.ReadInt32();
            var spawny = args.Data.ReadInt32();

            if (OnPlayerSpawn(player, spawnx, spawny))
                return true;

            if (args.Player.InitSpawn && args.TPlayer.inventory[args.TPlayer.selectedItem].type != 50)
            {
                if (args.TPlayer.difficulty == 1 && (tPulse.Config.KickOnMediumcoreDeath || tPulse.Config.BanOnMediumcoreDeath))
                {
                    if (args.TPlayer.selectedItem != 50)
                    {
                        if (tPulse.Config.BanOnMediumcoreDeath)
                        {
                            if (!tPulse.Ban(args.Player, tPulse.Config.MediumcoreBanReason))
                                tPulse.PlayerHandle.ForceKick(args.Player, "Death results in a ban, but can't ban you.", true);
                        }
                        else
                        {
                            tPulse.PlayerHandle.ForceKick(args.Player, tPulse.Config.MediumcoreKickReason, true, false);
                        }
                        return true;
                    }
                }
            }
            else
                args.Player.InitSpawn = true;

            args.Player.Dead = false;
            return false;
        }
Exemplo n.º 9
0
        private static bool HandleSpawnBoss(GetDataHandlerArgs args)
        {
            var spawnboss = false;
            var invasion = -1;
            var plr = args.Data.ReadInt32();
            var Type = args.Data.ReadInt32();
            spawnboss = (Type == 4 || Type == 13 || (Type == 50 || Type == 125) || (Type == 126 || Type == 134 || (Type == (int) sbyte.MaxValue || Type == 128)));
            if (!spawnboss)
            {
                switch (Type)
                {
                    case -1:
                        invasion = 1;
                        break;
                    case -2:
                        invasion = 2;
                        break;
                }
            }
            if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss))
            {
                args.Player.SendMessage("You don't have permission to summon a boss.", Color.Red);
                return true;
            }
            if (invasion != -1 && !args.Player.Group.HasPermission(Permissions.startinvasion))
            {
                args.Player.SendMessage("You don't have permission to start an invasion.", Color.Red);
                return true;
            }
            if (!spawnboss && invasion == -1)
                return true;
            if (plr != args.Player.Index)
                return true;

            string boss;
            switch (Type)
            {
                case -2:
                    boss = "the Snow Legion";
                    break;
                case -1:
                    boss = "a Goblin Invasion";
                    break;
                case 4:
                    boss = "the Eye of Cthulhu";
                    break;
                case 13:
                    boss = "the Eater of Worlds";
                    break;
                case 50:
                    boss = "the King Slime";
                    break;
                case 125:
                    boss = "Retinazer";
                    break;
                case 126:
                    boss = "Spazmatism";
                    break;
                case 134:
                    boss = "the Destroyer";
                    break;
                case sbyte.MaxValue:
                    boss = "Skeleton Prime";
                    break;
                case 128:
                    boss = "Skeleton Prime";
                    break;
                default:
                    boss = "error";
                    break;
            }

            tPulse.SendLogs(string.Format("{0} summoned {1}", args.Player.Name, boss), Color.Red, tPulse);
            return false;
        }
Exemplo n.º 10
0
        private static bool HandleSendTileSquare(GetDataHandlerArgs args)
        {
            if (args.Player.Group.HasPermission(Permissions.allowclientsideworldedit))
                return false;

            var size = args.Data.ReadInt16();
            var tileX = args.Data.ReadInt32();
            var tileY = args.Data.ReadInt32();

            if (OnSendTileSquare(size, tileX, tileY))
                return true;

            if (size > 5)
                return true;

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendTileSquare(tileX, tileY, size);
                return true;
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            var tiles = new NetTile[size,size];

            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    tiles[x, y] = new NetTile(args.Data);
                }
            }

            bool changed = false;
            for (int x = 0; x < size; x++)
            {
                int realx = tileX + x;
                if (realx < 0 || realx >= Main.maxTilesX)
                    continue;

                for (int y = 0; y < size; y++)
                {
                    int realy = tileY + y;
                    if (realy < 0 || realy >= Main.maxTilesY)
                        continue;

                    var tile = Main.tile[realx, realy];
                    var newtile = tiles[x, y];
                    if (tPulse.CheckTilePermission(args.Player, realx, realy))
                    {
                        continue;
                    }
                    // Server now has a range check built in
                    /*if (TShock.CheckRangePermission(args.Player, realx, realy))
                    {
                        continue;
                    }*/
                    if ((tile.type == 128 && newtile.Type == 128) || (tile.type == 105 && newtile.Type == 105) || (tile.type == 139 && newtile.Type == 139))
                    {
                        if (tPulse.Config.EnableInsecureTileFixes)
                        {
                            return false;
                        }
                    }

                    if (tile.type == 0x17 && newtile.Type == 0x2)
                    {
                        tile.type = 0x2;
                        changed = true;
                    }
                    else if (tile.type == 0x19 && newtile.Type == 0x1)
                    {
                        tile.type = 0x1;
                        changed = true;
                    }
                    else if ((tile.type == 0xF && newtile.Type == 0xF) ||
                             (tile.type == 0x4F && newtile.Type == 0x4F))
                    {
                        tile.frameX = newtile.FrameX;
                        tile.frameY = newtile.FrameY;
                        changed = true;
                    }
                        // Holy water/Unholy water
                    else if (tile.type == 1 && newtile.Type == 117)
                    {
                        tile.type = 117;
                        changed = true;
                    }
                    else if (tile.type == 1 && newtile.Type == 25)
                    {
                        tile.type = 25;
                        changed = true;
                    }
                    else if (tile.type == 117 && newtile.Type == 25)
                    {
                        tile.type = 25;
                        changed = true;
                    }
                    else if (tile.type == 25 && newtile.Type == 117)
                    {
                        tile.type = 117;
                        changed = true;
                    }
                    else if (tile.type == 2 && newtile.Type == 23)
                    {
                        tile.type = 23;
                        changed = true;
                    }
                    else if (tile.type == 2 && newtile.Type == 109)
                    {
                        tile.type = 109;
                        changed = true;
                    }
                    else if (tile.type == 23 && newtile.Type == 109)
                    {
                        tile.type = 109;
                        changed = true;
                    }
                    else if (tile.type == 109 && newtile.Type == 23)
                    {
                        tile.type = 23;
                        changed = true;
                    }
                    else if (tile.type == 23 && newtile.Type == 109)
                    {
                        tile.type = 109;
                        changed = true;
                    }
                    else if (tile.type == 53 && newtile.Type == 116)
                    {
                        tile.type = 116;
                        changed = true;
                    }
                    else if (tile.type == 53 && newtile.Type == 112)
                    {
                        tile.type = 112;
                        changed = true;
                    }
                    else if (tile.type == 112 && newtile.Type == 116)
                    {
                        tile.type = 116;
                        changed = true;
                    }
                    else if (tile.type == 116 && newtile.Type == 112)
                    {
                        tile.type = 112;
                        changed = true;
                    }
                    else if (tile.type == 112 && newtile.Type == 53)
                    {
                        tile.type = 53;
                        changed = true;
                    }
                    else if (tile.type == 109 && newtile.Type == 2)
                    {
                        tile.type = 2;
                        changed = true;
                    }
                    else if (tile.type == 116 && newtile.Type == 53)
                    {
                        tile.type = 53;
                        changed = true;
                    }
                    else if (tile.type == 117 && newtile.Type == 1)
                    {
                        tile.type = 1;
                        changed = true;
                    }
                }
            }

            if (changed)
            {
                TPPlayer.All.SendTileSquare(tileX, tileY, size);
                WorldGen.RangeFrame(tileX, tileY, tileX + size, tileY + size);
            }
            else
            {
                args.Player.SendTileSquare(tileX, tileY, size);
            }
            return true;
        }
Exemplo n.º 11
0
        private static bool HandleSign(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var x = args.Data.ReadInt32();
            var y = args.Data.ReadInt32();

            if (OnSignEvent(id, x, y))
                return true;

            if (tPulse.CheckTilePermission(args.Player, x, y))
            {
                args.Player.SendData(PacketTypes.SignNew, "", id);
                return true;
            }

            if (tPulse.CheckRangePermission(args.Player, x, y))
            {
                args.Player.SendData(PacketTypes.SignNew, "", id);
                return true;
            }
            return false;
        }
Exemplo n.º 12
0
        private static bool HandleProjectileNew(GetDataHandlerArgs args)
        {
            var ident = args.Data.ReadInt16();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var knockback = args.Data.ReadSingle();
            var dmg = args.Data.ReadInt16();
            var owner = args.Data.ReadInt8();
            var type = args.Data.ReadInt8();
            owner = (byte)args.Player.Index;
            var index = Utils.SearchProjectile(ident, owner);

            if (OnNewProjectile(ident, pos, vel, knockback, dmg, owner, type, index))
                return true;

            if (index > Main.maxProjectiles || index < 0)
            {
                return false;
            }

            // Server now checks owner + ident, if owner is different, server will create new projectile.
            /*if (args.Player.Index != owner)
            {
                args.Player.Disable(String.Format("Owner ({0}) and player ID ({1}) does not match to update projectile", owner, args.Player.Index));
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }*/

            if (dmg > tPulse.Config.MaxProjDamage && !args.Player.Group.HasPermission(Permissions.ignoredamagecap))
            {
                args.Player.Disable(String.Format("Projectile damage is higher than {0}.", tPulse.Config.MaxProjDamage));
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if (!tPulse.Config.IgnoreProjUpdate && tPulse.CheckProjectilePermission(args.Player, index, type))
            {
            if (type == 100)
                    {	//fix for skele prime
                        Log.Debug("Skeletron Prime's death laser ignored for cheat detection..");
                    }
                    else
                    {
                        args.Player.Disable("Does not have projectile permission to update projectile.");
                        args.Player.RemoveProjectile(ident, owner);
                    }
                return true;
            }

            if (args.Player.ProjectileThreshold >= tPulse.Config.ProjectileThreshold)
            {
                args.Player.Disable("Reached projectile update threshold.");
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if (!args.Player.Group.HasPermission(Permissions.ignoreprojectiledetection))
            {
                if ((type ==90) && (tPulse.Config.ProjIgnoreShrapnel))// ignore shrapnel
                    {
                        Log.Debug("Ignoring shrapnel per config..");
                    }
                    else
                    {
                        args.Player.ProjectileThreshold++;
                    }
            }

            return false;
        }
Exemplo n.º 13
0
        private static bool HandleProjectileKill(GetDataHandlerArgs args)
        {
            var ident = args.Data.ReadInt16();
            var owner = args.Data.ReadInt8();
            owner = (byte)args.Player.Index;
            var index = Utils.SearchProjectile(ident, owner);

            if (index > Main.maxProjectiles || index < 0)
            {
                return false;
            }

            var type = Main.projectile[index].type;

            // Players can no longer destroy projectiles that are not theirs as of 1.1.2
            /*if (args.Player.Index != Main.projectile[index].owner && type != 102 && type != 100 && !TShock.Config.IgnoreProjKill) // workaround for skeletron prime projectiles
            {
                args.Player.Disable(String.Format("Owner ({0}) and player ID ({1}) does not match to kill projectile of type: {3}", Main.projectile[index].owner, args.Player.Index, type));
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }*/

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if (tPulse.CheckProjectilePermission(args.Player, index, type) && type != 102 && type != 100 && !tPulse.Config.IgnoreProjKill)
            {
                args.Player.Disable("Does not have projectile permission to kill projectile.");
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.RemoveProjectile(ident, owner);
                return true;
            }

            return false;
        }
Exemplo n.º 14
0
        private static bool HandlePlayerUpdate(GetDataHandlerArgs args)
        {
            var plr = args.Data.ReadInt8();
            var control = args.Data.ReadInt8();
            var item = args.Data.ReadInt8();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            if (OnPlayerUpdate(plr, control, item, pos, vel))
                return true;
            if (item < 0 || item >= args.TPlayer.inventory.Length)
            {
                return true;
            }

            if (args.Player.LastNetPosition == Vector2.Zero)
            {
                return true;
            }

            if (!pos.Equals(args.Player.LastNetPosition))
            {
                float distance = Vector2.Distance(new Vector2(pos.X/16f, pos.Y/16f),
                                                  new Vector2(args.Player.LastNetPosition.X/16f, args.Player.LastNetPosition.Y/16f));
                if (tPulse.CheckIgnores(args.Player))
                {
                    if (distance > tPulse.Config.MaxRangeForDisabled)
                    {
                        if (args.Player.IgnoreActionsForCheating != "none")
                        {
                            args.Player.SendMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating,
                                                    Color.Red);
                        }
                        else if (args.Player.IgnoreActionsForDisabledArmor != "none")
                        {
                            args.Player.SendMessage(
                                "Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor, Color.Red);
                        }
                        else if (args.Player.IgnoreActionsForInventory != "none")
                        {
                            args.Player.SendMessage(
                                "Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory,
                                Color.Red);
                        }
                        else if (tPulse.Config.RequireLogin && !args.Player.IsLoggedIn)
                        {
                            args.Player.SendMessage("Please /register or /login to play!", Color.Red);
                        }
                        else if (args.Player.IgnoreActionsForClearingTrashCan)
                        {
                            args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red);
                        }
                        else if (tPulse.Config.PvPMode == "always" && !args.TPlayer.hostile)
                        {
                            args.Player.SendMessage("PvP is forced! Enable PvP or else you can't do anything!",
                                                    Color.Red);
                        }
                        int lastTileX = (int) (args.Player.LastNetPosition.X/16f);
                        int lastTileY = (int) (args.Player.LastNetPosition.Y/16f);
                        if (!args.Player.Teleport(lastTileX, lastTileY))
                        {
                            args.Player.Spawn();
                        }
                        return true;
                    }
                    return true;
                }

                if (args.Player.Dead)
                {
                    return true;
                }

                if (!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) &&
                    TSCheckNoclip(pos, args.TPlayer.width, args.TPlayer.height) && !tPulse.Config.IgnoreNoClip
                    && !args.TPlayer.tongued)
                {
                    int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
                    int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
                    if (!args.Player.Teleport(lastTileX, lastTileY + 3))
                    {
                        args.Player.SendErrorMessage("You got stuck in a solid object, Sent to spawn point.");
                        args.Player.Spawn();
                    }
                    return true;
                }
                args.Player.LastNetPosition = pos;
            }

            if ((control & 32) == 32)
            {
                if (!args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                    tPulse.Itembans.ItemIsBanned(args.TPlayer.inventory[item].name, args.Player))
                {
                    control -= 32;
                    args.Player.Disable("Using banned item");
                    args.Player.SendMessage(
                        string.Format("You cannot use {0} on this server. Your actions are being ignored.",
                                      args.TPlayer.inventory[item].name), Color.Red);
                }
            }

            args.TPlayer.selectedItem = item;
            args.TPlayer.position = pos;
            args.TPlayer.velocity = vel;
            args.TPlayer.oldVelocity = args.TPlayer.velocity;
            args.TPlayer.fallStart = (int) (pos.Y/16f);
            args.TPlayer.controlUp = false;
            args.TPlayer.controlDown = false;
            args.TPlayer.controlLeft = false;
            args.TPlayer.controlRight = false;
            args.TPlayer.controlJump = false;
            args.TPlayer.controlUseItem = false;
            args.TPlayer.direction = -1;
            if ((control & 1) == 1)
            {
                args.TPlayer.controlUp = true;
            }
            if ((control & 2) == 2)
            {
                args.TPlayer.controlDown = true;
            }
            if ((control & 4) == 4)
            {
                args.TPlayer.controlLeft = true;
            }
            if ((control & 8) == 8)
            {
                args.TPlayer.controlRight = true;
            }
            if ((control & 16) == 16)
            {
                args.TPlayer.controlJump = true;
            }
            if ((control & 32) == 32)
            {
                args.TPlayer.controlUseItem = true;
            }
            if ((control & 64) == 64)
            {
                args.TPlayer.direction = 1;
            }
            NetMessage.SendData((int) PacketTypes.PlayerUpdate, -1, args.Player.Index, "", args.Player.Index);

            return true;
        }
Exemplo n.º 15
0
        private static bool HandleChestOpen(GetDataHandlerArgs args)
        {
            var x = args.Data.ReadInt32();
            var y = args.Data.ReadInt32();

            if (OnChestOpen(x, y))
                return true;

            if (tPulse.CheckIgnores(args.Player))
            {
                return true;
            }

            if (tPulse.CheckRangePermission(args.Player, x, y))
            {
                return true;
            }

            if (tPulse.CheckTilePermission(args.Player, x, y) && tPulse.Config.RegionProtectChests)
            {
                return true;
            }

            return false;
        }
Exemplo n.º 16
0
        private static bool HandleSpecial(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();
            var type = args.Data.ReadInt8();

            if (OnNPCSpecial(id, type))
                return true;

            if (type == 1 && tPulse.Config.DisableDungeonGuardian)
            {
                args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple);
                args.Player.Spawn();
                return true;
            }

            return false;
        }
Exemplo n.º 17
0
        private static bool HandleConnecting(GetDataHandlerArgs args)
        {
            var user = tPulse.Users.GetUserByName(args.Player.Name);
            if (user != null && !tPulse.Config.DisableLoginBeforeJoin)
            {
                args.Player.RequiresPassword = true;
                NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
                return true;
            }
            else if (!string.IsNullOrEmpty(tPulse.Config.ServerPassword))
            {
                args.Player.RequiresPassword = true;
                NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
                return true;
            }

            if (args.Player.State == 1)
                args.Player.State = 2;
            NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index);
            return true;
        }
Exemplo n.º 18
0
        private static bool HandleTile(GetDataHandlerArgs args)
        {
            var type = args.Data.ReadInt8();
            var tileX = args.Data.ReadInt32();
            var tileY = args.Data.ReadInt32();
            var tiletype = args.Data.ReadInt8();
            var fail = args.Data.ReadBoolean();
            if (OnTileEdit(args.Player, tileX, tileY, tiletype, type, fail))
                return true;
            if (!MapTools.TileValid(tileX, tileY))
                return false;

            if (args.Player.Dead && tPulse.Config.PreventDeadModification)
                return true;

            if (args.Player.AwaitingName)
            {
                var protectedregions = tPulse.Regions.InAreaRegionName(tileX, tileY);
                if (protectedregions.Count == 0)
                {
                    args.Player.SendMessage("Region is not protected", Color.Yellow);
                }
                else
                {
                    string regionlist = string.Join(",", protectedregions.ToArray());
                    args.Player.SendMessage("Region Name(s): " + regionlist, Color.Yellow);
                }
                args.Player.SendTileSquare(tileX, tileY);
                args.Player.AwaitingName = false;
                return true;
            }

            if (args.Player.AwaitingTempPoint > 0)
            {
                args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].X = tileX;
                args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].Y = tileY;
                args.Player.SendMessage("Set Temp Point " + args.Player.AwaitingTempPoint, Color.Yellow);
                args.Player.SendTileSquare(tileX, tileY);
                args.Player.AwaitingTempPoint = 0;
                return true;
            }

            if (type == 1 || type == 3)
            {
                if (tiletype >= ((type == 1) ? Main.maxTileSets : Main.maxWallTypes))
                {
                    return true;
                }
                if (type == 1 && (tiletype == 29 || tiletype == 97) && tPulse.Config.ServerSideInventory && tPulse.Config.DisablePiggybanksOnSSI)
                {
                    args.Player.SendMessage("You cannot place this tile, server side inventory is enabled.", Color.Red);
                    args.Player.SendTileSquare(tileX, tileY);
                    return true;
                }
                if (tiletype == 48 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                    tPulse.Itembans.ItemIsBanned("Spike", args.Player))
                {
                    args.Player.Disable("Used banned spikes without permission.");
                    args.Player.SendTileSquare(tileX, tileY);
                    return true;
                }
                if (type == 1 && tiletype == 21)
                {
                    if (Utils.MaxChests())
                    {
                        args.Player.SendMessage("Reached the world's max chest limit, unable to place more.", Color.Red);
                        args.Player.SendTileSquare(tileX, tileY);
                        return true;
                    }
                    if ((MapTools.TileValid(tileX, tileY + 1) && Main.tile[tileX, tileY + 1].type == 138) ||
                        (MapTools.TileValid(tileX + 1, tileY + 1) && Main.tile[tileX + 1, tileY + 1].type == 138))
                    {
                        args.Player.SendTileSquare(tileX, tileY);
                        return true;
                    }
                }
                if (tiletype == 141 && !args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                    tPulse.Itembans.ItemIsBanned("Explosives", args.Player))
                {
                    args.Player.Disable("Used banned explosives tile without permission.");
                    args.Player.SendTileSquare(tileX, tileY);
                    return true;
                }
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (tPulse.CheckTilePermission(args.Player, tileX, tileY, tiletype, type))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if ((tiletype == 127 || Main.tileCut[tiletype]) && (type == 0 || type == 4))
            {
                return false;
            }

            if (tPulse.CheckRangePermission(args.Player, tileX, tileY))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (args.Player.TileKillThreshold >= tPulse.Config.TileKillThreshold)
            {
                args.Player.Disable("Reached TileKill threshold.");
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (args.Player.TilePlaceThreshold >= tPulse.Config.TilePlaceThreshold)
            {
                args.Player.Disable("Reached TilePlace threshold.");
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if ( ( type == 1 || type == 3 ) && !args.Player.Group.HasPermission(Permissions.ignoreplacetiledetection))
            {
                args.Player.TilePlaceThreshold++;
                var coords = new Vector2(tileX, tileY);
                if (!args.Player.TilesCreated.ContainsKey(coords))
                    args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY].Data);
            }

            if ((type == 0 || type == 4 || type == 2) && Main.tileSolid[Main.tile[tileX, tileY].type] &&
                !args.Player.Group.HasPermission(Permissions.ignorekilltiledetection))
            {
                args.Player.TileKillThreshold++;
                var coords = new Vector2(tileX, tileY);
                if (!args.Player.TilesDestroyed.ContainsKey(coords))
                    args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY].Data);
            }

            return false;
        }
Exemplo n.º 19
0
        private static bool HandleItemDrop(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var stacks = args.Data.ReadInt8();
            var prefix = args.Data.ReadInt8();
            var type = args.Data.ReadInt16();

            if (OnItemDrop(id, pos, vel, stacks, prefix, type))
                return true;

            // player is attempting to crash clients
            if (type < -24 || type >= Main.maxItemTypes)
            {
                return true;
            }
            if (type == 0) //Item removed, let client do this to prevent item duplication client side
            {
                return false;
            }

            if (tPulse.CheckRangePermission(args.Player, (int) (pos.X/16f), (int) (pos.Y/16f)))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            Item item = new Item();
            item.netDefaults(type);
            if (stacks > item.maxStack || tPulse.Itembans.ItemIsBanned(item.name, args.Player))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }
            if ((tPulse.Config.ServerSideInventory) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < tPulse.Config.LogonDiscardThreshold))
            {
            //Player is probably trying to sneak items onto the server in their hands!!!
                Log.ConsoleInfo(string.Format("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.name));
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;

            }
            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            return false;
        }
Exemplo n.º 20
0
        private static bool HandleTileKill(GetDataHandlerArgs args)
        {
            var tileX = args.Data.ReadInt32();
            var tileY = args.Data.ReadInt32();
            if (OnTileKill(tileX, tileY))
                return true;
            if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY)
                return false;

            if (args.Player.Dead && tPulse.Config.PreventDeadModification)
                return true;

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (Main.tile[tileX, tileY].type != 0x15 && (!Utils.MaxChests() && Main.tile[tileX, tileY].type != 0)) //Chest
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (tPulse.CheckTilePermission(args.Player, tileX, tileY))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            if (tPulse.CheckRangePermission(args.Player, tileX, tileY))
            {
                args.Player.SendTileSquare(tileX, tileY);
                return true;
            }

            return false;
        }
Exemplo n.º 21
0
        private static bool HandleNpcStrike(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();
            var direction = args.Data.ReadInt8();
            var dmg = args.Data.ReadInt16();
            var pvp = args.Data.ReadInt8();
            var crit = args.Data.ReadInt8();

            if (OnNPCStrike(id, direction, dmg, pvp, crit))
                return true;

            if (Main.npc[id] == null)
                return true;

            if (dmg > tPulse.Config.MaxDamage && !args.Player.Group.HasPermission(Permissions.ignoredamagecap))
            {
                args.Player.Disable(String.Format("NPC damage exceeded {0}.", tPulse.Config.MaxDamage ) );
                args.Player.SendData(PacketTypes.NpcUpdate, "", id);
                return true;
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.NpcUpdate, "", id);
                return true;
            }

            if (Main.npc[id].townNPC && !args.Player.Group.HasPermission(Permissions.movenpc))
            {
                args.Player.SendMessage( "You don't have permission to move this NPC.", Color.Yellow);
                args.Player.SendData(PacketTypes.NpcUpdate, "", id);
                return true;
            }

            if (tPulse.Config.RangeChecks &&
                tPulse.CheckRangePermission(args.Player, (int) (Main.npc[id].position.X/16f), (int) (Main.npc[id].position.Y/16f),
                                            128))
            {
                args.Player.SendData(PacketTypes.NpcUpdate, "", id);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendData(PacketTypes.NpcUpdate, "", id);
                return true;
            }

            return false;
        }
Exemplo n.º 22
0
        private static bool HandleTogglePvp(GetDataHandlerArgs args)
        {
            byte id = args.Data.ReadInt8();
            bool pvp = args.Data.ReadBoolean();
            if (OnPvpToggled(id, pvp))
                return true;

            if (id != args.Player.Index)
            {
                return true;
            }

            if (tPulse.Config.PvPMode == "disabled")
            {
                return true;
            }

            if (args.TPlayer.hostile != pvp)
            {
                long seconds = (long) (DateTime.UtcNow - args.Player.LastPvpChange).TotalSeconds;
                if (seconds > 5)
                {
                    TPPlayer.All.SendMessage(string.Format("{0} has {1} PvP!", args.Player.Name, pvp ? "enabled" : "disabled"),
                                             Main.teamColor[args.Player.Team]);
                }
                args.Player.LastPvpChange = DateTime.UtcNow;
            }

            args.TPlayer.hostile = pvp;

            if (tPulse.Config.PvPMode == "always")
            {
                if (!pvp)
                    args.Player.Spawn();
            }

            NetMessage.SendData((int) PacketTypes.TogglePvp, -1, -1, "", args.Player.Index);

            return true;
        }
Exemplo n.º 23
0
        private static bool HandlePlayerAnimation(GetDataHandlerArgs args)
        {
            if (OnPlayerAnimation())
                return true;

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
                return true;
            }

            if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
            {
                args.Player.SendData(PacketTypes.PlayerAnimation, "", args.Player.Index);
                return true;
            }

            return false;
        }
Exemplo n.º 24
0
        public static bool HandlePlayerHp(GetDataHandlerArgs args)
        {
            var plr = args.Data.ReadInt8();
            var cur = args.Data.ReadInt16();
            var max = args.Data.ReadInt16();

            if (OnPlayerHP(plr, cur, max))
                return true;

            if (args.Player.FirstMaxHP == 0)
                args.Player.FirstMaxHP = max;

            if (max > 400 && max > args.Player.FirstMaxHP)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Hacked Client Detected.", true);
                return false;
            }

            if (args.Player.IsLoggedIn)
            {
                args.Player.PlayerData.maxHealth = max;
            }

            return false;
        }
Exemplo n.º 25
0
        private static bool HandlePlayerBuffUpdate(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt8();

            if (OnPlayerBuffUpdate(id))
                return true;

            for (int i = 0; i < 10; i++)
            {
                var buff = args.Data.ReadInt8();

                if (buff == 10)
                {
                    if (!args.Player.Group.HasPermission(Permissions.usebanneditem) &&
                        tPulse.Itembans.ItemIsBanned("Invisibility Potion", args.Player))
                        buff = 0;
                    else if (tPulse.Config.DisableInvisPvP && args.TPlayer.hostile)
                        buff = 0;
                }

                args.TPlayer.buffType[i] = buff;
                if (args.TPlayer.buffType[i] > 0)
                {
                    args.TPlayer.buffTime[i] = 60;
                }
                else
                {
                    args.TPlayer.buffTime[i] = 0;
                }
            }
            NetMessage.SendData((int) PacketTypes.PlayerBuff, -1, args.Player.Index, "", args.Player.Index);
            return true;
        }
Exemplo n.º 26
0
        private static bool UpdateNPCHome(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var x = args.Data.ReadInt16();
            var y = args.Data.ReadInt16();
            var homeless = args.Data.ReadInt8();

            if (OnUpdateNPCHome(id, x, y, homeless))
                return true;

            if (!args.Player.Group.HasPermission(Permissions.movenpc))
            {
                args.Player.SendMessage("You do not have permission to relocate NPCs.", Color.Red);
                args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY,
                                     Convert.ToByte(Main.npc[id].homeless));
                return true;
            }

            if (tPulse.CheckTilePermission(args.Player, x, y))
            {
                args.Player.SendMessage( "You do not have access to modify this area.", Color.Red);
                args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY,
                                     Convert.ToByte(Main.npc[id].homeless));
                return true;
            }

            //removed until NPC Home packet actually sends their home coords.
            /*if (TShock.CheckRangePermission(args.Player, x, y))
            {
                args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY,
                                     Convert.ToByte(Main.npc[id].homeless));
                return true;
            }*/
            return false;
        }
Exemplo n.º 27
0
        private static bool HandlePlayerInfo(GetDataHandlerArgs args)
        {
            var playerid = args.Data.ReadInt8();
            var hair = args.Data.ReadInt8();
            var male = args.Data.ReadBoolean();
            args.Data.Position += 21;
            var difficulty = args.Data.ReadInt8();
            string name = Encoding.UTF8.GetString(args.Data.ReadBytes((int) (args.Data.Length - args.Data.Position - 1)));

            if (OnPlayerInfo(playerid, hair, male, difficulty, name))
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "A plugin cancelled the event.", true);
                return true;
            }

            if (name.Trim().Length == 0)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Empty Name.", true);
                return true;
            }
            var ban = tPulse.Bans.GetBanByName(name);
            if (ban != null)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, string.Format("You are banned: {0}", ban.Reason), true);
                return true;
            }
            if (args.Player.ReceivedInfo)
            {
                return true;
            }
            if (tPulse.Config.MediumcoreOnly && difficulty < 1)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Server is set to mediumcore and above characters only!", true);
                return true;
            }
            if (tPulse.Config.HardcoreOnly && difficulty < 2)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Server is set to hardcore characters only!", true);
                return true;
            }
            args.Player.Difficulty = difficulty;
            args.TPlayer.name = name;
            args.Player.ReceivedInfo = true;

            return false;
        }
Exemplo n.º 28
0
        private static bool HandleChestItem(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var slot = args.Data.ReadInt8();
            var stacks = args.Data.ReadInt8();
            var prefix = args.Data.ReadInt8();
            var type = args.Data.ReadInt16();

            if (OnChestItemChange(id, slot, stacks, prefix, type))
                return true;

            if (args.TPlayer.chest != id)
            {
                return false;
            }

            if (tPulse.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.ChestItem, "", id, slot);
                return true;
            }

            Item item = new Item();
            item.netDefaults(type);
            if (stacks > item.maxStack || tPulse.Itembans.ItemIsBanned(item.name, args.Player))
            {
                return false;
            }

            if (tPulse.CheckTilePermission(args.Player, Main.chest[id].x, Main.chest[id].y) && tPulse.Config.RegionProtectChests)
            {
                return false;
            }

            if (tPulse.CheckRangePermission(args.Player, Main.chest[id].x, Main.chest[id].y))
            {
                return false;
            }

            return false;
        }
Exemplo n.º 29
0
        private static bool HandlePlayerMana(GetDataHandlerArgs args)
        {
            var plr = args.Data.ReadInt8();
            var cur = args.Data.ReadInt16();
            var max = args.Data.ReadInt16();

            if (OnPlayerMana(plr, cur, max))
                return true;

            if (args.Player.FirstMaxMP == 0)
                args.Player.FirstMaxMP = max;

            if (max > 400 && max > args.Player.FirstMaxMP)
            {
                tPulse.PlayerHandle.ForceKick(args.Player, "Hacked Client Detected.", true);
                return false;
            }

            return false;
        }
Exemplo n.º 30
0
        private static bool HandlePlayerSlot(GetDataHandlerArgs args)
        {
            byte plr = args.Data.ReadInt8();
            byte slot = args.Data.ReadInt8();
            byte stack = args.Data.ReadInt8();
            byte prefix = args.Data.ReadInt8();
            short type = args.Data.ReadInt16();

            if (OnPlayerSlot(plr, slot, stack, prefix, type))
                return true;

            if (plr != args.Player.Index)
            {
                return true;
            }

            if (slot < 0 || slot > NetItem.maxNetInventory)
            {
                return true;
            }

            var item = new Item();
            item.netDefaults(type);
            item.Prefix(prefix);

            if (args.Player.IsLoggedIn)
            {
                args.Player.PlayerData.StoreSlot(slot, type, prefix, stack);
            }

            return false;
        }