Skip to content

Commit

Permalink
1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisKarolGajda committed Aug 18, 2022
1 parent 434f830 commit bae30a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/main/java/me/opkarol/opc/api/commands/OpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public OpCommand addArgSuggestion(OpCommandArg arg, OpSimpleSuggestion suggestio
return addArg(arg).addSuggestion(suggestion);
}

public OpCommand addArgSuggestion(OpCommandArg arg, OpCommandSuggestion suggestion) {
return addArg(arg).addSuggestion(suggestion);
}

public OpCommand addArgSuggestion(OpCommandArg arg, StaticSuggestions.SUGGESTION_TYPE suggestion) {
return addArg(arg).addSuggestion(suggestion);
}
Expand Down Expand Up @@ -154,7 +158,7 @@ public List<String> tabCompleteFunction(@NotNull CommandSender sender, @NotNull
if (simpleSuggestions.size() != 0) {
completions.addAll(simpleSuggestions.get(args.length - 1).getSuggestions());
} else if (suggestions.size() != 0) {
completions.add(suggestions.get(args.length - 1).apply(sender, args));
completions.add(suggestions.get(args.length - 1).apply(new OpCommandSender(sender), args));
}

if (completions.size() == 0) {
Expand All @@ -169,7 +173,7 @@ public List<String> tabCompleteFunction(@NotNull CommandSender sender, @NotNull
completions.addAll(simpleSuggestions.get(args.length - 2).getSuggestions());
}
if (suggestions.size() + 1 >= args.length) {
completions.add(suggestions.get(args.length - 2).apply(sender, args));
completions.add(suggestions.get(args.length - 2).apply(new OpCommandSender(sender), args));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package me.opkarol.opc.api.commands.suggestions;

import org.bukkit.command.CommandSender;
import me.opkarol.opc.api.commands.OpCommandSender;

import java.util.function.BiFunction;

public class OpCommandSuggestion {
private final BiFunction<CommandSender, String[], String> biFunction;
public record OpCommandSuggestion(
BiFunction<OpCommandSender, String[], String> biFunction) {

public OpCommandSuggestion(BiFunction<CommandSender, String[], String> biFunction) {
this.biFunction = biFunction;
}

public String apply(CommandSender commandSender, String[] args) {
public String apply(OpCommandSender commandSender, String[] args) {
return biFunction.apply(commandSender, args);
}
}
}

0 comments on commit bae30a4

Please sign in to comment.