Skip to content

Commit

Permalink
Add nullability checks to command
Browse files Browse the repository at this point in the history
  • Loading branch information
sqyyy-jar committed May 28, 2023
1 parent 58e79ad commit cb5d2c8
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import dev.jorel.commandapi.arguments.MultiLiteralArgument;
import dev.jorel.commandapi.arguments.NamespacedKeyArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import dev.jorel.commandapi.executors.PlayerCommandExecutor;
import io.github.liquip.api.item.Enchantment;
import io.github.liquip.api.item.Feature;
import io.github.liquip.api.item.Item;
Expand Down Expand Up @@ -49,7 +48,7 @@ public CommandManager(@NotNull StandaloneLiquip api) {
.map(NamespacedKey::asString)
.filter(s -> s.contains(suggestionInfo.currentArg()))
.toList())))
.executesPlayer((PlayerCommandExecutor) this::giveSubcommand);
.executesPlayer(this::giveSubcommand);
}

private @NotNull CommandAPICommand createCraftSubcommand() {
Expand All @@ -73,6 +72,9 @@ public CommandManager(@NotNull StandaloneLiquip api) {

private void giveSubcommand(Player player, CommandArguments args) {
final NamespacedKey key = (NamespacedKey) args.get(0);
if (key == null) {
return;
}
final Item item = this.api.getItemRegistry()
.get(key);
if (item == null) {
Expand All @@ -97,7 +99,11 @@ private void reloadSubcommand(CommandSender sender, CommandArguments args) {
}

private void dumpSubcommand(CommandSender sender, CommandArguments args) {
switch ((String) args.get(0)) {
final String arg = (String) args.get(0);
if (arg == null) {
return;
}
switch (arg) {
case "items" -> {
for (final Item item : this.api.getItemRegistry()) {
sender.sendMessage(Component.text(item.key()
Expand Down

0 comments on commit cb5d2c8

Please sign in to comment.