-
-
Notifications
You must be signed in to change notification settings - Fork 127
Shading PacketEvents
Learn how to safely shade PacketEvents by following this guide. Make sure to follow each step to avoid any issues.
Add this repository to your pom.xml
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>
Add the packetevents dependency to your pom.xml.
Replace PLATFORM with the platform you are developing for. (Supported platforms: spigot, bungeecord or velocity)
<dependency>
<groupId>com.github.retrooper.packetevents</groupId>
<artifactId>PLATFORM</artifactId>
<version>2.3.0</version>
<scope>compile</scope>
</dependency>
Add this repository to your build.gradle
maven { url 'https://repo.codemc.io/repository/maven-releases/' }
Add the packetevents dependency to your build.gradle
Replace PLATFORM with the platform you are developing for. (Supported platforms: spigot, bungeecord or velocity)
implementation 'com.github.retrooper.packetevents:PLATFORM:2.3.0'
Now that you have the dependency, you can use the maven-shade-plugin(on Maven) or shadowJar(on Gradle) to shade this dependency. Please relocate the following packetevents packages to avoid issues with multiple projects shading the library. Pick unique packages.
com.github.retrooper.packetevents -> me.username.firstplugin.packetevents.api
io.github.retrooper.packetevents -> me.username.firstplugin.packetevents.impl
net.kyori -> me.username.firstplugin.packetevents.kyori
The relocated packages I made up are just examples, I don't care what you use.
You can minimize the dependency to save space. Classes you don't use will not be shipped with your plugin allowing you to have a much smaller jar. This should clear up the packet wrappers you aren't using.
On Gradle you insert a minimize()
inside the shadowJar task.
On Maven you can set <minimizeJar>
to true in your maven-shade-plugin configuration.
If you are developing a Spigot/Paper/etc server plugin, read this carefully. You are going to want to open up your plugin.yml and soft-depend these plugins:
softdepend:
- ProtocolLib
- ProtocolSupport
- ViaVersion
- ViaBackwards
- ViaRewind
- Geyser-Spigot
This ensures that our injector is loaded last and will therefore operate correctly.
If you need any more support, consider joining the discord server: https://discord.gg/prqzNg9tRU
Examples of how to use PacketEvents
Click this!