Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c1bf4b7
Initial Commit
olijeffers0n Aug 9, 2023
04ec924
Fix Unit issue
olijeffers0n Aug 9, 2023
8e2183f
Fix Link Issue
olijeffers0n Aug 9, 2023
2cf142e
Attempt to fix links
olijeffers0n Aug 9, 2023
ea51c1c
Finally i think these links are fixed
olijeffers0n Aug 9, 2023
5d29dd2
Please Compile
olijeffers0n Aug 9, 2023
8140613
Surely this works now
olijeffers0n Aug 9, 2023
3ed6585
Fix compat with versioned pages
olijeffers0n Aug 10, 2023
47f72c5
Merge branch 'main' into feat/automate_versions
olijeffers0n Aug 12, 2023
33c5b57
Finalise the checker by updating on version changes
olijeffers0n Aug 12, 2023
0c105ef
guard the document from checks when undefined
olijeffers0n Aug 12, 2023
36fa8e9
Fix language highlighting
olijeffers0n Aug 12, 2023
8bfb130
Merge branch 'main' into feat/automate_versions
olijeffers0n Aug 12, 2023
0603b52
Address Some comments
olijeffers0n Aug 12, 2023
457114a
Fix the hyperlinks
olijeffers0n Aug 12, 2023
5dad555
Merge branch 'main' into feat/automate_versions
olijeffers0n Aug 12, 2023
6c002d6
Fix Link
olijeffers0n Aug 12, 2023
f7b1ac5
Formatting
olijeffers0n Aug 12, 2023
8ef187b
Finalise The Versioning
olijeffers0n Aug 15, 2023
83ebf89
Merge branch 'main' into feat/automate_versions
olijeffers0n Aug 27, 2023
9e0c980
Final Updates & Support Velocity
olijeffers0n Aug 28, 2023
1bd35e0
Support Velocity in the components
olijeffers0n Aug 28, 2023
28f8769
Add missed placeholders
olijeffers0n Aug 28, 2023
cd56215
Remove doubly nested A tags that trigger browser errors
olijeffers0n Aug 29, 2023
3145c3b
CSS Fixes
olijeffers0n Aug 29, 2023
48ee16e
Merge branch 'main' into fix/nested_a_tags
olijeffers0n Aug 29, 2023
cfa0772
Fix Javadoc links for velocity
olijeffers0n Aug 30, 2023
a651d3a
Merge branch 'main' into fix/nested_a_tags
olijeffers0n Aug 31, 2023
82025bf
Merge branch 'main' into feat/automate_versions
olijeffers0n Sep 2, 2023
1f6c70e
Fix Build
olijeffers0n Sep 2, 2023
916a4f8
Merge remote-tracking branch 'origin/feat/automate_versions' into fea…
olijeffers0n Sep 2, 2023
0c1df06
Revert weird behaviour
olijeffers0n Sep 2, 2023
af81d5b
Remove random newline
olijeffers0n Sep 2, 2023
b29a020
Fix 1.19 links which are now broken for some reason
olijeffers0n Sep 2, 2023
aead03f
Add the title
olijeffers0n Sep 5, 2023
2348f56
Caching fixed with code style improvements
olijeffers0n Sep 5, 2023
1bbe3f3
Merge branch 'main' into feat/automate_versions
olijeffers0n Sep 9, 2023
e657ce4
Merge branch 'main' into feat/automate_versions
olijeffers0n Sep 23, 2023
0c3669c
Merge branch 'main' into feat/automate_versions
olijeffers0n Sep 24, 2023
dd840b2
Merge branch 'main' into feat/automate_versions
olijeffers0n Sep 24, 2023
0897d94
Merge remote-tracking branch 'origin/feat/automate_versions' into fea…
olijeffers0n Oct 1, 2023
a1c24d7
Merge branch 'main' into feat/automate_versions
olijeffers0n Oct 21, 2023
300b8ce
Merge branch 'main' into feat/automate_versions
olijeffers0n Dec 30, 2023
9a6d5a5
Version description strings within the Config Component
olijeffers0n Dec 30, 2023
c602da5
Format the SoftwareVersionFetcher.tsx a bit nicelyier
olijeffers0n Dec 30, 2023
7fa722c
Whoops
olijeffers0n Dec 31, 2023
83d9417
Some types and formatting
olijeffers0n Jan 1, 2024
51db0a8
Merge remote-tracking branch 'origin/feat/automate_versions' into fea…
olijeffers0n Jan 1, 2024
7734c80
Add information to the CONTRIBUTING.md
olijeffers0n Jan 1, 2024
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
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,52 @@ To maintain consistency and readability across the documentation, please adhere

9. **Be Inclusive**: Be mindful of all readers and contributors. Use language that is inclusive and welcoming to everyone.

## Automatic Doc Versioning

There are components and methods in order to embed the current Project Version into the documentation. This is done one
of a few ways:

1) SoftwareVersion component
This component is used to embed the current version of the software into the documentation. An example of this would be:
```jsx
<SoftwareVersion versionType={"maj-min"}/> // E.g 1.19.2
<SoftwareVersion versionType={"maj"}/> // E.g 1.19
<SoftwareVersion versionType={"max"}/> // E.g 1.20.4

// You can set the project name to be used for the versioning:
<SoftwareVersion versionType={"maj-min"} project={"velocity"}/> // Project defaults to Paper
```
2) VersionedJavaDocLink component
This component is used to embed a link to the current version of the JavaDocs. An example of this would be:
```jsx
<VersionedJavaDocLink target={"/org/bukkit/event/Event.html"}>here</VersionedJavaDocLink>
// The project can also be set here, and defaults to Paper
```
3) VersionFormattedCode component
This component is used to embed a code block with the current version of the software. An example of this would be:
```jsx
<VersionFormattedCode language={"yaml"}>
```⠀
name: Paper-Test-Plugin
version: '1.0'
main: io.papermc.testplugin.TestPlugin
description: Paper Test Plugin
api-version: '%%_MAJ_MC_%%'
bootstrapper: io.papermc.testplugin.TestPluginBootstrap
loader: io.papermc.testplugin.TestPluginLoader
```⠀
</VersionFormattedCode>

// The possible placeholders are:
%%_MAJ_MC_%% - Major Paper Version (E.g 1.20)
%%_MAJ_MIN_MC_%% - Major-Minor Paper Version (E.g 1.20.4)
%%_MAJ_VEL_%% - Major Velocity Version (E.g 3.3)
%%_MAJ_MIN_VEL_%% - Major-Minor Velocity Version (E.g 3.3.0)
```

When the major version of the software changes, the docs will still need to have a "snapshot" created to keep documentation
for older versions. This is done by using yarn's docusaurus version command.

## Code of Conduct

Contributors are expected to follow the [Community Guidelines](https://papermc.io/community/guidelines) of the PaperMC organization in all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ messages:
as the server version is newer than the client version.

The message is formatted with legacy "&" style formatting, and "\\n" for newlines.
Additionally, it replaces {0} with "1.20.2" (the current server version)'
Additionally, it replaces {0} with "%%_MAJ_MIN_MC_%%" (the current server version)'
outdated-server:
default: 'Outdated server! I''m still on {0}'
description: 'The kick for a player when they can''t join,
as the server version is older than the client version.

The message is formatted with legacy "&" style formatting, and "\\n" for newlines.
Additionally, it replaces {0} with "1.20.2" (the current server version)'
Additionally, it replaces {0} with "%%_MAJ_MIN_MC_%%" (the current server version)'
restart:
default: 'Server is restarting'
description: 'The kick message for players on the server when it starts restarting,
Expand Down
4 changes: 2 additions & 2 deletions docs/paper/admin/reference/paper-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This documentation page serves to explain all the new semantics and possible con

:::info

Developers can get more information on Paper plugins [here](docs/paper/dev/getting-started/paper-plugins.md).
Developers can get more information on Paper plugins [here](docs/paper/dev/getting-started/paper-plugins.mdx).

:::

Expand All @@ -34,7 +34,7 @@ Paper plugins are added the same as Bukkit plugins, therefore, you can follow [t
### Cyclic Plugin Loading

With the introduction of Paper plugins, Paper introduces a new plugin loader that fixes some odd issues.
However, as a result, this now causes [cyclic loading](docs/paper/dev/getting-started/paper-plugins.md#cyclic-plugin-loading) between plugins to no longer be supported.
However, as a result, this now causes [cyclic loading](docs/paper/dev/getting-started/paper-plugins.mdx#cyclic-plugin-loading) between plugins to no longer be supported.

If Paper detects a loop, your server will be shut down with an error.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description: Developer guide for how to listen to the broadcasted events.

# Event Listeners

Events are an efficient way to listen for specific actions that happen in the game. They can be called by the server, or by plugins.
Events are an efficient way to listen for specific actions that happen in the game. They can be called by the server, or by plugins.
These are called by the server or plugins when something happens, such as a player joining the server, or a block being broken.
Plugins are able to call custom events, such as a player completing a quest, for other plugins to listen for.

## Your listener class

To listen for events, you need to create a class that implements `Listener`.
To listen for events, you need to create a class that implements `Listener`.
This class can be called anything you want, but it is recommended to name it something related to the events you are listening for.

```java title="ExampleListener.java"
Expand All @@ -22,14 +22,14 @@ public class ExampleListener implements Listener {

## `@EventHandler`

To listen for an event, you need to create a method that is annotated with `@EventHandler`.
To listen for an event, you need to create a method that is annotated with `@EventHandler`.
This method can be named anything you want, but it is recommended to name it something meaningful related to the event it is listening for.

## The listener method

The method body does not need to return any data, for this reason, use void as the return type.
Listeners take in a single parameter, which is the event that is being listened to.

```java title="ExampleListener.java"
public class ExampleListener implements Listener {

Expand All @@ -42,19 +42,20 @@ public class ExampleListener implements Listener {

:::note[Events]

There is no list of events that can be listened to, however take a look
[here](https://jd.papermc.io/paper/1.20/org/bukkit/event/Event.html) to see all events that extend `Event`.
There is no list of events that can be listened to, however take a
look { <VersionedJavaDocLink target={"/org/bukkit/event/Event.html"}>here</VersionedJavaDocLink> }
to see all classes that extend `Event`.
Comment thread
olijeffers0n marked this conversation as resolved.

An event can only be listened to if it has a static `getHandlerList` method.

:::

## Registering the listener

To register the listener, you need to call `Bukkit.getPluginManager().registerEvents()`
To register the listener, you need to call `Bukkit.getPluginManager().registerEvents()`
and pass in your listener class instance and an instance of your plugin.

This will register your listener class and allow it to listen for events.
This will register your listener class and allow it to listen for events.
This is commonly done in the `onEnable()` method of your plugin so that it is registered when the server starts ticking.

```java title="ExamplePlugin.java"
Expand All @@ -70,7 +71,7 @@ public class ExamplePlugin extends JavaPlugin {
## Event priority

You can also specify the priority of the event.

```java title="ExampleListener.java"
public class ExampleListener implements Listener {

Expand All @@ -88,8 +89,8 @@ There are six different priorities that you can use:
- `EventPriority.HIGHEST`
- `EventPriority.MONITOR`

The order of the priorities is somewhat counter-intuitive. The **higher** the priority, the **later** the event is called.
For example, If it is important that your plugin has the last say in a certain event - to avoid it being changed - you
The order of the priorities is somewhat counter-intuitive. The **higher** the priority, the **later** the event is called.
For example, If it is important that your plugin has the last say in a certain event - to avoid it being changed - you
should use `EventPriority.HIGHEST`.

:::note
Expand All @@ -102,7 +103,7 @@ This means you can get the result of any plugin interaction such as cancellation
## Event cancellation

Some events can be cancelled, preventing the given action from being completed. These events implement `Cancellable`.

```java title="ExampleListener.java"
public class ExampleListener implements Listener {

Expand All @@ -121,7 +122,7 @@ Always check the event before doing anything with it.
:::

The above example will cancel the event, meaning that the player will not be able to move.
Once an event is cancelled, it will continue to call any other listeners for that event unless they add
Once an event is cancelled, it will continue to call any other listeners for that event unless they add
`ignoreCancelled = true` to the `@EventHandler` annotation to ignore cancelled events.

```java title="ExampleListener.java"
Expand Down
2 changes: 1 addition & 1 deletion docs/paper/dev/api/plugin-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Configuration files allow users to change certain behavior and functionality of
By default, plugins use a YAML configuration format (`.yml` file). Other formats such as JSON or TOML can be used,
however these are not natively supported by Paper so will not be covered in this guide.

YAML works by having a tree-like `key: value` pair structure as you would have seen in your [plugin.yml](../getting-started/plugin-yml.md).
YAML works by having a tree-like `key: value` pair structure as you would have seen in your [plugin.yml](../getting-started/plugin-yml.mdx).
An example would look like this:

```yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ This will not act as a drop-in replacement for `plugin.yml`, as some things, as
It should be noted you still have the ability to include both `paper-plugin.yml` and `plugin.yml` in the same jar.

Here is an example configuration.
```yml
<VersionFormattedCode language={"yaml"}>
```
name: Paper-Test-Plugin
version: '1.0'
main: io.papermc.testplugin.TestPlugin
description: Paper Test Plugin
api-version: '1.20'
api-version: '%%_MAJ_MC_%%'
bootstrapper: io.papermc.testplugin.TestPluginBootstrap
loader: io.papermc.testplugin.TestPluginLoader
```
</VersionFormattedCode>

### Dependency Declaration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ example-plugin

Here is an example of a plugin.yml file:

```yaml
<VersionFormattedCode language={"yaml"}>
```
name: ExamplePlugin
version: 1.0.0
main: io.papermc.testplugin.ExamplePlugin
description: An example plugin
author: PaperMC
website: https://papermc.io
api-version: '1.20'
api-version: '%%_MAJ_MC_%%'
```
</VersionFormattedCode>

## Fields

Expand Down Expand Up @@ -90,8 +92,8 @@ This will be shown in the plugin info commands.

The version of the Paper API that your plugin is using. This doesn't include the minor version.
Servers with a version lower than the version specified here will refuse to load the plugin.
The valid versions are 1.13 - 1.20.
- `api-version: '1.20'`
The valid versions are 1.13 - <SoftwareVersion versionType={"maj"}/>.
- <VersionFormattedCode>`api-version: '%%_MAJ_MC_%%'`</VersionFormattedCode>

:::info

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ description: Step-by-step instructions on how to setup a plugin development envi

# Paper Project Setup

As the Paper team primarily uses [IntelliJ IDEA](https://www.jetbrains.com/idea/), this guide will be focused on that IDE.
As the Paper team primarily uses [IntelliJ IDEA](https://www.jetbrains.com/idea/), this guide will be focused on that IDE.
However, the steps below should apply to other IDEs as well, with some minor changes.

The Paper team uses [Gradle](https://gradle.org/) as its build system, and its tools are implemented for Gradle.
The Paper team uses [Gradle](https://gradle.org/) as its build system, and its tools are implemented for Gradle.
Most of the code below can be altered to work with other build systems, such as Maven, but this guide will only cover Gradle.

Follow the guide [here](https://docs.gradle.org/current/userguide/migrating_from_maven.html) to learn how to migrate from Maven to Gradle.

## Creating a new project

Open your IDE and select the option to create a new project.
Open your IDE and select the option to create a new project.
In Intellij, you will get the option to select the type of project you want to create - select `New Project`.
Select `Gradle - Kotlin DSL` and click `Create`.

Expand All @@ -25,20 +25,22 @@ You will land into the `build.gradle.kts` file where you can add your dependenci

To add Paper as a dependency, you will need to add the Paper repository to your `build.gradle.kts` file as well as the dependency itself.

```kotlin title=build.gradle.kts
<VersionFormattedCode language={"kotlin"} title={"build.gradle.kts"}>
```
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:%%_MAJ_MIN_MC_%%-R0.1-SNAPSHOT")
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
```
</VersionFormattedCode>

### Setting up the `src` directory

Expand Down Expand Up @@ -88,21 +90,21 @@ example-plugin

### Packages

You can see here that the `ExamplePlugin` class is inside the `io.papermc.testplugin` package.
A package is a way to organize your code - essentially, it's a folder. Java packages are used to group related classes.
You can see here that the `ExamplePlugin` class is inside the `io.papermc.testplugin` package.
A package is a way to organize your code - essentially, it's a folder. Java packages are used to group related classes.
Oracle has a guide on [packages](https://docs.oracle.com/javase/tutorial/java/package/packages.html) if you want to learn more.

When [naming](https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html) your packages, you should use your domain name in reverse order. For example, if your domain name is `papermc.io`,
your package name should be `io.papermc`. If you do not have a domain name, you could use something like your GitHub username.
If you were Linus Torvalds, your package would be `io.github.torvalds`.

This is then followed by the name of your project.
For example, if your project was called `ExamplePlugin`, your package would be `io.github.torvalds.exampleplugin`.
This is then followed by the name of your project.
For example, if your project was called `ExamplePlugin`, your package would be `io.github.torvalds.exampleplugin`.
This allows for a unique package name for every plugin.

### The _main_ class

The main class is the entry point to your plugin and will be the only class that extends `JavaPlugin` in your plugin.
The main class is the entry point to your plugin and will be the only class that extends `JavaPlugin` in your plugin.
This is an example of what your `ExamplePlugin` class could look like:

```java
Expand Down Expand Up @@ -198,7 +200,7 @@ It will automatically download a Paper server and run it for you.
:::

:::info

If you are using IntelliJ, you can use the Gradle GUI `Build` menu to compile your plugin - found on the top right of your IDE.
The output jar of your plugin will be in the `build/libs` directory.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ If you try to load your Gradle project now, you will receive an error saying you
a dev bundle dependency. You can do that by adding to your `dependencies` block in your `build.gradle.kts`
file.

```kotlin
<VersionFormattedCode language={"kotlin"}>
```
dependencies {
// Other Dependencies
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT")
paperweight.paperDevBundle("%%_MAJ_MIN_MC_%%-R0.1-SNAPSHOT")
}
```
</VersionFormattedCode>

:::tip

You should remove any dependency on the Paper API, as the dev bundle includes that.
Expand Down
5 changes: 3 additions & 2 deletions docs/paper/dev/misc/databases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dependencies {
:::caution

The Hikari library is not bundled with Paper, so you will need to shade/relocate it. In Gradle, you will need to use the shadow task.
Alternatively, you can use the Library loader with your paper plugin to load the library at runtime. See [here](../getting-started/paper-plugins.md#Loaders)
Alternatively, you can use the Library loader with your paper plugin to load the library at runtime. See [here](../getting-started/paper-plugins.mdx#Loaders)
for more information on how to use this.

:::
Expand Down Expand Up @@ -189,4 +189,5 @@ but it can be used to do much more malicious things, such as deleting the entire

Using prepared statements in Java with PreparedStatements helps prevent SQL injection.
They separate SQL code from user input by using placeholders, reducing the risk of executing unintended SQL commands.
**Always** use prepared statements to ensure the security and integrity of your data. Read more about SQL injection [here](https://www.baeldung.com/sql-injection).
**Always** use prepared statements to ensure the security and integrity of your data. Read more about SQL injection
[here](https://www.baeldung.com/sql-injection).
Loading