Fix behavior of itemdb command on legacy versions (#4320)

This commit is contained in:
triagonal 2021-07-06 14:29:24 +10:00 committed by GitHub
parent 8c8c85d753
commit 33ca3b2981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -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);
}

View File

@ -44,9 +44,11 @@ public class CustomItemResolver implements IItemDb.ItemResolver, IConf {
public List<String> getAliasesFor(String item) throws Exception {
final List<String> results = new ArrayList<>();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (item.equalsIgnoreCase(ess.getItemDb().name(ess.getItemDb().get(entry.getValue())))) {
results.add(entry.getKey());
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;

View File

@ -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

1 #version: ${full.version}
7490 shiningmelon,382,0
7491 gmelon,382,0
7492 smelon,382,0
7493 mobegg,383,0
7494 spawnegg,383,0
7495 mobspawnegg,383,0
7496 creeperegg,383,50
7497 eggcreeper,383,50
7498 skeletonegg,383,51