What is PlayerLangAPI ?
PlayerLangAPI is a library allowing developers to use client-side translations through the use of translation keys(block.minecraft.stone is the identifier of the stone).
For example, we can give a diamond sword with the name ItemStack "stone". Thus, when the player's client language is set to "English", the player will not see the same name if the game language is set to a different language (or if he uses a resourcepack).
Why use this library?
Usually several plugins use stored object names without taking into account the client's translation or the object name is fixed and if the client changes language, he will always see the old name.
This plugin in the form of a library gives you the possibility to use the languages used by the client. However, you will have to master the "TranslatableComponent" (see https://www.spigotmc.org/wiki/the-chat-component-api/#basics )
How use it ?
Maven repository
Maven dependency
Plugins folder
Place the plugin (.jar) in "./plugins/" folder
Usage
First example :
If you want to send the name of the stone sword according to the player's language :
Second example :
A translatable component into a sentence :
Third example :
Retrieve a class from the API (EnchantmentLang -> Enchantment, MaterialLang -> Material) :
Final example :
Add a translatable display name on a ItemStack (requires NBTAPI ) :
(You can see result with images which are uploaded)
NOTE : When I started to create the plugin, I hadn't noticed that there was a plugin similar to this one but that only supports 1.7-1.12 versions. ( https://www.spigotmc.org/resources/1-7-x-1-12-language-utils.8859/ )
If you have any suggestions, don't hesitate to tell me!
PlayerLangAPI is a library allowing developers to use client-side translations through the use of translation keys(block.minecraft.stone is the identifier of the stone).
For example, we can give a diamond sword with the name ItemStack "stone". Thus, when the player's client language is set to "English", the player will not see the same name if the game language is set to a different language (or if he uses a resourcepack).
This plugin is compatible with 1.13+ versions (until Mojang changes languages format) Why use this library?
Usually several plugins use stored object names without taking into account the client's translation or the object name is fixed and if the client changes language, he will always see the old name.
This plugin in the form of a library gives you the possibility to use the languages used by the client. However, you will have to master the "TranslatableComponent" (see https://www.spigotmc.org/wiki/the-chat-component-api/#basics )
How use it ?
Maven repository
Code (Text):
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Maven dependency
Code (Text):
<dependency>
<groupId>com.github.Yovach</groupId>
<artifactId>PlayerLangAPI</artifactId>
<version>0.4</version>
</dependency>
<groupId>com.github.Yovach</groupId>
<artifactId>PlayerLangAPI</artifactId>
<version>0.4</version>
</dependency>
Plugins folder
Place the plugin (.jar) in "./plugins/" folder
Usage
First example :
If you want to send the name of the stone sword according to the player's language :
Spoiler: FIRST EXAMPLE
This will send "Stone sword" for a player whose language of play is English and "Espada de piedre" for a Spanish player.
Code (Java):
final TranslatableComponent component
=
new TranslatableComponent
( MaterialLang.
STONE_SWORD .
getTranslation
(
)
)
;
player. sendMessage ( component ) ;
player. sendMessage ( component ) ;
Second example :
A translatable component into a sentence :
Spoiler: SECOND EXAMPLE
Code (Text):
/* Our text component (a sentence for example) */
final TextComponent text = new TextComponent("Please use your ");
/* Our component which will be translated by client */
final TranslatableComponent translatableDiamond = new TranslatableComponent(MaterialLang.DIAMOND.getTranslation());
text.addExtra(translatableDiamond);
/* We can put a color on the translated component :) */
translatableDiamond.setColor(net.md_5.bungee.api.ChatColor.GOLD);
player.sendMessage(text);
final TextComponent text = new TextComponent("Please use your ");
/* Our component which will be translated by client */
final TranslatableComponent translatableDiamond = new TranslatableComponent(MaterialLang.DIAMOND.getTranslation());
text.addExtra(translatableDiamond);
/* We can put a color on the translated component :) */
translatableDiamond.setColor(net.md_5.bungee.api.ChatColor.GOLD);
player.sendMessage(text);
Third example :
Retrieve a class from the API (EnchantmentLang -> Enchantment, MaterialLang -> Material) :
Spoiler: THIRD EXAMPLE
Code (Text):
final Enchantment enchantment = EnchantmentLang.DAMAGE_ALL.get();
final Material material = MaterialLang.DIAMOND.get();
final Material material = MaterialLang.DIAMOND.get();
Final example :
Add a translatable display name on a ItemStack (requires NBTAPI ) :
Spoiler: FINAL EXAMPLE
// We check if the PlayerLangAPI is enabled on the server
if(Bukkit.getPluginManager().isPluginEnabled("PlayerLangAPI")) {
// Get the instance of plugin
final PlayerLangAPI langAPI = (PlayerLangAPI) Bukkit.getPluginManager().getPlugin("PlayerLangAPI");
Validate.notNull(langAPI, "PlayerLangAPI is disabled!");
// We check if NBTAPI plugin is enabled on the server.
if(langAPI.hasNBTAPI()) {
/* Creation of a new ItemStack */
final ItemStack itemStack = new ItemStack(MaterialLang.DIAMOND.get());
/* We put properties of display */
final JsonObject gson = new JsonObject();
gson.addProperty("translate", MaterialLang.STONE_SWORD.getTranslation());
gson.addProperty("color", "red");
gson.addProperty("italic", "false");
/* We finally add itemstack into inventory of player */
player.getInventory().addItem(langAPI.setDisplay(itemStack, gson));
}
}
Code (Text):
// We check if the PlayerLangAPI is enabled on the server
if(Bukkit.getPluginManager().isPluginEnabled("PlayerLangAPI")) {
// Get the instance of plugin
final PlayerLangAPI langAPI = (PlayerLangAPI) Bukkit.getPluginManager().getPlugin("PlayerLangAPI");
Validate.notNull(langAPI, "PlayerLangAPI is disabled!");
// We check if NBTAPI plugin is enabled on the server.
if(langAPI.hasNBTAPI()) {
/* Creation of a new ItemStack */
final ItemStack itemStack = new ItemStack(MaterialLang.DIAMOND.get());
/* We put properties of display */
final JsonObject gson = new JsonObject();
gson.addProperty("translate", MaterialLang.STONE_SWORD.getTranslation());
gson.addProperty("color", "red");
gson.addProperty("italic", "false");
/* We finally add itemstack into inventory of player */
player.getInventory().addItem(langAPI.setDisplay(itemStack, gson));
}
}
(You can see result with images which are uploaded)
NOTE : When I started to create the plugin, I hadn't noticed that there was a plugin similar to this one but that only supports 1.7-1.12 versions. ( https://www.spigotmc.org/resources/1-7-x-1-12-language-utils.8859/ )
If you have any suggestions, don't hesitate to tell me!
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.13, 1.14, 1.15
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
PlayerLangAPI | Simple translation identifiers [1.13+] is a free Minecraft Java mod. Compatible with Minecraft 1.13, 1.14, 1.15. Downloaded 280 times (via Spigot). Download it and open it directly in the game.