mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-30 22:53:24 +01:00
Add script compile command
This commit is contained in:
parent
9ab17fdf13
commit
29e268b699
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user