Skip to content

Commit 85f9122

Browse files
committed
Update documentation references to code examples
1 parent 0cd01d4 commit 85f9122

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

docs/en/dev-setup/shading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class CommandAPIPaperConfig {
5757
}
5858
```
5959

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.
60+
In order to create a `CommandAPIPaperConfig` object, you must give it a reference to a `LifecycleEventOwner` instance, meaning either a `JavaPlugin` or `BootstrapContext` instance. The CommandAPI always uses this to register commands and events, so it is required when loading the CommandAPI on Paper.
6161

6262
For example, to load the CommandAPI on Paper with all logging disabled, you can use the following:
6363

docs/en/test/load-mock-commandapi.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
order: 3
3+
preferences: ["paper-spigot"]
34
authors:
45
- willkroboth
56
---
@@ -16,28 +17,63 @@ MockCommandAPIPlugin load()
1617

1718
Loads the CommandAPI Plugin in the test environment. Works exactly the same as `MockBukkit.load(MockCommandAPIPlugin.class)`.
1819

20+
<div class="paper">
21+
22+
```java
23+
MockCommandAPIPlugin load(Consumer<CommandAPIPaperConfig> configureSettings)
24+
```
25+
26+
Loads the CommandAPI Plugin after applying the given consumer. This allows configuring any setting from the [config.yml](../user-setup/config#configuration-settings) using the methods provided by [CommandAPIPaperConfig](../dev-setup/shading#loading).
27+
28+
:::tip Example - Loading test CommandAPI with settings
29+
30+
To change, for example, the `missing-executor-implementation` message while running tests, you can use the method `CommandAPIPaperConfig#missingExecutorImplementationMessage` when the `configureSettings` callback is run:
31+
32+
<<< @/../reference-code/paper/src/test/java/test/LoadMockCommandAPI.java#loadMockCommandAPIExample
33+
34+
:::
35+
36+
</div>
37+
<div class="spigot">
38+
1939
```java
20-
MockCommandAPIPlugin load(Consumer<CommandAPIBukkitConfig> configureSettings)
40+
MockCommandAPIPlugin load(Consumer<CommandAPISpigotConfig> configureSettings)
2141
```
2242

23-
Loads the CommandAPI Plugin after applying the given consumer. This allows configuring any setting from the [config.yml](../user-setup/config#configuration-settings) using the methods provided by [CommandAPIBukkitConfig](../dev-setup/shading#loading).
43+
Loads the CommandAPI Plugin after applying the given consumer. This allows configuring any setting from the [config.yml](../user-setup/config#configuration-settings) using the methods provided by [CommandAPISpigotConfig](../dev-setup/shading#loading).
2444

2545
:::tip Example - Loading test CommandAPI with settings
2646

27-
To change, for example, the `missing-executor-implementation` message while running tests, you can use the method `CommandAPIBukkitConfig#missingExecutorImplementationMessage` when the `configureSettings` callback is run:
47+
To change, for example, the `missing-executor-implementation` message while running tests, you can use the method `CommandAPISpigotConfig#missingExecutorImplementationMessage` when the `configureSettings` callback is run:
2848

29-
<<< @/../reference-code/bukkit/src/test/java/test/LoadMockCommandAPI.java#loadMockCommandAPIExample
49+
<<< @/../reference-code/spigot/src/test/java/test/LoadMockCommandAPI.java#loadMockCommandAPIExample
3050

3151
:::
3252

53+
</div>
54+
3355
## Shaded Dependency
3456

3557
If your plugin shades the CommandAPI, the CommandAPI will automatically load as usual when you use MockBukkit to load your plugin. Just note that you **must** call `CommandAPI.onDisable()` in your plugin's `onDisable` method in order for the test environment to reset properly after each test.
3658

3759
## Loading a custom CommandAPI platform implementation
3860

39-
By default, the testing environment will load `MockCommandAPIBukkit` as the CommandAPI platform object. This works for basic tests, but many methods in `MockCommandAPIBukkit` are not yet implemented and just throw an `UnimplementedMethodException`. This may cause your tests to fail if your code relies on any of these methods. If you see an `UnimplementedMethodException`, please tell us about it with a [GitHub Issue](https://github.com/CommandAPI/CommandAPI/issues) or a message in the CommandAPI Discord so we can get it solved for everyone.
4061

41-
In the short term, you can also try to avoid an `UnimplementedMethodException` by implementing the required method yourself. Simply create a class that extends `MockCommandAPIBukkit` and override the required method with an appropriate implementation. Before each test where you want to use your custom implementation, make sure to call `CommandAPIVersionHandler#usePlatformImplementation` to let the CommandAPI know what it should load.
62+
<div class="paper">
63+
64+
By default, the testing environment will load `MockCommandAPIPaper` and `MockPaperNMS` as the CommandAPI platform object. This works for basic tests, but many methods in `MockPaperNMS` are not yet implemented and just throw an `UnimplementedMethodException`. This may cause your tests to fail if your code relies on any of these methods. If you see an `UnimplementedMethodException`, please tell us about it with a [GitHub Issue](https://github.com/CommandAPI/CommandAPI/issues) or a message in the CommandAPI Discord so we can get it solved for everyone.
65+
66+
In the short term, you can also try to avoid an `UnimplementedMethodException` by implementing the required method yourself. Simply create a class that extends `MockCommandAPIPaper` or `MockPaperNMS` and override the required method with an appropriate implementation. Before each test where you want to use your custom implementation, make sure to call `CommandAPIVersionHandler#usePlatformImplementation` to let the CommandAPI know what it should load.
67+
68+
<<< @/../reference-code/paper/src/test/java/test/LoadMockCommandAPI.java#loadCustomCommandAPIPlatformImplementationExample
69+
70+
</div>
71+
<div class="spigot">
72+
73+
By default, the testing environment will load `MockCommandAPISpigot` as the CommandAPI platform object. This works for basic tests, but many methods in `MockCommandAPISpigot` are not yet implemented and just throw an `UnimplementedMethodException`. This may cause your tests to fail if your code relies on any of these methods. If you see an `UnimplementedMethodException`, please tell us about it with a [GitHub Issue](https://github.com/CommandAPI/CommandAPI/issues) or a message in the CommandAPI Discord so we can get it solved for everyone.
74+
75+
In the short term, you can also try to avoid an `UnimplementedMethodException` by implementing the required method yourself. Simply create a class that extends `MockCommandAPISpigot` and override the required method with an appropriate implementation. Before each test where you want to use your custom implementation, make sure to call `CommandAPIVersionHandler#usePlatformImplementation` to let the CommandAPI know what it should load.
76+
77+
<<< @/../reference-code/spigot/src/test/java/test/LoadMockCommandAPI.java#loadCustomCommandAPIPlatformImplementationExample
4278

43-
<<< @/../reference-code/bukkit/src/test/java/test/LoadMockCommandAPI.java#loadCustomCommandAPIPlatformImplementationExample
79+
</div>

0 commit comments

Comments
 (0)