Fixed plot permissions never working.

This commit is contained in:
Roman Alexander 2015-03-11 11:08:51 -04:00
parent 044abeaee9
commit e016cb5c85
5 changed files with 7 additions and 7 deletions

View File

@ -120,7 +120,7 @@ public class Auto extends SubCommand {
return false; return false;
} }
final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
final int diff = currentPlots - MainUtil.getAllowedPlots(plr, currentPlots); final int diff = currentPlots - MainUtil.getAllowedPlots(plr);
if ((diff + (size_x * size_z)) > 0) { if ((diff + (size_x * size_z)) > 0) {
if (diff < 0) { if (diff < 0) {
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");

View File

@ -68,7 +68,7 @@ public class Buy extends SubCommand {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(plr, C.NOT_IN_PLOT);
} }
final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {

View File

@ -91,7 +91,7 @@ public class Claim extends SubCommand {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(plr, C.NOT_IN_PLOT);
} }
final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {

View File

@ -1101,8 +1101,8 @@ public class MainUtil {
* @param p * @param p
* @return * @return
*/ */
public static int getAllowedPlots(final PlotPlayer p, final int current) { public static int getAllowedPlots(final PlotPlayer p) {
return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS, current); return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS);
} }
public static Plot getPlot(final Location loc) { public static Plot getPlot(final Location loc) {

View File

@ -36,14 +36,14 @@ public class Permissions {
return false; return false;
} }
public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range, final int min) { public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) {
if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) {
return Byte.MAX_VALUE; return Byte.MAX_VALUE;
} }
if (player.hasPermission(stub + ".*")) { if (player.hasPermission(stub + ".*")) {
return Byte.MAX_VALUE; return Byte.MAX_VALUE;
} }
for (int i = min; i < range; i++) { for (int i = range; i > 0; i--) {
if (player.hasPermission(stub + "." + i)) { if (player.hasPermission(stub + "." + i)) {
return i; return i;
} }