3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Just import the entire command manager from Polymer, without changing any names

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-05-23 13:58:27 -04:00
Ursprung 590f18dbe0
Commit 569bb4a16b
2 geänderte Dateien mit 105 neuen und 107 gelöschten Zeilen

Datei anzeigen

@ -34,7 +34,6 @@ import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand; import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandMeta; import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.RawCommand; import com.velocitypowered.api.command.RawCommand;
@ -174,9 +173,9 @@ public class CommandManagerTests {
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 14").join()); assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 14").join());
assertTrue(checkedRequires.compareAndSet(true, false)); assertTrue(checkedRequires.compareAndSet(true, false));
assertTrue(executed.get()); assertTrue(executed.get());
assertFalse(manager.execute(MockCommandSource.INSTANCE, "buy 9").join(), assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy 9").join(),
"Invalid arg returns false"); "Invalid arg returns false");
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas") assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas")
.join()); .join());
assertTrue(checkedRequires.get()); assertTrue(checkedRequires.get());
} }
@ -379,9 +378,8 @@ public class CommandManagerTests {
.join().isEmpty()); .join().isEmpty());
} }
// TODO: Hug needs to fix this test!
@Disabled
@Test @Test
@Disabled
void testHinting() { void testHinting() {
VelocityCommandManager manager = createManager(); VelocityCommandManager manager = createManager();
AtomicBoolean executed = new AtomicBoolean(false); AtomicBoolean executed = new AtomicBoolean(false);
@ -470,20 +468,20 @@ public class CommandManagerTests {
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo").get().isEmpty()); assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo").get().isEmpty());
assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo bar").get().isEmpty()); assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo bar").get().isEmpty());
Command oldCommand = new SimpleCommand() { SimpleCommand oldCommand = new SimpleCommand() {
@Override @Override
public void execute(Invocation invocation) { public void execute(Invocation invocation) {
fail("The Command should not be executed while testing suggestions"); fail("The Command should not be executed while testing suggestions");
} }
@Override @Override
public List<String> suggest(Invocation invocation) { public boolean hasPermission(Invocation invocation) {
return ImmutableList.of("suggestion"); return invocation.arguments().length > 0;
} }
@Override @Override
public boolean hasPermission(Invocation invocation) { public List<String> suggest(Invocation invocation) {
return invocation.arguments().length > 0; return ImmutableList.of("suggestion");
} }
}; };