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.ConfigFile;
|
||||||
import tk.alex3025.headstones.utils.Message;
|
import tk.alex3025.headstones.utils.Message;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ListHeadstonesCommand extends SubcommandBase {
|
public class ListHeadstonesCommand extends SubcommandBase {
|
||||||
@@ -19,12 +20,17 @@ public class ListHeadstonesCommand extends SubcommandBase {
|
|||||||
public boolean onCommand(CommandSender sender, String[] args) {
|
public boolean onCommand(CommandSender sender, String[] args) {
|
||||||
ConfigFile config = Headstones.getInstance().getDatabase();
|
ConfigFile config = Headstones.getInstance().getDatabase();
|
||||||
ConfigurationSection headstones = config.getConfigurationSection("headstones");
|
ConfigurationSection headstones = config.getConfigurationSection("headstones");
|
||||||
Message.sendPrefixedMessage(sender, "&a All headstones:");
|
Set<String> keys = headstones.getKeys(false);
|
||||||
headstones.getKeys(false).forEach(headstoneUUID -> {
|
if (keys.isEmpty()) {
|
||||||
ConfigurationSection headstone = headstones.getConfigurationSection(headstoneUUID);
|
Message.sendPrefixedMessage(sender, "&a There are no headstones.");
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(headstone.getString("owner")));
|
} else {
|
||||||
Message.sendMessage(sender, "&a " + player.getName() + ": " + headstone.getInt("x") + " " + headstone.getInt("y") + " " + headstone.getInt("z") + " (in world \"" + headstone.getString("world") + "\")");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user