Start adding commands

This commit is contained in:
Edith Boles 2021-10-01 18:17:37 -07:00
parent dcead18673
commit 52c9c592dd
2 changed files with 35 additions and 0 deletions

View File

@ -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<String, Ritual> recipes = new HashMap<String, Ritual>();
public Commands(List<Ritual> 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;
}
}

View File

@ -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());