diff --git a/src/main/java/net/citizensnpcs/command/command/AdminCommands.java b/src/main/java/net/citizensnpcs/command/command/AdminCommands.java index 1f273c871..9c83e79f3 100644 --- a/src/main/java/net/citizensnpcs/command/command/AdminCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/AdminCommands.java @@ -1,8 +1,13 @@ package net.citizensnpcs.command.command; +import java.io.File; + import net.citizensnpcs.Citizens; +import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.exception.NPCLoadException; import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.api.scripting.CompileCallback; +import net.citizensnpcs.api.scripting.ScriptFactory; import net.citizensnpcs.command.Command; import net.citizensnpcs.command.CommandContext; import net.citizensnpcs.command.Requirements; @@ -22,6 +27,28 @@ public class AdminCommands { this.plugin = plugin; } + @Command( + aliases = "citizens", + modifiers = "script", + desc = "compile and run a script", + min = 2, + max = 2, + permission = "scripts.run") + @ServerCommand + public void runScript(CommandContext args, final CommandSender sender, NPC npc) throws CommandException { + File file = new File(args.getString(1)); + if (!file.exists()) + throw new CommandException("file doesn't exist!"); + sender.sendMessage("Could put into queue? " + + CitizensAPI.getScriptCompiler().compile(file).withCallback(new CompileCallback() { + @Override + public void onScriptCompiled(ScriptFactory script) { + script.newInstance(); + sender.sendMessage("Script compiled."); + } + }).begin()); + } + @Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin") public void citizens(CommandContext args, Player player, NPC npc) { Messaging.send(player,