.
All checks were successful
Build and Deploy artifact / build (push) Successful in 1m17s

This commit is contained in:
kento2 2026-08-09 00:42:09 +02:00
parent 40af6b246d
commit 997906cd02
3 changed files with 35 additions and 10 deletions

View file

@ -1,8 +1,3 @@
## TODO
CI/CD:
- actually publish package
## Build ## Build
after installing bazel: after installing bazel:
@ -51,20 +46,18 @@ literal:coins/balance
### As code ### As code
```java ```java
import de.kentoj.kencommandapi.api.literal.RootLiteral;
/** /**
* Show the amount coins a user has. * Show the amount coins a user has.
* If no user is given, it should show the amount the sender of the command has. * If no user is given, it should show the amount the sender of the command has.
*/ */
public class CoinsCommand { public final class CoinsCommand {
private final RootLiteral<User> rootLiteral; private final RootLiteral<User> rootLiteral;
private final CommandArgumentSpec<User, User> userArg; private final CommandArgumentSpec<User, User> userArg;
public CoinsCommand() { public CoinsCommand() {
userArg = CommandArgumentSpec.builder("user", new UserArgumentType<User>()) userArg = CommandArgumentSpec.builder("user", new UserArgumentType<User>())
.withRequirement(p -> !p.hasPermission("economy.immune.getcoins"), .withRequirement(user -> !user.hasPermission("economy.immune.getcoins"),
"you can't see that player's balance") "you can't see that player's balance")
.withDefaultValue(CommandContext::sender) .withDefaultValue(CommandContext::sender)
.build(); .build();

View file

@ -0,0 +1,32 @@
package de.kentoj.kencommandapi.type;
import de.kentoj.kencommandapi.api.argument.ArgumentType;
import de.kentoj.kencommandapi.api.suggestion.SuggestionProvider;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.UUID;
import java.util.stream.Stream;
public class WorldArgumentType<T> implements ArgumentType<T, World> {
@Override
public World parseInputUnchecked(String input) throws IllegalArgumentException {
var world = Bukkit.getWorld(input);
if (world == null && input.length() == 36) {
try {
return Bukkit.getWorld(UUID.fromString(input));
} catch (IllegalArgumentException _) {
throw new IllegalArgumentException("World not found");
}
}
return world;
}
@Override
public SuggestionProvider<T> getDefaultSuggestionProvider() {
return _ -> Stream.concat(
Bukkit.getWorlds().stream().map(World::getName),
Bukkit.getWorlds().stream().map(w -> w.getUID().toString())
).toList();
}
}

View file

@ -1,2 +1,2 @@
GROUP = "de.kentoj.scrow" GROUP = "de.kentoj.scrow"
VERSION = "0.36-SNAPSHOT" VERSION = "0.37-SNAPSHOT"