Skip to content

Commit 0b06aed

Browse files
authored
feat: Better Javadoc Coverage (#370)
1 parent 293ba32 commit 0b06aed

38 files changed

+411
-287
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ of a few ways:
117117
<SoftwareVersion versionType={"maj-min"} project={"velocity"}/> // Project defaults to Paper
118118
```
119119

120-
2. `VersionedJavaDocLink` component
120+
2. `Javadoc` component
121121

122-
This component is used to embed a link to the current version of the JavaDocs. An example of this would be:
122+
This component is used to embed a link to the current version of the corresponding Javadoc. An example of this would be:
123123

124124
```jsx
125-
<VersionedJavaDocLink target={"/org/bukkit/event/Event.html"}>here</VersionedJavaDocLink>
125+
<Javadoc name={"org.bukkit.event.Event"}>here</Javadoc>
126126
// The project can also be set here, and defaults to Paper
127127
```
128128

config-specs/properties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"DOCS_JAVA": "21",
23
"PAPER_JAVA_MIN": "21",
34
"VELOCITY_JAVA_MIN": "17"
45
}

docs/paper/contributing/events.mdx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,29 @@ All new events should go in the package (sub-package of) `io.papermc.paper.event
1717

1818
### Constructors
1919

20-
All new constructors added should be annotated with `@ApiStatus.Internal` to signify that they are not considered
21-
API and can change at any time without warning.
20+
All new constructors added should be annotated with
21+
[`@ApiStatus.Internal`](https://javadoc.io/doc/org.jetbrains/annotations/latest/org/jetbrains/annotations/ApiStatus.Internal.html)
22+
to signify that they are not considered API and can change at any time without warning.
2223

23-
Constructors that are being replaced, if they aren't being removed, should be marked with `@Deprecated` and `@DoNotUse`.
24+
Constructors that are being replaced, if they aren't being removed, should be marked with
25+
<Javadoc name={"java.lang.Deprecated"} project={"java"}>`@Deprecated`</Javadoc> and
26+
<Javadoc name={"io.papermc.paper.annotation.DoNotUse"}>`@DoNotUse`</Javadoc>.
2427

2528
### Mutability
2629
Certain API types are "mutable" which can lead to unexpected behavior within events. Mutable types like
27-
`Location` and `Vector` should therefore be cloned when returned from a "getter" in an event.
30+
<Javadoc name={"org.bukkit.Location"}>`Location`</Javadoc> and <Javadoc name={"org.bukkit.util.Vector"}>`Vector`</Javadoc>
31+
should therefore be cloned when returned from a "getter" in an event.
2832

2933
### `HandlerList`
30-
For an event class or any subclass of it to be listened to, a `HandlerList` field must be present with an instance and static method
31-
to retrieve it. See the docs for <VersionedJavaDocLink target={"/org/bukkit/event/Event.html"}>`Event`</VersionedJavaDocLink> for specifics. This field should be static and
32-
final and named `HANDLER_LIST`.
34+
For an event class or any subclass of it to be listened to, a <Javadoc name={"org.bukkit.event.HandlerList"}>`HandlerList`</Javadoc>
35+
field must be present with an instance and static method to retrieve it.
36+
See the docs for <Javadoc name={"org.bukkit.event.Event"}>`Event`</Javadoc> for specifics.
37+
This field should be static and final and named `HANDLER_LIST`.
3338

3439
Also consider not putting a `HandlerList` on every event, just a "common parent" event so that a plugin can listen to the
3540
parent event and capture any child events but also listen to the child event separately.
3641

3742
### Miscellaneous
3843

39-
* New parameters or method returns of type `ItemStack` should be `@NotNull`.
44+
* New parameters or method returns of type <Javadoc name={"org.bukkit.inventory.ItemStack"}>`ItemStack`</Javadoc>
45+
should be [`@NotNull`](https://javadoc.io/doc/org.jetbrains/annotations/latest/org/jetbrains/annotations/NotNull.html).

docs/paper/dev/api/component-api/audiences.md renamed to docs/paper/dev/api/component-api/audiences.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ All `CommandSender`s are single audiences. This includes players, the console, a
1313
`World` are all forwarding audiences. This means that they are made up of multiple audiences. For example, the server is
1414
made up of all online players and the console.
1515

16-
This means that all the Audience methods are available on `CommandSender`, `Server`, `Team` and `World`.
16+
This means that all the [`Audience`](https://jd.advntr.dev/api/latest/net/kyori/adventure/audience/Audience.html)
17+
methods are available on <Javadoc name={"org.bukkit.command.CommandSender"}>`CommandSender`</Javadoc>,
18+
<Javadoc name={"org.bukkit.Server"}>`Server`</Javadoc>, <Javadoc name={"org.bukkit.scoreboard.Team"}>`Team`</Javadoc>
19+
and <Javadoc name={"org.bukkit.World"}>`World`</Javadoc>.
1720

1821
## `ForwardingAudience`
1922

20-
The `ForwardingAudience` wraps a collection of `Audience` instances and forwards messages to all of them. This is useful
21-
for sending messages to multiple audiences (players) at once.
23+
The [`ForwardingAudience`](https://jd.advntr.dev/api/latest/net/kyori/adventure/audience/ForwardingAudience.html)
24+
wraps a collection of [`Audience`](https://jd.advntr.dev/api/latest/net/kyori/adventure/audience/Audience.html)
25+
instances and forwards messages to all of them. This is useful for sending messages to multiple audiences (players) at once.
2226

2327
```java
2428
// Server is a ForwardingAudience which includes all online players and the console
@@ -33,8 +37,8 @@ Audience audience = Audience.audience(Audience...);
3337
## What do `Audience`s do?
3438

3539
Audiences are used for interacting with players. They can be used to send messages, play sounds, show bossbars, and more.
36-
They are mostly used for sending other parts of the API to players. For example, you can send a `Component` to a player
37-
using `Audience#sendMessage(Component)`.
40+
They are mostly used for sending other parts of the API to players. For example, you can send a [`Component`](https://jd.advntr.dev/api/latest/net/kyori/adventure/text/Component.html)
41+
to a player using [`Audience#sendMessage(Component)`](https://jd.advntr.dev/api/latest/net/kyori/adventure/audience/Audience.html#sendMessage(net.kyori.adventure.text.Component)).
3842

3943
## Pointers
4044

docs/paper/dev/api/component-api/i18n.md renamed to docs/paper/dev/api/component-api/i18n.mdx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@ Adventure's Javadocs for all-things translations can be found [here](https://jd.
1616

1717
## GlobalTranslator
1818

19-
All translation is done through the [GlobalTranslator](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/GlobalTranslator.html). You can render translations yourself and add new sources
20-
for translations.
19+
All translation is done through [`GlobalTranslator`](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/GlobalTranslator.html).
20+
You can render translations yourself and add new sources for translations.
2121

22-
You can add sources to the `GlobalTranslator` by creating instances of [TranslationRegistry](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/TranslationRegistry.html) or implementing
23-
the [Translator](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/Translator.html) interface yourself.
22+
You can add sources to the `GlobalTranslator` by creating instances of [`TranslationRegistry`](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/TranslationRegistry.html)
23+
or implementing the [`Translator`](https://jd.advntr.dev/api/latest/net/kyori/adventure/translation/Translator.html) interface yourself.
2424

2525
## Where translations work
2626

2727
Vanilla Minecraft handles translations on the client by using the language files bundled with the client or provided via resource packs. If you don't want to send custom language files
28-
in a resource pack, server-side translations are the only alternative. They work anywhere `Component` API exists, except for ItemStack display text like the display name or lore. So
29-
chat, entity display names, scoreboards, tab lists, etc., all support translations.
28+
in a resource pack, server-side translations are the only alternative. They work anywhere the component API exists, except for <Javadoc name={"org.bukkit.inventory.ItemStack"}>`ItemStack`</Javadoc>
29+
display text like the display name or lore. So chat, entity display names, scoreboards, tab lists, etc., all support translations.
3030

3131
:::caution
3232

3333
The player's language as declared in the settings packet sent by the client arrives **after** the player has joined the server, so there are no guarantees that
34-
translations will work for a client that is joining during the `PlayerJoinEvent` or any earlier event. You can listen for the first `PlayerClientOptionsChangeEvent` after
35-
joining to know with 100% certainty what language the client that joined is using.
34+
translations will work for a client that is joining during the <Javadoc name={"org.bukkit.event.player.PlayerJoinEvent"}>`PlayerJoinEvent`</Javadoc> or any earlier event.
35+
You can listen for the first <Javadoc name={"com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent"}>`PlayerClientOptionsChangeEvent`</Javadoc>
36+
after joining to know with 100% certainty what language the client that joined is using.
3637

3738
:::
3839

3940
## Examples
4041

41-
### ResourceBundle
42+
### `ResourceBundle`
4243
```properties title="src/main/resources/your/plugin/Bundle_en_US.properties"
4344
some.translation.key=Translated Message: {0}
4445
```
@@ -51,9 +52,10 @@ registry.registerAll(Locale.US, bundle, true);
5152
GlobalTranslator.translator().addSource(registry);
5253
```
5354

54-
This creates a new `TranslationRegistry` under a specified namespace. Then a `ResourceBundle` is created from a bundle located on the classpath with
55-
the specified `Locale`. Finally, that `ResourceBundle` is added to the registry. That registry is then added as a source to the `GlobalTranslator`. This
56-
makes all the translations available server-side.
55+
This creates a new `TranslationRegistry` under a specified namespace. Then, a <Javadoc name={"java.util.ResourceBundle"} project={"java"}>`ResourceBundle`</Javadoc>
56+
is created from a bundle located on the classpath with the specified <Javadoc name={"java.util.Locale"} project={"java"}>`Locale`</Javadoc>.
57+
Finally, that `ResourceBundle` is added to the registry. That registry is then added as a source to the `GlobalTranslator`.
58+
This makes all the translations available server-side.
5759

5860
Now you can use translation keys in translatable components.
5961

docs/paper/dev/api/component-api/intro.md renamed to docs/paper/dev/api/component-api/intro.mdx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ signal that a better alternative in components is available and should be migrat
4444

4545
:::
4646

47-
## Creating Components
47+
## Creating components
4848

4949
Components can be interacted with as objects. There are different interfaces for each type along with
5050
builders for all the types. These objects are immutable so when constructing more complex components, it's
@@ -76,7 +76,7 @@ For complete documentation on the Adventure Component API Paper and Velocity use
7676

7777
## MiniMessage
7878

79-
Paper and Velocity include the MiniMessage library which is a string representation of components. If you prefer working with
79+
Paper and Velocity include the MiniMessage library, which is a string representation of components. If you prefer working with
8080
strings rather than objects, MiniMessage is vastly superior to the legacy string format. It can utilize the tree
8181
structure for style inheritance and can represent the more complex component types while legacy cannot.
8282

@@ -102,7 +102,7 @@ MiniMessage has a [web viewer](https://webui.advntr.dev/), which is useful for c
102102

103103
:::
104104

105-
## JSON Format
105+
## JSON format
106106

107107
Components can be serialized and deserialized from a standard JSON format. This format is used
108108
in Vanilla in various commands which accept component arguments like `/tellraw`. Below is a simple example
@@ -142,37 +142,40 @@ There are online tools to make generating this format much easier like [JSON Tex
142142

143143
## Serializers
144144

145-
Paper and Velocity come bundled with different serializers for converting between `Component`s and other forms
146-
of serialized text.
145+
Paper and Velocity come bundled with different serializers for converting between
146+
[`Component`](https://jd.advntr.dev/api/latest/net/kyori/adventure/text/Component.html)s and other forms of serialized text.
147147

148-
### [GsonComponentSerializer](https://jd.advntr.dev/text-serializer-gson/latest)
148+
### [`GsonComponentSerializer`](https://jd.advntr.dev/text-serializer-gson/latest)
149149

150-
Converts between `Component` and JSON-formatted strings with convenience methods to directly deal with Gson's `JsonElement`.
151-
This conversion is lossless and is the preferred form of serialization
152-
for components that do not have to be edited by users regularly.
150+
Converts between `Component`
151+
and JSON-formatted strings with convenience methods to directly deal with Gson's
152+
[`JsonElement`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/JsonElement.html).
153+
This conversion is lossless and is the preferred form of serialization for components that do not have to be edited by users regularly.
153154

154-
### [MiniMessage](https://jd.advntr.dev/text-minimessage/latest)
155+
### [`MiniMessage`](https://jd.advntr.dev/text-minimessage/latest)
155156

156-
Converts between `Component` and a MiniMessage-formatted string. This conversion is lossless and is the preferred form of
157+
Converts between `Component`
158+
and a MiniMessage-formatted string. This conversion is lossless and is the preferred form of
157159
serialization for components that have to be edited by users. There is also extensive customization you can add to the
158160
serializer, which is [documented here](https://docs.advntr.dev/minimessage/api.html#getting-started).
159161

160-
### [PlainTextComponentSerializer](https://jd.advntr.dev/text-serializer-plain/latest)
162+
### [`PlainTextComponentSerializer`](https://jd.advntr.dev/text-serializer-plain/latest)
161163

162164
Serializes a `Component` into a plain text string. This is very lossy as all style information as well as most other
163-
types of components will lose information. There may be special handling for `TranslatableComponent`s to be serialized
165+
types of components will lose information. There may be special handling for
166+
[`TranslatableComponent`](https://jd.advntr.dev/api/latest/net/kyori/adventure/text/TranslatableComponent.html)s to be serialized
164167
into a default language, but generally this shouldn't be used except in certain circumstances, like logging to a text file.
165168

166-
### [LegacyComponentSerializer](https://jd.advntr.dev/text-serializer-legacy/latest)
169+
### [`LegacyComponentSerializer`](https://jd.advntr.dev/text-serializer-legacy/latest)
167170

168171
:::caution
169172

170173
This is not recommended for use as the legacy format may be removed in the future.
171174

172175
:::
173176

174-
Converts between `Component` and the legacy string format. This conversion is very lossy as component types and events
175-
do not have a legacy string representation.
177+
Converts between `Component` and the legacy string format.
178+
This conversion is very lossy as component types and events do not have a legacy string representation.
176179

177180
A more useful use case is converting legacy text to MiniMessage format in a migration process.
178181
```java
@@ -187,7 +190,8 @@ final String miniMessageString = MiniMessage.miniMessage().serialize(
187190
:::note
188191

189192
There are 2 built-in legacy serializers, one dealing with `§` symbols and the other for
190-
`&` symbols. They have their own instances available through `LegacyComponentSerializer#legacySection()`
191-
and `LegacyComponentSerializer#legacyAmpersand()`.
193+
`&` symbols. They have their own instances available through
194+
[`LegacyComponentSerializer#legacySection()`](https://jd.advntr.dev/text-serializer-legacy/latest/net/kyori/adventure/text/serializer/legacy/LegacyComponentSerializer.html#legacySection())
195+
and [`LegacyComponentSerializer#legacyAmpersand()`](https://jd.advntr.dev/text-serializer-legacy/latest/net/kyori/adventure/text/serializer/legacy/LegacyComponentSerializer.html#legacyAmpersand()).
192196

193197
:::

docs/paper/dev/api/custom-inventory-holder.md renamed to docs/paper/dev/api/custom-inventory-holder.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Custom `InventoryHolder`s have no such downsides and by using them you're guaran
1818

1919
## Creating a custom holder
2020

21-
The first step is to implement the `InventoryHolder` interface.
22-
We can do this the following way: create a new class that will create our `Inventory` in the constructor.
21+
The first step is to implement the <Javadoc name={"org.bukkit.inventory.InventoryHolder"}>`InventoryHolder`</Javadoc> interface.
22+
We can do this the following way: create a new class that will create our <Javadoc name={"org.bukkit.inventory.Inventory"}>`Inventory`</Javadoc> in the constructor.
2323

2424
:::info
2525

2626
The constructor takes your main plugin class as an argument in order to create the `Inventory`.
27-
If you wish, you can use the static method `Bukkit#createInventory(InventoryHolder, int)` instead and remove the argument.
27+
If you wish, you can use the static method <Javadoc name={"org.bukkit.Bukkit#createInventory(org.bukkit.inventory.InventoryHolder,int)"}>`Bukkit#createInventory(InventoryHolder, int)`</Javadoc> instead and remove the argument.
2828

2929
:::
3030

@@ -68,8 +68,8 @@ player.openInventory(myInventory.getInventory());
6868

6969
## Listening to an event
7070

71-
Once we have the inventory open, we can listen to any inventory events we like and check if the `Inventory#getHolder()`
72-
returns an instance of our `MyInventory`.
71+
Once we have the inventory open, we can listen to any inventory events we like and check if
72+
<Javadoc name={"org.bukkit.inventory.Inventory#getHolder()"}>`Inventory#getHolder()`</Javadoc> returns an instance of our `MyInventory`.
7373

7474
```java
7575
@EventHandler

0 commit comments

Comments
 (0)