|
| 1 | +--- |
| 2 | +slug: /dev/userdev |
| 3 | +sidebar_label: Paperweight Userdev |
| 4 | +--- |
| 5 | + |
| 6 | +# paperweight-userdev |
| 7 | + |
| 8 | +**paperweight** is the name of Paper's custom build tooling. The **paperweight-userdev** Gradle plugin part of that |
| 9 | +provides access to internal code (also known as NMS) during development. |
| 10 | + |
| 11 | +:::note |
| 12 | + |
| 13 | +This guide is written using the Kotlin DSL for Gradle and assumes you have some basic knowledge of Gradle. |
| 14 | +If you want to see a fully-functioning plugin that uses **paperweight-userdev**, |
| 15 | +check out this [example plugin](https://github.com/PaperMC/paperweight-test-plugin). |
| 16 | + |
| 17 | +::: |
| 18 | + |
| 19 | +## Why this is useful |
| 20 | +The Paper server jars we provide on the downloads page through the API are **paperclip** jars. These |
| 21 | +use Spigot's mappings, which are essentially some type names, but fully obfuscated fields and methods. |
| 22 | +This can make it hard to work with in a development environment. This plugin lets you use fully deobfuscated |
| 23 | +types, names and fields during development, and then remaps your plugin, so it can still be used with the obfuscated |
| 24 | +server. |
| 25 | + |
| 26 | +:::caution |
| 27 | + |
| 28 | +The re-obfuscation does not apply to reflection. Look at something like [this library](https://github.com/jpenilla/reflection-remapper) to be able to |
| 29 | +use non-obfuscated names in reflection. |
| 30 | + |
| 31 | +::: |
| 32 | + |
| 33 | +## Adding the plugin |
| 34 | +Add the plugin to your `build.gradle.kts` file. |
| 35 | +```kotlin |
| 36 | +plugins { |
| 37 | + id("io.papermc.paperweight.userdev") version "1.5.5" // the latest version can be found on the Gradle Plugin Portal |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +:::info[Snapshots] |
| 42 | + |
| 43 | +**paperweight-userdev** releases are available through the Gradle plugin portal, but if you |
| 44 | +want to use SNAPSHOT versions, you must add Paper's maven repo to `settings.gradle.kts` with: |
| 45 | +```kotlin |
| 46 | +pluginManagement { |
| 47 | + repositores { |
| 48 | + maven("https://repo.papermc.io/repository/maven-public/") |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +::: |
| 54 | + |
| 55 | +## Adding the dev-bundle dependency |
| 56 | +If you try to load your Gradle project now, you will receive an error saying you have to declare |
| 57 | +a dev bundle dependency. You can do that by adding to your `dependencies` block in your `build.gradle.kts` |
| 58 | +file. |
| 59 | + |
| 60 | +```kotlin |
| 61 | +dependencies { |
| 62 | + // Other Dependencies |
| 63 | + paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT") |
| 64 | +} |
| 65 | +``` |
| 66 | +:::tip |
| 67 | + |
| 68 | +You can remove any dependency for the Paper API, as the dev bundle includes that. |
| 69 | + |
| 70 | +::: |
| 71 | + |
| 72 | +## Gradle Tasks |
| 73 | + |
| 74 | +### reobfJar |
| 75 | + |
| 76 | +This task creates a plugin jar that is re-obfuscated to Spigot's runtime mappings. |
| 77 | +This means it will work on standard Paper servers. |
| 78 | + |
| 79 | +The output will be inside the `build/libs` folder. The jar whose filename includes `-dev` |
| 80 | +is mojang-mapped (not re-obfuscated) and will not work on most servers. |
| 81 | + |
| 82 | +:::info[Shadow] |
| 83 | + |
| 84 | +If you have the shadow Gradle plugin applied in your build script, **paperweight-userdev** will |
| 85 | +detect that and use the shaded jar as the input for the `reobfJar` task. |
| 86 | + |
| 87 | +The `-dev-all.jar` file in `build/libs` is the shaded, but not re-obfuscated jar. |
| 88 | + |
| 89 | +::: |
| 90 | + |
| 91 | +You can make the `reobfJar` task run on the default `build` task with: |
| 92 | +```kotlin |
| 93 | +tasks.assemble { |
| 94 | + dependsOn(reobfJar) |
| 95 | +} |
| 96 | +``` |
| 97 | + |
0 commit comments