diff --git a/src/main/java/net/citizensnpcs/commands/TemplateCommands.java b/src/main/java/net/citizensnpcs/commands/TemplateCommands.java index e251f7dea..d9c0adce3 100644 --- a/src/main/java/net/citizensnpcs/commands/TemplateCommands.java +++ b/src/main/java/net/citizensnpcs/commands/TemplateCommands.java @@ -86,4 +86,19 @@ public class TemplateCommands { TemplateBuilder.create(name).from(npc).override(args.hasFlag('o')).buildAndSave(); Messaging.sendTr(sender, Messages.TEMPLATE_CREATED); } + + @Command( + aliases = { "template", "tpl" }, + usage = "list", + desc = "Lists available templates", + modifiers = { "list" }, + min = 1, + max = 1, + permission = "citizens.templates.list") + public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException { + Messaging.sendTr(sender, Messages.TEMPLATE_LIST_HEADER); + for (Template template : Template.allTemplates()) { + Messaging.send(sender, "[[-]] " + template.getName()); + } + } } diff --git a/src/main/java/net/citizensnpcs/npc/Template.java b/src/main/java/net/citizensnpcs/npc/Template.java index 2ecdb0966..0017d856e 100644 --- a/src/main/java/net/citizensnpcs/npc/Template.java +++ b/src/main/java/net/citizensnpcs/npc/Template.java @@ -12,6 +12,8 @@ import net.citizensnpcs.api.util.MemoryDataKey; import net.citizensnpcs.api.util.YamlStorage; import net.citizensnpcs.api.util.YamlStorage.YamlKey; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -54,7 +56,6 @@ public class Template { private static class Node { String headKey; - Map map; private Node(String headKey, Map map) { @@ -102,7 +103,14 @@ public class Template { } } - private static YamlStorage templates = new YamlStorage(new File(CitizensAPI.getDataFolder(), "templates.yml")); + public static Iterable