Start adding commands
This commit is contained in:
parent
dcead18673
commit
52c9c592dd
32
src/main/java/top/penowl/quidproquo/Commands.java
Normal file
32
src/main/java/top/penowl/quidproquo/Commands.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user