Make /plot setowner require an argument. Fixes #2501.

This commit is contained in:
Alexander Söderberg 2019-11-10 12:06:33 +01:00
parent 834d786037
commit 37280779b0
2 changed files with 16 additions and 13 deletions

View File

@ -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<Plot> plots = plot.getConnectedPlots();
UUID uuid = null;
String name = null;
@ -75,8 +79,7 @@ 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() {
Runnable run = () -> {
if (plot.setOwner(finalUUID, player)) {
if (removeDenied)
plot.removeDenied(finalUUID);
@ -89,7 +92,6 @@ import java.util.UUID;
} else {
MainUtil.sendMessage(player, Captions.SET_OWNER_CANCELLED);
}
}
};
if (hasConfirmation(player)) {
CmdConfirm.addPending(player, "/plot set owner " + value, run);

View File

@ -578,6 +578,7 @@ public enum Captions {
//<editor-fold desc="Set Owner">
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>", "Owner"),
NOW_OWNER("$4You are now owner of plot %s", "Owner"),
//</editor-fold>
//<editor-fold desc="Signs">