Class VariableManager

java.lang.Object
me.hsgamer.hscore.variable.VariableManager
All Implemented Interfaces:
StringReplacer

public class VariableManager extends Object implements StringReplacer
The variable manager for the instance
  • Constructor Details

    • VariableManager

      public VariableManager()
  • Method Details

    • register

      public void register(String prefix, StringReplacer variable, boolean isWhole)
      Register new variable
      Parameters:
      prefix - the prefix
      variable - the replacer
      isWhole - whether the manager should check the whole string matches the prefix, set it to false if you want to check if the prefix is at the beginning of the string
    • register

      public void register(String prefix, StringReplacer variable)
      Register new variable
      Parameters:
      prefix - the prefix
      variable - the Variable object
    • unregister

      public void unregister(String prefix)
      Unregister a variable
      Parameters:
      prefix - the prefix
    • getVariables

      public Map<String,StringReplacer> getVariables()
      Get all variables
      Returns:
      the variables
    • getVariableEntries

      public List<Variable> getVariableEntries()
      Get all variable entries
      Returns:
      the variable entries
    • addExternalReplacer

      public void addExternalReplacer(StringReplacer replacer)
      Add an external replacer
      Parameters:
      replacer - the external string replacer
    • removeExternalReplacer

      public void removeExternalReplacer(StringReplacer replacer)
      Remove an external replacer
      Parameters:
      replacer - the external string replacer
    • clearExternalReplacers

      public void clearExternalReplacers()
      Clear all external replacers
    • getExternalReplacers

      public List<StringReplacer> getExternalReplacers()
      Get all external replacers
      Returns:
      the external replacers
    • setVariables

      @NotNull public @NotNull String setVariables(@NotNull @NotNull String message, @Nullable @Nullable UUID uuid)
      Replace the variables of the string until it cannot be replaced anymore
      Parameters:
      message - the string
      uuid - the unique id
      Returns:
      the replaced string
    • setSingleVariables

      @NotNull public @NotNull String setSingleVariables(@NotNull @NotNull String message, @Nullable @Nullable UUID uuid)
      Replace the variables of the string (single time)
      Parameters:
      message - the string
      uuid - the unique id
      Returns:
      the replaced string
    • replace

      @Nullable public @Nullable String replace(@NotNull @NotNull String original)
      Description copied from interface: StringReplacer
      Replace a string
      Specified by:
      replace in interface StringReplacer
      Parameters:
      original - the original string
      Returns:
      the replaced string
    • replace

      @Nullable public @Nullable String replace(@NotNull @NotNull String original, @NotNull @NotNull UUID uuid)
      Description copied from interface: StringReplacer
      Replace a string based on the unique id
      Specified by:
      replace in interface StringReplacer
      Parameters:
      original - the original string
      uuid - the unique id
      Returns:
      the replaced string