diff --git a/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java b/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java index 34527c3..546b26a 100644 --- a/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java +++ b/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java @@ -8,6 +8,7 @@ import tk.alex3025.headstones.Headstones; import tk.alex3025.headstones.utils.ConfigFile; import tk.alex3025.headstones.utils.Message; +import java.util.Set; import java.util.UUID; public class ListHeadstonesCommand extends SubcommandBase { @@ -19,12 +20,17 @@ public class ListHeadstonesCommand extends SubcommandBase { public boolean onCommand(CommandSender sender, String[] args) { ConfigFile config = Headstones.getInstance().getDatabase(); ConfigurationSection headstones = config.getConfigurationSection("headstones"); - Message.sendPrefixedMessage(sender, "&a All headstones:"); - headstones.getKeys(false).forEach(headstoneUUID -> { - ConfigurationSection headstone = headstones.getConfigurationSection(headstoneUUID); - OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(headstone.getString("owner"))); - Message.sendMessage(sender, "&a " + player.getName() + ": " + headstone.getInt("x") + " " + headstone.getInt("y") + " " + headstone.getInt("z") + " (in world \"" + headstone.getString("world") + "\")"); - }); + Set keys = headstones.getKeys(false); + if (keys.isEmpty()) { + Message.sendPrefixedMessage(sender, "&a There are no headstones."); + } else { + Message.sendPrefixedMessage(sender, "&a All headstones:"); + headstones.getKeys(false).forEach(headstoneUUID -> { + ConfigurationSection headstone = headstones.getConfigurationSection(headstoneUUID); + OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(headstone.getString("owner"))); + Message.sendMessage(sender, "&a " + player.getName() + ": " + headstone.getInt("x") + " " + headstone.getInt("y") + " " + headstone.getInt("z") + " (in world \"" + headstone.getString("world") + "\")"); + }); + } return true; }