diff --git a/docs/acf-core/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html b/docs/acf-core/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html index 425b4368..5e6ecd58 100644 --- a/docs/acf-core/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html +++ b/docs/acf-core/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html @@ -102,7 +102,7 @@

-
public static interface CommandCompletions.AsyncCommandCompletionHandler<C extends CommandCompletionContext>
+
public static interface CommandCompletions.AsyncCommandCompletionHandler<C extends CommandCompletionContext>
 extends CommandCompletions.CommandCompletionHandler<C>
diff --git a/docs/acf-core/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html b/docs/acf-core/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html index 5ac5c830..c32f1d4f 100644 --- a/docs/acf-core/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html +++ b/docs/acf-core/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html @@ -108,7 +108,7 @@ var activeTableTab = "activeTableTab";

-
public static interface CommandCompletions.CommandCompletionHandler<C extends CommandCompletionContext>
+
public static interface CommandCompletions.CommandCompletionHandler<C extends CommandCompletionContext>
@@ -154,7 +154,7 @@ var activeTableTab = "activeTableTab"; diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html index 7a53116a..1d0592a3 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.AsyncCommandCompletionHandler.html @@ -84,64 +84,67 @@ 076 final int argIndex = args.length - 1; 077 078 String input = args[argIndex]; -079 final String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; -080 if (completion == null) { -081 return ImmutableList.of(input); +079 String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; +080 if (completion == null && completionInfo.length > 0) { +081 completion = completionInfo[completionInfo.length - 1]; 082 } -083 -084 return getCompletionValues(command, sender, completion, args, isAsync); -085 } +083 if (completion == null) { +084 return ImmutableList.of(input); +085 } 086 -087 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { -088 completion = manager.getCommandReplacements().replace(completion); +087 return getCompletionValues(command, sender, completion, args, isAsync); +088 } 089 -090 List<String> allCompletions = Lists.newArrayList(); -091 String input = args.length > 0 ? args[args.length - 1] : ""; +090 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { +091 completion = manager.getCommandReplacements().replace(completion); 092 -093 for (String value : ACFPatterns.PIPE.split(completion)) { -094 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); -095 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); -096 if (handler != null) { -097 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { -098 ACFUtil.sneaky(new SyncCompletionRequired()); -099 return null; -100 } -101 String config = complete.length == 1 ? null : complete[1]; -102 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); -103 -104 try { -105 //noinspection unchecked -106 Collection<String> completions = handler.getCompletions(context); -107 if (completions != null) { -108 allCompletions.addAll(completions); -109 continue; -110 } -111 //noinspection ConstantIfStatement,ConstantConditions -112 if (false) { // Hack to fool compiler. since its sneakily thrown. -113 throw new CommandCompletionTextLookupException(); -114 } -115 } catch (CommandCompletionTextLookupException ignored) { -116 // This should only happen if some other feedback error occured. -117 } catch (Exception e) { -118 command.handleException(sender, Lists.newArrayList(args), e); -119 } -120 // Something went wrong in lookup, fall back to input -121 return ImmutableList.of(input); -122 } else { -123 // Plaintext value -124 allCompletions.add(value); -125 } -126 } -127 return allCompletions; -128 } -129 -130 public interface CommandCompletionHandler <C extends CommandCompletionContext> { -131 Collection<String> getCompletions(C context) throws InvalidCommandArgument; -132 } -133 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} -134 public static class SyncCompletionRequired extends Exception {} -135 -136} +093 List<String> allCompletions = Lists.newArrayList(); +094 String input = args.length > 0 ? args[args.length - 1] : ""; +095 +096 for (String value : ACFPatterns.PIPE.split(completion)) { +097 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); +098 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); +099 if (handler != null) { +100 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { +101 ACFUtil.sneaky(new SyncCompletionRequired()); +102 return null; +103 } +104 String config = complete.length == 1 ? null : complete[1]; +105 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); +106 +107 try { +108 //noinspection unchecked +109 Collection<String> completions = handler.getCompletions(context); +110 if (completions != null) { +111 allCompletions.addAll(completions); +112 continue; +113 } +114 //noinspection ConstantIfStatement,ConstantConditions +115 if (false) { // Hack to fool compiler. since its sneakily thrown. +116 throw new CommandCompletionTextLookupException(); +117 } +118 } catch (CommandCompletionTextLookupException ignored) { +119 // This should only happen if some other feedback error occured. +120 } catch (Exception e) { +121 command.handleException(sender, Lists.newArrayList(args), e); +122 } +123 // Something went wrong in lookup, fall back to input +124 return ImmutableList.of(input); +125 } else { +126 // Plaintext value +127 allCompletions.add(value); +128 } +129 } +130 return allCompletions; +131 } +132 +133 public interface CommandCompletionHandler <C extends CommandCompletionContext> { +134 Collection<String> getCompletions(C context) throws InvalidCommandArgument; +135 } +136 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} +137 public static class SyncCompletionRequired extends Exception {} +138 +139} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html index 7a53116a..1d0592a3 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.CommandCompletionHandler.html @@ -84,64 +84,67 @@ 076 final int argIndex = args.length - 1; 077 078 String input = args[argIndex]; -079 final String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; -080 if (completion == null) { -081 return ImmutableList.of(input); +079 String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; +080 if (completion == null && completionInfo.length > 0) { +081 completion = completionInfo[completionInfo.length - 1]; 082 } -083 -084 return getCompletionValues(command, sender, completion, args, isAsync); -085 } +083 if (completion == null) { +084 return ImmutableList.of(input); +085 } 086 -087 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { -088 completion = manager.getCommandReplacements().replace(completion); +087 return getCompletionValues(command, sender, completion, args, isAsync); +088 } 089 -090 List<String> allCompletions = Lists.newArrayList(); -091 String input = args.length > 0 ? args[args.length - 1] : ""; +090 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { +091 completion = manager.getCommandReplacements().replace(completion); 092 -093 for (String value : ACFPatterns.PIPE.split(completion)) { -094 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); -095 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); -096 if (handler != null) { -097 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { -098 ACFUtil.sneaky(new SyncCompletionRequired()); -099 return null; -100 } -101 String config = complete.length == 1 ? null : complete[1]; -102 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); -103 -104 try { -105 //noinspection unchecked -106 Collection<String> completions = handler.getCompletions(context); -107 if (completions != null) { -108 allCompletions.addAll(completions); -109 continue; -110 } -111 //noinspection ConstantIfStatement,ConstantConditions -112 if (false) { // Hack to fool compiler. since its sneakily thrown. -113 throw new CommandCompletionTextLookupException(); -114 } -115 } catch (CommandCompletionTextLookupException ignored) { -116 // This should only happen if some other feedback error occured. -117 } catch (Exception e) { -118 command.handleException(sender, Lists.newArrayList(args), e); -119 } -120 // Something went wrong in lookup, fall back to input -121 return ImmutableList.of(input); -122 } else { -123 // Plaintext value -124 allCompletions.add(value); -125 } -126 } -127 return allCompletions; -128 } -129 -130 public interface CommandCompletionHandler <C extends CommandCompletionContext> { -131 Collection<String> getCompletions(C context) throws InvalidCommandArgument; -132 } -133 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} -134 public static class SyncCompletionRequired extends Exception {} -135 -136} +093 List<String> allCompletions = Lists.newArrayList(); +094 String input = args.length > 0 ? args[args.length - 1] : ""; +095 +096 for (String value : ACFPatterns.PIPE.split(completion)) { +097 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); +098 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); +099 if (handler != null) { +100 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { +101 ACFUtil.sneaky(new SyncCompletionRequired()); +102 return null; +103 } +104 String config = complete.length == 1 ? null : complete[1]; +105 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); +106 +107 try { +108 //noinspection unchecked +109 Collection<String> completions = handler.getCompletions(context); +110 if (completions != null) { +111 allCompletions.addAll(completions); +112 continue; +113 } +114 //noinspection ConstantIfStatement,ConstantConditions +115 if (false) { // Hack to fool compiler. since its sneakily thrown. +116 throw new CommandCompletionTextLookupException(); +117 } +118 } catch (CommandCompletionTextLookupException ignored) { +119 // This should only happen if some other feedback error occured. +120 } catch (Exception e) { +121 command.handleException(sender, Lists.newArrayList(args), e); +122 } +123 // Something went wrong in lookup, fall back to input +124 return ImmutableList.of(input); +125 } else { +126 // Plaintext value +127 allCompletions.add(value); +128 } +129 } +130 return allCompletions; +131 } +132 +133 public interface CommandCompletionHandler <C extends CommandCompletionContext> { +134 Collection<String> getCompletions(C context) throws InvalidCommandArgument; +135 } +136 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} +137 public static class SyncCompletionRequired extends Exception {} +138 +139} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.SyncCompletionRequired.html b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.SyncCompletionRequired.html index 7a53116a..1d0592a3 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.SyncCompletionRequired.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.SyncCompletionRequired.html @@ -84,64 +84,67 @@ 076 final int argIndex = args.length - 1; 077 078 String input = args[argIndex]; -079 final String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; -080 if (completion == null) { -081 return ImmutableList.of(input); +079 String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; +080 if (completion == null && completionInfo.length > 0) { +081 completion = completionInfo[completionInfo.length - 1]; 082 } -083 -084 return getCompletionValues(command, sender, completion, args, isAsync); -085 } +083 if (completion == null) { +084 return ImmutableList.of(input); +085 } 086 -087 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { -088 completion = manager.getCommandReplacements().replace(completion); +087 return getCompletionValues(command, sender, completion, args, isAsync); +088 } 089 -090 List<String> allCompletions = Lists.newArrayList(); -091 String input = args.length > 0 ? args[args.length - 1] : ""; +090 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { +091 completion = manager.getCommandReplacements().replace(completion); 092 -093 for (String value : ACFPatterns.PIPE.split(completion)) { -094 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); -095 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); -096 if (handler != null) { -097 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { -098 ACFUtil.sneaky(new SyncCompletionRequired()); -099 return null; -100 } -101 String config = complete.length == 1 ? null : complete[1]; -102 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); -103 -104 try { -105 //noinspection unchecked -106 Collection<String> completions = handler.getCompletions(context); -107 if (completions != null) { -108 allCompletions.addAll(completions); -109 continue; -110 } -111 //noinspection ConstantIfStatement,ConstantConditions -112 if (false) { // Hack to fool compiler. since its sneakily thrown. -113 throw new CommandCompletionTextLookupException(); -114 } -115 } catch (CommandCompletionTextLookupException ignored) { -116 // This should only happen if some other feedback error occured. -117 } catch (Exception e) { -118 command.handleException(sender, Lists.newArrayList(args), e); -119 } -120 // Something went wrong in lookup, fall back to input -121 return ImmutableList.of(input); -122 } else { -123 // Plaintext value -124 allCompletions.add(value); -125 } -126 } -127 return allCompletions; -128 } -129 -130 public interface CommandCompletionHandler <C extends CommandCompletionContext> { -131 Collection<String> getCompletions(C context) throws InvalidCommandArgument; -132 } -133 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} -134 public static class SyncCompletionRequired extends Exception {} -135 -136} +093 List<String> allCompletions = Lists.newArrayList(); +094 String input = args.length > 0 ? args[args.length - 1] : ""; +095 +096 for (String value : ACFPatterns.PIPE.split(completion)) { +097 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); +098 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); +099 if (handler != null) { +100 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { +101 ACFUtil.sneaky(new SyncCompletionRequired()); +102 return null; +103 } +104 String config = complete.length == 1 ? null : complete[1]; +105 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); +106 +107 try { +108 //noinspection unchecked +109 Collection<String> completions = handler.getCompletions(context); +110 if (completions != null) { +111 allCompletions.addAll(completions); +112 continue; +113 } +114 //noinspection ConstantIfStatement,ConstantConditions +115 if (false) { // Hack to fool compiler. since its sneakily thrown. +116 throw new CommandCompletionTextLookupException(); +117 } +118 } catch (CommandCompletionTextLookupException ignored) { +119 // This should only happen if some other feedback error occured. +120 } catch (Exception e) { +121 command.handleException(sender, Lists.newArrayList(args), e); +122 } +123 // Something went wrong in lookup, fall back to input +124 return ImmutableList.of(input); +125 } else { +126 // Plaintext value +127 allCompletions.add(value); +128 } +129 } +130 return allCompletions; +131 } +132 +133 public interface CommandCompletionHandler <C extends CommandCompletionContext> { +134 Collection<String> getCompletions(C context) throws InvalidCommandArgument; +135 } +136 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} +137 public static class SyncCompletionRequired extends Exception {} +138 +139} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.html b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.html index 7a53116a..1d0592a3 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandCompletions.html @@ -84,64 +84,67 @@ 076 final int argIndex = args.length - 1; 077 078 String input = args[argIndex]; -079 final String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; -080 if (completion == null) { -081 return ImmutableList.of(input); +079 String completion = argIndex < completionInfo.length ? completionInfo[argIndex] : null; +080 if (completion == null && completionInfo.length > 0) { +081 completion = completionInfo[completionInfo.length - 1]; 082 } -083 -084 return getCompletionValues(command, sender, completion, args, isAsync); -085 } +083 if (completion == null) { +084 return ImmutableList.of(input); +085 } 086 -087 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { -088 completion = manager.getCommandReplacements().replace(completion); +087 return getCompletionValues(command, sender, completion, args, isAsync); +088 } 089 -090 List<String> allCompletions = Lists.newArrayList(); -091 String input = args.length > 0 ? args[args.length - 1] : ""; +090 List<String> getCompletionValues(RegisteredCommand command, CommandIssuer sender, String completion, String[] args, boolean isAsync) { +091 completion = manager.getCommandReplacements().replace(completion); 092 -093 for (String value : ACFPatterns.PIPE.split(completion)) { -094 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); -095 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); -096 if (handler != null) { -097 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { -098 ACFUtil.sneaky(new SyncCompletionRequired()); -099 return null; -100 } -101 String config = complete.length == 1 ? null : complete[1]; -102 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); -103 -104 try { -105 //noinspection unchecked -106 Collection<String> completions = handler.getCompletions(context); -107 if (completions != null) { -108 allCompletions.addAll(completions); -109 continue; -110 } -111 //noinspection ConstantIfStatement,ConstantConditions -112 if (false) { // Hack to fool compiler. since its sneakily thrown. -113 throw new CommandCompletionTextLookupException(); -114 } -115 } catch (CommandCompletionTextLookupException ignored) { -116 // This should only happen if some other feedback error occured. -117 } catch (Exception e) { -118 command.handleException(sender, Lists.newArrayList(args), e); -119 } -120 // Something went wrong in lookup, fall back to input -121 return ImmutableList.of(input); -122 } else { -123 // Plaintext value -124 allCompletions.add(value); -125 } -126 } -127 return allCompletions; -128 } -129 -130 public interface CommandCompletionHandler <C extends CommandCompletionContext> { -131 Collection<String> getCompletions(C context) throws InvalidCommandArgument; -132 } -133 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} -134 public static class SyncCompletionRequired extends Exception {} -135 -136} +093 List<String> allCompletions = Lists.newArrayList(); +094 String input = args.length > 0 ? args[args.length - 1] : ""; +095 +096 for (String value : ACFPatterns.PIPE.split(completion)) { +097 String[] complete = ACFPatterns.COLONEQUALS.split(value, 2); +098 CommandCompletionHandler handler = this.completionMap.get(complete[0].toLowerCase()); +099 if (handler != null) { +100 if (isAsync && !(handler instanceof AsyncCommandCompletionHandler)) { +101 ACFUtil.sneaky(new SyncCompletionRequired()); +102 return null; +103 } +104 String config = complete.length == 1 ? null : complete[1]; +105 CommandCompletionContext context = manager.createCompletionContext(command, sender, input, config, args); +106 +107 try { +108 //noinspection unchecked +109 Collection<String> completions = handler.getCompletions(context); +110 if (completions != null) { +111 allCompletions.addAll(completions); +112 continue; +113 } +114 //noinspection ConstantIfStatement,ConstantConditions +115 if (false) { // Hack to fool compiler. since its sneakily thrown. +116 throw new CommandCompletionTextLookupException(); +117 } +118 } catch (CommandCompletionTextLookupException ignored) { +119 // This should only happen if some other feedback error occured. +120 } catch (Exception e) { +121 command.handleException(sender, Lists.newArrayList(args), e); +122 } +123 // Something went wrong in lookup, fall back to input +124 return ImmutableList.of(input); +125 } else { +126 // Plaintext value +127 allCompletions.add(value); +128 } +129 } +130 return allCompletions; +131 } +132 +133 public interface CommandCompletionHandler <C extends CommandCompletionContext> { +134 Collection<String> getCompletions(C context) throws InvalidCommandArgument; +135 } +136 public interface AsyncCommandCompletionHandler <C extends CommandCompletionContext> extends CommandCompletionHandler <C> {} +137 public static class SyncCompletionRequired extends Exception {} +138 +139} diff --git a/docs/acf-core/src-html/co/aikar/commands/CommandExecutionContext.html b/docs/acf-core/src-html/co/aikar/commands/CommandExecutionContext.html index 8bc7185f..c44a6864 100644 --- a/docs/acf-core/src-html/co/aikar/commands/CommandExecutionContext.html +++ b/docs/acf-core/src-html/co/aikar/commands/CommandExecutionContext.html @@ -69,10 +69,10 @@ 061 if (flags != null) { 062 parseFlags(flags.value()); 063 } -064 inheritContextFlagsFlags(cmd.scope); +064 inheritContextFlags(cmd.scope); 065 } 066 -067 private void inheritContextFlagsFlags(BaseCommand scope) { +067 private void inheritContextFlags(BaseCommand scope) { 068 if (!scope.contextFlags.isEmpty()) { 069 Class<?> pCls = param.getType(); 070 do { @@ -80,7 +80,7 @@ 072 } while ((pCls = pCls.getSuperclass()) != null); 073 } 074 if (scope.parentCommand != null) { -075 inheritContextFlagsFlags(scope.parentCommand); +075 inheritContextFlags(scope.parentCommand); 076 } 077 } 078