mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Allow global plot limit across all worlds. Closes #261
This commit is contained in:
		@@ -828,6 +828,7 @@ public class PlotSquared {
 | 
			
		||||
        options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES);
 | 
			
		||||
        options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES);
 | 
			
		||||
        options.put("comments.notifications.interval", Settings.COMMENT_NOTIFICATION_INTERVAL);
 | 
			
		||||
        options.put("global_limit", Settings.GLOBAL_LIMIT);
 | 
			
		||||
        for (final Entry<String, Object> node : options.entrySet()) {
 | 
			
		||||
            if (!config.contains(node.getKey())) {
 | 
			
		||||
                config.set(node.getKey(), node.getValue());
 | 
			
		||||
@@ -874,6 +875,7 @@ public class PlotSquared {
 | 
			
		||||
        Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase");
 | 
			
		||||
        Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
 | 
			
		||||
        Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
 | 
			
		||||
        Settings.GLOBAL_LIMIT = config.getBoolean("global_limit");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setupConfigs() {
 | 
			
		||||
 
 | 
			
		||||
@@ -119,7 +119,7 @@ public class Auto extends SubCommand {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
 | 
			
		||||
        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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PlotSquared;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.Flag;
 | 
			
		||||
import com.intellectualcrafters.plot.flag.FlagManager;
 | 
			
		||||
@@ -68,7 +69,7 @@ public class Buy extends SubCommand {
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
 | 
			
		||||
        final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
 | 
			
		||||
        if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
 | 
			
		||||
            return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PlotSquared;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
@@ -89,7 +90,7 @@ public class Claim extends SubCommand {
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return sendMessage(plr, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
 | 
			
		||||
        final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
 | 
			
		||||
        if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
 | 
			
		||||
            return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@ import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PlotSquared;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
@@ -75,7 +76,7 @@ public class SetOwner extends SubCommand {
 | 
			
		||||
        else {
 | 
			
		||||
        	if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
 | 
			
		||||
        		int size = plots.size();
 | 
			
		||||
        		final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), other) + size;
 | 
			
		||||
                final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr)) + size;
 | 
			
		||||
        		if (currentPlots > MainUtil.getAllowedPlots(other)) {
 | 
			
		||||
                    sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
 | 
			
		||||
                    return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -152,6 +152,10 @@ public class Settings {
 | 
			
		||||
    public static boolean CONFIRM_CLEAR = true;
 | 
			
		||||
    public static boolean CONFIRM_DELETE = true;
 | 
			
		||||
    public static boolean CONFIRM_UNLINK = true;
 | 
			
		||||
    /**
 | 
			
		||||
     * Use global plot limit?
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean GLOBAL_LIMIT = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Database settings
 | 
			
		||||
 
 | 
			
		||||
@@ -97,6 +97,14 @@ public class MainUtil {
 | 
			
		||||
        }
 | 
			
		||||
        return count;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getPlayerPlotCount(final PlotPlayer plr) {
 | 
			
		||||
        int count = 0;
 | 
			
		||||
        for (final String world : PlotSquared.getPlotWorldsString()) {
 | 
			
		||||
            count += getPlayerPlotCount(world, plr);
 | 
			
		||||
        }
 | 
			
		||||
        return count;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static Location getDefaultHome(Plot plot) {
 | 
			
		||||
        PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user