diff --git a/src/main/java/tk/alex3025/headstones/Headstones.java b/src/main/java/tk/alex3025/headstones/Headstones.java index 73dbb71..d85e13a 100644 --- a/src/main/java/tk/alex3025/headstones/Headstones.java +++ b/src/main/java/tk/alex3025/headstones/Headstones.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import tk.alex3025.headstones.commands.HeadstonesCommand; import tk.alex3025.headstones.commands.subcommands.ClearDatabaseCommand; +import tk.alex3025.headstones.commands.subcommands.ListHeadstonesCommand; import tk.alex3025.headstones.commands.subcommands.ReloadConfigCommand; import tk.alex3025.headstones.listeners.BlockBreakListener; import tk.alex3025.headstones.listeners.PlayerDeathListener; @@ -50,6 +51,7 @@ public final class Headstones extends JavaPlugin { // Subcommands new ClearDatabaseCommand(); new ReloadConfigCommand(); + new ListHeadstonesCommand(); } public static Headstones getInstance() { diff --git a/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java b/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java new file mode 100644 index 0000000..34527c3 --- /dev/null +++ b/src/main/java/tk/alex3025/headstones/commands/subcommands/ListHeadstonesCommand.java @@ -0,0 +1,31 @@ +package tk.alex3025.headstones.commands.subcommands; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.ConfigurationSection; +import tk.alex3025.headstones.Headstones; +import tk.alex3025.headstones.utils.ConfigFile; +import tk.alex3025.headstones.utils.Message; + +import java.util.UUID; + +public class ListHeadstonesCommand extends SubcommandBase { + public ListHeadstonesCommand() { + super("list", "headstones.list", false); + } + + @Override + 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") + "\")"); + }); + + return true; + } +}