Package sawfowl.localeapi.api
Interface PluginLocale
public interface PluginLocale
-
Method Summary
Modifier and TypeMethodDescription<T extends LocaleReference>
TasReference(Class<T> clazz) Getting the serializable class from the given localization if it was previously assigned.booleancheckComponent(boolean json, Component component, String comment, Object... path) Checking for the existence of a path in the localization file.booleancheckListComponents(boolean json, List<Component> components, String comment, Object... path) Checking for the existence of a path in the localization file.booleancheckListStrings(List<String> strings, String comment, Object... path) Checking for the existence of a path in the localization file.booleancheckString(String string, String comment, Object... path) Checking for the existence of a path in the localization file.booleanChecking for the existence of a localization file on disk.getComponent(Object... path) Getteng deserializedComponentfrom locale configuration node.getListComponents(Object... path) Getting a deserialized list ofComponentclasses from the locale configuration node.getListStrings(Object... path) Getting a list of strings from the locale configuration node.org.spongepowered.configurate.ConfigurationNodegetLocaleNode(Object... path) Getting data from the localization file.org.spongepowered.configurate.ConfigurationNodeGetting data from the localization file.Getting String from locale configuration node.Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEventevent.Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEventevent.voidreload()Reload locale filevoidSaving the localization file.<T extends LocaleReference>
voidsetLocaleReference(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>
voidsetLocaleReference(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
Getting data from the localization file.- Returns:
- ConfigurationNode or CommentedConfigurationNode
-
getComponent
Getteng deserializedComponentfrom locale configuration node.- Parameters:
path- - Path in the config file.- Returns:
Component
-
getListComponents
Getting a deserialized list ofComponentclasses from the locale configuration node.- Parameters:
path- - Path in the config file.- Returns:
- "List<Component>"
-
getText
Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEventevent. -
getTexts
Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEventevent. -
getString
Getting String from locale configuration node.- Parameters:
path- - Path in the config file.- Returns:
- "String"
-
getListStrings
Getting a list of strings from the locale configuration node.- Parameters:
path-- Returns:
-
checkComponent
Checking for the existence of a path in the localization file. And the serialization of theComponentclass to JSON string.
The path is created if it does not exist.- Parameters:
json- - If true, theComponentwill be serialized to a JSON string.component- - Component classcomment- - 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 theComponentclasses list to JSON strings.
The path is created if it does not exist.- Parameters:
json- - If true, then the list ofComponentclasses will be serialized to JSON strings.components- - List ofComponentclasses.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
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 classcomment- - 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
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 classescomment- - 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 extendsLocaleReference- Throws:
org.spongepowered.configurate.serialize.SerializationExceptionorg.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 extendsLocaleReference- Throws:
org.spongepowered.configurate.serialize.SerializationExceptionorg.spongepowered.configurate.ConfigurateException
-
asReference
Getting the serializable class from the given localization if it was previously assigned.- Type Parameters:
T- clazz - The serializable class extendsLocaleReference- 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.
-