Class AliasesParser

java.lang.Object
ch.njol.skript.aliases.AliasesParser

public class AliasesParser extends Object
Parses aliases.
  • Field Details

    • provider

      protected final AliasesProvider provider
      Aliases provider, which takes the aliases and variations we parse.
  • Constructor Details

  • Method Details

    • load

      public void load(SectionNode root)
      Loads aliases from a section node.
      Parameters:
      root - Root section node for us to load.
    • parseBlockStates

      protected Map<String,​String> parseBlockStates(String input)
      Parses block states from string input to a map.
      Parameters:
      input - Block states as used in Vanilla commands.
      Returns:
      Them put to a map.
    • loadVariations

      protected @Nullable AliasesProvider.VariationGroup loadVariations(SectionNode root)
      Loads variations from a section node.
      Parameters:
      root - Root node for this variation.
      Returns:
      Group of variations.
    • parseVariation

      protected AliasesProvider.Variation parseVariation(String item)
      Parses a single variation from a string.
      Parameters:
      item - Raw variation info.
      Returns:
      Variation instance.
    • parseKeyPattern

      protected List<String> parseKeyPattern(String name)
      Parses alias key pattern using some black magic.
      Parameters:
      name - Key/name of alias.
      Returns:
      All strings that match aliases with this pattern.
    • parseKeyVariations

      protected Map<String,​AliasesProvider.Variation> parseKeyVariations(String name)
      Parses all possible variations from given name.
      Parameters:
      name - Name which might contain variations.
      Returns:
      Map of variations.
    • loadAlias

      protected void loadAlias(String name, String data)
      Loads an alias with given name (key pattern) and data (material id and tags).
      Parameters:
      name - Name of alias.
      data - Data of alias.
    • getAliasPlural

      protected NonNullPair<String,​String> getAliasPlural(String name)
      Gets singular and plural forms for given name. This might work slightly differently from Noun.getPlural(String), to ensure it meets specification of aliases.
      Parameters:
      name - Name to get forms from.
      Returns:
      Singular form, plural form.
    • loadSingleAlias

      protected void loadSingleAlias(Map<String,​AliasesProvider.Variation> variations, String item)
    • fixName

      protected String fixName(String name)
      Fixes an alias name by trimming it and removing all extraneous spaces between the words.
      Parameters:
      name - Name to be fixed.
      Returns:
      Name fixed.
    • registerCondition

      public void registerCondition(String name, Function<String,​Boolean> condition)