Commits

James Crasta committed d568a74

Mark 0.7-pre2 with limits support

  • Participants
  • Parent commits b97066e

Comments (0)

Files changed (4)

  * Fix bug in chest break protection
  * Implement a more stringent and specific ACL
  * Conversation-based ACL controls
+ * Permissions can control chest limits
 
 Version 0.6.2: 2013-02-04
  * Play nice with SignThatChest by allowing signs right in front of a chest.
 name: MondoChest
 main: us.crast.mondochest.MondoChest
-version: 0.7-pre1
+version: 0.7-pre2
 author: Crast
 description: "Sort your items into appropriate chests"
 website: "http://dev.bukkit.org/server-mods/mondochest/"

File src/us/crast/mondochest/Limits.java

+package us.crast.mondochest;
+
+import org.bukkit.configuration.ConfigurationSection;
+
+import us.crast.mondochest.security.MondoSecurity;
+import us.crast.mondochest.security.PermissionChecker;
+
+public final class Limits {
+    public static final int UNLIMITED = -1;
+    public final int findMaxRadius;
+    public final int mastersPerUser;
+    public final int slaveMaxAddRadius;
+    public final int slavesPerMaster;
+    public final PermissionChecker checker;
+
+    public Limits(final ConfigurationSection config, Limits base) {
+        findMaxRadius = parseLimit(config, "find_max_radius", (base == null)? 300 : base.findMaxRadius);
+        mastersPerUser = parseLimitWithFallback(config, "mondochests_per_user", "mondochests.per_user", (base == null)? UNLIMITED : base.mastersPerUser);
+        slaveMaxAddRadius = parseLimitWithFallback(config, "slave_max_add_radius", "slaves.max_add_radius", (base == null)? 150 : base.slaveMaxAddRadius);
+        slavesPerMaster = parseLimitWithFallback(config, "slaves_per_master", "slaves.per_master", (base == null)? UNLIMITED : base.slavesPerMaster);
+        checker = MondoSecurity.getChecker("mondochest.limits." + config.getName());
+    }
+
+    private static int parseLimit(ConfigurationSection config, String path, int defaultValue) {
+        String val = config.getString(path);
+        if (val == null) {
+            return defaultValue;
+        } else if (val.equals("unlimited") || val.equals("inf")) {
+            return -1;
+        } else {
+            return Integer.parseInt(val);
+        }
+    }
+    
+    private static int parseLimitWithFallback(ConfigurationSection c, String path, String altpath, int defaultValue) {
+        int val = parseLimit(c, path, -2);
+        if (val == -2) {
+            val = parseLimit(c, altpath, defaultValue);
+        }
+        return val;
+    }
+}

File src/us/crast/mondochest/MondoConstants.java

 
 public final class MondoConstants {
 	public static final String APP_NAME = "MondoChest";
-	public static final String MONDOCHEST_VERSION = "0.7-pre1";
+	public static final String MONDOCHEST_VERSION = "0.7-pre2";
 	
 	public static final String MASTER_SIGN_NAME = "[MondoChest]";
 	public static final String SLAVE_SIGN_NAME = "[MondoSlave]";