From 0cdda8b0ae1935eeb2acf68a01ad1fa91d085f18 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 12 Mar 2021 15:05:25 +0100 Subject: [PATCH] Fix a few issues with debugexec --- .../plotsquared/core/command/DebugExec.java | 20 +++++++++++++++---- .../java/com/plotsquared/core/plot/Plot.java | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 6e0f7fc82..bd59fa6a3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -49,8 +49,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import java.util.stream.Stream; @CommandDeclaration(command = "debugexec", permission = "plots.admin", @@ -58,8 +62,6 @@ import java.util.List; category = CommandCategory.DEBUG) public class DebugExec extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger("P2/" + DebugExec.class.getSimpleName()); - private final PlotAreaManager plotAreaManager; private final EventDispatcher eventDispatcher; private final HybridUtils hybridUtils; @@ -155,8 +157,10 @@ public class DebugExec extends SubCommand { case "stop-expire": if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) { player.sendMessage(TranslatableCaption.of("debugexec.task_halted")); + } else { + player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); } - player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); + return true; case "remove-flag": if (args.length != 2) { player.sendMessage( @@ -220,9 +224,17 @@ public class DebugExec extends SubCommand { return true; } } - player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + StringMan.join(allowedParams, " | ") + ">")); return false; } + @Override + public Collection tab(final PlotPlayer player, String[] args, boolean space) { + return Stream.of("analyze", "calibrate-analysis", "start-expire", "stop-expire", "remove-flag", "start-rgar", "stop-rgar") + .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) + .map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) { + }).collect(Collectors.toList()); + } + } diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 39289b045..5e8d0ce40 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1174,7 +1174,7 @@ public class Plot { * @return success */ public boolean removeFlag(final @NonNull PlotFlag flag) { - if (flag == null) { + if (flag == null || origin == null) { return false; } boolean removed = false;