Beispiel #1
0
        /// <summary>
        /// Initializes a new player object when someone joins
        /// </summary>
        /// <param name="args"></param>
        private void ServerJoin(JoinEventArgs args)
        {
            Players[args.Who]        = new Player(TShock.Players[args.Who], this);
            Players[args.Who].IsDead = true;

            for (int i = 0; i < (int)(NetItem.ArmorSlots / 2); i++)
            {
                if (Players[args.Who].TPlayer.armor[i].netID != 0 &&
                    EquipController.ShouldPreventEquip(Players[args.Who], Players[args.Who].TPlayer.armor[i], 59 + i))
                {
                    Players[args.Who].TPlayer.armor[i].SetDefaults(0);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Prevents prefixes on armor items
        /// </summary>
        /// <param name="args">The GetDataHandlerArgs object containing the player who sent the packet and the
        /// data in it</param>
        /// <returns>Whether or not the packet was handled (and should therefore not be processed
        /// by anything else)</returns>
        private bool HandleInventoryUpdate(GetDataHandlerArgs args)
        {
            args.Data.ReadByte();
            int slotId = args.Data.ReadByte();

            args.Data.ReadInt16();
            byte prefix = (byte)args.Data.ReadByte();
            int  netId  = args.Data.ReadInt16();

            // Is prefixed armor armor
            if (Controller.Config.BanPrefixedArmor && prefix > 0 && slotId >= 59 && slotId <= 61)
            {
                Item fixedArmorItem = new Item();
                fixedArmorItem.Prefix(0);
                fixedArmorItem.stack = 1;
                Controller.DataSender.SendSlotUpdate(args.Player, slotId, fixedArmorItem);
            }

            bool impossibleEquip = false;

            if (Controller.Config.PreventImpossibleEquipment && netId != 0)
            {
                if (slotId >= 59 && slotId <= 66)
                {
                    Item newEquip = new Item();
                    newEquip.SetDefaults(netId);
                    newEquip.Prefix(prefix);
                    if (EquipController.ShouldPreventEquip(args.Player, newEquip, slotId))
                    {
                        impossibleEquip = true;
                        args.Player.TPlayer.armor[slotId - 59].SetDefaults(0);
                    }
                }
            }
            return(impossibleEquip);
        }