Fix //expand, improve //help

This commit is contained in:
Kenzie Togami
2019-05-17 22:24:14 -07:00
parent 71df3716dd
commit 3173e26109
14 changed files with 209 additions and 226 deletions

View File

@ -27,6 +27,8 @@ import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.Command;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.part.SubCommandPart;
import java.util.Comparator;
@ -120,6 +122,12 @@ public class CommandUtil {
}
}
public static <T> T requireIV(Key<T> type, String name, InjectedValueAccess injectedValueAccess) {
return injectedValueAccess.injectedValue(type).orElseThrow(() ->
new IllegalStateException("No injected value for " + name + " (type " + type + ")")
);
}
private CommandUtil() {
}
}