Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add info about plugin remapping and update paperweight version. #366

Merged
merged 19 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config-specs/paper/paper-global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ proxies:
forwarding.secret file
scoreboards:
save-empty-scoreboard-teams:
default: "false"
default: "true"
description: >-
Some scoreboard plugins leave hundreds of empty scoreboard teams around,
dramatically slowing down login times. This sets whether the server should
Expand Down
5 changes: 5 additions & 0 deletions docs/paper/admin/reference/system-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,8 @@ It also remaps plugin CB calls to remove the version information.

- **default**: `false`
- **description**: Disables Paper's automatic upgrading of commands, including items with custom data defined in command blocks and other places that may contain commands, to the new component format introduced in version 1.20.5.

#### paper.disable-plugin-rewriting

- **default**: `false`
- **description**: Disables plugin remapping introduced in 1.20.5 and everything involving automatic plugin conversion by commodore. For more information see the [userdev](../../dev/getting-started/userdev.mdx#1205) documentation and the official [announcement](https://discord.com/channels/289587909051416579/976631292747735080/1232740079097876570).
98 changes: 98 additions & 0 deletions docs/paper/dev/getting-started/project-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ slug: /dev/project-setup
description: Step-by-step instructions on how to set up a plugin development environment.
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


# Paper Project Setup

As the Paper team primarily uses [IntelliJ IDEA](https://www.jetbrains.com/idea/), this guide will be focused on that IDE.
Expand Down Expand Up @@ -187,6 +191,100 @@ If everything went well, you should see something like this:

![](assets/paper-plugin-overview.png)

## Plugin remapping

As of 1.20.5, Paper ships with a Mojang-mapped runtime instead of reobfuscating the server to Spigot mappings.
If you are using Spigot/Bukkit plugins, your plugin will be assumed to be Spigot-mapped.
This means that the server will have to deobfuscate and remap the plugin JAR when it's loaded for the first time.

:::info

`paperweight-userdev` already sets this attribute automatically. For more information see the [userdev](./userdev) documentation.

:::

### Mojang mappings

To tell the server that your plugin is Mojang-mapped, you need to add the following code to your build script:

:::note[Paper plugins]

If you are using Paper plugins, this step is not needed as plugins will be assumed to be Mojang-mapped.

:::

<Tabs groupId="author-front-matter">
<TabItem value="gradle" label="Gradle Kotlin DSL" default>
```kotlin
tasks.jar {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
}
// if you have shadowJar configured
tasks.shadowJar {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
}
```
</TabItem>
<TabItem value="maven" label="Maven POM">
```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
</configuration>
</plugin>
```
</TabItem>
</Tabs>

### Spigot mappings

If you explicitly want to tell the server that your plugin is Spigot-mapped, you need to add the following code to your build script:

<Tabs groupId="author-front-matter">
<TabItem value="gradle" label="Gradle Kotlin DSL">
```kotlin
tasks.jar {
manifest {
attributes["paperweight-mappings-namespace"] = "spigot"
}
}
// if you have shadowJar configured
tasks.shadowJar {
manifest {
attributes["paperweight-mappings-namespace"] = "spigot"
}
}
```
</TabItem>
<TabItem value="maven" label="Maven POM">
```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
</manifestEntries>
</archive>
</configuration>
</plugin>
```
</TabItem>
</Tabs>

## Conclusion

You should now have a project set up with Paper as a dependency.
Expand Down
46 changes: 45 additions & 1 deletion docs/paper/dev/getting-started/userdev.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ This can make it hard to work with in a development environment. This plugin let
types, names, and fields during development, and then remaps your plugin, so it can still be used with the obfuscated
server.

:::caution[1.20.5]

As of Minecraft version 1.20.5, Paper ships with a Mojang-mapped runtime instead of reobfuscating the server to Spigot mappings.
See [here](#1205) for more details.

:::

:::caution

The re-obfuscation does not apply to reflection. Look at something like [this library](https://github.com/jpenilla/reflection-remapper) to be able to
Expand All @@ -35,7 +42,7 @@ use non-obfuscated names in reflection.
Add the plugin to your `build.gradle.kts` file.
```kotlin
plugins {
id("io.papermc.paperweight.userdev") version "1.5.12" // Check for new versions at https://plugins.gradle.org/plugin/io.papermc.paperweight.userdev
id("io.papermc.paperweight.userdev") version "1.7.0" // Check for new versions at https://plugins.gradle.org/plugin/io.papermc.paperweight.userdev
}
```

Expand Down Expand Up @@ -103,3 +110,40 @@ tasks.assemble {
}
```

## 1.20.5

As of 1.20.5, Paper ships with a Mojang-mapped runtime instead of reobfuscating the server to Spigot mappings.
Additionally, CraftBukkit classes will no longer be relocated into a versioned package.
This requires plugins to be deobfuscated before loading when necessary.

Most of this process is done automatically by paperweight but there are some important things to know when using NMS from now on.

### Default mappings assumption
* By default, all Spigot/Bukkit plugins will be assumed to be Spigot-mapped if they do not specify their mappings namespace in the manifest. Conversely, all Paper plugins will be assumed to be Mojang-mapped if they do not specify their mappings namespace in the manifest.
* Spigot-mapped plugins will need to be deobfuscated on first load, Mojang-mapped plugins will not.

### Mojang mappings

If you want to map your plugin with Mojang mappings, you need to add the following code to your build script:

:::note

You only have to change this setting if you are using Bukkit/Spigot plugins. Paper plugins are already assumed to be Mojang-mapped.

:::

```kotlin title="build.gradle.kts"
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
```

Additionally, you need to remove all `dependsOn(reobfJar)` lines.

### Spigot mappings

If you are using Paper plugins but want to explicitly use Spigot mappings, you need to change the property to:

```kotlin title="build.gradle.kts"
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION
```