mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Add command to list all available scripts
Additional debugexec subcommand
This commit is contained in:
parent
95d03e878c
commit
44e11e9c6b
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotAnalysis;
|
|||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotMessage;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||||
@ -43,6 +44,7 @@ import java.sql.Timestamp;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
import javax.script.ScriptContext;
|
import javax.script.ScriptContext;
|
||||||
@ -57,7 +59,6 @@ import javax.script.SimpleScriptContext;
|
|||||||
aliases = {"exec", "$"},
|
aliases = {"exec", "$"},
|
||||||
category = CommandCategory.DEBUG)
|
category = CommandCategory.DEBUG)
|
||||||
public class DebugExec extends SubCommand {
|
public class DebugExec extends SubCommand {
|
||||||
|
|
||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ public class DebugExec extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
java.util.List<String> allowed_params =
|
java.util.List<String> allowed_params =
|
||||||
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
|
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "list-scripts");
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
String script;
|
String script;
|
||||||
@ -329,6 +330,42 @@ public class DebugExec extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "list-scripts":
|
||||||
|
final String path = PS.get().IMP.getDirectory() + File.separator + "scripts";
|
||||||
|
File folder = new File(path);
|
||||||
|
File[] filesArray = folder.listFiles();
|
||||||
|
|
||||||
|
int page;
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
page = 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (MathMan.isInteger(args[1])) {
|
||||||
|
page = Integer.parseInt(args[1]) - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
C.COMMAND_SYNTAX.send(player, "/plot debugexec list-scripts [#]");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<File> allFiles = Arrays.asList(filesArray);
|
||||||
|
paginate(player, allFiles, 8, page, new RunnableVal3<Integer, File, PlotMessage>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(Integer i, File file, PlotMessage message) {
|
||||||
|
String name;
|
||||||
|
name = file.getName();
|
||||||
|
|
||||||
|
message.text("[").color("$3")
|
||||||
|
.text(i + "").color("$1")
|
||||||
|
.text("]").color("$3")
|
||||||
|
.text(" " + name).color("$1");
|
||||||
|
|
||||||
|
}
|
||||||
|
}, "/plot debugexec list-scripts", "List of scripts");
|
||||||
|
return true;
|
||||||
case "allcmd":
|
case "allcmd":
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
C.COMMAND_SYNTAX.send(player, "/plot debugexec allcmd <condition> <command>");
|
C.COMMAND_SYNTAX.send(player, "/plot debugexec allcmd <condition> <command>");
|
||||||
|
Loading…
Reference in New Issue
Block a user