You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
<Javadocname={"org.bukkit.Location"}>`Location`</Javadoc> and <Javadocname={"org.bukkit.util.Vector"}>`Vector`</Javadoc>
31
+
should therefore be cloned when returned from a "getter" in an event.
28
32
29
33
### `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 <VersionedJavaDocLinktarget={"/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 <Javadocname={"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 <Javadocname={"org.bukkit.event.Event"}>`Event`</Javadoc> for specifics.
37
+
This field should be static and final and named `HANDLER_LIST`.
33
38
34
39
Also consider not putting a `HandlerList` on every event, just a "common parent" event so that a plugin can listen to the
35
40
parent event and capture any child events but also listen to the child event separately.
36
41
37
42
### Miscellaneous
38
43
39
-
* New parameters or method returns of type `ItemStack` should be `@NotNull`.
44
+
* New parameters or method returns of type <Javadocname={"org.bukkit.inventory.ItemStack"}>`ItemStack`</Javadoc>
45
+
should be [`@NotNull`](https://javadoc.io/doc/org.jetbrains/annotations/latest/org/jetbrains/annotations/NotNull.html).
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)).
Copy file name to clipboardExpand all lines: docs/paper/dev/api/component-api/i18n.mdx
+14-12Lines changed: 14 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -16,29 +16,30 @@ Adventure's Javadocs for all-things translations can be found [here](https://jd.
16
16
17
17
## GlobalTranslator
18
18
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.
21
21
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.
24
24
25
25
## Where translations work
26
26
27
27
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 <Javadocname={"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.
30
30
31
31
:::caution
32
32
33
33
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 <Javadocname={"org.bukkit.event.player.PlayerJoinEvent"}>`PlayerJoinEvent`</Javadoc> or any earlier event.
35
+
You can listen for the first <Javadocname={"com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent"}>`PlayerClientOptionsChangeEvent`</Javadoc>
36
+
after joining to know with 100% certainty what language the client that joined is using.
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 <Javadocname={"java.util.ResourceBundle"}project={"java"}>`ResourceBundle`</Javadoc>
56
+
is created from a bundle located on the classpath with the specified <Javadocname={"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.
57
59
58
60
Now you can use translation keys in translatable components.
and [`LegacyComponentSerializer#legacyAmpersand()`](https://jd.advntr.dev/text-serializer-legacy/latest/net/kyori/adventure/text/serializer/legacy/LegacyComponentSerializer.html#legacyAmpersand()).
Copy file name to clipboardExpand all lines: docs/paper/dev/api/custom-inventory-holder.mdx
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,13 @@ Custom `InventoryHolder`s have no such downsides and by using them you're guaran
18
18
19
19
## Creating a custom holder
20
20
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 <Javadocname={"org.bukkit.inventory.InventoryHolder"}>`InventoryHolder`</Javadoc> interface.
22
+
We can do this the following way: create a new class that will create our <Javadocname={"org.bukkit.inventory.Inventory"}>`Inventory`</Javadoc> in the constructor.
23
23
24
24
:::info
25
25
26
26
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 <Javadocname={"org.bukkit.Bukkit#createInventory(org.bukkit.inventory.InventoryHolder,int)"}>`Bukkit#createInventory(InventoryHolder, int)`</Javadoc> instead and remove the argument.
0 commit comments