LocaleLib 1.2

Show translated item/entity/etc. names in client's language

  1. PikaMug
    Native Minecraft Version:
    1.13
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    Source Code:
    https://github.com/PikaMug/LocaleLib
    Contributors:
    https://github.com/PikaMug/LocaleLib/graphs/contributors
    Languages Supported:
    All of them!
    [​IMG][​IMG]

    From the author of Quests: A new library for developers! When imported, you will be able to send messages to players in which Minecraft will translate Material, EntityType, and Enchantment names into the target client's language. From Afrikaans and Albanian, to Welsh and Yoruba - tearing down the language barrier has never been easier!

    Compatible with Bukkit 1.7.2 and up!
    [​IMG]
    Getting Started

    To use the library, first add LocaleLib jar to your Java build path or add it as a Maven dependency via Jitpack:
    Code (Text):
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    Code (Text):
    <dependency>
        <groupId>com.github.PikaMug</groupId>
        <artifactId>LocaleLib</artifactId>
        <version>1.1</version>
    </dependency>
    Then, add LocaleLib as a dependency (or soft-dependency, if you can live without it) to your plugin.yml file:
    Code (YAML):
    depend: [LocaleLib]
    Next, you'll need a reference to LocaleManager. Just add the following in your onEnable() method:
    Code (Java):
    private LocaleManager localeManager;

    @Override
    public void onEnable() {
       localeManager = LocaleLib.getLocaleManager();
    }
    Lastly, you'll want to decide which message command to use (but first, get your player - here's one way to do it):
    Code (Java):
    org.bukkit.entity.Player p = Bukkit.getPlayer("PikaMug");
    Translate Items

    To send the message "I make Dirt look good", do the following:
    Code (Java):
    localeManager.sendMessage(p, "I make "
            + ChatColor.GREEN + "<item>" + ChatColor.RESET
            +" look good", Material.DIRT, (short) 0, null);
    In Enligsh (US), this will appear as...

    [​IMG]

    ...but if the player is using Español (México), it will appear as...

    [​IMG]

    Let's say you want Podzod instead of Dirt. On Minecraft 1.13 or above, do this:
    Code (Java):
    if (localeManager.isBelow113()) {
        localeManager.sendMessage(p, "I make <item> look good", Material.DIRT, (short) 1, null);
    } else {
        localeManager.sendMessage(p, "I make <item> look good", Material.PODZOL, (short) 0, null);
    }
    Note the durability value of '1' for older versions of Minecraft, rather than '0' for newer ones.

    For an item with enchantments, like "A Diamond Sword with Impaling V", try this:
    Code (Java):
    Map<Enchantment, Integer> ench = new LinkedHashMap<Enchantment, Integer>();
            ench.put(Enchantment.IMPALING, 5);
            localeManager.sendMessage(p, "A <item> with <enchantment> V", Material.DIAMOND_SWORD, (short) 0, ench);
    Note that levels do not automatically appear in the message at this time, but this may be added in a future release.

    Translate Enchantments

    To send the message "Enchant Silk Touch I and Luck III"
    Code (Java):
    Map<Enchantment, Integer> enchs = new LinkedHashMap<Enchantment, Integer>();
            enchs.put(Enchantment.SILK_TOUCH, 1);
            enchs.put(Enchantment.LUCK, 3);
            localeManager.sendMessage(p, "Enchant <enchantment> I and <enchantment> III", enchs);
    Note that levels do not automatically appear in the message at this time, but this may be added in a future release.

    Translate Mobs

    To send the message "Pig is best mob?"
    Code (Java):
    localeManager.sendMessage(p, "<mob> is best mob?", EntityType.PIG, null);
    Or, to send the message "The Killer Bunny strikes again!"
    Code (Java):
    localeManager.sendMessage(p, "<mob> strikes again!", EntityType.RABBIT, Rabbit.Type.THE_KILLER_BUNNY);

    [​IMG] [​IMG] [​IMG]

Recent Updates

  1. Correct key for Enderman
  2. Slight improvements