Class CommandHelper

java.lang.Object
net.darkhax.bookshelf.common.api.util.CommandHelper

public class CommandHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 boolean
    getBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx)
     
    static boolean
    getBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, Supplier<Boolean> fallback)
     
    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)
     
    static net.minecraft.world.entity.Entity
    getEntityOrSender(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx)
     
    static <T extends Enum<T> & IEnumCommand>
    PermissionLevel
    getLowestLevel(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> boolean
    hasArgument(String argument, com.mojang.brigadier.context.CommandContext<T> context)
    Deprecated.
    This only works on Fabric.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static <T extends Enum<T> & IEnumCommand> PermissionLevel getLowestLevel(Class<T> enumClass)
      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

      public static <T, C> boolean hasArgument(String argument, com.mojang.brigadier.context.CommandContext<C> context, Class<T> argType)
    • getArgument

      public static <T, C> T getArgument(String argument, com.mojang.brigadier.context.CommandContext<C> context, Class<T> argType, Supplier<T> fallback)
    • 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

      public static boolean getBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, Supplier<Boolean> fallback)
    • getBooleanArg

      public static boolean getBooleanArg(String argName, com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx)