From f953099c23ac55d274e1dbaeade57382429aadc3 Mon Sep 17 00:00:00 2001 From: Edith Boles Date: Fri, 1 Oct 2021 21:00:39 -0700 Subject: [PATCH 1/2] Ritual info command --- .../java/top/penowl/quidproquo/Commands.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/top/penowl/quidproquo/Commands.java b/src/main/java/top/penowl/quidproquo/Commands.java index 04dbd93..f40aad3 100644 --- a/src/main/java/top/penowl/quidproquo/Commands.java +++ b/src/main/java/top/penowl/quidproquo/Commands.java @@ -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 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 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; From 1fd4616cca5bb0d13e69dc3d15719c432a344909 Mon Sep 17 00:00:00 2001 From: Edith Boles Date: Fri, 1 Oct 2021 21:02:50 -0700 Subject: [PATCH 2/2] Change colors --- src/main/java/top/penowl/quidproquo/Commands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/top/penowl/quidproquo/Commands.java b/src/main/java/top/penowl/quidproquo/Commands.java index f40aad3..e9855fe 100644 --- a/src/main/java/top/penowl/quidproquo/Commands.java +++ b/src/main/java/top/penowl/quidproquo/Commands.java @@ -72,7 +72,7 @@ public class Commands implements CommandExecutor { 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(" \n" + ChatColor.GOLD + "" + 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;