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 b5bbbd2e0..5741fb7ba 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; @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", - requiredType = RequiredType.NONE) public class Add extends Command { + requiredType = RequiredType.PLAYER) public class Add extends Command { public Add() { super(MainCommand.getInstance(), true); @@ -63,21 +63,19 @@ import java.util.UUID; checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), Captions.PLOT_MAX_MEMBERS); - confirm.run(this, new Runnable() { - @Override // Success - public void run() { - for (UUID uuid : uuids) { - if (uuid != DBFunc.EVERYONE) { - if (!plot.removeTrusted(uuid)) { - if (plot.getDenied().contains(uuid)) { - plot.removeDenied(uuid); - } + // Success + confirm.run(this, () -> { + for (UUID uuid : uuids) { + if (uuid != DBFunc.EVERYONE) { + if (!plot.removeTrusted(uuid)) { + if (plot.getDenied().contains(uuid)) { + plot.removeDenied(uuid); } } - plot.addMember(uuid); - EventUtil.manager.callMember(player, plot, uuid, true); - MainUtil.sendMessage(player, Captions.MEMBER_ADDED); } + plot.addMember(uuid); + EventUtil.manager.callMember(player, plot, uuid, true); + MainUtil.sendMessage(player, Captions.MEMBER_ADDED); } }, null); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java index 11d9c30f4..fb6d571be 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java @@ -25,8 +25,12 @@ public class Auto extends SubCommand { if (allowedPlots == null) { allowedPlots = player.getAllowedPlots(); } - int currentPlots = - Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname); + int currentPlots; + if (Settings.Limit.GLOBAL) { + currentPlots = player.getPlotCount(); + } else { + currentPlots = player.getPlotCount(plotarea.worldname); + } int diff = currentPlots - allowedPlots; if (diff + sizeX * sizeZ > 0) { if (diff < 0) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java index 6f80ba6c5..b40167b4c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java @@ -27,11 +27,9 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; return false; } plot.addRunning(); - plot.setBiome(value.toUpperCase(), new Runnable() { - @Override public void run() { - plot.removeRunning(); - MainUtil.sendMessage(player, Captions.BIOME_SET_TO.s() + value.toLowerCase()); - } + plot.setBiome(value.toUpperCase(), () -> { + plot.removeRunning(); + MainUtil.sendMessage(player, Captions.BIOME_SET_TO.s() + value.toLowerCase()); }); return true; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Condense.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Condense.java index 040fd97b8..1245d2cce 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Condense.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Condense.java @@ -126,13 +126,11 @@ import java.util.concurrent.atomic.AtomicBoolean; } i++; final AtomicBoolean result = new AtomicBoolean(false); - result.set(origin.move(possible, new Runnable() { - @Override public void run() { - if (result.get()) { - MainUtil.sendMessage(player, - "Moving: " + origin + " -> " + possible); - TaskManager.runTaskLater(task, 1); - } + result.set(origin.move(possible, () -> { + if (result.get()) { + MainUtil.sendMessage(player, + "Moving: " + origin + " -> " + possible); + TaskManager.runTaskLater(task, 1); } }, false)); if (result.get()) { 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 fe917e08a..34a2936f8 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 @@ -16,7 +16,7 @@ import java.util.UUID; @CommandDeclaration(command = "deny", aliases = {"d", "ban"}, description = "Deny a user from a plot", usage = "/plot deny ", - category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Deny + category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny extends SubCommand { public Deny() { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java index ed3cc9856..a3e46dd08 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java @@ -38,8 +38,12 @@ import java.util.UUID; if (args.length > 2) { break; } - final UUID uuid = - args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID(); + final UUID uuid; + if (args.length == 2) { + uuid = UUIDHandler.getUUIDFromString(args[1]); + } else { + uuid = player.getUUID(); + } if (uuid == null) { Captions.INVALID_PLAYER.send(player, args[1]); return; @@ -47,12 +51,20 @@ import java.util.UUID; MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal() { @Override public void run(byte[] array) { if (arg0.equals("check")) { // check - int granted = - array == null ? 0 : ByteArrayUtilities.bytesToInteger(array); + int granted; + if (array == null) { + granted = 0; + } else { + granted = ByteArrayUtilities.bytesToInteger(array); + } Captions.GRANTED_PLOTS.send(player, granted); } else { // add - int amount = - 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array)); + int amount; + if (array == null) { + amount = 1; + } else { + amount = 1 + ByteArrayUtilities.bytesToInteger(array); + } boolean replace = array != null; String key = "grantedPlots"; byte[] rawData = ByteArrayUtilities.integerToBytes(amount); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java index 259395b5a..4a59850a9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Inbox.java @@ -15,7 +15,7 @@ import java.util.List; @CommandDeclaration(command = "inbox", description = "Review the comments for a plot", usage = "/plot inbox [inbox] [delete |clear|page]", permission = "plots.inbox", - category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Inbox + category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) public class Inbox extends SubCommand { public void displayComments(PlotPlayer player, List oldComments, int page) { @@ -23,7 +23,7 @@ import java.util.List; MainUtil.sendMessage(player, Captions.INBOX_EMPTY); return; } - PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]); + PlotComment[] comments = oldComments.toArray(new PlotComment[0]); if (page < 0) { page = 0; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java index 4fb4d6859..f93d95a32 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java @@ -130,9 +130,15 @@ import java.util.UUID; if (arg != null) { info = getCaption(arg); if (info == null) { - MainUtil.sendMessage(player, - "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " - + "&aowner&7, " + (Settings.Ratings.USE_LIKES ? " &alikes" : " &arating")); + if (Settings.Ratings.USE_LIKES) { + MainUtil.sendMessage(player, + "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + + "&aowner&7, " + " &alikes"); + } else { + MainUtil.sendMessage(player, + "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + + "&aowner&7, " + " &arating"); + } return false; } full = true; 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 88e69f556..b749eaba4 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 @@ -19,7 +19,7 @@ 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, - requiredType = RequiredType.NONE) public class Kick extends SubCommand { + requiredType = RequiredType.PLAYER) public class Kick extends SubCommand { public Kick() { super(Argument.PlayerName); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java index d7c6223c3..7f1b57c6d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java @@ -96,8 +96,11 @@ public class Like extends SubCommand { final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating)); if (result != null) { plot.addRating(uuid, result); - sendMessage(player, like ? Captions.RATING_LIKED : Captions.RATING_DISLIKED, - plot.getId().toString()); + if (like) { + sendMessage(player, Captions.RATING_LIKED, plot.getId().toString()); + } else { + sendMessage(player, Captions.RATING_DISLIKED, plot.getId().toString()); + } } }; if (plot.getSettings().ratings == null) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Swap.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Swap.java index d911ae3a5..da709d2a3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Swap.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Swap.java @@ -9,7 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.Permissions; @CommandDeclaration(usage = "/plot swap ", command = "swap", description = "Swap two plots", - aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) + aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER) public class Swap extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java index abca00a79..dc928c765 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Unlink.java @@ -7,8 +7,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.util.*; -@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"}, - description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true) +@CommandDeclaration(command = "unlink", aliases = {"u", + "unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true) public class Unlink extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { @@ -38,14 +38,12 @@ public class Unlink extends SubCommand { } else { createRoad = true; } - Runnable runnable = new Runnable() { - @Override public void run() { - if (!plot.unlinkPlot(createRoad, createRoad)) { - MainUtil.sendMessage(player, "&cUnlink has been cancelled"); - return; - } - MainUtil.sendMessage(player, Captions.UNLINK_SUCCESS); + Runnable runnable = () -> { + if (!plot.unlinkPlot(createRoad, createRoad)) { + MainUtil.sendMessage(player, "&cUnlink has been cancelled"); + return; } + MainUtil.sendMessage(player, Captions.UNLINK_SUCCESS); }; if (hasConfirmation(player)) { CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);