From 52c9c592ddf4469c3444a42b3a4a2a0239fa997a Mon Sep 17 00:00:00 2001 From: Edith Boles Date: Fri, 1 Oct 2021 18:17:37 -0700 Subject: [PATCH] Start adding commands --- .../java/top/penowl/quidproquo/Commands.java | 32 +++++++++++++++++++ .../top/penowl/quidproquo/QuidProQuo.java | 3 ++ 2 files changed, 35 insertions(+) create mode 100644 src/main/java/top/penowl/quidproquo/Commands.java diff --git a/src/main/java/top/penowl/quidproquo/Commands.java b/src/main/java/top/penowl/quidproquo/Commands.java new file mode 100644 index 0000000..15f12d5 --- /dev/null +++ b/src/main/java/top/penowl/quidproquo/Commands.java @@ -0,0 +1,32 @@ +package top.penowl.quidproquo; + +import java.util.HashMap; +import java.util.List; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class Commands implements CommandExecutor { + + HashMap recipes = new HashMap(); + + public Commands(List rituals) { + for (Ritual ritual : rituals) { + recipes.put(ritual.name.toUpperCase(), ritual); + } + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length < 1) { + // display help + return true; + } else if (recipes.containsKey(args[0].toUpperCase())) { + // display recipe info + return true; + } + return false; + } + +} diff --git a/src/main/java/top/penowl/quidproquo/QuidProQuo.java b/src/main/java/top/penowl/quidproquo/QuidProQuo.java index 82c3cda..778a2e0 100644 --- a/src/main/java/top/penowl/quidproquo/QuidProQuo.java +++ b/src/main/java/top/penowl/quidproquo/QuidProQuo.java @@ -30,6 +30,9 @@ public class QuidProQuo extends JavaPlugin { getLogger().info("Loading rituals..."); getServer().getPluginManager().registerEvents(new Events(), this); + // register command handler + getCommand("ritual").setExecutor(new Commands(rituals)); + // register all rituals rituals.add(new HealRitual()); rituals.add(new WoolingRitual());