LangUtils icon

LangUtils -----

Item - Enchant - Entity - Potion - Biome - More - Name - Translation



Language Utils

A Bukkit/Spigot API to get the localized names of vanilla items, entitys, enchantments, biomes, potions, etc.

This project comes from MascusJeoraly.

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: LanguageUtils

Features
  • 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.

Install
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.

Configuration
This is an example:
Code (YAML):
# 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]
# Or
LoadLanguage
:
  - ja_jp
  - ko_kr
  - ru_ru
  - zh_cn
  - zh_tw
# If you want to load all the languages, add "all" to the list:
# - all
Use LangUtils in your plugin

1. Declaring repositories and dependencies to your build tools

Build with Gradle:
Add a repository and a dependency to your build.gradle:
Code (Text):
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 your pom.xml:
Code (Text):
<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>

2. Add plugin dependencies to your plugin.yml

If your plugin must depend on LangUtils to run, add this line to your plugin.yml:
Code (YAML):
depend : [ ..., LangUtils ]
Where ' ... ' are other plugins.

If your plugin does not depend on LangUtils, it can also run, add this line to your plugin.yml:
Code (YAML):
softdepend : [ ..., LangUtils ]
Where ' ... ' are other plugins.

3. 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:
Code (Java):
package com.exampleplugin.hooks ;

import com.meowj.langutils.lang.LanguageHelper ;
import org.bukkit.entity.Entity ;
import org.bukkit.inventory.ItemStack ;
import org.bukkit.plugin.Plugin ;

public class LangUtilsHook {

    private static boolean hooked ;

    public static void init ( ) {
        Plugin plugin = Bukkit. getPluginManager ( ). getPlugin ( "LangUtils" ) ;
        hooked = plugin != null && plugin. isEnabled ( ) ;
    }

    public static String getItemName (ItemStack itemStack, String locale ) {
        if (hooked ) {
            return LanguageHelper. getItemName (itemStack, locale ) ;
        }
        return itemStack. getType ( ). name ( ) ;
    }

    public static String getEntityName ( Entity entity, String locale ) {
        if (hooked ) {
            return LanguageHelper. getEntityName (entity, locale ) ;
        }
        return entity. getName ( ) ;
    }

    // Add another method...
}

Then initialize the hook when your plugin starts:
Code (Java):
package com.exampleplugin ;

import org.bukkit.plugin.java.JavaPlugin ;

public class MyPlugin extends JavaPlugin {

    @Override
    public void onEnable ( ) {
        // Initialize LangUtilsHook
        LangUtilsHook. init ( ) ;
    }

}

Call the hook where needed:
Code (Java):
ItemStack item = new ItemStack (Material. STONE ) ;
// Call LangUtilsHook to get the name of the item.
String name = LangUtilsHook. getItemName (item, "zh_cn" ) ;

Contribute to this Project

If you find any problems or want to improve the efficiency, please send me Pull requests or Issues.
Resource Information
Author:
----------
Total Downloads: 1,661
First Release: Mar 11, 2021
Last Update: Jul 4, 2021
Category: ---------------
All-Time Rating:
1 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings