diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java index c4e4c43..6610780 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftTabCompleter.java @@ -1,44 +1,23 @@ package nl.SBDeveloper.V10Lift.Commands; -import nl.SBDeveloper.V10Lift.Managers.DataManager; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; +import org.bukkit.util.StringUtil; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; public class V10LiftTabCompleter implements TabCompleter { + private static final List COMMANDS = Arrays.asList("create", "delete", "rename", "abort", "whois", "edit", "floor", "input", "build", "rope", "door", "speed", "realistic", "repair", "whitelist", "reload", "help", "start", "stop", "offline"); + @Override public List onTabComplete(@Nonnull CommandSender commandSender, @Nonnull Command cmd, @Nonnull String label, @Nonnull String[] args) { if (label.equalsIgnoreCase("v10lift")) { - ArrayList returns = new ArrayList<>(); - if (args.length == 1) { - String[] strs = { "create", "delete", "rename", "abort", "whois", "edit", "floor", "input", "build", "rope", "door", "speed", "realistic", "repair", "whitelist", "reload", "help", "start", "stop", "offline" }; - returns.addAll(Arrays.asList(strs)); - } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("floor")) { - returns.add("add"); - returns.add("del"); - returns.add("rename"); - } else if (args[0].equalsIgnoreCase("input") || args[0].equalsIgnoreCase("offline") || args[0].equalsIgnoreCase("whitelist") || args[0].equalsIgnoreCase("rope")) { - returns.add("add"); - returns.add("del"); - } else if (args[0].equalsIgnoreCase("edit") || args[0].equalsIgnoreCase("start") || args[0].equalsIgnoreCase("stop")) { - returns.addAll(DataManager.getLifts().keySet()); - } - } else if (args.length == 3) { - if (args[0].equalsIgnoreCase("start")) { - returns.addAll(DataManager.getLift(args[1]).getFloors().keySet()); - } - } - - Collections.sort(returns); - return returns; + return (args.length > 0) ? StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<>()) : null; } return null; }