use of com.elmakers.mine.bukkit.api.spell.SpellCategory in project MagicPlugin by elBukkit.
the class SpellsCommandExecutor method listSpellsByCategory.
public void listSpellsByCategory(CommandSender sender, String category) {
List<SpellTemplate> categorySpells = new ArrayList<>();
Collection<SpellTemplate> spellVariants = api.getSpellTemplates(sender.hasPermission("Magic.bypass_hidden"));
Player player = sender instanceof Player ? (Player) sender : null;
for (SpellTemplate spell : spellVariants) {
SpellCategory spellCategory = spell.getCategory();
if (spellCategory != null && spellCategory.getKey().equalsIgnoreCase(category) && (player == null || spell.hasCastPermission(player))) {
categorySpells.add(spell);
}
}
if (categorySpells.size() == 0) {
String message = api.getMessages().get("general.no_spells_in_category");
message = message.replace("$category", category);
sender.sendMessage(message);
return;
}
sender.sendMessage(category + ":");
Collections.sort(categorySpells);
for (SpellTemplate spell : categorySpells) {
String name = spell.getName();
String description = spell.getDescription();
if (!name.equals(spell.getKey())) {
description = name + " : " + description;
}
sender.sendMessage(ChatColor.AQUA + spell.getKey() + ChatColor.BLUE + " [" + spell.getIcon().getName() + "] : " + ChatColor.YELLOW + description);
}
}
Aggregations