diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/GraphNode_SetDefaults.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/GraphNode_SetDefaults.h index 0bbcb59e..7048b954 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/GraphNode_SetDefaults.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/GraphNode_SetDefaults.h @@ -94,7 +94,8 @@ public: UEdGraphNode* Node = F.Node(Entry.Node).Cast(); if (!Node) return; - MCPProperty P = MCPProperty::GetOneExactMatch(Node, CPF_Edit, Entry.Name); + TArray All = MCPProperty::GetAll(Node, CPF_Edit); + MCPProperty P = MCPProperty::FindOneExactMatch(All, Entry.Name); if (!P) return; UMCPServer::AddTouchedObject(Node); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Dump.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Dump.h index 38ead339..41786dc4 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Dump.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Dump.h @@ -43,8 +43,8 @@ public: MCPFetcher F; UObject* Template = F.Walk(Object).Cast(); if (!Template) return; - - TArray Props = MCPProperty::GetAllSubstring(Template, CPF_Edit, Query); + TArray AllProps = MCPProperty::GetAll(Template, CPF_Edit); + TArray Props = MCPProperty::FindAllSubstring(AllProps, Query); if (Local) { UClass* ObjClass = Template->GetClass(); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Get.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Get.h index 2acea61a..4045f313 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Get.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Get.h @@ -36,7 +36,8 @@ public: UObject* Obj = F.Walk(Object).Cast(); if (!Obj) return; - MCPProperty P = MCPProperty::GetOneExactMatch(Obj, CPF_Edit, Property); + TArray All = MCPProperty::GetAll(Obj, CPF_Edit); + MCPProperty P = MCPProperty::FindOneExactMatch(All, Property); if (!P) return; UMCPServer::Print(P.GetText()); diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Set.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Set.h index e80748ef..9a072ffe 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Set.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Handlers/Property_Set.h @@ -44,10 +44,11 @@ public: } // Validation pass — resolve all properties and values before modifying anything. + TArray All = MCPProperty::GetAll(Obj, CPF_Edit); TArray> Resolved; for (const auto& Pair : Properties.Json->Values) { - MCPProperty P = MCPProperty::GetOneExactMatch(Obj, CPF_Edit, Pair.Key); + MCPProperty P = MCPProperty::FindOneExactMatch(All, Pair.Key); if (!P) return; FString ValueStr; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPProperty.cpp b/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPProperty.cpp index 90bde8cd..af5e7483 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPProperty.cpp +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Private/MCPProperty.cpp @@ -160,12 +160,11 @@ TArray MCPProperty::GetAll(UStruct* StructType, void* Container, EP return Result; } -TArray MCPProperty::GetAllSubstring(UObject* Obj, EPropertyFlags Flags, const FString& Substring) +TArray MCPProperty::FindAllSubstring(const TArray& Props, const FString& Substring) { - TArray All = GetAll(Obj, Flags); - if (Substring.IsEmpty()) return All; + if (Substring.IsEmpty()) return Props; TArray Result; - for (const MCPProperty& P : All) + for (const MCPProperty& P : Props) { if (MCPUtils::FormatName(P.Prop).Contains(Substring, ESearchCase::IgnoreCase)) Result.Add(P); @@ -173,31 +172,22 @@ TArray MCPProperty::GetAllSubstring(UObject* Obj, EPropertyFlags Fl return Result; } -TArray MCPProperty::GetAllExactMatch(UObject* Obj, EPropertyFlags Flags, const FString& Name) +MCPProperty MCPProperty::FindOneExactMatch(const TArray& Props, const FString& Name) { - TArray All = GetAll(Obj, Flags); - TArray Result; - for (const MCPProperty& P : All) + TArray Matches; + for (const MCPProperty& P : Props) { if (MCPUtils::Identifies(Name, P.Prop)) - Result.Add(P); + Matches.Add(P); } - return Result; -} - -MCPProperty MCPProperty::GetOneExactMatch(UObject* Obj, EPropertyFlags Flags, const FString& Name) -{ - TArray Matches = GetAllExactMatch(Obj, Flags, Name); if (Matches.Num() == 0) { - UMCPServer::Printf(TEXT("ERROR: Property '%s' not found on %s\n"), - *Name, *MCPUtils::FormatName(Obj->GetClass())); + UMCPServer::Printf(TEXT("ERROR: Property '%s' not found\n"), *Name); return MCPProperty(); } if (Matches.Num() > 1) { - UMCPServer::Printf(TEXT("ERROR: Ambiguous property '%s' on %s\n"), - *Name, *MCPUtils::FormatName(Obj->GetClass())); + UMCPServer::Printf(TEXT("ERROR: Ambiguous property '%s'\n"), *Name); return MCPProperty(); } return Matches[0]; diff --git a/Plugins/BlueprintMCP/Source/BlueprintMCP/Public/MCPProperty.h b/Plugins/BlueprintMCP/Source/BlueprintMCP/Public/MCPProperty.h index 627227a1..feb1a9dc 100644 --- a/Plugins/BlueprintMCP/Source/BlueprintMCP/Public/MCPProperty.h +++ b/Plugins/BlueprintMCP/Source/BlueprintMCP/Public/MCPProperty.h @@ -23,9 +23,8 @@ public: static void Remove(TArray& Props, const FString& Name); static TArray GetAll(UObject* Obj, EPropertyFlags Flags); static TArray GetAll(UStruct* StructType, void* Container, EPropertyFlags Flags); - static TArray GetAllSubstring(UObject* Obj, EPropertyFlags Flags, const FString& Substring); - static TArray GetAllExactMatch(UObject* Obj, EPropertyFlags Flags, const FString& Name); - static MCPProperty GetOneExactMatch(UObject* Obj, EPropertyFlags Flags, const FString& Name); + static TArray FindAllSubstring(const TArray& Props, const FString& Substring); + static MCPProperty FindOneExactMatch(const TArray& Props, const FString& Name); private: bool TryParseEnum(UEnum* Enum, const FString& Text, int64 &OutValue);