LogoLogo
LogoLogo
  • What is PacketEvents?
  • Prerequisites
  • Getting Started
  • The PacketEvents Instance
  • Creating Your PacketEvents Instance
    • (Optional) Configuring PacketEvents
  • What is a PacketEvents Listener
  • Creating Your First Listener
  • Registering a Packet Listener
  • Sending and Simulating Packets
  • Advanced PacketEvents Example: Combining our Knowledge
  • FAQ (WIP)
Powered by GitBook
On this page
  • What it takes to use the PacketEvents API
  • Instance Creation
  • Settings
  • Initialization
  • Termination

Was this helpful?

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.

Most importantly, initialization should only be done if you are shading the library. 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! (if you aren't shading) You usually want to terminate the instance as soon as your plugin has been disabled.

PreviousGetting StartedNextCreating Your PacketEvents Instance

Last updated 4 months ago

Was this helpful?