Interface PluginLocale


public interface PluginLocale
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends LocaleReference>
    T
    asReference(Class<T> clazz)
    Getting the serializable class from the given localization if it was previously assigned.
    boolean
    checkComponent(boolean json, Component component, String comment, Object... path)
    Checking for the existence of a path in the localization file.
    boolean
    checkListComponents(boolean json, List<Component> components, String comment, Object... path)
    Checking for the existence of a path in the localization file.
    boolean
    checkListStrings(List<String> strings, String comment, Object... path)
    Checking for the existence of a path in the localization file.
    boolean
    checkString(String string, String comment, Object... path)
    Checking for the existence of a path in the localization file.
    boolean
    Checking for the existence of a localization file on disk.
    Getteng deserialized Component from locale configuration node.
    Getting a deserialized list of Component classes from the locale configuration node.
    Getting a list of strings from the locale configuration node.
    org.spongepowered.configurate.ConfigurationNode
    Getting data from the localization file.
    org.spongepowered.configurate.ConfigurationNode
    Getting data from the localization file.
    getString(Object... path)
    Getting String from locale configuration node.
    getText(Object... path)
    Getting deserialized text in the constructor for its further modification.
    The operation is possible only after the constructor is registered in the RegisterBuilderEvent event.
    getTexts(Object... path)
    Getting deserialized text in the constructor for its further modification.
    The operation is possible only after the constructor is registered in the RegisterBuilderEvent event.
    void
    Reload locale file
    void
    Saving the localization file.
    <T extends LocaleReference>
    void
    setLocaleReference(Class<T> reference)
    Assign a serializable class to this localization.
    If no data has been previously written to this localization, it will be applied from the specified class.
    <T extends LocaleReference>
    void
    setLocaleReference(T reference)
    Assign a serializable class to this localization.
    If no data has been previously written to this localization, it will be applied from the specified class.
    This method accepts the created class object and applies all the data written to it, as well as performs saving to disk.
  • Method Details

    • reload

      void reload()
      Reload locale file
    • saveLocaleNode

      void saveLocaleNode()
      Saving the localization file.
    • getLocaleRootNode

      org.spongepowered.configurate.ConfigurationNode getLocaleRootNode()
      Getting data from the localization file.
      Returns:
      ConfigurationNode or CommentedConfigurationNode
    • getLocaleNode

      org.spongepowered.configurate.ConfigurationNode getLocaleNode(Object... path)
      Getting data from the localization file.
      Returns:
      ConfigurationNode or CommentedConfigurationNode
    • getComponent

      Component getComponent(Object... path)
      Getteng deserialized Component from locale configuration node.
      Parameters:
      path - - Path in the config file.
      Returns:
      Component
    • getListComponents

      List<Component> getListComponents(Object... path)
      Getting a deserialized list of Component classes from the locale configuration node.
      Parameters:
      path - - Path in the config file.
      Returns:
      "List<Component>"
    • getText

      Text getText(Object... path)
      Getting deserialized text in the constructor for its further modification.
      The operation is possible only after the constructor is registered in the RegisterBuilderEvent event.
    • getTexts

      List<Text> getTexts(Object... path)
      Getting deserialized text in the constructor for its further modification.
      The operation is possible only after the constructor is registered in the RegisterBuilderEvent event.
    • getString

      String getString(Object... path)
      Getting String from locale configuration node.
      Parameters:
      path - - Path in the config file.
      Returns:
      "String"
    • getListStrings

      List<String> getListStrings(Object... path)
      Getting a list of strings from the locale configuration node.
      Parameters:
      path -
      Returns:
    • checkComponent

      boolean checkComponent(boolean json, Component component, String comment, Object... path)
      Checking for the existence of a path in the localization file. And the serialization of the Component class to JSON string.
      The path is created if it does not exist.
      Parameters:
      json - - If true, the Component will be serialized to a JSON string.
      component - - Component class
      comment - - Comment to path. Not necessary. You can specify null. Not used with JSON configuration.
      path - - Path in the config file.
      Returns:
      false if the path already exists.
      true if path is created.
    • checkListComponents

      boolean checkListComponents(boolean json, List<Component> components, String comment, Object... path)
      Checking for the existence of a path in the localization file. And the serialization of the Component classes list to JSON strings.
      The path is created if it does not exist.
      Parameters:
      json - - If true, then the list of Component classes will be serialized to JSON strings.
      components - - List of Component classes.
      comment - - Comment to path. Not necessary. You can specify null. Not used with JSON configuration.
      path - - Path in the config file.
      Returns:
      false if the path already exists.
      true if path is created.
    • checkString

      boolean checkString(String string, String comment, Object... path)
      Checking for the existence of a path in the localization file. And set String value.
      The path is created if it does not exist.
      Parameters:
      string - - String class
      comment - - Comment to path. Not necessary. You can specify null. Not used with JSON configuration.
      path - - Path in the config file.
      Returns:
      false if the path already exists.
      true if path is created.
    • checkListStrings

      boolean checkListStrings(List<String> strings, String comment, Object... path)
      Checking for the existence of a path in the localization file. And set list of String classes.
      The path is created if it does not exist.
      Parameters:
      strings - - List of String classes
      comment - - Comment to path. Not necessary. You can specify null. Not used with JSON configuration.
      path - - Path in the config file.
      Returns:
      false if the path already exists.
      true if path is created.
    • setLocaleReference

      <T extends LocaleReference> void setLocaleReference(Class<T> reference) throws org.spongepowered.configurate.serialize.SerializationException, org.spongepowered.configurate.ConfigurateException
      Assign a serializable class to this localization.
      If no data has been previously written to this localization, it will be applied from the specified class.
      Type Parameters:
      T - reference - The serializable class extends LocaleReference
      Throws:
      org.spongepowered.configurate.serialize.SerializationException
      org.spongepowered.configurate.ConfigurateException
    • setLocaleReference

      <T extends LocaleReference> void setLocaleReference(T reference) throws org.spongepowered.configurate.serialize.SerializationException, org.spongepowered.configurate.ConfigurateException
      Assign a serializable class to this localization.
      If no data has been previously written to this localization, it will be applied from the specified class.
      This method accepts the created class object and applies all the data written to it, as well as performs saving to disk.
      Type Parameters:
      T - reference - The serializable class extends LocaleReference
      Throws:
      org.spongepowered.configurate.serialize.SerializationException
      org.spongepowered.configurate.ConfigurateException
    • asReference

      <T extends LocaleReference> T asReference(Class<T> clazz)
      Getting the serializable class from the given localization if it was previously assigned.
      Type Parameters:
      T - clazz - The serializable class extends LocaleReference
      Returns:
      Serializable class, or null if no class assignment was previously made.
    • fileExists

      boolean fileExists()
      Checking for the existence of a localization file on disk.