enebo / Purugin

Ruby Minecraft Plugin support on top of bukkit
238 stars 32 forks source link

visitors_log.rb #60

Open NigelThorne opened 7 years ago

NigelThorne commented 7 years ago

I tried to write a plugin in a file called visitors_log.rb (it could have been visitor_log.rb ) and a plugin called VisitorsLogPlugin. For some reason I couldn't get this to work in any way... finally I ended up removing all content and it still failed to load. In the end I named it something different and it works fine. same code. different name

What are the limitations on names you can call your plugins?

Cheers Nigel

enebo commented 7 years ago

Yeah it took me a bit to remember how this works but there is no obvious naming issue I know of for this...unless you happen to be naming the plugin something that MAYBE is registered already via Spigot (if you happen to be using other Java plugins). Or perhaps you are loading multiple plugins across multiple threads (never really thought about people making user threads for that).

The way it works is a tiny bit wonky. We glob on plugins/*.rb and load all files in turn. If those files include Purugin::Plugin then it registers the class which includes it via Module#included. "registers" is the wonky part. It is saved via side-effect via global (since this happens before RubyPluginLoader is ready for it to be registered). Then immediately after it is loaded .new is called on it. It is likely somehow that name is blowing up lower within Java code itself and it is not a Purugin issue. Well it is in that it is crapping the bed and not telling you what went wrong, but I do not think Purugin is what is not loading the plugin.

If you can deduce it is some naming conflict with Java plugin then we can consider how we would deal with it:

Of course I am just guessing at this point.