mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Add plot grants for /plot auto
This commit is contained in:
parent
cf6ca67ce7
commit
830a5111f4
@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
@ -122,16 +123,31 @@ public class Auto extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||
return false;
|
||||
}
|
||||
|
||||
int removeGrants = 0;
|
||||
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
|
||||
final int diff = currentPlots - MainUtil.getAllowedPlots(plr);
|
||||
if ((diff + (size_x * size_z)) > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
|
||||
} else {
|
||||
if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
if (grantedPlots < size_x * size_z) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
} else {
|
||||
removeGrants = size_x * size_z;
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
}
|
||||
if (removeGrants == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PlotWorld pWorld = PS.get().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
double cost = pWorld.PLOT_PRICE;
|
||||
@ -145,6 +161,11 @@ public class Auto extends SubCommand {
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (removeGrants > 0) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grantedPlots - removeGrants));
|
||||
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + removeGrants, "" + (grantedPlots - removeGrants));
|
||||
}
|
||||
if (!schematic.equals("")) {
|
||||
// if (pWorld.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!pWorld.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
|
@ -133,7 +133,7 @@ public class Claim extends SubCommand {
|
||||
if (removeGrantedPlot) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grantedPlots - 1));
|
||||
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + (grantedPlots - 1));
|
||||
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grantedPlots - 1));
|
||||
}
|
||||
if (!schematic.equals("")) {
|
||||
if (world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
|
@ -258,7 +258,7 @@ public enum C {
|
||||
CANNOT_AFFORD_MERGE("$2You cannot afford to merge the plots. It costs $1%s", "Economy"),
|
||||
ADDED_BALANCE("$1%s $2has been added to your balance", "Economy"),
|
||||
REMOVED_BALANCE("$1%s $2has been taken from your balance", "Economy"),
|
||||
REMOVED_GRANTED_PLOT("$2You used a plot grant, you've got $1%s $2left", "Economy"),
|
||||
REMOVED_GRANTED_PLOT("$2You used %s plot grant(s), you've got $1%s $2left", "Economy"),
|
||||
/*
|
||||
* Setup Stuff
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user