public static T GetDataOrDefault <T>(string modid, string key, T defaultValue, bool log = true) { if (!_instance.modData.TryGetValue(modid, out Dictionary <string, object> modDataEntries)) { if (log) { XLShredLogger.Log($"The mod '{modid}' does not have any data registered.", _instance.GetType()); } return(defaultValue); } if (!modDataEntries.TryGetValue(key, out object modData)) { if (log) { XLShredLogger.Log($"The mod '{modid}' does not have the any data registered with key '{key}'.", _instance.GetType()); } return(defaultValue); } return((T)modData); }
public static bool TryGetData(string modid, string key, out dynamic data, bool log = true) { if (!_instance.modData.TryGetValue(modid, out Dictionary <string, object> modDataEntries)) { if (log) { XLShredLogger.Log($"The mod '{modid}' does not have any data registered.", _instance.GetType()); } data = null; return(false); } if (!modDataEntries.TryGetValue(key, out object modData)) { if (log) { XLShredLogger.Log($"The mod '{modid}' does not have the any data registered with key '{key}'.", _instance.GetType()); } data = null; return(false); } data = modData; return(true); }