fix tab complete order

This commit is contained in:
Ryder Belserion 2023-11-27 16:09:16 -05:00
parent fddbcef0a7
commit 663ae04381
No known key found for this signature in database
2 changed files with 10 additions and 19 deletions

View File

@ -1,8 +1,11 @@
package com.badbones69.crazyauctions.paper.commands;
import com.badbones69.crazyauctions.paper.CrazyAuctions;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -10,6 +13,8 @@ import java.util.Arrays;
import java.util.List;
public class AuctionTab implements TabCompleter {
private final CrazyAuctions plugin = CrazyAuctions.get();
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
@ -28,23 +33,17 @@ public class AuctionTab implements TabCompleter {
if (hasPermission(sender, "bid")) completions.add("bid");
return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
} else if (args.length == 2) { // /crazyauctions arg0
switch (args[0].toLowerCase()) {
case "bid", "sell" -> completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
case "view" -> completions.addAll(this.plugin.getServer().getOnlinePlayers().stream().map(Player::getName).toList());
}
return StringUtil.copyPartialMatches(args[1], completions, new ArrayList<>());
} else if (args.length == 3) { // /crazyauctions arg0 arg1
switch (args[0].toLowerCase()) {
case "bid", "sell" -> {
if (hasPermission(sender, "bid") || hasPermission(sender, "sell")) completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
}
case "bid", "sell" -> completions.addAll(Arrays.asList("1", "2", "4", "8", "10", "20", "40", "64"));
}
return StringUtil.copyPartialMatches(args[2], completions, new ArrayList<>());
} else if (args.length == 4) { // /crazyauctions arg0 arg1 arg2
switch (args[0].toLowerCase()) {
case "bid", "sell" -> {
if (hasPermission(sender, "bid") || hasPermission(sender, "sell")) completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
}
}
return StringUtil.copyPartialMatches(args[3], completions, new ArrayList<>());
}
return new ArrayList<>();

View File

@ -1,8 +0,0 @@
name: '${name}'
main: '${group}.CrazyAuctions'
version: '${version}'
api-version: '${apiVersion}'
description: '${description}'
bootstrapper: '${group}.CrazyStarter'