-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-498 Fabric command supports alias. Add an option to change the bri…
…gadier input inspection display. (#498) * fabric command supports alias * Remove useless abstraction. Add an option to change the brigadier input inspection display. * Add unit tests for keyed arguments. --------- Co-authored-by: Rollczi <[email protected]>
- Loading branch information
1 parent
fd19489
commit 47db6a8
Showing
13 changed files
with
109 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...mmands-annotations/test/dev/rollczi/litecommands/annotations/key/KeyCombinationsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.rollczi.litecommands.annotations.key; | ||
|
||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.argument.Key; | ||
import dev.rollczi.litecommands.annotations.command.RootCommand; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.argument.parser.ParseResult; | ||
import dev.rollczi.litecommands.argument.parser.Parser; | ||
import dev.rollczi.litecommands.unit.annotations.LiteTestSpec; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class KeyCombinationsTest extends LiteTestSpec { | ||
|
||
static class Faction {} | ||
|
||
static LiteTestConfig config = builder -> builder | ||
.argumentParser(Faction.class, Parser.of((invocation, text) -> ParseResult.success(new Faction()))) | ||
.advanced(); | ||
|
||
@RootCommand | ||
static class TestCommand { | ||
|
||
@Execute(name = "keyed") | ||
void keyed(@Arg("arg-name") @Key("faction") Faction argValue) {} | ||
|
||
@Execute(name = "undefined") | ||
void undefined(@Arg("arg-name") Faction argValue) {} | ||
|
||
} | ||
|
||
@Test | ||
void test() { | ||
platform.execute("keyed factionValue") | ||
.assertSuccess(); | ||
|
||
platform.execute("undefined factionValue") | ||
.assertSuccess(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
litecommands-fabric/src/main/java/dev/rollczi/litecommands/fabric/LiteFabricSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
package dev.rollczi.litecommands.fabric; | ||
|
||
import dev.rollczi.litecommands.platform.PlatformSettings; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
public class LiteFabricSettings implements PlatformSettings { | ||
|
||
private String inputInspectionDisplay = "[...]"; | ||
|
||
String getInputInspectionDisplay() { | ||
return this.inputInspectionDisplay; | ||
} | ||
|
||
/** | ||
* The name of the brigadier argument used to inspection, default is "[...]". | ||
* Inspection sometimes displays while the player is typing the command. | ||
* LiteCommands don't support brigadier suggestions, but we must provide a name for the default input argument. | ||
*/ | ||
@ApiStatus.Experimental | ||
public LiteFabricSettings inputInspectionDisplay(String name) { | ||
this.inputInspectionDisplay = name; | ||
return this; | ||
} | ||
|
||
} |
22 changes: 0 additions & 22 deletions
22
...ands-fabric/src/main/java/dev/rollczi/litecommands/fabric/client/FabricClientCommand.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
...ands-fabric/src/main/java/dev/rollczi/litecommands/fabric/server/FabricServerCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.