Class CommandDescriptions

java.lang.Object
dev.ua.theroer.magicutils.commands.CommandDescriptions

public final class CommandDescriptions extends Object
Resolves command descriptions, optionally treating @key values as language keys.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable String
    defaultDescriptionKey(@Nullable String commandName)
    Builds the implicit description translation key for a root command.
    static @Nullable String
    defaultDescriptionKey(@Nullable String commandName, @Nullable List<String> subCommandPath)
    Builds the implicit description translation key for a command or subcommand.
    static boolean
    isTranslationKey(@Nullable String description)
    Returns whether the description uses the @key localisation syntax.
    static String
    resolveForAudience(@Nullable String languageScope, @Nullable Audience audience, @Nullable String description)
    Resolves a command description for a specific audience, respecting per-player language overrides.
    static String
    resolveForAudience(@Nullable String languageScope, @Nullable Audience audience, @Nullable String description, @Nullable String commandName)
    Resolves a command description for a specific audience, respecting per-player language overrides, and falling back to the implicit commands.<name>.description key when the description is blank.
    static String
    resolveForAudience(@Nullable String languageScope, @Nullable Audience audience, @Nullable String description, @Nullable String commandName, @Nullable List<String> subCommandPath)
    Resolves a command description for a specific audience, respecting per-player language overrides, and falling back to the implicit commands.<command>[.<subcommand>...].description key when the description is blank.
    static String
    resolveGlobal(@Nullable String languageScope, @Nullable String description)
    Resolves a command description for global metadata such as registration and schema inspection.
    static String
    resolveGlobal(@Nullable String languageScope, @Nullable String description, @Nullable String commandName)
    Resolves a command description for global metadata such as registration and schema inspection, falling back to the implicit commands.<name>.description key when the description is blank.
    static String
    resolveGlobal(@Nullable String languageScope, @Nullable String description, @Nullable String commandName, @Nullable List<String> subCommandPath)
    Resolves a command description for global metadata such as registration and schema inspection, falling back to the implicit commands.<command>[.<subcommand>...].description key when the description is blank.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • resolveGlobal

      public static String resolveGlobal(@Nullable @Nullable String languageScope, @Nullable @Nullable String description)
      Resolves a command description for global metadata such as registration and schema inspection.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      description - raw description or @key
      Returns:
      resolved description text
    • resolveGlobal

      public static String resolveGlobal(@Nullable @Nullable String languageScope, @Nullable @Nullable String description, @Nullable @Nullable String commandName)
      Resolves a command description for global metadata such as registration and schema inspection, falling back to the implicit commands.<name>.description key when the description is blank.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      description - raw description or @key
      commandName - root command name
      Returns:
      resolved description text
    • resolveGlobal

      public static String resolveGlobal(@Nullable @Nullable String languageScope, @Nullable @Nullable String description, @Nullable @Nullable String commandName, @Nullable @Nullable List<String> subCommandPath)
      Resolves a command description for global metadata such as registration and schema inspection, falling back to the implicit commands.<command>[.<subcommand>...].description key when the description is blank.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      description - raw description or @key
      commandName - root command name
      subCommandPath - relative subcommand path
      Returns:
      resolved description text
    • resolveForAudience

      public static String resolveForAudience(@Nullable @Nullable String languageScope, @Nullable @Nullable Audience audience, @Nullable @Nullable String description)
      Resolves a command description for a specific audience, respecting per-player language overrides.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      audience - recipient audience
      description - raw description or @key
      Returns:
      resolved description text
    • resolveForAudience

      public static String resolveForAudience(@Nullable @Nullable String languageScope, @Nullable @Nullable Audience audience, @Nullable @Nullable String description, @Nullable @Nullable String commandName)
      Resolves a command description for a specific audience, respecting per-player language overrides, and falling back to the implicit commands.<name>.description key when the description is blank.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      audience - recipient audience
      description - raw description or @key
      commandName - root command name
      Returns:
      resolved description text
    • resolveForAudience

      public static String resolveForAudience(@Nullable @Nullable String languageScope, @Nullable @Nullable Audience audience, @Nullable @Nullable String description, @Nullable @Nullable String commandName, @Nullable @Nullable List<String> subCommandPath)
      Resolves a command description for a specific audience, respecting per-player language overrides, and falling back to the implicit commands.<command>[.<subcommand>...].description key when the description is blank.
      Parameters:
      languageScope - plugin/mod scope used for scoped language managers
      audience - recipient audience
      description - raw description or @key
      commandName - root command name
      subCommandPath - relative subcommand path
      Returns:
      resolved description text
    • isTranslationKey

      public static boolean isTranslationKey(@Nullable @Nullable String description)
      Returns whether the description uses the @key localisation syntax.
      Parameters:
      description - description to inspect
      Returns:
      true when the value should be resolved through LanguageManager
    • defaultDescriptionKey

      @Nullable public static @Nullable String defaultDescriptionKey(@Nullable @Nullable String commandName)
      Builds the implicit description translation key for a root command.
      Parameters:
      commandName - root command name
      Returns:
      translation key or null when the name is blank
    • defaultDescriptionKey

      @Nullable public static @Nullable String defaultDescriptionKey(@Nullable @Nullable String commandName, @Nullable @Nullable List<String> subCommandPath)
      Builds the implicit description translation key for a command or subcommand.

      The key format is commands.<command>[.<subcommand>...].description.

      Parameters:
      commandName - root command name
      subCommandPath - relative subcommand path
      Returns:
      translation key or null when the command name is blank