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'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.11
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.11
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -170,6 +170,10 @@ public class CommandPart {
|
|||||||
CheckArgumentResult checkArgumentResult = checkArgument(GuardCheckType.TAB_COMPLETE, commandSender, args, startIndex);
|
CheckArgumentResult checkArgumentResult = checkArgument(GuardCheckType.TAB_COMPLETE, commandSender, args, startIndex);
|
||||||
if (checkArgumentResult.success && next != null) {
|
if (checkArgumentResult.success && next != null) {
|
||||||
next.generateTabComplete(current, commandSender, args, startIndex + 1);
|
next.generateTabComplete(current, commandSender, args, startIndex + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (optional != null && next != null) {
|
||||||
|
next.generateTabComplete(current, commandSender, args, startIndex);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ public class SimpleCommandPartTest {
|
|||||||
|
|
||||||
private CommandPart optionalCommandPart;
|
private CommandPart optionalCommandPart;
|
||||||
|
|
||||||
|
private CommandPart optionalCommandPartMultipleNext;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
stringCommandPart = new CommandPart(SWCommandUtils.createMapper("hello", "world"), null, null, null, GuardCheckType.COMMAND);
|
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 = new CommandPart(SWCommandUtils.createMapper("hello", "world"), null, null, "hello", GuardCheckType.COMMAND);
|
||||||
optionalCommandPart.setNext(new CommandPart(SWCommandUtils.createMapper("hello2", "world2"), null, null, null, 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
|
@Test
|
||||||
@ -240,4 +247,43 @@ public class SimpleCommandPartTest {
|
|||||||
assertThat(argumentArray.get(0), is("world"));
|
assertThat(argumentArray.get(0), is("world"));
|
||||||
assertThat(argumentArray.get(1), is("hello2"));
|
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'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.11
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.11
|
||||||
|
|
||||||
mainClassName = ''
|
mainClassName = ''
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren