commands: Print custom message if there are no headstones
This commit is contained in:
@@ -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");
|
||||
Set<String> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user