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

Fix checkstyle violations

Dieser Commit ist enthalten in:
Hugo Manrique 2021-06-10 20:35:36 +02:00
Ursprung fb7aafe8ae
Commit f6e6f02a84
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A60730A4A4ACE782
7 geänderte Dateien mit 23 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -285,9 +285,6 @@ final class SuggestionsProvider<S> {
* Parses the hint nodes under the given node, which is either an alias node of * Parses the hint nodes under the given node, which is either an alias node of
* a {@link Command} or another hint node. * a {@link Command} or another hint node.
* *
* The caller must check the requirements
* are satisfied by a given source prior to calling this method.
*
* <p>The reader and context are not mutated by this method. * <p>The reader and context are not mutated by this method.
* *
* @param node the node to parse * @param node the node to parse

Datei anzeigen

@ -220,7 +220,8 @@ public class VelocityCommandManager implements CommandManager {
final String normalizedInput = VelocityCommands.normalizeInput(cmdLine, false); final String normalizedInput = VelocityCommands.normalizeInput(cmdLine, false);
try { try {
return suggestionsProvider.provideSuggestions(normalizedInput, source) return suggestionsProvider.provideSuggestions(normalizedInput, source)
.thenApply(suggestions -> Lists.transform(suggestions.getList(), Suggestion::getText)); .thenApply(suggestions ->
Lists.transform(suggestions.getList(), Suggestion::getText));
} catch (final Throwable e) { } catch (final Throwable e) {
// Again, plugins are naughty // Again, plugins are naughty
return CompletableFutures.exceptionallyCompletedFuture( return CompletableFutures.exceptionallyCompletedFuture(

Datei anzeigen

@ -33,6 +33,16 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public final class VelocityArgumentBuilder<S, T> public final class VelocityArgumentBuilder<S, T>
extends ArgumentBuilder<S, VelocityArgumentBuilder<S, T>> { extends ArgumentBuilder<S, VelocityArgumentBuilder<S, T>> {
/**
* Creates a builder for creating {@link VelocityArgumentCommandNode}s with
* the given name and type.
*
* @param name the name of the node
* @param type the type of the argument to parse
* @param <S> the type of the command source
* @param <T> the type of the argument to parse
* @return a builder
*/
public static <S, T> VelocityArgumentBuilder<S, T> velocityArgument(final String name, public static <S, T> VelocityArgumentBuilder<S, T> velocityArgument(final String name,
final ArgumentType<T> type) { final ArgumentType<T> type) {
Preconditions.checkNotNull(name, "name"); Preconditions.checkNotNull(name, "name");
@ -44,7 +54,7 @@ public final class VelocityArgumentBuilder<S, T>
private final ArgumentType<T> type; private final ArgumentType<T> type;
private SuggestionProvider<S> suggestionsProvider = null; private SuggestionProvider<S> suggestionsProvider = null;
public VelocityArgumentBuilder(final String name, final ArgumentType<T> type) { private VelocityArgumentBuilder(final String name, final ArgumentType<T> type) {
this.name = name; this.name = name;
this.type = type; this.type = type;
} }

Datei anzeigen

@ -51,7 +51,7 @@ public class VelocityArgumentCommandNode<S, T> extends ArgumentCommandNode<S, St
private final ArgumentType<T> type; private final ArgumentType<T> type;
public VelocityArgumentCommandNode( VelocityArgumentCommandNode(
final String name, final ArgumentType<T> type, final Command<S> command, final String name, final ArgumentType<T> type, final Command<S> command,
final Predicate<S> requirement, final Predicate<S> requirement,
final BiPredicate<CommandContextBuilder<S>, ImmutableStringReader> contextRequirement, final BiPredicate<CommandContextBuilder<S>, ImmutableStringReader> contextRequirement,

Datei anzeigen

@ -85,7 +85,7 @@ public class CommandManagerTests extends CommandTestSuite {
final var oldMeta = manager.metaBuilder("foo").build(); final var oldMeta = manager.metaBuilder("foo").build();
manager.register(oldMeta, DummyCommand.INSTANCE); // fails on execution manager.register(oldMeta, DummyCommand.INSTANCE); // fails on execution
final var newMeta = manager.metaBuilder("foo").build(); final var newMeta = manager.metaBuilder("foo").build();
manager.register("foo", (RawCommand) invocation -> called.set(true)); manager.register(newMeta, (RawCommand) invocation -> called.set(true));
manager.executeAsync(MockCommandSource.INSTANCE, "foo").join(); manager.executeAsync(MockCommandSource.INSTANCE, "foo").join();
assertTrue(called.get()); assertTrue(called.get());

Datei anzeigen

@ -93,10 +93,10 @@ public class StringArrayArgumentTypeTests {
@Test @Test
void testMultipleWhitespaceCharsArePreserved() throws CommandSyntaxException { void testMultipleWhitespaceCharsArePreserved() throws CommandSyntaxException {
final StringReader reader = new StringReader( final StringReader reader = new StringReader(
" This is a message that shouldn't be normalized "); " This is a message that shouldn't be normalized ");
assertArrayEquals(new String[] { assertArrayEquals(new String[] {
"", "This", "", "is", "a", "", "", "message", "", "that", "shouldn't", "", "", "", "be", "", "This", "", "is", "a", "", "", "message", "", "that", "shouldn't", "", "", "", "be",
"normalized", "", ""}, TYPE.parse(reader)); "normalized", "", ""}, TYPE.parse(reader));
assertFalse(reader.canRead()); assertFalse(reader.canRead());
} }

Datei anzeigen

@ -18,7 +18,11 @@
package com.velocitypowered.proxy.command.brigadier; package com.velocitypowered.proxy.command.brigadier;
import static com.velocitypowered.proxy.command.brigadier.VelocityArgumentBuilder.velocityArgument; import static com.velocitypowered.proxy.command.brigadier.VelocityArgumentBuilder.velocityArgument;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.StringReader; import com.mojang.brigadier.StringReader;