Added tabcompleter
This commit is contained in:
parent
2fa2cd9b95
commit
4b5ee21872
4 changed files with 56 additions and 1 deletions
|
@ -1008,7 +1008,8 @@ public class V10LiftCommand implements CommandExecutor {
|
|||
sender.sendMessage("§6/v10lift whois [Name]§f: See information about a lift.");
|
||||
sender.sendMessage("§6/v10lift edit <Name>§f: Edit a lift.");
|
||||
sender.sendMessage("§6/v10lift floor <add/del/rename> <Name> [New name]§f: Add/remove/rename a floor.");
|
||||
sender.sendMessage("§6/v10lift input <add/del> [Floorname]§f: Add/remove a input.");
|
||||
sender.sendMessage("§6/v10lift input <add/del> [Floorname]§f: Add/remove an input.");
|
||||
sender.sendMessage("§6/v10lift offline <add/del> [Floorname]§f: Add/remove an offline input.");
|
||||
sender.sendMessage("§6/v10lift build§f: Add/remove blocks to/from a cab.");
|
||||
sender.sendMessage("§6/v10lift rope <add/del>§f: Add/remove a rope.");
|
||||
sender.sendMessage("§6/v10lift door§f: Add doors to a lift.");
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
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 javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class V10LiftTabCompleter implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@Nonnull CommandSender commandSender, @Nonnull Command cmd, @Nonnull String label, @Nonnull String[] args) {
|
||||
if (label.equalsIgnoreCase("v10lift")) {
|
||||
ArrayList<String> returns = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
String[] strs = { "create", "delete", "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")) {
|
||||
returns.add("add");
|
||||
returns.add("del");
|
||||
} else if (args[0].equalsIgnoreCase("offline")) {
|
||||
returns.add("add");
|
||||
returns.add("del");
|
||||
} else if (args[0].equalsIgnoreCase("whitelist")) {
|
||||
returns.add("add");
|
||||
returns.add("del");
|
||||
} else if (args[0].equalsIgnoreCase("rope")) {
|
||||
returns.add("add");
|
||||
returns.add("del");
|
||||
} else if (args[0].equalsIgnoreCase("edit")) {
|
||||
returns.addAll(DataManager.getLifts().keySet());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(returns);
|
||||
return returns;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package nl.SBDeveloper.V10Lift;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import nl.SBDeveloper.V10Lift.API.V10LiftAPI;
|
||||
import nl.SBDeveloper.V10Lift.Commands.V10LiftCommand;
|
||||
import nl.SBDeveloper.V10Lift.Commands.V10LiftTabCompleter;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.BlockBreakListener;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.EntityDamageListener;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.PlayerInteractListener;
|
||||
|
@ -50,6 +51,7 @@ public class V10LiftPlugin extends JavaPlugin {
|
|||
|
||||
//Load the command
|
||||
Objects.requireNonNull(getCommand("v10lift"), "Internal error! Command not found.").setExecutor(new V10LiftCommand());
|
||||
Objects.requireNonNull(getCommand("v10lift"), "Internal error! Command not found.").setTabCompleter(new V10LiftTabCompleter());
|
||||
|
||||
//Register the listeners
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
||||
|
|
|
@ -2,6 +2,7 @@ name: V10Lift
|
|||
main: nl.SBDeveloper.V10Lift.V10LiftPlugin
|
||||
version: ${project.version}
|
||||
api-version: "1.13"
|
||||
author: SBDeveloper
|
||||
commands:
|
||||
v10lift:
|
||||
description: The V10Lift Command
|
Loading…
Reference in a new issue