API methods
You can access our API by SlimefunTranslationAPI
class.
(net.guizhanss.slimefuntranslation.api.SlimefunTranslationAPI
)
Avoid accessing other classes/methods directly, as they are subject to change.
Methods
Get the User
A User
represents an online player, it stores the player's language and some other information.
SlimefunTranslationAPI.getUser(UUID uuid)
SlimefunTranslationAPI.getUser(Player player)
The method returns a User
object (Reference) to pass to other API methods.
User user = SlimefunTranslationAPI.getUser(player);
Get translated item name
SlimefunTranslationAPI.getItemName(User user, String id)
SlimefunTranslationAPI.getItemName(User user, @Nullable SlimefunItem sfItem)
The method returns a String
that is the translated name of the item for the given User
.
If the item is invalid (sfItem
is null
, or id
is not a valid item id), the method returns an empty string.
If there is no available translation for the item, the default item name is returned.
Translate an item
SlimefunTranslationAPI.translateItem(User user, ItemStack item)
The method translates the item for the given User
. It returns a boolean value representing whether the translation is applied to the item. Check out "How do translations work?" page for more information.
This method modifies the provided ItemStack
. Pass a copy of item if you want to keep the original item unchanged.
Get the lore
SlimefunTranslationAPI.getLore(User user, String id, boolean defaultToId)
The method returns the lore line String
by given id. (Reference)
Get the MessageFactory
The MessageFactory
provides methods to send translated messages to the player.
SlimefunTranslationAPI.getMessageFactory(Plugin plugin)