-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Support async parse result. WiP * Create requirement match service (cleanup of CommandExecutorService). Support async context results. * Remove typed resolvers. Remove wrappers. Add the argument profile system (APS) to replace typed resolvers. Implement "wrapper" solutions in argument resolvers. * Use the argument profile system (APS) for quoted argument and nullable arguments. Add @sender. Add RequirementDefinition to easy declaration simple annotations. Clean up parsers. * Fix quoted profile * Enhance performance of SchedulerExecutorPoolImpl * Make ArgumentProfile Prioritized. Expose ChatGTP's client. Rewrite ChatGPT argument to APS. Add unit tests. * Make ArgumentProfile Prioritized. Expose ChatGTP's client. Rewrite ChatGPT argument to APS. Add unit tests. Add support for programmatic for ChatGPT. * Add CompletableFutureResolver and related unit tests. Add missing ParserChained API. * Skip modules without tests while running global tests. * Fix for local tests. * Add test for context's aliases. * Add unit tests for programmatic API. Fix issue with async programmatic executor. Add api for async arguments, contexts, and binds (programmatic) * Add ProfileNamespaces * Limit async pool in tests. * Add argument matcher subdomain. * Remove annotation holder and RequirementProcessor * Add more API for async context and parse result
- Loading branch information
Showing
280 changed files
with
4,350 additions
and
2,723 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
plugins { | ||
`java-library` | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
maxParallelForks = Runtime.getRuntime().availableProcessors() | ||
|
||
if (isTest()) { | ||
gradle.startParameter.taskRequests.forEach { | ||
if (it.args.contains("test") && !it.args.contains("--rerun")) { | ||
it.args.add("--rerun") | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun isTest() = gradle.startParameter.taskNames.any { it.contains("test") } |
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
27 changes: 27 additions & 0 deletions
27
examples/bukkit/src/main/java/dev/rollczi/example/bukkit/user/User.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,27 @@ | ||
package dev.rollczi.example.bukkit.user; | ||
|
||
import java.util.UUID; | ||
|
||
public class User { | ||
|
||
private final UUID uuid; | ||
private final String name; | ||
|
||
User(UUID uuid, String name) { | ||
this.uuid = uuid; | ||
this.name = name; | ||
} | ||
|
||
User(String name) { | ||
this(UUID.randomUUID(), name); | ||
} | ||
|
||
public UUID getUuid() { | ||
return uuid; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
examples/bukkit/src/main/java/dev/rollczi/example/bukkit/user/UserArgumentResolver.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,43 @@ | ||
package dev.rollczi.example.bukkit.user; | ||
|
||
import dev.rollczi.litecommands.argument.Argument; | ||
import dev.rollczi.litecommands.argument.parser.ParseResult; | ||
import dev.rollczi.litecommands.argument.resolver.ArgumentResolver; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
import dev.rollczi.litecommands.suggestion.SuggestionContext; | ||
import dev.rollczi.litecommands.suggestion.SuggestionResult; | ||
import java.util.regex.Pattern; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class UserArgumentResolver extends ArgumentResolver<CommandSender, User> { | ||
|
||
private final Pattern VALID_USER_PATTERN = Pattern.compile("^[a-zA-Z0-9_]{3,16}$"); | ||
private final UserService userService; | ||
|
||
public UserArgumentResolver(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
@Override | ||
protected ParseResult<User> parse(Invocation<CommandSender> invocation, Argument<User> context, String argument) { | ||
return ParseResult.completableFuture(userService.getUser(argument), user -> { | ||
if (user == null) { | ||
return ParseResult.failure("User not found."); | ||
} | ||
|
||
return ParseResult.success(user); | ||
}); | ||
} | ||
|
||
@Override | ||
public SuggestionResult suggest(Invocation<CommandSender> invocation, Argument<User> argument, SuggestionContext context) { | ||
return userService.getCachedUsers().stream().map(user -> user.getName()) | ||
.collect(SuggestionResult.collector()); | ||
} | ||
|
||
@Override | ||
public boolean match(Invocation<CommandSender> invocation, Argument<User> context, String argument) { | ||
return VALID_USER_PATTERN.matcher(argument).matches(); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
examples/bukkit/src/main/java/dev/rollczi/example/bukkit/user/UserCommand.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,17 @@ | ||
package dev.rollczi.example.bukkit.user; | ||
|
||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import org.bukkit.command.CommandSender; | ||
|
||
@Command(name = "user") | ||
public class UserCommand { | ||
|
||
@Execute(name = "show-async") | ||
void show(@Context CommandSender sender, @Arg User user) { | ||
sender.sendMessage("User: " + user.getUuid() + " " + user.getName()); | ||
} | ||
|
||
} |
Oops, something went wrong.