Skip to content

Commit 2bf24f0

Browse files
committed
chore: refactor project setup page
1 parent b6e60a2 commit 2bf24f0

4 files changed

Lines changed: 24 additions & 151 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ These constants can be imported and used in MDX, like so:
132132
import {
133133
LATEST_MC_RELEASE,
134134
LATEST_PAPER_RELEASE,
135+
LATEST_PAPER_BUILD_API_VERSION,
135136
LATEST_VELOCITY_RELEASE,
136137
LATEST_FOLIA_RELEASE,
137138
LATEST_WATERFALL_RELEASE,
138139
LATEST_USERDEV_RELEASE,
139140
} from "/src/utils/versions";
140141
141142
Latest Paper version is {LATEST_PAPER_RELEASE}.
143+
Latest Paper API build version is {LATEST_PAPER_BUILD_API_VERSION}
142144
Latest Velocity version is {LATEST_VELOCITY_RELEASE}.
143145
Latest Minecraft version is {LATEST_MC_RELEASE}.
144146
Latest Folia version is {LATEST_FOLIA_RELEASE}.

astro.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
LATEST_ANSI_RELEASE,
1616
LATEST_FOLIA_RELEASE,
1717
LATEST_MC_RELEASE,
18+
LATEST_PAPER_BUILD_API_VERSION,
1819
LATEST_PAPER_RELEASE,
1920
LATEST_USERDEV_RELEASE,
2021
LATEST_VELOCITY_RELEASE,
@@ -560,6 +561,7 @@ export default defineConfig({
560561
constants: {
561562
LATEST_MC_RELEASE,
562563
LATEST_PAPER_RELEASE,
564+
LATEST_PAPER_BUILD_API_VERSION,
563565
LATEST_VELOCITY_RELEASE,
564566
LATEST_FOLIA_RELEASE,
565567
LATEST_WATERFALL_RELEASE,

src/content/docs/paper/dev/getting-started/project-setup.mdx

Lines changed: 15 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ You will land into the `build.gradle.kts` file where you can add your dependenci
2424

2525
### Adding Paper as a dependency
2626

27-
To add Paper as a dependency, you will need to add the Paper repository to your `build.gradle.kts` or `pom.xml` file as well as the dependency itself.
27+
To add Paper as a dependency, you will need to add the Paper repository and dependency to your `build.gradle.kts` file.
28+
29+
:::tip
30+
31+
If you want to reference a specific build, you can do so by replacing the + with the build identifier
32+
(i.e. `{VERSION}.build.25-alpha` for the 25th alpha build of a version). Before `26.1` (`1.21.11` and below), the
33+
version string format used was `{VERSION}-R0.1-SNAPSHOT`, with no way to reference a specific build.
34+
35+
:::
2836

2937
<Tabs syncKey="build-system">
3038
<TabItem label="Gradle (Kotlin)">
@@ -37,29 +45,18 @@ To add Paper as a dependency, you will need to add the Paper repository to your
3745
}
3846

3947
dependencies {
40-
compileOnly("io.papermc.paper:paper-api:\{LATEST_PAPER_RELEASE}-R0.1-SNAPSHOT")
48+
compileOnly("io.papermc.paper:paper-api:\{LATEST_PAPER_RELEASE}.build.+")
4149
}
4250

4351
java {
44-
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
52+
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
4553
}
4654
```
4755
</TabItem>
48-
<TabItem label="Gradle (Groovy)">
49-
```groovy title="build.gradle" replace
50-
repositories {
51-
maven {
52-
name = 'papermc'
53-
url = 'https://repo.papermc.io/repository/maven-public/'
54-
}
55-
}
56+
<TabItem label="Maven (Discouraged)">
57+
Maven unfortunately does not support obtaining the latest version using version ranges the way Gradle
58+
does. You will need to explicitly declare the build of a version you are targeting.
5659

57-
dependencies {
58-
compileOnly 'io.papermc.paper:paper-api:\{LATEST_PAPER_RELEASE}-R0.1-SNAPSHOT'
59-
}
60-
```
61-
</TabItem>
62-
<TabItem label="Maven">
6360
```xml title="pom.xml" replace
6461
<project>
6562
<repositories>
@@ -73,7 +70,7 @@ To add Paper as a dependency, you will need to add the Paper repository to your
7370
<dependency>
7471
<groupId>io.papermc.paper</groupId>
7572
<artifactId>paper-api</artifactId>
76-
<version>\{LATEST_PAPER_RELEASE}-R0.1-SNAPSHOT</version>
73+
<version>\{LATEST_PAPER_BUILD_API_VERSION}</version>
7774
<scope>provided</scope>
7875
</dependency>
7976
</dependencies>
@@ -222,138 +219,6 @@ If everything went well, you should see something like this:
222219

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

225-
## Plugin remapping
226-
227-
As of 1.20.5, Paper ships with a Mojang-mapped runtime instead of reobfuscating the server to Spigot mappings.
228-
If you are using Spigot/Bukkit plugins, your plugin will be assumed to be Spigot-mapped.
229-
This means that the server will have to deobfuscate and remap the plugin JAR when it's loaded for the first time.
230-
231-
:::note
232-
233-
`paperweight-userdev` already sets this attribute automatically. For more information see the [userdev](/paper/dev/userdev) documentation.
234-
235-
:::
236-
237-
### Mojang mappings
238-
239-
To tell the server that your plugin is Mojang-mapped, you need to add the following code to your build script:
240-
241-
:::note[Paper plugins]
242-
243-
If you are using Paper plugins, this step is not needed as plugins will be assumed to be Mojang-mapped.
244-
245-
:::
246-
247-
<Tabs syncKey="build-system">
248-
<TabItem label="Gradle (Kotlin)">
249-
```kotlin title="build.gradle.kts"
250-
tasks.jar {
251-
manifest {
252-
attributes["paperweight-mappings-namespace"] = "mojang"
253-
}
254-
}
255-
// if you have shadowJar configured
256-
tasks.shadowJar {
257-
manifest {
258-
attributes["paperweight-mappings-namespace"] = "mojang"
259-
}
260-
}
261-
```
262-
</TabItem>
263-
<TabItem label="Gradle (Groovy)">
264-
```groovy title="build.gradle"
265-
jar {
266-
manifest {
267-
attributes(
268-
'paperweight-mappings-namespace': 'mojang'
269-
)
270-
}
271-
}
272-
// if you have shadowJar configured
273-
shadowJar {
274-
manifest {
275-
attributes(
276-
'paperweight-mappings-namespace': 'mojang'
277-
)
278-
}
279-
}
280-
```
281-
</TabItem>
282-
<TabItem label="Maven">
283-
```xml title="pom.xml"
284-
<plugin>
285-
<groupId>org.apache.maven.plugins</groupId>
286-
<artifactId>maven-jar-plugin</artifactId>
287-
<version>3.4.1</version>
288-
<configuration>
289-
<archive>
290-
<manifestEntries>
291-
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
292-
</manifestEntries>
293-
</archive>
294-
</configuration>
295-
</plugin>
296-
```
297-
</TabItem>
298-
</Tabs>
299-
300-
### Spigot mappings
301-
302-
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:
303-
304-
<Tabs syncKey="build-system">
305-
<TabItem label="Gradle (Kotlin)">
306-
```kotlin title="build.gradle.kts"
307-
tasks.jar {
308-
manifest {
309-
attributes["paperweight-mappings-namespace"] = "spigot"
310-
}
311-
}
312-
// if you have shadowJar configured
313-
tasks.shadowJar {
314-
manifest {
315-
attributes["paperweight-mappings-namespace"] = "spigot"
316-
}
317-
}
318-
```
319-
</TabItem>
320-
<TabItem label="Gradle (Groovy)">
321-
```groovy title="build.gradle"
322-
jar {
323-
manifest {
324-
attributes(
325-
'paperweight-mappings-namespace': 'spigot'
326-
)
327-
}
328-
}
329-
// if you have shadowJar configured
330-
shadowJar {
331-
manifest {
332-
attributes(
333-
'paperweight-mappings-namespace': 'spigot'
334-
)
335-
}
336-
}
337-
```
338-
</TabItem>
339-
<TabItem label="Maven">
340-
```xml title="pom.xml"
341-
<plugin>
342-
<groupId>org.apache.maven.plugins</groupId>
343-
<artifactId>maven-jar-plugin</artifactId>
344-
<version>3.4.1</version>
345-
<configuration>
346-
<archive>
347-
<manifestEntries>
348-
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
349-
</manifestEntries>
350-
</archive>
351-
</configuration>
352-
</plugin>
353-
```
354-
</TabItem>
355-
</Tabs>
356-
357222
## Conclusion
358223

359224
You should now have a project set up with Paper as a dependency.

src/utils/versions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const findLatest = async (project: Project): Promise<string> => {
5656
// find the newest version with at least one non-alpha build
5757
for (const version of versions) {
5858
const builds = await fetchBuilds(project, version);
59-
if (builds.some((b) => b.channel !== "ALPHA")) {
59+
if (builds.some((b) => true || b.channel !== "ALPHA")) { // TODO: Remove this, temporary change
6060
return version;
6161
}
6262
}
@@ -68,6 +68,10 @@ const paperProject = await fetchProject("paper");
6868

6969
export const LATEST_PAPER_RELEASE = await findLatest(paperProject);
7070

71+
const paperBuild = (await fetchBuilds(paperProject, LATEST_PAPER_RELEASE)).at(0);
72+
73+
export const LATEST_PAPER_BUILD_API_VERSION = `${LATEST_PAPER_RELEASE}.build.${paperBuild?.id}-${paperBuild?.channel.toLocaleLowerCase()}`
74+
7175
const velocityProject = await fetchProject("velocity");
7276

7377
export const LATEST_VELOCITY_RELEASE = await findLatest(velocityProject);

0 commit comments

Comments
 (0)