From 30d3a458e2e368b072fa739583528c40602d805c Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 28 Mar 2021 17:39:02 +0200 Subject: [PATCH] Addressing more issues --- .../com/plotsquared/core/command/Cluster.java | 4 ++- .../com/plotsquared/core/command/Debug.java | 2 +- .../com/plotsquared/core/command/Info.java | 31 +++++++++++++++++++ .../core/command/SchematicCmd.java | 8 ++--- Core/src/main/resources/lang/messages_en.json | 2 +- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java index 2fdd48d26..5ec809915 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -294,7 +294,9 @@ public class Cluster extends SubCommand { } } DBFunc.delete(cluster); - player.sendMessage(TranslatableCaption.of("cluster.cluster_deleted")); + player.sendMessage(TranslatableCaption.of("cluster.cluster_deleted"), Template.of("cluster", + String.valueOf(cluster) + )); return true; } case "res": diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index bde044042..cde04ad76 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -58,7 +58,7 @@ import java.util.stream.Stream; @CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, - usage = "/plot debug [msg]", + usage = "/plot debug", permission = "plots.admin") public class Debug extends SubCommand { diff --git a/Core/src/main/java/com/plotsquared/core/command/Info.java b/Core/src/main/java/com/plotsquared/core/command/Info.java index aadffa3f5..509d0af7d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Info.java +++ b/Core/src/main/java/com/plotsquared/core/command/Info.java @@ -25,6 +25,7 @@ */ package com.plotsquared.core.command; +import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.StaticCaption; @@ -34,8 +35,18 @@ import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.HideInfoFlag; +import com.plotsquared.core.util.Permissions; +import com.plotsquared.core.util.TabCompletions; import net.kyori.adventure.text.minimessage.Template; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import java.util.stream.Stream; + @CommandDeclaration(command = "info", aliases = "i", usage = "/plot info [-f to force info]", @@ -153,6 +164,26 @@ public class Info extends SubCommand { return true; } + @Override + public Collection tab(PlotPlayer player, String[] args, boolean space) { + final List completions = new LinkedList<>(); + if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE)) { + completions.add("-f"); + } + + final List commands = completions.stream().filter(completion -> completion + .toLowerCase() + .startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { + }).collect(Collectors.toCollection(LinkedList::new)); + + if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE) && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + + return commands; + } + private Caption getCaption(String string) { switch (string) { case "trusted": diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index 8b7677ac5..158147802 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -57,9 +57,9 @@ import java.util.stream.Collectors; @CommandDeclaration(command = "schematic", permission = "plots.schematic", - aliases = {"sch", "schem"}, + aliases = "schem", category = CommandCategory.SCHEMATIC, - usage = "/plot schematic ") + usage = "/plot schematic ") public class SchematicCmd extends SubCommand { private final PlotAreaManager plotAreaManager; @@ -190,10 +190,10 @@ public class SchematicCmd extends SubCommand { return false; } if (args.length != 2) { - player.sendMessage(TranslatableCaption.of("schematic_exportall_world_args")); + player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_world_args")); player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax"), - Template.of("value", "Use /plot sch exportall area") + Template.of("value", "Use /plot schematic exportall area") ); return false; } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 584ccfc3e..cbe8ee2cb 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -37,7 +37,7 @@ "cluster.cluster_intersection": "The proposed area overlaps with: ", "cluster.cluster_outside": "The proposed area is outside the plot area: ", "cluster.cluster_added": "Successfully created the cluster.", - "cluster.cluster_deleted": "Successfully deleted the cluster.", + "cluster.cluster_deleted": "Successfully deleted the cluster .", "cluster.cluster_resized": "Successfully resized the cluster.", "cluster.cluster_added_user": "Successfully added user to the cluster.", "cluster.cannot_kick_player": "You cannot kick that player: ",