From 44e11e9c6bb113cad2905797d0668983ba732887 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 14:42:34 +0200 Subject: [PATCH 1/6] Add command to list all available scripts Additional debugexec subcommand --- .../plot/commands/DebugExec.java | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 69265fd83..dc2de88c9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotAnalysis; import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotMessage; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal2; @@ -43,6 +44,7 @@ import java.sql.Timestamp; import java.util.Arrays; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.UUID; import javax.script.Bindings; import javax.script.ScriptContext; @@ -57,7 +59,6 @@ import javax.script.SimpleScriptContext; aliases = {"exec", "$"}, category = CommandCategory.DEBUG) public class DebugExec extends SubCommand { - private ScriptEngine engine; private Bindings scope; @@ -145,7 +146,7 @@ public class DebugExec extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { java.util.List 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) { String arg = args[0].toLowerCase(); String script; @@ -329,6 +330,42 @@ public class DebugExec extends SubCommand { return false; } 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 allFiles = Arrays.asList(filesArray); + paginate(player, allFiles, 8, page, new RunnableVal3() { + + @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": if (args.length < 3) { C.COMMAND_SYNTAX.send(player, "/plot debugexec allcmd "); From 510b9a47dc77110e2ed0575a787c1a02b8431940 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 14:42:41 +0200 Subject: [PATCH 2/6] Formatting --- .../main/java/com/intellectualcrafters/plot/commands/Grant.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java index c479f86b5..052707bc8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java @@ -9,7 +9,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.CommandDeclaration; - import java.util.UUID; @CommandDeclaration( From 429fed2ab338469b182afd3c4c54bc18febd28a9 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 14:43:04 +0200 Subject: [PATCH 3/6] Fix target command Threw an exception when you didnt pass an argument --- .../java/com/intellectualcrafters/plot/commands/Target.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java index acb47aa16..17e4214f4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; +import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( @@ -18,6 +19,10 @@ import com.plotsquared.general.commands.CommandDeclaration; category = CommandCategory.INFO) public class Target extends SubCommand { + public Target() { + super(Argument.PlotID); + } + @Override public boolean onCommand(PlotPlayer plr, String[] args) { Location plrLocation = plr.getLocation(); From 6fc8bf587be6129298eabaa27c3623c0f8f2c3bd Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 14:43:16 +0200 Subject: [PATCH 4/6] Comma-separate list of plot worlds --- .../com/intellectualcrafters/plot/commands/Debug.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index c0879c059..464bd0e96 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -2,11 +2,10 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.MainUtil; import com.plotsquared.general.commands.CommandDeclaration; +import org.apache.commons.lang.StringUtils; @CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, @@ -29,13 +28,7 @@ public class Debug extends SubCommand { String header = C.DEBUG_HEADER.s(); String line = C.DEBUG_LINE.s(); String section = C.DEBUG_SECTION.s(); - final StringBuilder worlds = new StringBuilder(""); - PS.get().foreachPlotArea(new RunnableVal() { - @Override - public void run(PlotArea value) { - worlds.append(value.toString()).append(" "); - } - }); + String worlds = StringUtils.join(PS.get().getPlotAreas(), ", "); information.append(header); information.append(getSection(section, "PlotArea")); information.append(getLine(line, "Plot Worlds", worlds)); From ea17ba8e46b61d08bd0a4b6fbb8255c13cfe231a Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 15:09:00 +0200 Subject: [PATCH 5/6] Fix sponge conflicts --- .../com/intellectualcrafters/plot/commands/Debug.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index 464bd0e96..c0879c059 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -2,10 +2,11 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.MainUtil; import com.plotsquared.general.commands.CommandDeclaration; -import org.apache.commons.lang.StringUtils; @CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, @@ -28,7 +29,13 @@ public class Debug extends SubCommand { String header = C.DEBUG_HEADER.s(); String line = C.DEBUG_LINE.s(); String section = C.DEBUG_SECTION.s(); - String worlds = StringUtils.join(PS.get().getPlotAreas(), ", "); + final StringBuilder worlds = new StringBuilder(""); + PS.get().foreachPlotArea(new RunnableVal() { + @Override + public void run(PlotArea value) { + worlds.append(value.toString()).append(" "); + } + }); information.append(header); information.append(getSection(section, "PlotArea")); information.append(getLine(line, "Plot Worlds", worlds)); From 25dfc3469575ac08667dd4486494ab8f97bf7303 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Wed, 30 Mar 2016 15:25:25 +0200 Subject: [PATCH 6/6] Comma-separate plot area list again --- .../java/com/intellectualcrafters/plot/commands/Debug.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index c0879c059..b2c7ee346 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -33,12 +33,12 @@ public class Debug extends SubCommand { PS.get().foreachPlotArea(new RunnableVal() { @Override public void run(PlotArea value) { - worlds.append(value.toString()).append(" "); + worlds.append(value.toString()).append(", "); } }); information.append(header); information.append(getSection(section, "PlotArea")); - information.append(getLine(line, "Plot Worlds", worlds)); + information.append(getLine(line, "Plot Worlds", worlds.substring(0, worlds.length() - 2))); information.append(getLine(line, "Owned Plots", PS.get().getPlots().size())); information.append(getSection(section, "Messages")); information.append(getLine(line, "Total Messages", C.values().length));