API returning nullSolved

I'm dissapointed that I've given up, but I just can't seem to return a list of monuments from the API_FindMonuments call.  Below is what I have, and it always is null.  Thanks in advance!

[PluginReference]
 private Plugin MonumentFinder;

 private List<Dictionary<string, object>> _monuments;

 private void Init()
        {
            Puts("Initializing...");

            _monuments = GetMonuments();
            
            
            if (_monuments == null || _monuments.Count == 0)
            {
                Puts("couldn't retreive monuments");
            }
            else {
                Puts("got monuments..");
            }

        }

private List<Dictionary<string, object>> GetMonuments(string filter = null)
        {
            return MonumentFinder?.Call("API_FindMonuments", filter) as List<Dictionary<string, object>>;
        }
​

One note is that you should be running that code in OnServerInitialized(), and ideally delaying 1 tick in case your plugin loads before Monument Finder (plugins load in alphabetical order on server boot). Are you seeing "couldn't retreive monuments" even when reloading your plugin?

I ran the following code on my server and it printed that there were 23 monuments.

var monumentList = MonumentFinder?.Call("API_FindMonuments", null) as List<Dictionary<string, object>>;
Puts($"{monumentList?.Count} monuments found");

Maybe Monument Finder hasn't found the monuments for some reason. I've had very sparse reports of the plugin failing to find monuments on server boot, but I haven't been able to reproduce that issue. To see if that is the issue, could you try reloading Monument Finder, then reload your plugin to see if it can find them? If that works, there's probably something that needs to be fixed in Monument Finder's early monument detection.

Nothing worked until I moved everything into the OnServerInitialized() method.  Now it works perfectly.

Thanks!

Locked automatically