From 86cfeb76b619e872efb7228dcade472c7cf59ace Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Tue, 18 Aug 2020 12:22:26 +0200 Subject: [PATCH] More json stuff --- .../java/com/plotsquared/core/command/Condense.java | 2 +- .../java/com/plotsquared/core/command/Grant.java | 10 ++++++++++ .../java/com/plotsquared/core/command/Inbox.java | 2 +- .../java/com/plotsquared/core/command/Target.java | 13 +++++++++++++ .../java/com/plotsquared/core/command/Template.java | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java index 9333446f3..7258bf70d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -71,7 +71,7 @@ public class Condense extends SubCommand { if (args.length != 2 && args.length != 3) { player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax"), - Template.of("value", "/plot condense [radius]") + Template.of("value", "/plot condense [radius]") ); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java index ca5a832d7..4a2e83f5d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -40,10 +40,14 @@ import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; import net.kyori.adventure.text.minimessage.Template; +import java.util.Collection; +import java.util.Locale; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import java.util.stream.Stream; @CommandDeclaration(command = "grant", category = CommandCategory.CLAIMING, @@ -132,4 +136,10 @@ public class Grant extends Command { sendUsage(player); return CompletableFuture.completedFuture(true); } + @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) { + return Stream.of("check", "add") + .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) + .map(value -> new Command(null, false, value, "plots.grant", RequiredType.NONE, null) { + }).collect(Collectors.toList()); + } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Inbox.java b/Core/src/main/java/com/plotsquared/core/command/Inbox.java index ffde09ab4..458df04ec 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -45,7 +45,7 @@ import java.util.List; @CommandDeclaration(command = "inbox", description = "Review the comments for a plot", - usage = "/plot inbox [inbox] [delete |clear|page]", + usage = "/plot inbox [inbox] [delete | clear | page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) diff --git a/Core/src/main/java/com/plotsquared/core/command/Target.java b/Core/src/main/java/com/plotsquared/core/command/Target.java index c49a7237c..bd860616a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Target.java +++ b/Core/src/main/java/com/plotsquared/core/command/Target.java @@ -30,9 +30,16 @@ import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.util.StringMan; +import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import net.kyori.adventure.text.minimessage.Template; +import java.util.Collection; +import java.util.Collections; +import java.util.Locale; +import java.util.stream.Collectors; +import java.util.stream.Stream; + @CommandDeclaration(command = "target", usage = "/plot target < | nearest>", description = "Target a plot with your compass", @@ -79,4 +86,10 @@ public class Target extends SubCommand { player.sendMessage(TranslatableCaption.of("compass.compass_target")); return true; } + @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) { + return Stream.of("", "nearest") + .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) + .map(value -> new Command(null, false, value, "plots.target", RequiredType.NONE, null) { + }).collect(Collectors.toList()); + } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Template.java b/Core/src/main/java/com/plotsquared/core/command/Template.java index de7942293..c7bde1161 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -54,7 +54,11 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.util.Collection; +import java.util.Locale; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; @@ -263,4 +267,10 @@ public class Template extends SubCommand { } return false; } + @Override public Collection tab(final PlotPlayer player, String[] args, boolean space) { + return Stream.of("import", "export") + .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) + .map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) { + }).collect(Collectors.toList()); + } }