8000 Release/9.7.0 by JorelAli · Pull Request #618 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Release/9.7.0 #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b38936a
Set version to 9.6.2-SNAPSHOT
JorelAli Oct 28, 2024
558f09c
Create `commandapi-bukkit-test-toolkit`
willkroboth Jul 4, 2024
1816bff
Add `MockCommandAPIPlugin` for testing with `commandapi-bukkit-plugin`
willkroboth Jul 5, 2024
9ad579f
Add `assertCommandSucceeds` and `assertCommandFails` methods to Comma…
willkroboth Jul 5, 2024
8ed2acf
Add `assertCommandRunsWithArguments` methods to CommandAPITestUtilities
willkroboth Jul 9, 2024
d2fa55e
Implement testing IntegerRangeArgument NMS independently
willkroboth Jul 9, 2024
b86eb60
Fix CommandAPIHandler javadoc error that breaks full build
willkroboth Jul 9, 2024
be330ca
Add `assertCommandSuggests` methods to CommandAPITestUtilities
willkroboth Jul 10, 2024
7178477
Add `assertCommandFailsWithArguments` methods
willkroboth Jul 10, 2024
dafa99a
Improve coverage report by using Supplier<String> in CommandAPITestUt…
willkroboth Jul 10, 2024
83e5133
Add example argument and suggestion tests
willkroboth Jul 10, 2024
8000
363c247
Add EntitySelectorArgument, PlayerArgument, and OfflinePlayerArgument…
willkroboth Jul 13, 2024
874770b
Implement ArgumentType suggestions for test toolkit
willkroboth Jul 16, 2024
2824ed8
Refactor Parser building syntax
willkroboth Jul 17, 2024
421fa57
Add README files for the test toolkit example projects
willkroboth Jul 17, 2024
4b67594
Add javadocs for important test toolkit methods and classes
willkroboth Jul 18, 2024
2ab0c17
Add docs for the test toolkit
willkroboth Jul 19, 2024
3b92c11
Fix trailing space (markdown lint)
willkroboth Jul 19, 2024
7b5750a
Add manual update notes to `update.sh`
willkroboth Jul 22, 2024
6b5f791
Allow developers to load custom MockCommandAPIBukkit instances in the…
willkroboth Aug 24, 2024
3b74499
Use translation keys instead of literal messages
willkroboth Sep 23, 2024
c8264e3
Update note about unimplemented methods in test_intro.md
willkroboth Sep 23, 2024
764f72e
Update MockBukkit-v1.21 to match paper updates
willkroboth Sep 23, 2024
5b286a3
Add javadocs to ArgumentUtilities and parser package
willkroboth Oct 6, 2024
87406f3
Update dependencies to 1.21
willkroboth Oct 16, 2024
40e8f87
Add @n to suggestions
willkroboth Oct 16, 2024
e9003b5
Add braces to inlined if-statements
willkroboth Oct 16, 2024
d2a8f88
Update documented dependency versions and mention gradle dependencies
willkroboth Oct 16, 2024
461f9f9
Fix markdownlint errors in test_setup.md
willkroboth Oct 16, 2024
ba8d578
Update MockBukkit to fix Paper 1.21 api update
willkroboth Oct 22, 2024
ac84d75
Rework `Parser` definition
willkroboth Oct 25, 2024
0bb04fa
Fix test-toolkit dependencies
willkroboth Oct 26, 2024
8688a08
Code review
willkroboth Oct 26, 2024
cf61f14
Update test toolkit versions to 9.6.2-SNAPSHOT manually
willkroboth Oct 28, 2024
e000a4b
Add new 9.6.0 NMS methods to MockCommandAPIBukkit
willkroboth Oct 28, 2024
c53e451
Merge pull request #575 from JorelAli/dev/simple-test-suite
willkroboth Oct 28, 2024
b27fc71
complete #529
MC-XiaoHei Nov 13, 2024
a47d939
format, docs, and fix tests
MC-XiaoHei Nov 15, 2024
1582991
format
MC-XiaoHei Nov 15, 2024
ab330ee
use const for more readable
MC-XiaoHei Nov 15, 2024
2c9b081
Update commandapi-core/src/main/java/dev/jorel/commandapi/AbstractArg…
MC-XiaoHei Nov 18, 2024
fd2eca8
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
90e6045
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
994653c
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 18, 2024
d0dd2c8
add thenNested() list ver, implement array ver with list ver
MC-XiaoHei Nov 18, 2024
0203144
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
3a8a6f2
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
59572b2
Update docssrc/src/commandtrees.md
MC-XiaoHei Nov 19, 2024
a31e859
implement nested { } with list ver thenNested() method
MC-XiaoHei Nov 19, 2024
54d3e36
Update commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/…
MC-XiaoHei Nov 19, 2024
8771911
fix indentation
MC-XiaoHei Nov 20, 2024
50fa068
fix indentation
MC-XiaoHei Nov 20, 2024
27b9360
Merge pull request #613 from MC-XiaoHei/dev/dev
JorelAli Nov 20, 2024
082bee7
Initial work for 1.21.4 support
DerEchtePilz Dec 3, 2024
ed915a3
Adds support for new Trail particle in 1.21.4
JorelAli Dec 3, 2024
0cb559a
Adds documentation for Trail particle and adds thenNested to the docu…
JorelAli Dec 3, 2024
362b8e6
Add 1.21.4 to the issue template
DerEchtePilz Dec 3, 2024
32319cf
Add test toolkit to 9.7.0 documentation changelog
willkroboth Dec 4, 2024
6017fd0
Set version to 9.7.0
JorelAli Dec 4, 2024
28cc2f5
Adds 9.7.0 documentation
JorelAli Dec 4, 2024
e79fb6e
Update homepage to point to 9.7.0
JorelAli Dec 4, 2024
aea0a3e
Generate 9.7.0 JavaDocs
JorelAli Dec 4, 2024
2e3adc2
Update documentation wiki.vg links to point to the MinecraftWiki wiki…
JorelAli Dec 4, 2024
7fe69b7
Merge branch 'master' into release/9.7.0
JorelAli Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
Prev Previous commit
Next Next commit
Allow developers to load custom MockCommandAPIBukkit instances in the…
…ir tests

This makes it possible to avoid UnimplementedMethodExceptions by overriding and implementing the method yourself

NOTE: CommandAPIVersionHandler was changed from an interface to an abstract class so the test-toolkit version could have a non-final field. I don't think this affects anything else.
  • Loading branch information
willkroboth committed Oct 28, 2024
commit 6b5f791ff4b3e0a30b176152f1125ada479fd1ff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file within the commandapi-core module is NOT used at run time. Instead, the platform modules
* replace this class with their own version that handles loads the correct class for their version.
*/
public interface CommandAPIVersionHandler {
public abstract class CommandAPIVersionHandler {

/**
* Returns an instance of the version's implementation of CommandAPIPlatform.
Expand Down
26 changes: 14 additions & 12 deletions commandapi-documentation-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,15 @@
<scope>provided</scope>
</dependency>

<!-- CommandAPI -->
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-kotlin</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Testing examples dependencies -->
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.20</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<!-- Note: This is before the other CommandAPI dependencies so example `testLoadMockCommandAPI2`
can resolve the correct instance of the CommandAPIVersionHandler class -->
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-test-toolkit</artifactId>
<version>${project.version}</version>
Expand All @@ -85,6 +75,18 @@
<version>5.8.2</version>
</dependency>

<!-- CommandAPI -->
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-kotlin</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Other -->
<dependency>
<groupId>de.tr7zw</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,9 @@ class test {
class Main extends JavaPlugin {

}
/* ANCHOR: testLoadMockPlugin1 */

class example1 {
/* ANCHOR: testLoadMockCommandAPI1 */
@BeforeEach
public void setUp() {
// Set up MockBukkit server
Expand All @@ -2547,7 +2549,32 @@ public void tearDown() {
// Reset for a clean slate next test
MockBukkit.unmock();
}
/* ANCHOR_END: testLoadMockPlugin1 */
/* ANCHOR_END: testLoadMockCommandAPI1 */
}

class example2 {
/* ANCHOR: testLoadMockCommandAPI2 */
public class CustomMockCommandAPIBukkit extends MockCommandAPIBukkit {
// Implement a method that usually throws `UnimplementedMethodException`
@Override
public void reloadDataPacks() {
CommandAPI.logInfo("Simulating data pack reload");
// Further logic
}
}

@BeforeEach
public void setUp() {
// Set up MockBukkit server
MockBukkit.mock();

// Tell the CommandAPI to use your custom platform implementation
CommandAPIVersionHandler.usePlatformImplementation(new CustomMockCommandAPIBukkit());

// Load CommandAPI and your plugin as mentioned above...
}
/* ANCHOR_END: testLoadMockCommandAPI2 */
}
}

class tooltips {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
package dev.jorel.commandapi;

public interface CommandAPIVersionHandler {
static CommandAPIPlatform<?, ?, ?> getPlatform() {
return new MockCommandAPIBukkit();
public abstract class CommandAPIVersionHandler {
// Allow loading a different platform implementation (most likely to implement something `MockCommandAPIBukkit` doesn't)
private static CommandAPIPlatform<?, ?, ?> alternativePlatform = null;

/**
* Configures the test kit to use the given {@link CommandAPIPlatform} when the CommandAPI is loaded.
*
* @param platform The {@link CommandAPIPlatform} to use for the next test. This will likely be a custom
* implementation of {@link MockCommandAPIBukkit} that overrides a method you need to run
* tests that doesn't have a proper implementation in {@link MockCommandAPIBukkit}.
*/
public static void usePlatformImplementation(CommandAPIPlatform<?, ?, ?> platform) {
alternativePlatform = platform;
}

static LoadContext getPlatform() {
// Default to MockCommandAPIBukkit if not given
CommandAPIPlatform<?, ?, ?> platform = alternativePlatform == null ? new MockCommandAPIBukkit() : alternativePlatform;

// Reset to avoid platform persisting between tests
alternativePlatform = null;

return new LoadContext(platform);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public MockCommandSource getBrigadierSourceFromCommandSender(AbstractCommandSend
* using {@link CommandAPI#setLogger(CommandAPILogger)} and set this to {@code true} before calling
* {@link CommandAPI#onLoad(CommandAPIConfig)}, then the CommandAPI will write messages into the test log.
*/
public boolean ENABLE_LOGGING = false;
public static boolean ENABLE_LOGGING = false;

@Override
public CommandAPILogger getLogger() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package dev.jorel.commandapi;

import be.seeseemelk.mockbukkit.MockBukkit;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Tests for using {@link CommandAPIVersionHandler#usePlatformImplementation(CommandAPIPlatform)}
*/
class CommandAPIVersionHandlerOverridingTests {
// Setup
@BeforeEach
public void setUp() {
MockBukkit.mock();
}

@AfterEach
public void tearDown() {
MockBukkit.unmock();
}

private static class CustomMockCommandAPIBukkit extends MockCommandAPIBukkit {

}

// Tests
@Test
void testDefaultPlatform() {
MockCommandAPIPlugin.load();

assertEquals(MockCommandAPIBukkit.class, CommandAPITestUtilities.getCommandAPIPlatform().getClass());
}

@Test
void testChangingPlatform() {
CommandAPIVersionHandler.usePlatformImplementation(new CustomMockCommandAPIBukkit());
MockCommandAPIPlugin.load();

assertEquals(CustomMockCommandAPIBukkit.class, CommandAPITestUtilities.getCommandAPIPlatform().getClass());
}

@Test
void testPlatformDoesNotPersist() {
CommandAPIVersionHandler.usePlatformImplementation(new CustomMockCommandAPIBukkit());
MockCommandAPIPlugin.load();

assertEquals(CustomMockCommandAPIBukkit.class, CommandAPITestUtilities.getCommandAPIPlatform().getClass());

MockBukkit.unmock();
MockBukkit.mock();

MockCommandAPIPlugin.load();
assertEquals(MockCommandAPIBukkit.class, CommandAPITestUtilities.getCommandAPIPlatform().getClass());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dev.jorel.commandapi.test.MockNMS;
* file within the commandapi-core module is NOT used at run time. Instead, the platform modules
* replace this class with their own version that handles loads the correct class for their version
*/
interface CommandAPIVersionHandler {
abstract class CommandAPIVersionHandler {

companion object {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* file within the commandapi-core module is NOT used at run time. Instead, the platform modules
* replace this class with their own version that handles loads the correct class for their version
*/
public interface CommandAPIVersionHandler {
public abstract class CommandAPIVersionHandler {

public static final String profileId = getProfileId();
public static final boolean IS_MOJANG_MAPPED = isMojangMapped();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* depends on CommandListenerWrapper and then our main NMS_VERSION class extends
* that.
*/
public interface CommandAPIVersionHandler {
public abstract class CommandAPIVersionHandler {

/**
* Returns an instance of the current running version's implementation of the Bukkit NMS.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.jorel.commandapi;

public interface CommandAPIVersionHandler {
public abstract class CommandAPIVersionHandler {
static CommandAPIPlatform<?, ?, ?> getPlatform() {
return new CommandAPISponge();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.jorel.commandapi;

public interface CommandAPIVersionHandler {
public abstract class CommandAPIVersionHandler {
static LoadContext getPlatform() {
return new LoadContext(new CommandAPIVelocity());
}
Expand Down
2 changes: 1 addition & 1 deletion docssrc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

- [Testing Commands](./test_intro.md)
- [Set Up](./test_setup.md)
- [Loading Test CommandAPI](./test_loadmockplugin.md)
- [Loading Test CommandAPI](./test_loadmockcommandapi.md)
- [Testing Utilities](./test_utilities.md)

-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ Loads the CommandAPI Plugin after applying the given consumer. This allows confi
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:

```java
{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:testLoadMockPlugin1}}
{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:testLoadMockCommandAPI1}}
```

</div>

## Shaded Dependency

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.

## Loading a custom CommandAPI platform implementation

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/JorelAli/CommandAPI/issues) or a message in the CommandAPI Discord so we can get it solved for everyone.

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.

```java
{{#include ../../commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java:testLoadMockCommandAPI2}}
```
0