A Bukkit/Spigot API to get the localized names of vanilla items, entitys, enchantments, biomes, potions, etc.
This project comes from MascusJeoraly:LanguageUtils.
Now, it has been completely refactored, improved performance, can support more vanilla object name translations, is compatible with the previous LangUtils, and a copy can support all Minecraft versions above 1.13 at the same time.
Tip: If you want to use it on a server of 1.12.2 and below, please go to the original project: MascusJeoraly:LanguageUtils
- Get localized name of Items and Materials.
- Get localized name of Biomes.
- Get localized name of Entitys.
- Get localized name of Enchantments.
- Get localized name of Potions, Potion Effects, and Tipped Arrows.
- Get Tropical Fish Type(Pattern) names and Predefined Tropical Fish names.
- Get localized name of Dye Colors.
- Get localized name of Villagers’ Level and Professions.
- Get localized name of Banner Patterns and Colored Shields.
- Get the description of the Music-Disk and the new Banner-Pattern in 1.14 and above.
- 1.13, 1.14, 1.15, 1.16, 1.17
Please go to Releases to download the latest version, put it in your server 'plugins' directory, and restart your server. Please delete all old LangUtils plugins before this.
This is an example:
# Please do not remove this.Extra-TAG: tag_r72EhIAL# When a name in the language requested does not exist, the name will be# retrieved in this language. The default fall back language is English.FallbackLanguage: en_us# If you want to enable the loading of a language, add it to the following list# LoadLanguage: [ja_jp, ko_kr, ru_ru, zh_cn, zh_tw]# OrLoadLanguage:
- ja_jp
- ko_kr
- ru_ru
- zh_cn
- zh_tw# If you want to load all the languages, add "all" to the list:# - all- Declaring repositories and dependencies to your build tools
- Build with Gradle
Add a repository and a dependency to yourbuild.gradle:repositories { maven { url 'https://jitpack.io' } } dependencies { // Please check the latest version provided group: 'com.github.apachezy', name: 'LangUtils', version: '3.2.1' } - Build with Maven
Add a repository and a dependency to yourpom.xml:<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories> <dependencies> <!-- LangUtils --> <dependency> <groupId>com.github.apachezy</groupId> <artifactId>LangUtils</artifactId> <!--Please check the latest version --> <version>3.2.1</version> <scope>provided</scope> </dependency> </dependencies>
- Add plugin dependencies to your plugin.yml
- If your plugin must depend on LangUtils to run:
Add this line to yourplugin.yml:depend: [..., LangUtils]
Where...are other plugins. - If your plugin does not depend on LangUtils, it can also run:
Add this line to yourplugin.yml:softdepend: [..., LangUtils]
Where...are other plugins.
- Use LangUtils
- The best usage is to create a hook for LangUtils:
The hook may be static class, or be singleton, or be a parameterized instance, as you like.
The following is an example of a hook using a static class:packagecom.exampleplugin.hooks; importcom.meowj.langutils.lang.LanguageHelper; importorg.bukkit.entity.Entity; importorg.bukkit.inventory.ItemStack; importorg.bukkit.plugin.Plugin; publicclassLangUtilsHook { privatestaticbooleanhooked; publicstaticvoidinit() { Pluginplugin = Bukkit.getPluginManager().getPlugin("LangUtils"); hooked = plugin != null && plugin.isEnabled(); } publicstaticStringgetItemName(ItemStackitemStack, Stringlocale) { if (hooked) { returnLanguageHelper.getItemName(itemStack, locale); } returnitemStack.getType().name(); } publicstaticStringgetEntityName(Entityentity, Stringlocale) { if (hooked) { returnLanguageHelper.getEntityName(entity, locale); } returnentity.getName(); } // Add another method... }
- Then initialize the hook when your plugin starts:
packagecom.exampleplugin; importcom.exampleplugin.hooks; importorg.bukkit.plugin.java.JavaPlugin; publicclassMyPluginextendsJavaPlugin { @OverridepublicvoidonEnable() { // Initialize LangUtilsHookLangUtilsHook.init(); } }
- Call the hook where needed:
ItemStackitem = newItemStack(Material.STONE); // Call LangUtilsHook to get the name of the item.Stringname = LangUtilsHook.getItemName(item, "zh_cn");
If you find any problems or want to improve the efficiency, please send me PR or issues.