I've seen multiple ways that plugin developers create their own API in their plugins for others to use. Some create public static functions that return an instance of that plugin. Is this necessary? Is there a more effective way? I know you can use this PHP: $this->getServer()->getPluginManager()->getPlugin("myPluginName"); to get a Plugin, but after that, can I use the retrieved plugin to run public functions? I ask this question because there doesn't seem to be any clear, preferred method for making an API. I want to create a good API with a plugin I am working on, but I don't know if I need to make a static instance getter in my plugin. (I recently saw quite a discussion about static functions, so I am a little uneasy about using them much.) I would appreciate any advice or guidance you can give, and thank you for your time.
Some plugins do use static getters, but it isn't exactly required to use the API of a plugin, using the way you showed in your post. Using the getPlugin() function will allow you to run the functions of your PluginBase class. Aside from that, an API doesn't necessarily just exist out of public functions. Think about creating custom events for example as well.
the static instance getter is called singleton which in some people opinion is evil and anything that is public means if another plugin can get your instance they can use it
So why do people use singleton getters? Is there any advantage? I just want to make my plugin as easy as possible to extend.
Forget all the talk about static methods. Someone who doesn't understand what APIs are started an illogical debate comparing performance of static methods in that thread, which is totally irrelevant to APIs. Just provide public ways to retrieve or change stuff in your plugin, and that's all an API is for.