Skip to content

Commit

Permalink
feat: properly do the above
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jun 19, 2024
1 parent 4dfabc2 commit 6fc0a61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class BukkitCommand extends BaseCommand<CommandSender> {
Expand Down Expand Up @@ -78,12 +79,18 @@ public Impl(@NotNull Uniform uniform, @NotNull BukkitCommand command) {
// Setup command properties
this.setDescription(command.getDescription());
this.setAliases(command.getAliases());
this.setUsage(command.build().getUsageText());
this.setUsage(getUsageText());
if (permission != null) {
this.setPermission(permission.node());
}
}

@NotNull
private String getUsageText() {
return dispatcher.getSmartUsage(dispatcher.getRoot(), null).values().stream()
.map("/%s"::formatted).collect(Collectors.joining("\n"));
}

@SuppressWarnings("deprecation")
@Override
public boolean execute(@NotNull CommandSender commandSender, @NotNull String alias, @NotNull String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class LegacyPaperCommand extends BaseCommand<CommandSender> {
Expand Down Expand Up @@ -83,12 +84,18 @@ public Impl(@NotNull Uniform uniform, @NotNull LegacyPaperCommand command) {
// Setup command properties
this.setDescription(command.getDescription());
this.setAliases(command.getAliases());
this.setUsage(command.build().getUsageText());
this.setUsage(getUsageText());
if (permission != null) {
this.setPermission(permission.node());
}
}

@NotNull
private String getUsageText() {
return dispatcher.getSmartUsage(dispatcher.getRoot(), null).values().stream()
.map("/%s"::formatted).collect(Collectors.joining("\n"));
}

@SuppressWarnings("deprecation")
@Override
public boolean execute(@NotNull CommandSender commandSender, @NotNull String alias, @NotNull String[] args) {
Expand Down

0 comments on commit 6fc0a61

Please sign in to comment.