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.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.getComponent
(Object... path) Getteng deserializedComponent
from locale configuration node.getListComponents
(Object... path) Getting a deserialized list ofComponent
classes from the locale configuration node.getListStrings
(Object... path) Getting a list of strings from the locale configuration node.org.spongepowered.configurate.ConfigurationNode
getLocaleNode
(Object... path) Getting data from the localization file.org.spongepowered.configurate.ConfigurationNode
Getting 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 theRegisterBuilderEvent
event.Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEvent
event.void
reload()
Reload locale filevoid
Saving 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 deserializedComponent
from locale configuration node.- Parameters:
path
- - Path in the config file.- Returns:
Component
-
getListComponents
Getting a deserialized list ofComponent
classes 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 theRegisterBuilderEvent
event. -
getTexts
Getting deserialized text in the constructor for its further modification.
The operation is possible only after the constructor is registered in theRegisterBuilderEvent
event. -
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 theComponent
class to JSON string.
The path is created if it does not exist.- Parameters:
json
- - If true, theComponent
will 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 theComponent
classes list to JSON strings.
The path is created if it does not exist.- Parameters:
json
- - If true, then the list ofComponent
classes will be serialized to JSON strings.components
- - List ofComponent
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
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.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 extendsLocaleReference
- Throws:
org.spongepowered.configurate.serialize.SerializationException
org.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.
-