Fix NPE in key configuration, fixed tab completion

Added missing key mapping to prevent NullPointerException when no UUIDs are present in KeyStorage. Also adjusted tab completion logic in Key.java to handle cases with more than one argument.
This commit is contained in:
auto committed 2024-10-04 21:19:53 +02:00
1 parent ad9a3491eb
commit d43f269c22
2 files changed
+4

No files matched your search

@@ -74,6 +74,9 @@ public class Key extends SubCommand {
@Override @Override
public List<String> getTabComplete(CommandSender commandSender, String[] args) { public List<String> getTabComplete(CommandSender commandSender, String[] args) {
if (args.length > 1) {
return List.of();
}
return Config.KEY.CRATES.keySet().stream().toList(); return Config.KEY.CRATES.keySet().stream().toList();
} }
@@ -49,6 +49,7 @@ public class KeyStorage extends AbstractConfig {
List<UUID> uuids = configurationSection.getKeys(false).stream().map(UUID::fromString).toList(); List<UUID> uuids = configurationSection.getKeys(false).stream().map(UUID::fromString).toList();
if (uuids.isEmpty()) { if (uuids.isEmpty()) {
config.logger.info(String.format("No keys yet for crate %s", crate)); config.logger.info(String.format("No keys yet for crate %s", crate));
KEYS.put(crate, count);
continue; continue;
} }
for (UUID uuid : uuids) { for (UUID uuid : uuids) {