Files
brigadier/src/main/java/com/mojang/brigadier/tree/RootCommandNode.java
T
2017-11-08 14:50:25 +01:00

53 lines
1.5 KiB
Java

package com.mojang.brigadier.tree;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
public class RootCommandNode<S> extends CommandNode<S> {
public RootCommandNode() {
super(null, c -> true, null, s -> Collections.singleton(s.getSource()));
}
@Override
protected Object getMergeKey() {
throw new UnsupportedOperationException("Cannot add a RootCommandNode as a child to any other CommandNode");
}
@Override
public String getUsageText() {
return "";
}
@Override
public void parse(final StringReader reader, final CommandContextBuilder<S> contextBuilder) throws CommandSyntaxException {
}
@Override
public CompletableFuture<Collection<String>> listSuggestions(final String command) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof RootCommandNode)) return false;
return super.equals(o);
}
@Override
public ArgumentBuilder<S, ?> createBuilder() {
throw new IllegalStateException("Cannot convert root into a builder");
}
@Override
protected String getSortedKey() {
return "";
}
}