Skip to content

Translate item (Material)

PikaMug edited this page Dec 7, 2021 · 6 revisions

To send the message "I make Dirt look good", do the following where p is the Player:

localeManager.sendMessage(p, "I make " + ChatColor.GREEN + "<item>" + ChatColor.RESET + " look good",
    Material.DIRT, (short) 0, null);

In English (US), this will appear as...

I make Dirt look good

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

I make Tierra look good

Let's say you want Podzol instead of Dirt. Give this a try:

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.

With enchantments

For an item with enchantments, like "A Diamond Sword with Impaling V", try this:

Map<Enchantment, Integer> ench = new LinkedHashMap<Enchantment, Integer>();
        ench.put(Enchantment.IMPALING, 5);
localeManager.sendMessage(p, "A <item> with <enchantment> <level>", Material.DIAMOND_SWORD, (short) 0, ench);
Clone this wiki locally