Skip to content

Commit

Permalink
change: allow null AlpineArgumentResolver keys
Browse files Browse the repository at this point in the history
  • Loading branch information
BestBearr committed Dec 8, 2024
1 parent d9ea803 commit bdde1ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/main/java/co/crystaldev/alpinecore/AlpinePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ private void activateAll() {
this.activate(classes, c -> AlpineConfig.class.isAssignableFrom(c) && !AlpinePluginConfig.class.isAssignableFrom(c));
this.activate(classes, AlpineIntegration.class::isAssignableFrom);
this.activate(classes, AlpineEngine.class::isAssignableFrom);
this.activate(classes, AlpineCommand.class::isAssignableFrom);
this.activate(classes, AlpineArgumentResolver.class::isAssignableFrom);
this.activate(classes, AlpineCommand.class::isAssignableFrom);
this.activate(classes, c -> !AlpinePluginConfig.class.isAssignableFrom(c));
}

Expand Down Expand Up @@ -447,7 +447,13 @@ private void setupCommandManager() {

// Register all argument resolvers
AlpineCore.getInstance().forEachResolver(resolver -> {
builder.argument(resolver.getType(), ArgumentKey.of(resolver.getKey()), resolver);
String key = resolver.getKey();
if (key == null) {
builder.argument(resolver.getType(), resolver);
}
else {
builder.argument(resolver.getType(), ArgumentKey.of(key), resolver);
}
});

// Let individual plugin commands mutate the command manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.Getter;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* @author BestBearr
Expand All @@ -18,7 +19,7 @@ public abstract class AlpineArgumentResolver<T> extends ArgumentResolver<Command

private final @NotNull Class<T> type;

private final @NotNull String key;
private final @Nullable String key;

@Override
public final void activate(@NotNull AlpinePlugin context) {
Expand Down

0 comments on commit bdde1ec

Please sign in to comment.