Class CommandHelper
java.lang.Object
net.darkhax.bookshelf.common.api.util.CommandHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Enum<T> & IEnumCommand>
voidbuildFromEnum(com.mojang.brigadier.builder.ArgumentBuilder<net.minecraft.commands.CommandSourceStack, ?> parent, Class<T> enumClass) Creates branching command paths that represent the values of an enum.static <T extends Enum<T> & IEnumCommand>
com.mojang.brigadier.builder.LiteralArgumentBuilder<net.minecraft.commands.CommandSourceStack> buildFromEnum(String parent, Class<T> enumClass) Creates a command with branching paths that represent the values of an enum.static <T,C> T getArgument(String argument, com.mojang.brigadier.context.CommandContext<C> context, Class<T> argType, Supplier<T> fallback) static booleangetBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx) static booleangetBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, Supplier<Boolean> fallback) static net.minecraft.world.entity.EntitygetEntity(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, Supplier<net.minecraft.world.entity.Entity> fallback) static net.minecraft.world.entity.EntitygetEntityOrSender(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx) static <T extends Enum<T> & IEnumCommand>
PermissionLevelgetLowestLevel(Class<T> enumClass) Gets the lowest required permission level for an enum command.static <T,C> boolean hasArgument(String argument, com.mojang.brigadier.context.CommandContext<C> context, Class<T> argType) static <T> booleanhasArgument(String argument, com.mojang.brigadier.context.CommandContext<T> context) Deprecated.This only works on Fabric.
-
Constructor Details
-
CommandHelper
public CommandHelper()
-
-
Method Details
-
buildFromEnum
public static <T extends Enum<T> & IEnumCommand> com.mojang.brigadier.builder.LiteralArgumentBuilder<net.minecraft.commands.CommandSourceStack> buildFromEnum(String parent, Class<T> enumClass) Creates a command with branching paths that represent the values of an enum.- Type Parameters:
T- The type of the enum.- Parameters:
parent- The name of the root parent command node.enumClass- The enum class to use.- Returns:
- The newly created command node.
-
buildFromEnum
public static <T extends Enum<T> & IEnumCommand> void buildFromEnum(com.mojang.brigadier.builder.ArgumentBuilder<net.minecraft.commands.CommandSourceStack, ?> parent, Class<T> enumClass) Creates branching command paths that represent the values of an enum.- Type Parameters:
T- The type of the enum.- Parameters:
parent- The parent node to branch off from.enumClass- The enum class to use.
-
getLowestLevel
Gets the lowest required permission level for an enum command.- Type Parameters:
T- The type of the enum.- Parameters:
enumClass- The enum class to use.- Returns:
- The lowest required permission level for an enum command.
-
hasArgument
@Deprecated public static <T> boolean hasArgument(String argument, com.mojang.brigadier.context.CommandContext<T> context) Deprecated.This only works on Fabric. -
hasArgument
-
getArgument
-
getEntity
public static net.minecraft.world.entity.Entity getEntity(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, Supplier<net.minecraft.world.entity.Entity> fallback) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
getEntityOrSender
public static net.minecraft.world.entity.Entity getEntityOrSender(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
getBooleanArg
-
getBooleanArg
public static boolean getBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx)
-