LiteCommands v3.6.0
What's Changed
- GH-357 Add priority api, strict mode, event api and @DefaultExecute. Snapshot 3.6.0-SNAPSHOT by @Rollczi in #366
- GH-412 Remove panda sdk and expiringmap by @Rollczi in #430
- GH-431 Use Versions.kt object to centralize versions. by @vLuckyyy in #433
- GH-434 Hot fix BukkitScheduler by @Rollczi in #434
Thanks @vLuckyyy
🟢 Add an option to disable strict mode.
If you disable strict mode for a command, then users will be able to add unexpected arguments e.g.
/help first asdfioaosdf asodfn asodimf
<- this will work!
@Command(name = "help", strict = StrictMode.DISABLED)
class HelpCommand {
@Execute
void helpCommand(@Arg String arg) {
}
}
You can also disable strict mode by calling:
.strictMode(StrictMode.DISABLED);
on builder.
@ExecuteDefault
@Command(name = "kick")
public class KickCommand {
@ExecuteDefault
void commandHelp(@Context SENDER sender) {
// /kick incorrect input
}
@Execute(name = "-all")
void kickAll() {
// /kick -all
}
}
@Priority
@Command(name = "test")
public class TestCommand {
@Execute
@Priority(PriorityValue.HIGH)
void execute(int number) {
// ...
}
@Execute
@Priority(PriorityValue.LOW)
void execute(String text) {
// ...
}
}
Available events:
- CandidateExecutorFoundEvent
- CandidateExecutorMatchEvent
- CommandPreExecutionEvent
- CommandPostExecutionEvent
Simple example, how to block the execution of a command:
public class TellCommandController<SENDER> implements EventListener {
@Subscriber
public void onEvent(CommandPreExecutionEvent<SENDER> event) {
SENDER sender = event.getInvocation().sender();
if (event.getInvocation().name().equals("tell") && sender.isMuted()) {
event.stopFlow(FailedReason.of("&cYou are muted!"));
}
}
}
Update dependencies
implementation("dev.rollczi:{artifact}:3.6.0")
<dependency>
<groupId>dev.rollczi</groupId>
<artifactId>{artifact}</artifactId>
<version>3.6.0</version>
</dependency>
{artifact}
with platform artifact
Full Changelog: v3.5.0...v3.6.0