This commit is contained in:
boy0001 2015-03-31 17:18:05 +11:00
parent fffead4a16
commit b6d86ec1e1
2 changed files with 33 additions and 5 deletions

View File

@ -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<PlotId> 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;
}
}

View File

@ -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
*/