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
- Functions page needs a rewrite
- The IntegerRange/DoubleRange argument page needs a new screenshot
- Apparently there might be some rendering issues with the diff on the upgrade page to 11.0.0?
|`bootstrap(BootstrapContext)` method | Register commands to be used in Minecraft functions ([see the Function section for more info](./functions-and-tags/functions)) |
213
-
|`onLoad()`/`onEnable()` method | Register regular commands not available in datapacks by default|
213
+
|`onLoad()`/`onEnable()` method | Register regular commands not available in datapacks |
Copy file name to clipboardExpand all lines: docs/en/dev-setup/shading.md
+41-34Lines changed: 41 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,47 +33,29 @@ If you want to handle reloading, the CommandAPI has minimal support for it with
33
33
34
34
The `onLoad(CommandAPIConfig)` method initializes the CommandAPI's loading sequence. This must be called _before_ you start to access the CommandAPI and must be placed in your plugin's `onLoad()` method. The argument `CommandAPIConfig` is used to configure how the CommandAPI works. The `CommandAPIConfig` class has the following parameters which let you set how the CommandAPI works similar to the `config.yml`, which is described [here](../user-setup/config).
CommandAPIConfigsilentLogs(booleanvalue); // Disables ALL logging (except errors)
40
-
CommandAPIConfigdispatcherFile(Filefile); // If not null, the CommandAPI will create a JSON file with Brigadier's command tree
41
-
CommandAPIConfigsetNamespace(Stringnamespace); // The namespace to use when the CommandAPI registers a command
42
-
}
43
-
```
44
-
45
36
The `CommandAPIConfig` class follows a typical builder pattern (without you having to run `.build()` at the end), which lets you easily construct configuration instances.
46
37
47
-
However, the `CommandAPIConfig`class is abstract and can’t be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you’re developing for. For example, when developing for a Bukkit-based server, you should use the `CommandAPIPaperConfig` or the `CommandAPISpigotConfig` class.
38
+
<divclass="paper">
48
39
49
-
<!-- TODO: Add tabs and explanations for other platforms -->
40
+
However, the `CommandAPIConfig` class is abstract and can’t be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you’re developing for. For example, when developing for a Paper server, you should use the `CommandAPIPaperConfig` class.
CommandAPIBukkitConfigfallbackToLatestNMS(booleanfallbackToLatestNMS); // Whether the CommandAPI should fall back to the latest NMS version if no implementation for the current version was found
56
-
CommandAPIBukkitConfigmissingExecutorImplementationMessage(Stringvalue); // Set message to display when executor implementation is missing
57
-
<T>CommandAPIConfiginitializeNBTAPI(Class<T>nbtContainerClass, Function<Object, T>nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
CommandAPIPaperConfigsilentLogs(booleanvalue); // Disables ALL logging (except errors)
50
+
CommandAPIPaperConfigdispatcherFile(Filefile); // If not null, the CommandAPI will create a JSON file with Brigadier's command tree
51
+
CommandAPIPaperConfigsetNamespace(Stringnamespace); // The namespace to use when the CommandAPI registers a command
52
+
53
+
// General CommandAPI configuration for Bukkit-based servers
54
+
CommandAPIPaperConfigfallbackToLatestNMS(booleanfallbackToLatestNMS); // Whether the CommandAPI should fall back to the latest NMS version if no implementation for the current version was found
55
+
CommandAPIPaperConfigmissingExecutorImplementationMessage(Stringvalue); // Set message to display when executor implementation is missing
56
+
<T>CommandAPIPaperConfiginitializeNBTAPI(Class<T>nbtContainerClass, Function<Object, T>nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
72
57
}
73
58
```
74
-
:::
75
-
76
-
<divclass="paper">
77
59
78
60
In order to create a `CommandAPIPaperConfig` object, you must give it a reference to your `PluginMeta` and a `LifecycleEventOwner` instance, meaning either a `JavaPlugin` or `BootstrapContext` instance. The CommandAPI always uses this to register events, so it is required when loading the CommandAPI on Paper.
79
61
@@ -89,6 +71,29 @@ For example, to load the CommandAPI on Paper with all logging disabled, you can
89
71
</div>
90
72
<divclass="spigot">
91
73
74
+
However, the `CommandAPIConfig` class is abstract and can’t be used to configure the CommandAPI directly. Instead, you must use a subclass of `CommandAPIConfig` that corresponds to the platform you’re developing for. For example, when developing for a Spigot server, you should use the `CommandAPISpigotConfig` class.
CommandAPISpigotConfigsilentLogs(booleanvalue); // Disables ALL logging (except errors)
84
+
CommandAPISpigotConfigdispatcherFile(Filefile); // If not null, the CommandAPI will create a JSON file with Brigadier's command tree
85
+
CommandAPISpigotConfigsetNamespace(Stringnamespace); // The namespace to use when the CommandAPI registers a command
86
+
87
+
// General CommandAPI configuration for Bukkit-based servers
88
+
CommandAPISpigotConfigfallbackToLatestNMS(booleanfallbackToLatestNMS); // Whether the CommandAPI should fall back to the latest NMS version if no implementation for the current version was found
89
+
CommandAPISpigotConfigmissingExecutorImplementationMessage(Stringvalue); // Set message to display when executor implementation is missing
90
+
<T>CommandAPISpigotConfiginitializeNBTAPI(Class<T>nbtContainerClass, Function<Object, T>nbtContainerConstructor); // Initializes hooks with an NBT API. See NBT arguments documentation page for more info
91
+
92
+
// Spigot-specific configuration
93
+
CommandAPISpigotConfigskipReloadDatapacks(booleanskip); // Whether the CommandAPI should reload datapacks on server load
94
+
}
95
+
```
96
+
92
97
In order to create a `CommandAPISpigotConfig` object, you must give it a reference to your `JavaPlugin` instance. The CommandAPI always uses this to register events, so it is required when loading the CommandAPI on Spigot.
93
98
94
99
For example, to load the CommandAPI on Spigot with all logging disabled, you can use the following:
@@ -102,6 +107,8 @@ For example, to load the CommandAPI on Spigot with all logging disabled, you can
102
107
103
108
</div>
104
109
110
+
<!-- TODO: Add tabs and explanations for other platforms -->
111
+
105
112
### Enabling & Disabling
106
113
107
114
The `onEnable()` method initializes the CommandAPI's enabling sequence. Similar to the `onLoad(CommandAPIConfig)` method, this must be placed in your plugin's `onEnable()` method. This isn't as strict as the `onLoad(CommandAPIConfig)` method, and can be placed anywhere in your `onEnable()` method.
0 commit comments