Ritual listing

This commit is contained in:
Edith Boles 2021-10-01 20:03:37 -07:00
parent 52c9c592dd
commit 7e773c88e4
4 changed files with 34 additions and 13 deletions

View File

@ -1,8 +1,11 @@
package top.penowl.quidproquo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -21,6 +24,24 @@ public class Commands implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1) {
// display help
return false;
} else if (args[0].toLowerCase().equals("list")) {
List<String> ritualNames = new ArrayList<String>(recipes.keySet());
int max = ritualNames.size() - 1;
int maxPages = max / 10;
int page = 0;
try {
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);
for (int i = page * 10; i < Math.min(page * 10 + 10, max + 1); i++) {
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

View File

@ -30,9 +30,6 @@ 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());
@ -53,6 +50,9 @@ public class QuidProQuo extends JavaPlugin {
getLogger().info("Loaded a " + ritual.name + " ritual.");
}
// register command handler
getCommand("ritual").setExecutor(new Commands(rituals));
}
@Override
public void onDisable() {

View File

@ -11,10 +11,7 @@ public class HitRitual extends Ritual {
@Override
public void setup() {
addIngredient(Material.IRON_SWORD, 1);
<<<<<<< HEAD
addIngredient(Material.IRON_INGOT, 1);
=======
>>>>>>> 7f77c0dac5cb9bbd0ceaf70f710f7fdecac3e9ad
addIngredient(Material.WHEAT, 9);
name = "shadow hit";
health = 1;
@ -22,14 +19,8 @@ public class HitRitual extends Ritual {
@Override
public void execute(Player caster, Player target, Location location) {
<<<<<<< HEAD
target.playSound(target.getLocation(), Sound.HURT_FLESH, 1, 1);
//target.damage(1.0);
=======
for(int i = 0; i < 3; i ++) {
target.playSound(target.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
}
>>>>>>> 7f77c0dac5cb9bbd0ceaf70f710f7fdecac3e9ad
}
}

View File

@ -1,3 +1,12 @@
main: top.penowl.quidproquo.QuidProQuo
name: QuidProQuo
version: 0.1
commands:
ritual:
description: Check ritual information.
aliases: [quidproquo, rt]
permission: quidproquo.command
permission-message: You do not have /&lt;permission&gt;
usage: |
§3/ritual list - List all available rituals.
§3/ritual <ritual> - See the information on a ritual