From 37280779b076c7a2ce4e783c5e2d2683b1d85d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 10 Nov 2019 12:06:33 +0100 Subject: [PATCH] Make `/plot setowner` require an argument. Fixes #2501. --- .../plotsquared/plot/commands/Owner.java | 28 ++++++++++--------- .../plotsquared/plot/config/Captions.java | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java index 55dbdbda4..82ec9f652 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java @@ -20,6 +20,10 @@ import java.util.UUID; requiredType = RequiredType.NONE, confirmation = true) public class Owner extends SetCommand { @Override public boolean set(final PlotPlayer player, final Plot plot, String value) { + if (value == null || value.isEmpty()) { + Captions.SET_OWNER_MISSING_PLAYER.send(player); + return false; + } Set plots = plot.getConnectedPlots(); UUID uuid = null; String name = null; @@ -75,20 +79,18 @@ import java.util.UUID; final String finalName = name; final UUID finalUUID = uuid; final boolean removeDenied = plot.isDenied(finalUUID); - Runnable run = new Runnable() { - @Override public void run() { - if (plot.setOwner(finalUUID, player)) { - if (removeDenied) - plot.removeDenied(finalUUID); - plot.setSign(finalName); - MainUtil.sendMessage(player, Captions.SET_OWNER); - if (other != null) { - MainUtil.sendMessage(other, Captions.NOW_OWNER, - plot.getArea() + ";" + plot.getId()); - } - } else { - MainUtil.sendMessage(player, Captions.SET_OWNER_CANCELLED); + Runnable run = () -> { + if (plot.setOwner(finalUUID, player)) { + if (removeDenied) + plot.removeDenied(finalUUID); + plot.setSign(finalName); + MainUtil.sendMessage(player, Captions.SET_OWNER); + if (other != null) { + MainUtil.sendMessage(other, Captions.NOW_OWNER, + plot.getArea() + ";" + plot.getId()); } + } else { + MainUtil.sendMessage(player, Captions.SET_OWNER_CANCELLED); } }; if (hasConfirmation(player)) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 68783e02e..16c9ac3d8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -578,6 +578,7 @@ public enum Captions { // SET_OWNER("$4You successfully set the plot owner", "Owner"), SET_OWNER_CANCELLED("$2The set owner action was cancelled", "Owner"), + SET_OWNER_MISSING_PLAYER("$1You need to specify a new owner. Correct usage is: $2/plot setowner ", "Owner"), NOW_OWNER("$4You are now owner of plot %s", "Owner"), // //