Ritual info command

This commit is contained in:
Edith Boles 2021-10-01 21:00:39 -07:00
parent eb8b70a6f1
commit f953099c23

View File

@ -3,12 +3,17 @@ package top.penowl.quidproquo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class Commands implements CommandExecutor {
@ -37,14 +42,39 @@ public class Commands implements CommandExecutor {
StringBuilder builder = new StringBuilder();
builder.append(ChatColor.DARK_PURPLE + "======== Rituals ======== " + ChatColor.YELLOW + "Page " + String.valueOf(page + 1) + " / " + String.valueOf(maxPages + 1));
builder.append("\n" + ChatColor.GREEN);
for (int i = page * 9; i < Math.min(page * 9 + 9, max + 1); i++) {
for (int i = page * 9; i < page * 9 + 9; i++) {
if (i > max) {
builder.append(" \n");
continue;
}
builder.append(ritualNames.get(i));
builder.append("\n" + ChatColor.GREEN);
}
sender.sendMessage(builder.toString());
return true;
} else if (recipes.containsKey(args[0].toUpperCase())) {
// display recipe info
} else if (recipes.containsKey(String.join(" ", args).toLowerCase())) {
String key = String.join(" ", args).toLowerCase();
StringBuilder builder = new StringBuilder();
Ritual ritual = recipes.get(key);
builder.append("\n");
builder.append(ChatColor.DARK_RED + "======== " + ChatColor.YELLOW + WordUtils.capitalizeFully(key) + " Ritual" + ChatColor.DARK_RED + " ========\n ");
builder.append("\n" + ChatColor.GREEN + "" + ChatColor.BOLD + "Ingredients:\n");
for (Map.Entry<Material, Integer> entry : ritual.ingredients.entrySet()) {
builder.append(ChatColor.GOLD);
builder.append(WordUtils.capitalizeFully(entry.getKey().toString().replace('_', ' ').toLowerCase()));
builder.append(": " + ChatColor.AQUA + entry.getValue().toString());
builder.append("\n");
}
builder.append(" \n" + ChatColor.RED + "" + ChatColor.BOLD + "Sacrifices:\n");
for (Map.Entry<EntityType, Integer> entry : ritual.sacrifices.entrySet()) {
builder.append(ChatColor.GOLD);
builder.append(WordUtils.capitalizeFully(entry.getKey().toString().replace('_', ' ').toLowerCase()));
builder.append(": " + ChatColor.AQUA + entry.getValue().toString());
builder.append("\n");
}
builder.append(" \n" + ChatColor.AQUA + "" + ChatColor.BOLD + "Blood: " + ChatColor.RESET + "" + ChatColor.AQUA + String.valueOf(ritual.health / 2.0) + ChatColor.RED + "\n");
builder.append(ChatColor.GOLD + "" + ChatColor.BOLD + "Backfire: " + ChatColor.RESET + "" + ChatColor.AQUA + String.valueOf(Math.round(ritual.backfire * 100)) + ChatColor.GREEN + "%\n");
sender.sendMessage(builder.toString());
return true;
}
return false;