commands: Add headstone list subcommand
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user