The PacketEvents Instance

What it takes to use the PacketEvents API

The majority of features offered by PacketEvents are accessible through the PacketEvents instance. If you decide to shade the library, you are responsible for initializing and terminating the instance.

Instance Creation

The PacketEvents instance is your friend and allows you to access functionality within our API. This instance can be created using the PacketEvents builder of your PacketEvents implementation.

E.g. SpigotPacketEventsBuilder (for Minecraft Spigot-based platforms)

Settings

Settings in your PacketEvents instance can change the way the API behaves. Only do this if you are shading the library. Modifying certain settings on an external version of PacketEvents could break other plugins.

Initialization

The PacketEvents instance offers two functions for initialization: the load method and the init method. The load method must be called before the init method. Normally, the init method is sufficient, but for Spigot, it is crucial to call load as soon as the plugin loads and then call init once the plugin is enabled.

Termination

Once you have finished using your PacketEvents instance, terminate it! You usually want to terminate the instance as soon as your plugin has been disabled.

Last updated