Hotfix CommandPart tabComplete #145
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Dieser Commit ist enthalten in:
Ursprung
99cc770c3b
Commit
256cf4140d
@ -27,8 +27,8 @@ version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 1.11
|
||||
targetCompatibility = 1.11
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -170,6 +170,10 @@ public class CommandPart {
|
||||
CheckArgumentResult checkArgumentResult = checkArgument(GuardCheckType.TAB_COMPLETE, commandSender, args, startIndex);
|
||||
if (checkArgumentResult.success && next != null) {
|
||||
next.generateTabComplete(current, commandSender, args, startIndex + 1);
|
||||
return;
|
||||
}
|
||||
if (optional != null && next != null) {
|
||||
next.generateTabComplete(current, commandSender, args, startIndex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ public class SimpleCommandPartTest {
|
||||
|
||||
private CommandPart optionalCommandPart;
|
||||
|
||||
private CommandPart optionalCommandPartMultipleNext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
stringCommandPart = new CommandPart(SWCommandUtils.createMapper("hello", "world"), null, null, null, GuardCheckType.COMMAND);
|
||||
@ -54,6 +56,11 @@ public class SimpleCommandPartTest {
|
||||
|
||||
optionalCommandPart = new CommandPart(SWCommandUtils.createMapper("hello", "world"), null, null, "hello", GuardCheckType.COMMAND);
|
||||
optionalCommandPart.setNext(new CommandPart(SWCommandUtils.createMapper("hello2", "world2"), null, null, null, GuardCheckType.COMMAND));
|
||||
|
||||
optionalCommandPartMultipleNext = new CommandPart(SWCommandUtils.createMapper("hello", "world"), null, null, "hello", GuardCheckType.COMMAND);
|
||||
CommandPart next = new CommandPart(SWCommandUtils.createMapper("hello2", "world2"), null, null, null, GuardCheckType.COMMAND);
|
||||
next.setNext(new CommandPart(SWCommandUtils.createMapper("hello3", "world3"), null, null, null, GuardCheckType.COMMAND));
|
||||
optionalCommandPartMultipleNext.setNext(next);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -240,4 +247,43 @@ public class SimpleCommandPartTest {
|
||||
assertThat(argumentArray.get(0), is("world"));
|
||||
assertThat(argumentArray.get(1), is("hello2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalCommandPartExecutionMultipleNext() {
|
||||
List<Object> argumentArray = new ArrayList<>();
|
||||
optionalCommandPartMultipleNext.generateArgumentArray(argumentArray, new TestCommandSender(), new String[]{"world", "hello2", "hello3"}, 0);
|
||||
assertThat(argumentArray.size(), is(3));
|
||||
assertThat(argumentArray.get(0), is("world"));
|
||||
assertThat(argumentArray.get(1), is("hello2"));
|
||||
assertThat(argumentArray.get(2), is("hello3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalCommandPartExecutionMultipleTabComplete() {
|
||||
List<String> tabCompletes = new ArrayList<>();
|
||||
optionalCommandPartMultipleNext.generateTabComplete(tabCompletes, new TestCommandSender(), new String[]{""}, 0);
|
||||
assertThat(tabCompletes.size(), is(4));
|
||||
assertThat(tabCompletes.get(0), is("hello"));
|
||||
assertThat(tabCompletes.get(1), is("world"));
|
||||
assertThat(tabCompletes.get(2), is("hello2"));
|
||||
assertThat(tabCompletes.get(3), is("world2"));
|
||||
|
||||
tabCompletes = new ArrayList<>();
|
||||
optionalCommandPartMultipleNext.generateTabComplete(tabCompletes, new TestCommandSender(), new String[]{"hello", ""}, 0);
|
||||
assertThat(tabCompletes.size(), is(2));
|
||||
assertThat(tabCompletes.get(0), is("hello2"));
|
||||
assertThat(tabCompletes.get(1), is("world2"));
|
||||
|
||||
tabCompletes = new ArrayList<>();
|
||||
optionalCommandPartMultipleNext.generateTabComplete(tabCompletes, new TestCommandSender(), new String[]{"hello", "world2", ""}, 0);
|
||||
assertThat(tabCompletes.size(), is(2));
|
||||
assertThat(tabCompletes.get(0), is("hello3"));
|
||||
assertThat(tabCompletes.get(1), is("world3"));
|
||||
|
||||
tabCompletes = new ArrayList<>();
|
||||
optionalCommandPartMultipleNext.generateTabComplete(tabCompletes, new TestCommandSender(), new String[]{"world2", ""}, 0);
|
||||
assertThat(tabCompletes.size(), is(2));
|
||||
assertThat(tabCompletes.get(0), is("hello3"));
|
||||
assertThat(tabCompletes.get(1), is("world3"));
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ ext {
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 1.11
|
||||
targetCompatibility = 1.11
|
||||
|
||||
mainClassName = ''
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren