-
-
Notifications
You must be signed in to change notification settings - Fork 156
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>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</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</groupId>
<artifactId>packetevents-PLATFORM</artifactId>
<version>2.7.0</version>
<scope>compile</scope>
</dependency>
Add this repository to your build.gradle
maven { url = uri("https://repo.codemc.io/repository/maven-releases/") }
maven { url = uri("https://repo.codemc.io/repository/maven-snapshots/") }
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.7.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
The relocated packages I made up are just examples, you may pick whatever you wish.
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!