mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-07 03:19:54 +01:00
Majorly improved auto complete
This commit is contained in:
parent
9ec4c3b78a
commit
7a747a86f9
@ -37,7 +37,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
|
|
||||||
for(Material material : Material.values()) {
|
for(Material material : Material.values()) {
|
||||||
this.blockMaterialList.add("triggerblock:" + material.name());
|
this.blockMaterialList.add("triggerblock:" + material.name().toLowerCase());
|
||||||
}
|
}
|
||||||
plugin.getCommand("advancedportals").setExecutor(this);
|
plugin.getCommand("advancedportals").setExecutor(this);
|
||||||
}
|
}
|
||||||
@ -633,6 +633,15 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||||
|
|
||||||
|
/*System.out.printf("%s %s %s %s%n", sender, cmd, command, args);
|
||||||
|
|
||||||
|
System.out.println(args.length);
|
||||||
|
System.out.println("ARRAY");
|
||||||
|
for(String arg : args) {
|
||||||
|
System.out.println(arg);
|
||||||
|
}*/
|
||||||
|
|
||||||
LinkedList<String> autoComplete = new LinkedList<String>();
|
LinkedList<String> autoComplete = new LinkedList<String>();
|
||||||
if (sender.hasPermission("advancedportals.createportal")) {
|
if (sender.hasPermission("advancedportals.createportal")) {
|
||||||
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
|
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
|
||||||
@ -650,55 +659,75 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
|
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
|
||||||
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
// For if partially complete found and also valid
|
||||||
String argTag = getTag(args[i].toLowerCase());
|
boolean partialComplete = true;
|
||||||
if (argTag.length() + 1 < args[i].length()) {
|
|
||||||
switch (argTag) {
|
|
||||||
case "name":
|
|
||||||
hasName = true;
|
|
||||||
break;
|
|
||||||
case "destination":
|
|
||||||
hasDestination = true;
|
|
||||||
break;
|
|
||||||
case "desti":
|
|
||||||
hasDestination = true;
|
|
||||||
break;
|
|
||||||
case "triggerblock":
|
|
||||||
hasTriggerBlock = true;
|
|
||||||
break;
|
|
||||||
case "bungee":
|
|
||||||
isBungeePortal = true;
|
|
||||||
break;
|
|
||||||
case "permission":
|
|
||||||
needsPermission = true;
|
|
||||||
break;
|
|
||||||
case "command":
|
|
||||||
hasCommand = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// TODO add a better version of this to the new api.
|
||||||
|
|
||||||
if (!hasName) {
|
//System.out.println(args[args.length - 1].equals(""));
|
||||||
autoComplete.add("name:");
|
|
||||||
}
|
String stillToComplete = args[args.length - 1];
|
||||||
if (!hasTriggerBlock) {
|
|
||||||
autoComplete.add("triggerblock:");
|
if(stillToComplete.toLowerCase().startsWith("triggerblock:")) {
|
||||||
autoComplete.addAll(this.blockMaterialList);
|
autoComplete.addAll(this.blockMaterialList);
|
||||||
}
|
}
|
||||||
if (!hasDestination) {
|
else {
|
||||||
autoComplete.add("destination:");
|
partialComplete = false;
|
||||||
autoComplete.add("desti:");
|
|
||||||
}
|
}
|
||||||
if (!isBungeePortal) {
|
|
||||||
autoComplete.add("bungee:");
|
if(!partialComplete) {
|
||||||
}
|
for (int i = 1; i < args.length; i++) {
|
||||||
if (!needsPermission) {
|
String argTag = getTag(args[i].toLowerCase());
|
||||||
autoComplete.add("permission:");
|
if (argTag.length() + 1 < args[i].length()) {
|
||||||
}
|
switch (argTag) {
|
||||||
if (!hasCommand) {
|
case "name":
|
||||||
autoComplete.add("command:");
|
hasName = true;
|
||||||
|
break;
|
||||||
|
case "destination":
|
||||||
|
hasDestination = true;
|
||||||
|
break;
|
||||||
|
case "desti":
|
||||||
|
hasDestination = true;
|
||||||
|
break;
|
||||||
|
case "triggerblock":
|
||||||
|
hasTriggerBlock = true;
|
||||||
|
break;
|
||||||
|
case "bungee":
|
||||||
|
isBungeePortal = true;
|
||||||
|
break;
|
||||||
|
case "permission":
|
||||||
|
needsPermission = true;
|
||||||
|
break;
|
||||||
|
case "command":
|
||||||
|
hasCommand = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasName) {
|
||||||
|
autoComplete.add("name:");
|
||||||
|
}
|
||||||
|
if (!hasTriggerBlock) {
|
||||||
|
autoComplete.add("triggerblock:");
|
||||||
|
}
|
||||||
|
if (!hasDestination) {
|
||||||
|
autoComplete.add("destination:");
|
||||||
|
autoComplete.add("desti:");
|
||||||
|
}
|
||||||
|
if (!isBungeePortal) {
|
||||||
|
autoComplete.add("bungee:");
|
||||||
|
}
|
||||||
|
if (!needsPermission) {
|
||||||
|
autoComplete.add("permission:");
|
||||||
|
}
|
||||||
|
if (!hasCommand) {
|
||||||
|
autoComplete.add("command:");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
autoComplete.add("@player");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user