diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemdb.java index 45a2f55bc..7f75b0beb 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemdb.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commanditemdb.java @@ -1,6 +1,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.CommandSource; +import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.VersionUtil; import org.bukkit.Material; import org.bukkit.Server; @@ -52,10 +53,16 @@ public class Commanditemdb extends EssentialsCommand { sender.sendMessage(tl("durability", Integer.toString(durability))); } } - final String itemNameList = ess.getItemDb().names(itemStack); - if (itemNameList != null) { - sender.sendMessage(tl("itemNames", ess.getItemDb().names(itemStack))); + + List nameList = ess.getItemDb().nameList(itemStack); + nameList.addAll(ess.getCustomItemResolver().getAliasesFor(ess.getItemDb().name(itemStack))); + Collections.sort(nameList); + + if (nameList.size() > 15) { + nameList = nameList.subList(0, 14); } + final String itemNameList = StringUtil.joinList(", ", nameList); + sender.sendMessage(tl("itemNames", itemNameList)); } @Override diff --git a/Essentials/src/main/java/com/earth2me/essentials/items/CustomItemResolver.java b/Essentials/src/main/java/com/earth2me/essentials/items/CustomItemResolver.java index b0c043b0a..18fbdfb05 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/items/CustomItemResolver.java +++ b/Essentials/src/main/java/com/earth2me/essentials/items/CustomItemResolver.java @@ -8,8 +8,11 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; import java.io.File; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; +import java.util.Map; public class CustomItemResolver implements IItemDb.ItemResolver, IConf { private final EssentialsConf config; @@ -39,6 +42,16 @@ public class CustomItemResolver implements IItemDb.ItemResolver, IConf { return map.keySet(); } + public List getAliasesFor(String item) throws Exception { + final List results = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (item.equalsIgnoreCase(ess.getItemDb().name(ess.getItemDb().get(entry.getValue())))) { + results.add(entry.getKey()); + } + } + return results; + } + @Override public void reloadConfig() { map.clear();