Geyser icon indicating copy to clipboard operation
Geyser copied to clipboard

Events can be handled by any class

Open ImDaBigBoss opened this issue 2 years ago • 6 comments

The Extension class extends EventListener, and any class can implement it and then register it:

ClassThatImplementsEventListener eventListener = new ClassThatImplementsEventListener();
GeyserApi.api().eventBus().register(eventListener, eventListener);

Also:

  • Loggers have the same implementation (AbstractLogger) so that we make sure they follow each other
  • Stopped the extensions folder from being created at the server root for non standalone and moved it into the data folder.

ImDaBigBoss avatar Jun 19 '22 17:06 ImDaBigBoss

I would suggest using the onLoad function for that, but I need to make sure that moving code around like that won’t break anything.

ImDaBigBoss avatar Jun 23 '22 06:06 ImDaBigBoss

I'm not sure if we need a whole Logger interface - maybe we should just use Java's?

This PR looks fine to me otherwise. But, before we merge, we do need to figure out a good way for, say, Spigot plugins to reliably attach themselves to Geyser before Geyser initializes.

Java's one is full of things that we don't need in Geyser isn't it? I can remove the AbstractLogger and put it back to the way it was.

ImDaBigBoss avatar Jul 02 '22 06:07 ImDaBigBoss

I have no idea if this broke anything. This code needs checking by someone who knows Geyser better than me, but I was able to catch the init events by registering my listeners in the onLoad event of my spigot plugin. If the code is fine, notify me, and I'll make this PR not be a draft anymore if you can't merge.

ImDaBigBoss avatar Jul 02 '22 19:07 ImDaBigBoss

The only thing I'm wondering is if we should delay plugin loading after onEnable so plugins have a chance to register lifecycle events at any point during initialization.

Camotoy avatar Jul 12 '22 16:07 Camotoy

Do people really want Geyser to be slower? I thought you had been working on trying to make the load time faster.

ImDaBigBoss avatar Jul 13 '22 19:07 ImDaBigBoss

I think there's a difference here, since we're simply delaying triggering parts of the plugin. It doesn't really matter for us when the load time is. Our only requirement is that Geyser is booted by/around the time the server is ready.

Camotoy avatar Jul 13 '22 20:07 Camotoy

Registering listeners is broken for now but the code for loading in onLoad is fixed.

ImDaBigBoss avatar Aug 19 '22 17:08 ImDaBigBoss

Superseded by https://github.com/GeyserMC/Geyser/commit/f1da9d70728ad50cbff5c345052f8b18fabb06f2.

Redned235 avatar Sep 04 '22 21:09 Redned235