diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 389331aae..b35c3dbc6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -60,14 +60,37 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); - return false; - } - final String world = loc.getWorld(); + final PlotId bot = MainUtil.getBottomPlot(plot).id; final PlotId top = MainUtil.getTopPlot(plot).id; final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); + + PlotPlayer other = UUIDHandler.getPlayer(args[0]); + if (other == null) { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER); + return false; + } + } + else { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + int size = plots.size(); + final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), other) + size; + if (currentPlots > MainUtil.getAllowedPlots(other)) { + sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS); + return false; + } + } + } + + if (!plot.isOwner(plr.getUUID())) { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); + return false; + } + } + + final String world = loc.getWorld(); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); final UUID uuid = getUUID(args[0]); @@ -81,6 +104,9 @@ public class SetOwner extends SubCommand { } MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); + if (other != null) { + MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.id); + } return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 911aca4be..b252c5292 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -213,6 +213,7 @@ public enum C { NO_PERMISSION("$2You are lacking the permission node: $1%s"), NO_PLOT_PERMS("$2You must be the plot owner to perform this action"), CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."), + CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user"), CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"), YOU_BE_DENIED("$2You are not allowed to enter this plot"), NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"), @@ -437,6 +438,7 @@ public enum C { * Set Owner */ SET_OWNER("$4You successfully set the plot owner"), + NOW_OWNER("$4You are now owner of plot %s"), /* * Signs */