✨ Get rid of some annoying warnings
This commit is contained in:
parent
a4544a8550
commit
ec233fcc20
4 changed files with 29 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public final class CommandHelpHandler<C> {
|
public final class CommandHelpHandler<C> {
|
||||||
|
|
@ -73,7 +74,7 @@ public final class CommandHelpHandler<C> {
|
||||||
public @NonNull List<@NonNull String> getLongestSharedChains() {
|
public @NonNull List<@NonNull String> getLongestSharedChains() {
|
||||||
final List<String> chains = new ArrayList<>();
|
final List<String> chains = new ArrayList<>();
|
||||||
this.commandManager.getCommandTree().getRootNodes().forEach(node ->
|
this.commandManager.getCommandTree().getRootNodes().forEach(node ->
|
||||||
chains.add(node.getValue()
|
chains.add(Objects.requireNonNull(node.getValue())
|
||||||
.getName() + this.commandManager.getCommandSyntaxFormatter()
|
.getName() + this.commandManager.getCommandSyntaxFormatter()
|
||||||
.apply(Collections
|
.apply(Collections
|
||||||
.emptyList(),
|
.emptyList(),
|
||||||
|
|
@ -216,7 +217,11 @@ public final class CommandHelpHandler<C> {
|
||||||
if (index < queryFragments.length) {
|
if (index < queryFragments.length) {
|
||||||
/* We might still be able to match an argument */
|
/* We might still be able to match an argument */
|
||||||
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
|
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
final StaticArgument<C> childArgument = (StaticArgument<C>) child.getValue();
|
final StaticArgument<C> childArgument = (StaticArgument<C>) child.getValue();
|
||||||
|
if (childArgument == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (final String childAlias : childArgument.getAliases()) {
|
for (final String childAlias : childArgument.getAliases()) {
|
||||||
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
|
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
|
||||||
head = child;
|
head = child;
|
||||||
|
|
@ -253,6 +258,7 @@ public final class CommandHelpHandler<C> {
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface HelpTopic<C> {
|
public interface HelpTopic<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@ import java.util.function.Function;
|
||||||
*
|
*
|
||||||
* @param <C> Command sender type
|
* @param <C> Command sender type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public abstract class CommandManager<C> {
|
public abstract class CommandManager<C> {
|
||||||
|
|
||||||
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
|
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
|
||||||
|
|
@ -371,7 +370,7 @@ public abstract class CommandManager<C> {
|
||||||
* @return Flag builder
|
* @return Flag builder
|
||||||
*/
|
*/
|
||||||
public CommandFlag.@NonNull Builder<Void> flagBuilder(final @NonNull String name) {
|
public CommandFlag.@NonNull Builder<Void> flagBuilder(final @NonNull String name) {
|
||||||
return CommandFlag.<C>newBuilder(name);
|
return CommandFlag.newBuilder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -580,6 +579,7 @@ public abstract class CommandManager<C> {
|
||||||
* @param setting Setting to set
|
* @param setting Setting to set
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setSetting(final @NonNull ManagerSettings setting,
|
public void setSetting(final @NonNull ManagerSettings setting,
|
||||||
final boolean value) {
|
final boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public final class CommandTree<C> {
|
public final class CommandTree<C> {
|
||||||
|
|
||||||
private static final @Nullable Exception NULL_EXCEPTION = null;
|
|
||||||
|
|
||||||
private final Object commandLock = new Object();
|
private final Object commandLock = new Object();
|
||||||
|
|
||||||
private final Node<CommandArgument<C, ?>> internalTree = new Node<>(null);
|
private final Node<CommandArgument<C, ?>> internalTree = new Node<>(null);
|
||||||
|
|
@ -144,6 +142,7 @@ public final class CommandTree<C> {
|
||||||
commandContext.getSender(),
|
commandContext.getSender(),
|
||||||
this.getChain(root)
|
this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -169,6 +168,7 @@ public final class CommandTree<C> {
|
||||||
.apply(parsedArguments, root),
|
.apply(parsedArguments, root),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -179,6 +179,7 @@ public final class CommandTree<C> {
|
||||||
.apply(parsedArguments, root),
|
.apply(parsedArguments, root),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -219,6 +220,7 @@ public final class CommandTree<C> {
|
||||||
commandContext.getSender(),
|
commandContext.getSender(),
|
||||||
this.getChain(root)
|
this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -230,6 +232,7 @@ public final class CommandTree<C> {
|
||||||
.apply(parsedArguments, root),
|
.apply(parsedArguments, root),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -252,6 +255,7 @@ public final class CommandTree<C> {
|
||||||
commandContext.getSender(),
|
commandContext.getSender(),
|
||||||
this.getChain(child)
|
this.getChain(child)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toList())));
|
Collectors.toList())));
|
||||||
|
|
@ -273,6 +277,7 @@ public final class CommandTree<C> {
|
||||||
commandContext.getSender(),
|
commandContext.getSender(),
|
||||||
this.getChain(root)
|
this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -287,6 +292,7 @@ public final class CommandTree<C> {
|
||||||
.getArguments(), child),
|
.getArguments(), child),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toList())));
|
Collectors.toList())));
|
||||||
|
|
@ -301,6 +307,7 @@ public final class CommandTree<C> {
|
||||||
commandContext.getSender(),
|
commandContext.getSender(),
|
||||||
this.getChain(root)
|
this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -312,6 +319,7 @@ public final class CommandTree<C> {
|
||||||
.apply(parsedArguments, root),
|
.apply(parsedArguments, root),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -336,6 +344,7 @@ public final class CommandTree<C> {
|
||||||
.apply(parsedArguments, child),
|
.apply(parsedArguments, child),
|
||||||
commandContext.getSender(), this.getChain(root)
|
commandContext.getSender(), this.getChain(root)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toList())));
|
Collectors.toList())));
|
||||||
|
|
@ -349,6 +358,7 @@ public final class CommandTree<C> {
|
||||||
result.getFailure().get(), commandContext.getSender(),
|
result.getFailure().get(), commandContext.getSender(),
|
||||||
this.getChain(child)
|
this.getChain(child)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(node -> node.getValue() != null)
|
||||||
.map(Node::getValue)
|
.map(Node::getValue)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -429,7 +439,8 @@ public final class CommandTree<C> {
|
||||||
commandContext.store(child.getValue().getName(), result.getParsedValue().get());
|
commandContext.store(child.getValue().getName(), result.getParsedValue().get());
|
||||||
return this.getSuggestions(commandContext, commandQueue, child);
|
return this.getSuggestions(commandContext, commandQueue, child);
|
||||||
} else if (result.getFailure().isPresent()) {
|
} else if (result.getFailure().isPresent()) {
|
||||||
return child.getValue().getSuggestionsProvider().apply(commandContext, commandQueue.peek());
|
final String value = commandQueue.peek() == null ? "" : commandQueue.peek();
|
||||||
|
return child.getValue().getSuggestionsProvider().apply(commandContext, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -606,7 +617,10 @@ public final class CommandTree<C> {
|
||||||
if (child.getValue() != null && !child.getValue().isRequired() && size > 1) {
|
if (child.getValue() != null && !child.getValue().isRequired() && size > 1) {
|
||||||
throw new AmbiguousNodeException(node.getValue(),
|
throw new AmbiguousNodeException(node.getValue(),
|
||||||
child.getValue(),
|
child.getValue(),
|
||||||
node.getChildren().stream().map(Node::getValue).collect(Collectors.toList()));
|
node.getChildren()
|
||||||
|
.stream()
|
||||||
|
.filter(n -> n.getValue() != null)
|
||||||
|
.map(Node::getValue).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.children.forEach(this::checkAmbiguity);
|
node.children.forEach(this::checkAmbiguity);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class PaperBrigadierListener<C> implements Listener {
|
||||||
private final PaperCommandManager<C> paperCommandManager;
|
private final PaperCommandManager<C> paperCommandManager;
|
||||||
private final String nmsVersion;
|
private final String nmsVersion;
|
||||||
|
|
||||||
PaperBrigadierListener(@Nonnull final PaperCommandManager<C> paperCommandManager) throws Exception {
|
PaperBrigadierListener(@Nonnull final PaperCommandManager<C> paperCommandManager) {
|
||||||
this.paperCommandManager = paperCommandManager;
|
this.paperCommandManager = paperCommandManager;
|
||||||
this.brigadierManager = new CloudBrigadierManager<>(this.paperCommandManager,
|
this.brigadierManager = new CloudBrigadierManager<>(this.paperCommandManager,
|
||||||
() -> new CommandContext<>(
|
() -> new CommandContext<>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue