diff --git a/src/main/java/top/penowl/quidproquo/Commands.java b/src/main/java/top/penowl/quidproquo/Commands.java index a355c08..7f1b044 100644 --- a/src/main/java/top/penowl/quidproquo/Commands.java +++ b/src/main/java/top/penowl/quidproquo/Commands.java @@ -13,6 +13,14 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.dom4j.Text; + +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; public class Commands implements CommandExecutor { @@ -39,18 +47,40 @@ public class Commands implements CommandExecutor { page = Math.min(Math.max(Integer.parseInt(args[1]) - 1, 0), maxPages); } catch(Exception e) { } - 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); + ComponentBuilder builder = new ComponentBuilder(""); + builder.append(ChatColor.DARK_PURPLE + "======== Rituals ======== "); + if (page != 0) { + builder.append(" < "); + builder.color(net.md_5.bungee.api.ChatColor.YELLOW); + builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rt list " + String.valueOf(page))); + } else { + builder.append(" < "); + builder.color(net.md_5.bungee.api.ChatColor.GRAY); + } + builder.append("Page " + String.valueOf(page + 1) + " / " + String.valueOf(maxPages + 1) + " "); + builder.color(net.md_5.bungee.api.ChatColor.AQUA); + if (page != maxPages) { + builder.append(" > "); + builder.color(net.md_5.bungee.api.ChatColor.YELLOW); + builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rt list " + String.valueOf(page + 2))); + } else { + builder.append(" > "); + builder.color(net.md_5.bungee.api.ChatColor.GRAY); + } 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); + builder.append("\n" + ritualNames.get(i)); + builder.color(net.md_5.bungee.api.ChatColor.GREEN); + builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ritual " + ritualNames.get(i))); + builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.YELLOW + "Click to see more...").create())); + } + if (sender instanceof Player) { + Player playerSender = (Player) sender; + playerSender.spigot().sendMessage(builder.create()); } - sender.sendMessage(builder.toString()); return true; } else if (recipes.containsKey(String.join(" ", args).toLowerCase())) { String key = String.join(" ", args).toLowerCase(); diff --git a/src/main/java/top/penowl/quidproquo/QuidProQuo.java b/src/main/java/top/penowl/quidproquo/QuidProQuo.java index e70856a..52e2b95 100644 --- a/src/main/java/top/penowl/quidproquo/QuidProQuo.java +++ b/src/main/java/top/penowl/quidproquo/QuidProQuo.java @@ -1,10 +1,12 @@ package top.penowl.quidproquo; import java.lang.reflect.Constructor; +import java.nio.Buffer; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; @@ -38,10 +40,13 @@ public class QuidProQuo extends JavaPlugin { for (Class ritualClass : subClasses) { Class[] params = {}; try { - Constructor constructor = ritualClass.getConstructor(params); - Object[] args = {}; - rituals.add(constructor.newInstance(args)); + if (ritualClass.getField("enabled").getBoolean(null)) { + Constructor constructor = ritualClass.getConstructor(params); + Object[] args = {}; + rituals.add(constructor.newInstance(args)); + } } catch (Exception e) { + System.out.println(e.toString()); } } diff --git a/src/main/java/top/penowl/quidproquo/Ritual.java b/src/main/java/top/penowl/quidproquo/Ritual.java index bcf993e..d4f0a34 100644 --- a/src/main/java/top/penowl/quidproquo/Ritual.java +++ b/src/main/java/top/penowl/quidproquo/Ritual.java @@ -11,6 +11,9 @@ import org.bukkit.inventory.ItemStack; public abstract class Ritual { + // whether the ritual is enabled, shouldn't change during runtime + public static boolean enabled = true; + // ingredients, map of type to count public HashMap ingredients = new HashMap(); diff --git a/src/main/java/top/penowl/quidproquo/rituals/BlankRitual.java b/src/main/java/top/penowl/quidproquo/rituals/BlankRitual.java index f0caef7..8ab6511 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/BlankRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/BlankRitual.java @@ -7,6 +7,8 @@ import top.penowl.quidproquo.Ritual; public class BlankRitual extends Ritual { + public static boolean enabled = false; + @Override public void setup() {