Skip to content

Commit

Permalink
chore: update config and code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulu13022002 committed Dec 2, 2024
1 parent 9bf60fb commit cae9c7a
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 122 deletions.
6 changes: 0 additions & 6 deletions config-specs/paper/server-properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,9 @@ simulation-distance:
updated by the server, measured in chunks in each direction of the player (radius, not diameter).
If entities are outside this radius, then they will not be ticked by the server nor will they be
visible to players. Must be between 3 and 32 inclusive.
spawn-animals:
default: "true"
description: "Determines if animals will be able to spawn."
spawn-monsters:
default: "true"
description: "Determines if monsters will be spawned."
spawn-npcs:
default: "true"
description: "Determines if villagers will be spawned."
spawn-protection:
default: "16"
description: >
Expand Down
3 changes: 2 additions & 1 deletion docs/paper/contributing/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ parent event and capture any child events but also listen to the child event sep
### Miscellaneous

* New parameters or method returns of type <Javadoc name={"org.bukkit.inventory.ItemStack"}>`ItemStack`</Javadoc>
should be [`@NotNull`](https://javadoc.io/doc/org.jetbrains/annotations/latest/org/jetbrains/annotations/NotNull.html).
should not be [`@Nullable`](https://javadoc.io/doc/org.jspecify/jspecify/latest/org/jspecify/annotations/Nullable.html)
in most case and instead accept an empty itemStack.
23 changes: 12 additions & 11 deletions docs/paper/dev/api/command-api/arguments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Argument type, but there are many others:
|---------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| GAME_EVENT | GameEvent | [Game events](https://minecraft.wiki/w/Sculk_Sensor#Vibration_frequencies) |
| STRUCTURE_TYPE | StructureType | [Structure types](https://minecraft.wiki/w/Structure#Overworld) |
| INSTRUMENT | MusicInstrument | [Goat horns](https://minecraft.wiki/w/Goat_Horn#Playing) |
| MOB_EFFECT | PotionEffectType | [Potion effect](https://minecraft.wiki/w/Effect#List) |
| BLOCK | BlockType | [Block type](https://minecraft.wiki/w/Block#List_of_blocks) |
| ITEM | ItemType | [Item type](https://minecraft.wiki/w/Item#List_of_items) |
Expand All @@ -72,23 +71,24 @@ Argument type, but there are many others:
| VILLAGER_TYPE | Villager.Type | [Villager biome specific type](https://minecraft.wiki/w/Villager#Professions) |
| MAP_DECORATION_TYPE | MapCursor.Type | [Types of sprites displayed on a map](https://minecraft.wiki/w/Map#Map_icons) |
| MENU | MenuType | [Menu type](https://wiki.vg/Inventory) |
| ATTRIBUTE | Attribute | [Entity attribute](https://minecraft.wiki/w/Attribute) |
| FLUID | Fluid | [Fluid types](https://minecraft.wiki/w/Fluid) |
| SOUND_EVENT | Sound | [Events that trigger sound effects](https://minecraft.wiki/w/Sounds.json#Sound_events) |
| BIOME | Biome | [Biome type](https://minecraft.wiki/w/Biome#Biome_types) |
| STRUCTURE | Structure | [Structures](https://minecraft.wiki/w/Structure#Overworld) |
| TRIM_MATERIAL | TrimMaterial | [Materials used to trim armor](https://minecraft.wiki/w/Smithing#Material) |
| TRIM_PATTERN | TrimPattern | [Trim patterns](https://minecraft.wiki/w/Smithing#Trimming) |
| DAMAGE_TYPE | DamageType | [All types of damage dealt to an entity](https://minecraft.wiki/w/Damage_type) |
| WOLF_VARIANT | Wolf.Variant | [Wolf variants](https://minecraft.wiki/w/Wolf#Variants) |
| ENCHANTMENT | Enchantment | [Enchantment type](https://minecraft.wiki/w/Enchanting#Summary_of_enchantments) |
| JUKEBOX_SONG | JukeboxSong | Music disc songs |
| WOLF_VARIANT | Wolf.Variant | [Wolf variants](https://minecraft.wiki/w/Wolf#Variants) |
| BANNER_PATTERN | PatternType | [Banner patterns](https://minecraft.wiki/w/Banner_Pattern#Variants) |
| BIOME | Biome | [Biome type](https://minecraft.wiki/w/Biome#Biome_types) |
| PAINTING_VARIANT | Art | [Painting variants](https://minecraft.wiki/w/Painting#Canvases) |
| ATTRIBUTE | Attribute | [Entity attribute](https://minecraft.wiki/w/Attribute) |
| INSTRUMENT | MusicInstrument | [Goat horns](https://minecraft.wiki/w/Goat_Horn#Playing) |
| ENTITY_TYPE | EntityType | [Every entity type](https://minecraft.wiki/w/Entity#Types_of_entities) |
| PARTICLE_TYPE | Particle | [Every particle type](https://minecraft.wiki/w/Particles_(Java_Edition)#Types_of_particles) |
| POTION | PotionType | [Every potion type](https://minecraft.wiki/w/Potion#Effect_potions) |
| SOUND_EVENT | Sound | [Events that trigger sound effects](https://minecraft.wiki/w/Sounds.json#Sound_events) |
| MEMORY_MODULE_TYPE | MemoryKey | Keys for saving per-entity data |
| FLUID | Fluid | [Fluid types](https://minecraft.wiki/w/Fluid) |

Paper specifies many more argument types. For more information on them, see <Javadoc name={"io.papermc.paper.command.brigadier.argument.ArgumentTypes"}>ArgumentTypes</Javadoc>

Expand All @@ -100,7 +100,7 @@ interface.
Now, let's say that we want to implement a command which lets you order ice cream. For that,
we add an enum that specifies all available values for our custom type.

```java
```java title="IceCreamType.java"
public enum IceCreamType {
VANILLA,
CHOCOLATE,
Expand All @@ -111,11 +111,11 @@ public enum IceCreamType {
```
Now, we have to define the argument itself. We do this by implementing the <Javadoc name={"io.papermc.paper.command.brigadier.argument.CustomArgumentType$Converted"}>CustomArgumentType.Converted</Javadoc> interface:

```java
```java title="IceCreamTypeArgument.java"
public class IceCreamTypeArgument implements CustomArgumentType.Converted<IceCreamType, String> {

@Override
public @NotNull IceCreamType convert(String nativeType) throws CommandSyntaxException {
public IceCreamType convert(String nativeType) throws CommandSyntaxException {
try {
return IceCreamType.valueOf(nativeType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ignored) {
Expand All @@ -126,7 +126,7 @@ public class IceCreamTypeArgument implements CustomArgumentType.Converted<IceCre
}

@Override
public @NotNull ArgumentType<String> getNativeType() {
public ArgumentType<String> getNativeType() {
return StringArgumentType.word();
}

Expand Down Expand Up @@ -154,7 +154,8 @@ detail.

We then need to register the command:

```java
```java title="TestPlugin.java"
@Override
public void onEnable() {
final LifecycleEventManager<Plugin> manager = this.getLifecycleManager();
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
Expand Down
8 changes: 4 additions & 4 deletions docs/paper/dev/api/command-api/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ method of the plugin. Commands registered here will not be available to datapack
functions are loaded by the server before plugins are loaded. To make commands available to
datapacks, register them via the [PluginBootstrap](#pluginbootstrap).

```java
```java title="YourPluginClass.java"
public class YourPluginClass extends JavaPlugin {

@Override
Expand Down Expand Up @@ -69,7 +69,7 @@ Commands are registered in the same way in a plugin's
The benefit of registering commands here is that they will be available to datapack functions
because the command registration happens early enough.

```java
```java title="YourPluginBootstrap.java"
public class YourPluginBootstrap implements PluginBootstrap {

@Override
Expand Down Expand Up @@ -97,11 +97,11 @@ manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
});
```

```java
```java title="FunCommand.java"
class FunCommand implements BasicCommand {

@Override
public void execute(@NotNull CommandSourceStack stack, @NotNull String[] args) {
public void execute(CommandSourceStack stack, String[] args) {
if (args.length == 1 && args[0].equalsIgnoreCase("start")) {
stack.getSender().sendRichMessage("<rainbow>Fun activated!");
}
Expand Down
6 changes: 3 additions & 3 deletions docs/paper/dev/api/component-api/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ final Component component = MiniMessage.miniMessage().deserialize(
// if the syntax above is too verbose for you, create a helper method!

public final class Components {
public static Component mm(String miniMessageString) { // mm, short for MiniMessage
return MiniMessage.miniMessage().deserialize(miniMessageString);
}
public static Component mm(String miniMessageString) { // mm, short for MiniMessage
return MiniMessage.miniMessage().deserialize(miniMessageString);
}
}

// ...
Expand Down
4 changes: 2 additions & 2 deletions docs/paper/dev/api/custom-inventory-holder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you wish, you can use the static method <Javadoc name={"org.bukkit.Bukkit#cre

:::

```java
```java title="MyInventory.java"
public class MyInventory implements InventoryHolder {

private final Inventory inventory;
Expand Down Expand Up @@ -93,7 +93,7 @@ You can store extra data for your inventories on the `InventoryHolder` by adding
Let's make an inventory that counts the amount of times we clicked a stone inside it.
First, let's modify our `MyInventory` class a little:

```java
```java title="MyInventory.java"
public class MyInventory implements InventoryHolder {

private final Inventory inventory;
Expand Down
6 changes: 3 additions & 3 deletions docs/paper/dev/api/entity-api/entity-teleport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ Teleport a player relatively, preventing velocity from being reset in the X, Y a
```java
player.teleport(
location,
TeleportFlag.Relative.X,
TeleportFlag.Relative.Y,
TeleportFlag.Relative.Z
TeleportFlag.Relative.VELOCITY_X,
TeleportFlag.Relative.VELOCITY_Y,
TeleportFlag.Relative.VELOCITY_Z
);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/paper/dev/api/event-api/chat-event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ method. Previously, this was done by using the <Javadoc name={"org.bukkit.event.
with its <Javadoc name={"org.bukkit.event.player.AsyncPlayerChatEvent#setFormat(java.lang.String)"}>`setFormat`</Javadoc> method.

```java title="ChatRenderer#render"
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
public Component render(Player source, Component sourceDisplayName, Component message, Audience viewer) {
// ...
}
```
Expand Down Expand Up @@ -82,7 +82,7 @@ public class ChatListener implements Listener, ChatRenderer { // Implement the C

// Override the render method
@Override
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
public Component render(Player source, Component sourceDisplayName, Component message, Audience viewer) {
// ...
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public class ChatListener implements Listener, ChatRenderer {
// Listener logic

@Override
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer) {
public Component render(Player source, Component sourceDisplayName, Component message, Audience viewer) {
return sourceDisplayName
.append(Component.text(": "))
.append(message);
Expand Down
16 changes: 8 additions & 8 deletions docs/paper/dev/api/event-api/custom-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public class PaperIsCoolEvent extends Event {
this.message = message;
}

public Component getMessage() {
return this.message;
}

public void setMessage(Component message) {
this.message = message;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
Expand All @@ -61,14 +69,6 @@ public class PaperIsCoolEvent extends Event {
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public Component getMessage() {
return this.message;
}

public void setMessage(Component message) {
this.message = message;
}
}
```

Expand Down
Loading

0 comments on commit cae9c7a

Please sign in to comment.