diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-03-03 07:03:54 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-03-03 07:03:54 +0000 |
commit | c0fa03ede259bedb8946bc559a0e64e54c9b464e (patch) | |
tree | 08a287b62ae502319451fd187cf9f8f4b17c54bd | |
parent | 301b609e9357a21931653baffe9c3bed1f06dd8f (diff) | |
download | Essentials-c0fa03ede259bedb8946bc559a0e64e54c9b464e.tar Essentials-c0fa03ede259bedb8946bc559a0e64e54c9b464e.tar.gz Essentials-c0fa03ede259bedb8946bc559a0e64e54c9b464e.tar.lz Essentials-c0fa03ede259bedb8946bc559a0e64e54c9b464e.tar.xz Essentials-c0fa03ede259bedb8946bc559a0e64e54c9b464e.zip |
Force all kits to lowercase.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Kit.java | 8 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Settings.java | 41 |
2 files changed, 35 insertions, 14 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 88816368c..138a12979 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -60,11 +60,15 @@ public class Kit } } - public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception + public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception { + if (kit == null) { + throw new Exception(_("kitError2")); + } + try { - return (List<String>)els.get("items"); + return (List<String>)kit.get("items"); } catch (Exception e) { diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 732b5485c..e3992e52c 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -13,6 +13,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.MemoryConfiguration; import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; @@ -208,18 +209,22 @@ public class Settings implements ISettings { return config.getDouble("heal-cooldown", 0); } + private ConfigurationSection kits; - @Override - public Map<String, Object> getKit(String name) + public ConfigurationSection _getKits() { - name = name.replace('.', '_').replace('/', '_'); if (config.isConfigurationSection("kits")) { - final ConfigurationSection kits = getKits(); - if (kits.isConfigurationSection(name)) + final ConfigurationSection section = config.getConfigurationSection("kits"); + final ConfigurationSection newSection = new MemoryConfiguration(); + for (String kitItem : section.getKeys(false)) { - return kits.getConfigurationSection(name).getValues(true); + if (section.isConfigurationSection(kitItem)) + { + newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem)); + } } + return newSection; } return null; } @@ -227,9 +232,20 @@ public class Settings implements ISettings @Override public ConfigurationSection getKits() { + return kits; + } + + @Override + public Map<String, Object> getKit(String name) + { + name = name.replace('.', '_').replace('/', '_'); if (config.isConfigurationSection("kits")) { - return config.getConfigurationSection("kits"); + final ConfigurationSection kits = getKits(); + if (kits.isConfigurationSection(name)) + { + return kits.getConfigurationSection(name).getValues(true); + } } return null; } @@ -358,8 +374,9 @@ public class Settings implements ISettings { config.load(); noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds")); - enabledSigns = getEnabledSigns(); - itemSpawnBl = getItemSpawnBlacklist(); + enabledSigns = _getEnabledSigns(); + itemSpawnBl = _getItemSpawnBlacklist(); + kits = _getKits(); chatFormats.clear(); } private List<Integer> itemSpawnBl = new ArrayList<Integer>(); @@ -370,7 +387,7 @@ public class Settings implements ISettings return itemSpawnBl; } - private List<Integer> getItemSpawnBlacklist() + private List<Integer> _getItemSpawnBlacklist() { final List<Integer> epItemSpwn = new ArrayList<Integer>(); if (ess.getItemDb() == null) @@ -405,7 +422,7 @@ public class Settings implements ISettings return enabledSigns; } - private List<EssentialsSign> getEnabledSigns() + private List<EssentialsSign> _getEnabledSigns() { List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>(); @@ -559,7 +576,7 @@ public class Settings implements ISettings { return config.getBoolean("economy-log-enabled", false); } - + @Override public boolean isEcoLogUpdateEnabled() { |