Sort available enchantments alphabetically

This commit is contained in:
Pim van der Loos 2022-05-04 12:03:28 +02:00
parent 2af028a074
commit 93a290cea6
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8

View File

@ -141,11 +141,14 @@ public class CommandHandler implements CommandExecutor
BY_KEY_FIELD.setAccessible(true);
}
@SuppressWarnings("unchecked")
final Map<NamespacedKey, Enchantment> byKey = (Map<NamespacedKey, Enchantment>) BY_KEY_FIELD.get(null);
StringBuilder sb = new StringBuilder("\nAvailable enchantments: \n");
for (NamespacedKey key : byKey.keySet())
sb.append(" - ").append(key.toString()).append("\n");
final StringBuilder sb = new StringBuilder("\nAvailable enchantments: \n");
byKey.keySet().stream()
.map(NamespacedKey::toString).sorted()
.forEach(name -> sb.append(" - ").append(name).append("\n"));
Bukkit.getLogger().info(sb.toString());
}
catch (NoSuchFieldException | IllegalAccessException e)