/// <summary> /// Ensures that this player has non-prefixed armor if the option is enabled /// </summary> /// <param name="handlers"></param> internal void CheckArmorAndEnforce(GetDataHandlers handlers) { if (TPlayer.armor[0].prefix > 0) { TPlayer.armor[0].prefix = 0; DataSender.SendSlotUpdate(this, 59, TPlayer.armor[0]); } if (TPlayer.armor[1].prefix > 0) { DataSender.SendSlotUpdate(this, 60, TPlayer.armor[1]); } if (TPlayer.armor[2].prefix > 0) { DataSender.SendSlotUpdate(this, 61, TPlayer.armor[2]); } }
/// <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; 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); }