--- title: Geyser Events --- # Geyser Events Geyser has a powerful event system that allows you to listen to events that are sent by Geyser. Events are at the heart of Geyser Extensions, and can be used by plugins and mods as well. Full documentation can be found [here](https://github.com/GeyserMC/Geyser/tree/master/api/src/main/java/org/geysermc/geyser/api/event). ## Event Categories To use events in a Spigot/Paper plugin or a Fabric mod, you need to register the Geyser Event Bus as a listener and then subscribe to the events you want to listen to. Extensions can use the @Subscribe annotation. Events are categorized into the following categories: - [Bedrock](https://github.com/GeyserMC/Geyser/tree/master/api/src/main/java/org/geysermc/geyser/api/event/bedrock): Events that are sent for each connecting Bedrock client, for example the ClientEmoteEvent that is sent when a Bedrock player uses an emote - or the SessionLoginEvent that is sent when a Bedrock player logged in and is about to join a server. - [Java](https://github.com/GeyserMC/Geyser/tree/master/api/src/main/java/org/geysermc/geyser/api/event/java): Events that are sent for the java server, for example the ServerDefineCommandsEvent - it is fired when the Java sends the commands to show for Bedrock players. - [Connection](https://github.com/GeyserMC/Geyser/tree/master/api/src/main/java/org/geysermc/geyser/api/event/connection): Connection-related events, such as a ping event to return e.g. a custom MOTD. - [Lifecycle](https://github.com/GeyserMC/Geyser/tree/master/api/src/main/java/org/geysermc/geyser/api/event/lifecycle): Events that are sent during Geyser's lifecycle, such as the loading of custom items, resource packs, or Geyser commands. To see all the events in the respective categories, click on the links above. ## Usage Examples: Each method that you want to subscribe to an event needs to be annotated with the @Subscribe annotation (from the GeyserMC events package). ```java @Subscribe public void onGeyserLoadResourcePacksEvent(GeyserLoadResourcePacksEvent event) { logger().info("Loading: " + event.resourcePacks().size() + " resource packs."); // you could add a resource pack with event.resourcePacks().add(path-to-pack) } ``` If you wish to listen to events in a Spigot/Paper plugin or a Fabric mod, you need to register the Geyser Event Bus as a listener first. Just make sure you implement `EventRegistrar` in the main class of your mod or plugin. Extensions do not need to do that - they are automatically registered, so a simple @Subscribe annotation is enough. **Fabric mod example:** ```java public class ExampleMod implements ModInitializer, EventRegistrar { public static final Logger LOGGER = LoggerFactory.getLogger("modid"); @Override public void onInitialize() { ServerLifecycleEvents.SERVER_STARTING.register((server) -> { GeyserApi.api().eventBus().register(this, ExampleMod.class); // register your mod & this class as a listener }); LOGGER.info("Geyser is cool!"); } // here an event, we subscribe as usual with the @Subscribe annotation @Subscribe public void onGeyserPostInitializeEvent(GeyserPostInitializeEvent eventad { LOGGER.info("Geyser started!"); } } ```