From 1d04df7e3b53330f6cae585c1dd61709e478df04 Mon Sep 17 00:00:00 2001 From: Kadava Date: Tue, 13 Oct 2026 03:18:59 +0100 Subject: [PATCH] Fixing keycard labels not updating Simple fix to custom keycards not updating their label if their colour doesn't have a value - also just streamlined the code to run the same function because it was doing the same thing anyway --- CustomItemsAPI/Items/CustomKeyCardBase.cs | 63 +++++------------------ 1 file changed, 12 insertions(+), 51 deletions(-) diff --git a/CustomItemsAPI/Items/CustomKeyCardBase.cs b/CustomItemsAPI/Items/CustomKeyCardBase.cs index 00d1103..024f188 100644 --- a/CustomItemsAPI/Items/CustomKeyCardBase.cs +++ b/CustomItemsAPI/Items/CustomKeyCardBase.cs @@ -72,56 +72,12 @@ public override void Parse(Pickup pickup) throw new Exception("Pickup is not a Keycard Pickup"); if (OpenDoorsOnThrow.HasValue) keycardPickup.Base._openDoorsOnCollision = OpenDoorsOnThrow.Value; - if (!keycardPickup.Base.TryGetTemplate(out var template)) throw new Exception("Cannot get a template for this item"); - if (!template.Customizable) return; - // getting all than later checking - // me when a keycard isnt customisable cant do shit with these. - IC.NametagDetail? nametag = template.Details.OfType().FirstOrDefault(); - IC.CustomPermsDetail? customPermsDetail = template.Details.OfType().FirstOrDefault(); - IC.CustomTintDetail? customTint = template.Details.OfType().FirstOrDefault(); - IC.CustomWearDetail? customWear = template.Details.OfType().FirstOrDefault(); - IC.CustomItemNameDetail? customItemName = template.Details.OfType().FirstOrDefault(); - IC.CustomSerialNumberDetail? customSerialNumber = template.Details.OfType().FirstOrDefault(); - IC.CustomLabelDetail? customLabel = template.Details.OfType().FirstOrDefault(); - IC.CustomRankDetail? customRank = template.Details.OfType().FirstOrDefault(); - - if (customRank != null) - IC.CustomRankDetail._index = RankIndex; - - if (Levels.HasValue && customPermsDetail != null) - IC.CustomPermsDetail._customLevels = Levels.Value; - - if (PermissionColor.HasValue && customPermsDetail != null) - IC.CustomPermsDetail._customColor = PermissionColor; - - if (TintColor.HasValue && customTint != null) - IC.CustomTintDetail._customColor = TintColor.Value; - - if (WearLevel.HasValue && customWear != null) - IC.CustomWearDetail._customWearLevel = WearLevel.Value; - - if (nametag != null && !string.IsNullOrEmpty(CustomNameTag)) - IC.NametagDetail._customNametag = CustomNameTag; - - if (customItemName != null && !string.IsNullOrEmpty(CustomName)) - IC.CustomItemNameDetail._customText = CustomName; - - if (customSerialNumber != null && !string.IsNullOrEmpty(CustomSerial)) - IC.CustomSerialNumberDetail._customVal = CustomSerial; - - if (customLabel != null && !string.IsNullOrEmpty(CustomLabelText) && CustomLabelColor.HasValue) - { - IC.CustomLabelDetail._customText = CustomLabelText; - IC.CustomLabelDetail._customColor = CustomLabelColor.Value; - } - - IC.KeycardDetailSynchronizer.Database.Remove(keycardPickup.Base.Info.Serial); - IC.KeycardDetailSynchronizer.ServerProcessPickup(keycardPickup.Base); + SetCustomDetails(template); } /// @@ -132,13 +88,17 @@ public override void Parse(Item item) throw new ArgumentOutOfRangeException("Type", item.Type, "Invalid Keycard type."); if (item.Base is not IC.KeycardItem keycard) throw new ArgumentException($"keycard must not be null! {item.GetType()}"); - if (OpenDoorsOnThrow.HasValue) keycard.OpenDoorsOnThrow = OpenDoorsOnThrow.Value; - if (!keycard.Customizable) return; + SetCustomDetails(keycard); + } + + private void SetCustomDetails(IC.KeycardItem keycard) + { + CL.Info($"Setting custom details for keycard {keycard.ItemSerial}, {keycard.name}, {keycard.DisplayName}"); // getting all than later checking // me when a keycard isnt customisable cant do shit with these. IC.NametagDetail? nametag = keycard.Details.OfType().FirstOrDefault(); @@ -174,17 +134,18 @@ public override void Parse(Item item) if (customSerialNumber != null && !string.IsNullOrEmpty(CustomSerial)) IC.CustomSerialNumberDetail._customVal = CustomSerial; - if (customLabel != null && !string.IsNullOrEmpty(CustomLabelText) && CustomLabelColor.HasValue) + if (customLabel != null) { - IC.CustomLabelDetail._customText = CustomLabelText; - IC.CustomLabelDetail._customColor = CustomLabelColor.Value; + if (!string.IsNullOrEmpty(CustomLabelText)) + IC.CustomLabelDetail._customText = CustomLabelText; + if (CustomLabelColor.HasValue) + IC.CustomLabelDetail._customColor = CustomLabelColor.Value; } IC.KeycardDetailSynchronizer.Database.Remove(keycard.ItemSerial); IC.KeycardDetailSynchronizer.ServerProcessItem(keycard); } - /// /// Called when is interacted with the . ///