diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/ISettings.java | 6 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Settings.java | 134 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandsethome.java | 4 | ||||
-rw-r--r-- | Essentials/src/config.yml | 14 |
4 files changed, 114 insertions, 44 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 82c057648..af95e2cbc 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -73,7 +73,11 @@ public interface ISettings extends IConf boolean getRespawnAtHome(); - int getMultipleHomes(); + List getMultipleHomes(); + + int getHomeLimit(String set); + + int getHomeLimit(User user); boolean getSortListByGroups(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 5bcbd7311..3c06fb300 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -30,17 +30,45 @@ public class Settings implements ISettings { return config.getBoolean("respawn-at-home", false); } - + @Override - public int getMultipleHomes() + public boolean getBedSetsHome() { - return config.getInt("multiple-homes", 5); + return config.getBoolean("bed-sethome", false); } @Override - public boolean getBedSetsHome() + public List<String> getMultipleHomes() { - return config.getBoolean("bed-sethome", false); + return config.getKeys("sethome-multiple"); + } + + @Override + public int getHomeLimit(final User user) + { + final List<String> homeList = getMultipleHomes(); + if (homeList == null) + { + //TODO: Replace this code to remove backwards compat, after settings are automatically updated + // return getHomeLimit("default"); + return config.getInt("multiple-homes", 5); + } + int limit = getHomeLimit("default"); + for (String set : homeList) + { + logger.log(Level.INFO, "Found home set: " + set); + if (user.hasPermission("essentials.sethome.multiple." + set) && limit < getHomeLimit(set)) + { + limit = getHomeLimit(set); + } + } + return limit; + } + + @Override + public int getHomeLimit(final String set) + { + return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3)); } @Override @@ -60,7 +88,7 @@ public class Settings implements ISettings { return config.getInt("default-stack-size", 64); } - + @Override public int getStartingBalance() { @@ -84,7 +112,10 @@ public class Settings implements ISettings { for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0))) { - if (!c.equalsIgnoreCase(label)) continue; + if (!c.equalsIgnoreCase(label)) + { + continue; + } return true; } return config.getBoolean("disable-" + label.toLowerCase(), false); @@ -101,18 +132,24 @@ public class Settings implements ISettings { for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0))) { - if (!c.equalsIgnoreCase(label)) continue; + if (!c.equalsIgnoreCase(label)) + { + continue; + } return true; } return config.getBoolean("restrict-" + label.toLowerCase(), false); } - + @Override public boolean isPlayerCommand(String label) { for (String c : config.getStringList("player-commands", new ArrayList<String>(0))) { - if (!c.equalsIgnoreCase(label)) continue; + if (!c.equalsIgnoreCase(label)) + { + continue; + } return true; } return false; @@ -126,7 +163,9 @@ public class Settings implements ISettings for (String c : config.getStringList("overridden-commands", defaultList)) { if (!c.equalsIgnoreCase(name)) + { continue; + } return true; } return config.getBoolean("override-" + name.toLowerCase(), false); @@ -143,7 +182,9 @@ public class Settings implements ISettings { double cost = config.getDouble("command-costs." + label, 0.0); if (cost == 0.0) + { cost = config.getDouble("cost-" + label, 0.0); + } return cost; } @@ -171,13 +212,14 @@ public class Settings implements ISettings Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits"); for (Map.Entry<String, Object> entry : kits.entrySet()) { - if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) { + if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) + { return entry.getValue(); } } return null; } - + @Override public Map<String, Object> getKits() { @@ -190,9 +232,13 @@ public class Settings implements ISettings String colorName = config.getString("ops-name-color", null); if (colorName == null) + { return ChatColor.RED; - if("none".equalsIgnoreCase(colorName) || colorName.isEmpty()) + } + if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty()) + { throw new Exception(); + } try { @@ -228,18 +274,18 @@ public class Settings implements ISettings { return config.getInt("spawnmob-limit", 10); } - + @Override public boolean showNonEssCommandsInHelp() { return config.getBoolean("non-ess-in-help", true); } - + @Override - public boolean hidePermissionlessHelp() + public boolean hidePermissionlessHelp() { return config.getBoolean("hide-permissionless-help", true); - } + } @Override public int getProtectCreeperMaxHeight() @@ -301,12 +347,13 @@ public class Settings implements ISettings { return config.getString("newbies.spawnpoint", "default"); } + @Override - public boolean getPerWarpPermission() + public boolean getPerWarpPermission() { return config.getBoolean("per-warp-permission", false); } - + @Override public boolean getSortListByGroups() { @@ -314,7 +361,8 @@ public class Settings implements ISettings } @Override - public void reloadConfig() { + public void reloadConfig() + { config.load(); } @@ -322,16 +370,21 @@ public class Settings implements ISettings public List<Integer> itemSpawnBlacklist() { final List<Integer> epItemSpwn = new ArrayList<Integer>(); - for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) { + for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) + { itemName = itemName.trim(); - if (itemName.isEmpty()) { + if (itemName.isEmpty()) + { continue; } ItemStack is; - try { + try + { is = ess.getItemDb().get(itemName); epItemSpwn.add(is.getTypeId()); - } catch (Exception ex) { + } + catch (Exception ex) + { logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist")); } } @@ -355,16 +408,17 @@ public class Settings implements ISettings { return config.getBoolean("nether.use-1to1-ratio", false); } - + @Override public double getNetherRatio() { - if (config.getBoolean("nether.use-1to1-ratio", false)) { + if (config.getBoolean("nether.use-1to1-ratio", false)) + { return 1.0; } return config.getDouble("nether.ratio", 8.0); } - + @Override public boolean isDebug() { @@ -374,9 +428,9 @@ public class Settings implements ISettings @Override public boolean warnOnSmite() { - return config.getBoolean("warn-on-smite" ,true); + return config.getBoolean("warn-on-smite", true); } - + @Override public boolean permissionBasedItemSpawn() { @@ -410,23 +464,28 @@ public class Settings implements ISettings @Override public boolean getProtectPreventSpawn(final String creatureName) { - return config.getBoolean("protect.prevent.spawn."+creatureName, false); + return config.getBoolean("protect.prevent.spawn." + creatureName, false); } @Override public List<Integer> getProtectList(final String configName) { final List<Integer> list = new ArrayList<Integer>(); - for (String itemName : config.getString(configName, "").split(",")) { + for (String itemName : config.getString(configName, "").split(",")) + { itemName = itemName.trim(); - if (itemName.isEmpty()) { + if (itemName.isEmpty()) + { continue; } ItemStack itemStack; - try { + try + { itemStack = ess.getItemDb().get(itemName); list.add(itemStack.getTypeId()); - } catch (Exception ex) { + } + catch (Exception ex) + { logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName)); } } @@ -444,12 +503,13 @@ public class Settings implements ISettings { return config.getBoolean(configName, def); } - private final static double MAXMONEY = 10000000000000.0; + public double getMaxMoney() { double max = config.getDouble("max-money", MAXMONEY); - if (Math.abs(max) > MAXMONEY) { + if (Math.abs(max) > MAXMONEY) + { max = max < 0 ? -MAXMONEY : MAXMONEY; } return max; @@ -459,7 +519,7 @@ public class Settings implements ISettings { return config.getBoolean("economy-log-enabled", false); } - + public boolean removeGodOnDisconnect() { return config.getBoolean("remove-god-on-disconnect", false); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index 82d66a71c..b59984f05 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand { if (user.isAuthorized("essentials.sethome.multiple")) { - if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes()) + if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user)) || (user.getHomes().contains(args[0].toLowerCase()))) { user.setHome(args[0].toLowerCase()); } else { - throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes())); + throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user))); } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 82639d157..7b1525d40 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -260,10 +260,16 @@ bed-sethome: false # If no home is set send you to spawn when /home is used spawn-if-no-home: false -# If users have essentials.sethome.multiple how many homes can they have -# People with essentials.sethome.multiple.unlimited are not limited by this number -multiple-homes: 5 - +# Allow players to have multiple homes. +# Define different amounts of multiple homes for different permissions, e.g. essentials.sethome.multiple.vip +# People with essentials.sethome.multiple.unlimited are not limited by these numbers. +sethome-multiple: + # essentials.sethome.multiple + default: 3 + # essentials.sethome.multiple.vip + vip: 5 + # essentials.sethome.multiple.staff + staff: 10 ############################################################ # +------------------------------------------------------+ # |