From 5c5c0d800377020bc94d5c889c7ebcf8258d2238 Mon Sep 17 00:00:00 2001 From: Kai Roth Date: Thu, 2 Mar 2023 17:43:59 +0100 Subject: [PATCH] refactor: :recycle: ModManifest added type checks Added type check to `_get_string_from_dict()` and `_get_array_from_dict()` --- addons/mod_loader/classes/mod_manifest.gd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/mod_loader/classes/mod_manifest.gd b/addons/mod_loader/classes/mod_manifest.gd index a5d053bc..a83b13a3 100644 --- a/addons/mod_loader/classes/mod_manifest.gd +++ b/addons/mod_loader/classes/mod_manifest.gd @@ -218,17 +218,25 @@ static func is_mod_id_valid(original_mod_id: String, check_mod_id: String, type return true -# Returns an empty String if the key does not exist +# Returns an empty String if the key does not exist or is not type of String static func _get_string_from_dict(dict: Dictionary, key: String) -> String: if not dict.has(key): return "" + + if not dict[key] is String: + return "" + return dict[key] -# Returns an empty Array if the key does not exist +# Returns an empty Array if the key does not exist or is not type of Array static func _get_array_from_dict(dict: Dictionary, key: String) -> Array: if not dict.has(key): return [] + + if not dict[key] is Array: + return [] + return dict[key]