use of net.aufdemrand.denizen.utilities.command.Command in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method reload.
/*
* DENIZEN RELOAD
*/
@Command(aliases = { "denizen" }, usage = "reload (saves|notables|config|scripts|externals) (-a)", desc = "Reloads various Denizen files from disk to memory.", modifiers = { "reload" }, min = 1, max = 3, permission = "denizen.basic", flags = "a")
public void reload(CommandContext args, CommandSender sender) throws CommandException {
// Get reload type
if (args.hasFlag('a')) {
denizen.reloadConfig();
denizen.runtimeCompiler.reload();
DenizenCore.reloadScripts();
denizen.notableManager().reloadNotables();
denizen.reloadSaves();
Messaging.send(sender, "Denizen/saves.yml, Denizen/notables.yml, Denizen/config.yml, Denizen/scripts/..., and Denizen/externals/... reloaded from disk to memory.");
if (ScriptHelper.hadError()) {
Messaging.sendError(sender, "There was an error loading your scripts, check the console for details!");
}
// TODO: Properly handle player vs. npc?
ReloadScriptsScriptEvent.instance.reset();
ReloadScriptsScriptEvent.instance.all = true;
ReloadScriptsScriptEvent.instance.hadError = ScriptHelper.hadError();
ReloadScriptsScriptEvent.instance.sender = sender.getName();
ReloadScriptsScriptEvent.instance.data = new BukkitScriptEntryData(sender instanceof Player ? new dPlayer((Player) sender) : null, null);
ReloadScriptsScriptEvent.instance.fire();
return;
}
// Reload a specific item
if (args.length() > 2) {
if (args.getString(1).equalsIgnoreCase("saves")) {
denizen.reloadSaves();
Messaging.send(sender, "Denizen/saves.yml reloaded from disk to memory.");
return;
} else if (args.getString(1).equalsIgnoreCase("notables")) {
denizen.notableManager().reloadNotables();
Messaging.send(sender, "Denizen/notables.yml reloaded from disk to memory.");
return;
} else if (args.getString(1).equalsIgnoreCase("config")) {
denizen.reloadConfig();
Messaging.send(sender, "Denizen/config.yml reloaded from disk to memory.");
return;
} else if (args.getString(1).equalsIgnoreCase("scripts")) {
DenizenCore.reloadScripts();
Messaging.send(sender, "Denizen/scripts/... reloaded from disk to memory.");
if (ScriptHelper.hadError()) {
Messaging.sendError(sender, "There was an error loading your scripts, check the console for details!");
}
// TODO: Properly handle player vs. npc?
ReloadScriptsScriptEvent.instance.reset();
ReloadScriptsScriptEvent.instance.all = false;
ReloadScriptsScriptEvent.instance.hadError = ScriptHelper.hadError();
ReloadScriptsScriptEvent.instance.sender = sender.getName();
ReloadScriptsScriptEvent.instance.data = new BukkitScriptEntryData(sender instanceof Player ? new dPlayer((Player) sender) : null, null);
ReloadScriptsScriptEvent.instance.fire();
return;
} else if (args.getString(1).equalsIgnoreCase("externals")) {
denizen.runtimeCompiler.reload();
Messaging.send(sender, "Denizen/externals/... reloaded from disk to memory.");
return;
}
}
Messaging.send(sender, "");
Messaging.send(sender, "<f>Specify which parts to reload. Valid options are: SAVES, NOTABLES, CONFIG, SCRIPTS, EXTERNALS");
Messaging.send(sender, "<b>Example: /denizen reload scripts");
Messaging.send(sender, "<f>Use '-a' to reload all parts.");
Messaging.send(sender, "");
}
use of net.aufdemrand.denizen.utilities.command.Command in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method scripts.
/*
* DENIZEN SCRIPTS
*/
@Command(aliases = { "denizen" }, usage = "scripts (--type assignment|task|...) (--filter string)", desc = "Lists currently loaded dScripts.", modifiers = { "scripts" }, min = 1, max = 4, permission = "denizen.basic")
public void scripts(CommandContext args, CommandSender sender) throws CommandException {
// Fill arguments
String type = null;
if (args.hasValueFlag("type")) {
type = args.getFlag("type");
}
String filter = null;
if (args.hasValueFlag("filter")) {
filter = args.getFlag("filter");
}
// Get script names from the scripts.yml in memory
Set<String> scripts = ScriptRegistry._getScriptNames();
// New Paginator to display script names
Paginator paginator = new Paginator().header("Scripts");
paginator.addLine("<e>Key: <a>Type <b>Name");
// Add scripts to Paginator
for (String script : scripts) {
ScriptContainer scriptContainer = ScriptRegistry.getScriptContainer(script);
// If a --type has been specified...
if (type != null) {
if (scriptContainer.getContainerType().equalsIgnoreCase(type)) {
if (filter != null) {
if (script.contains(filter.toUpperCase())) {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
} else {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
}
// If a --filter has been specified...
} else if (filter != null) {
if (script.contains(filter.toUpperCase())) {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
} else {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
}
// Send the contents of the Paginator to the Player (or Console)
if (!paginator.sendPage(sender, args.getInteger(1, 1))) {
throw new CommandException("The page " + args.getInteger(1, 1) + " does not exist.");
}
}
use of net.aufdemrand.denizen.utilities.command.Command in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method addnotable.
@Command(aliases = { "notable" }, usage = "add", desc = "Adds a new notable to your current location", modifiers = { "add", "save" }, // before that, so it needs to be high
min = 2, max = 20, permission = "denizen.notable.basic")
public void addnotable(CommandContext args, CommandSender sender) throws CommandException {
NotableManager.saveAs(new dLocation(((Player) sender).getLocation()), args.getString(1));
Messaging.send(sender, "Created new notable called " + (args.getString(1)));
}
use of net.aufdemrand.denizen.utilities.command.Command in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method scriptcheck.
/*
* DENIZEN SCRIPTVERSIONS
*/
@Command(aliases = { "denizen" }, usage = "scriptversions", desc = "Shows the currently loaded version of your scripts and checks them against the script repo.", modifiers = { "scriptversions" }, min = 1, max = 3, permission = "denizen.basic")
public void scriptcheck(CommandContext args, CommandSender sender) throws CommandException {
sender.sendMessage(ChatColor.GREEN + "Checking " + VersionScriptContainer.scripts.size() + " script(s)!");
for (VersionScriptContainer cont : VersionScriptContainer.scripts) {
ScriptVersionChecker svc = new ScriptVersionChecker(cont);
svc.runme(sender);
}
}
use of net.aufdemrand.denizen.utilities.command.Command in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method submit.
// <--[language]
// @name denizen permissions
// @group Console Commands
// @description
// The following is a list of all permission nodes Denizen uses within Bukkit.
//
// denizen.basic # use the basics of the /denizen command
// denizen.notable # use the /notable command
// denizen.notable.basic # functionality within the /notable command, such as add or list
// denizen.ex # use the /ex command
// denizen.debug # use the /denizen debug command
// denizen.submit # use the /denizen submit command
//
// Additionally:
// denizen.npc.health, denizen.npc.sneak,
// denizen.npc.effect, denizen.npc.fish, denizen.npc.sleep, denizen.npc.stand,
// denizen.npc.sit, denizen.npc.nameplate, denizen.npc.nickname, denizen.npc.trigger,
// denizen.npc.assign, denizen.npc.constants, denizen.npc.pushable
//
// However, we recommend just giving op to whoever needs to access Denizen - they can
// op themselves through Denizen anyway, why not save the trouble?
// ( EG, /ex execute as_server "op <player.name>" )
//
// -->
// <--[language]
// @name /denizen submit command
// @group Console Commands
// @description
// Use the '/denizen submit' command with '/denizen debug -r' to record debug output and post
// it online for assisting developers to see.
//
// To begin recording, simply use '/denizen debug -r'. After that, any debug output sent to the
// console and any player chat will be added to an internal record. Once enabled, you should then
// fire off scripts and events that aren't working fully. Finally, you use the '/denizen submit'
// command to take all the recording information and paste it to an online pastebin hosted by
// the Denizen team. It will give you back a direct link to the full debug output, which you
// can view yourself and send to other helpers without trouble.
//
// There is no limit to the recording size, to prevent any important information from being trimmed
// away. Be careful not to leave debug recording enabled by accident, as it may eventually begin
// using up large amounts of memory. (The submit command will automatically disable recording,
// or you can instead just use '/denizen debug -r' again.)
//
// -->
@Command(aliases = { "denizen" }, usage = "submit", desc = "Submits recorded logs triggered by /denizen debug -r", modifiers = { "submit" }, min = 1, max = 3, permission = "denizen.submit")
public void submit(CommandContext args, final CommandSender sender) throws CommandException {
if (!dB.record) {
Messaging.sendError(sender, "Use /denizen debug -r to record debug information to be submitted");
return;
}
dB.record = false;
Messaging.send(sender, "Submitting...");
final DebugSubmit submit = new DebugSubmit();
submit.recording = dB.Recording.toString();
dB.Recording = new StringBuilder();
submit.start();
BukkitRunnable task = new BukkitRunnable() {
public void run() {
if (!submit.isAlive()) {
if (submit.Result == null) {
Messaging.sendError(sender, "Error while submitting.");
} else {
Messaging.send(sender, "Successfully submitted to http://old.mcmonkey.org" + submit.Result);
}
this.cancel();
}
}
};
task.runTaskTimer(DenizenAPI.getCurrentInstance(), 0, 10);
}
Aggregations