From 808a1ed70339e9c65971c7aa7569d4a28e396f6d Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 10 Jan 2020 13:35:59 +0100 Subject: [PATCH 1/3] Add wildcards to command args --- .../intellectualsites/plotsquared/commands/Argument.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Add.java | 3 ++- .../intellectualsites/plotsquared/plot/commands/Deny.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Kick.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Remove.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Trust.java | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java index 7ae1985ce..088dd40c1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Argument.java @@ -33,7 +33,7 @@ public abstract class Argument { } }; public static final Argument PlayerName = - new Argument("PlayerName", "") { + new Argument("PlayerName", "") { @Override public String parse(String in) { return in.length() <= 16 ? in : null; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java index d92dd4ea3..ba2d1b07b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java @@ -1,5 +1,6 @@ package com.github.intellectualsites.plotsquared.plot.commands; +import com.github.intellectualsites.plotsquared.commands.Argument; import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.config.Captions; @@ -19,7 +20,7 @@ import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "add", description = "Allow a user to build in a plot while you are online", - usage = "/plot add ", category = CommandCategory.SETTINGS, permission = "plots.add", + usage = "/plot add ", category = CommandCategory.SETTINGS, permission = "plots.add", requiredType = RequiredType.PLAYER) public class Add extends Command { public Add() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java index 220341f5f..669a53368 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java @@ -19,7 +19,7 @@ import java.util.Set; import java.util.UUID; @CommandDeclaration(command = "deny", aliases = {"d", "ban"}, - description = "Deny a user from a plot", usage = "/plot deny ", + description = "Deny a user from a plot", usage = "/plot deny ", category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny extends SubCommand { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java index eb36f8e67..b453abeb3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Kick.java @@ -18,7 +18,7 @@ import java.util.Set; import java.util.UUID; @CommandDeclaration(command = "kick", aliases = "k", description = "Kick a player from your plot", - permission = "plots.kick", usage = "/plot kick ", category = CommandCategory.TELEPORT, + permission = "plots.kick", usage = "/plot kick ", category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER) public class Kick extends SubCommand { public Kick() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java index 038355d83..debf93c28 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Remove.java @@ -18,7 +18,7 @@ import java.util.Set; import java.util.UUID; @CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"}, - description = "Remove a player from a plot", usage = "/plot remove ", + description = "Remove a player from a plot", usage = "/plot remove ", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.remove") public class Remove extends SubCommand { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java index c0cd3309e..d67db31c3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java @@ -18,7 +18,7 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER, - usage = "/plot trust ", + usage = "/plot trust ", description = "Allow a user to build in a plot and use WorldEdit while you are offline", category = CommandCategory.SETTINGS) public class Trust extends Command { From 6ee9d91aef6dd34b7db03c5f46d6a6aab67a0808 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 10 Jan 2020 14:01:28 +0100 Subject: [PATCH 2/3] Update requriedTypes --- .../intellectualsites/plotsquared/plot/commands/Add.java | 4 ++-- .../intellectualsites/plotsquared/plot/commands/Alias.java | 4 ++-- .../intellectualsites/plotsquared/plot/commands/Claim.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Clear.java | 2 +- .../plotsquared/plot/commands/CreateRoadSchematic.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Deny.java | 2 +- .../intellectualsites/plotsquared/plot/commands/Trust.java | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java index ba2d1b07b..b35c0f50d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java @@ -19,7 +19,7 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "add", - description = "Allow a user to build in a plot while you are online", + description = "Allow a user to build in a plot while the plot owner is online.", usage = "/plot add ", category = CommandCategory.SETTINGS, permission = "plots.add", requiredType = RequiredType.PLAYER) public class Add extends Command { @@ -35,7 +35,7 @@ import java.util.concurrent.CompletableFuture; checkTrue(plot.isOwner(player.getUUID()) || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), Captions.NO_PLOT_PERMS); - checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); + checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, "/plot add "); final Set uuids = MainUtil.getUUIDsFromString(args[0]); checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]); Iterator iterator = uuids.iterator(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Alias.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Alias.java index 401446243..f569674f8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Alias.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Alias.java @@ -46,7 +46,7 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; switch (args[0].toLowerCase()) { case "set": if (args.length != 2) { - Captions.COMMAND_SYNTAX.send(player, "/plot alias "); + Captions.COMMAND_SYNTAX.send(player, getUsage()); return false; } @@ -74,7 +74,7 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; private boolean setAlias(PlotPlayer player, Plot plot, String alias) { if (alias.isEmpty()) { - Captions.COMMAND_SYNTAX.send(player, "/plot alias "); + Captions.COMMAND_SYNTAX.send(player, getUsage()); return false; } if (alias.length() >= 50) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java index a10e83aca..c6acc1010 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java @@ -18,7 +18,7 @@ import com.google.common.primitives.Ints; @CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, - requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim") + requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim") public class Claim extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java index 9dcd475a1..d736154fd 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java @@ -16,7 +16,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue import java.util.concurrent.CompletableFuture; -@CommandDeclaration(command = "clear", description = "Clear the plot you stand on", +@CommandDeclaration(command = "clear", description = "Clear the plot you stand on", requiredType = RequiredType.NONE, permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear", aliases = "reset", confirmation = true) public class Clear extends Command { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/CreateRoadSchematic.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/CreateRoadSchematic.java index 14fa6347e..70b5952b1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/CreateRoadSchematic.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/CreateRoadSchematic.java @@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; @CommandDeclaration(command = "createroadschematic", aliases = {"crs"}, - category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, + category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.PLAYER, permission = "plots.createroadschematic", description = "Add a road schematic to your world using the roads around your current plot", usage = "/plot createroadschematic") public class CreateRoadSchematic extends SubCommand { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java index 669a53368..b50e68762 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Deny.java @@ -19,7 +19,7 @@ import java.util.Set; import java.util.UUID; @CommandDeclaration(command = "deny", aliases = {"d", "ban"}, - description = "Deny a user from a plot", usage = "/plot deny ", + description = "Deny a user from entering a plot", usage = "/plot deny ", category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny extends SubCommand { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java index d67db31c3..7d4d3a20e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java @@ -19,7 +19,7 @@ import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER, usage = "/plot trust ", - description = "Allow a user to build in a plot and use WorldEdit while you are offline", + description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.", category = CommandCategory.SETTINGS) public class Trust extends Command { public Trust() { @@ -37,7 +37,7 @@ import java.util.concurrent.CompletableFuture; checkTrue(currentPlot.isOwner(player.getUUID()) || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), Captions.NO_PLOT_PERMS); - checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); + checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, "/plot trust "); final Set uuids = MainUtil.getUUIDsFromString(args[0]); checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]); Iterator iterator = uuids.iterator(); From f3187a465c8d9273617e7f7a8090530420134334 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 10 Jan 2020 19:38:38 +0100 Subject: [PATCH 3/3] Oops --- .../intellectualsites/plotsquared/plot/commands/Add.java | 3 +-- .../intellectualsites/plotsquared/plot/commands/Trust.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java index b35c0f50d..6c2423021 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java @@ -1,6 +1,5 @@ package com.github.intellectualsites.plotsquared.plot.commands; -import com.github.intellectualsites.plotsquared.commands.Argument; import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.config.Captions; @@ -35,7 +34,7 @@ import java.util.concurrent.CompletableFuture; checkTrue(plot.isOwner(player.getUUID()) || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), Captions.NO_PLOT_PERMS); - checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, "/plot add "); + checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); final Set uuids = MainUtil.getUUIDsFromString(args[0]); checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]); Iterator iterator = uuids.iterator(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java index 7d4d3a20e..345fe8851 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java @@ -37,7 +37,7 @@ import java.util.concurrent.CompletableFuture; checkTrue(currentPlot.isOwner(player.getUUID()) || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), Captions.NO_PLOT_PERMS); - checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, "/plot trust "); + checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); final Set uuids = MainUtil.getUUIDsFromString(args[0]); checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]); Iterator iterator = uuids.iterator();