mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Fix behavior of itemdb command on legacy versions (#4320)
This commit is contained in:
parent
8c8c85d753
commit
33ca3b2981
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -55,9 +56,13 @@ public class Commanditemdb extends EssentialsCommand {
|
||||
}
|
||||
|
||||
List<String> nameList = ess.getItemDb().nameList(itemStack);
|
||||
nameList = nameList != null ? new ArrayList<>(nameList) : new ArrayList<>();
|
||||
nameList.addAll(ess.getCustomItemResolver().getAliasesFor(ess.getItemDb().name(itemStack)));
|
||||
Collections.sort(nameList);
|
||||
if (nameList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collections.sort(nameList);
|
||||
if (nameList.size() > 15) {
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
|
@ -44,11 +44,13 @@ public class CustomItemResolver implements IItemDb.ItemResolver, IConf {
|
||||
|
||||
public List<String> getAliasesFor(String item) throws Exception {
|
||||
final List<String> results = new ArrayList<>();
|
||||
if (item != null) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
if (item.equalsIgnoreCase(ess.getItemDb().name(ess.getItemDb().get(entry.getValue())))) {
|
||||
results.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -7490,6 +7490,9 @@ sparklymelon,382,0
|
||||
shiningmelon,382,0
|
||||
gmelon,382,0
|
||||
smelon,382,0
|
||||
mobegg,383,0
|
||||
spawnegg,383,0
|
||||
mobspawnegg,383,0
|
||||
creeperegg,383,50
|
||||
eggcreeper,383,50
|
||||
skeletonegg,383,51
|
||||
|
|
Loading…
Reference in New Issue
Block a user