diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-03-03 07:03:54 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-03-05 08:35:48 +0000 |
commit | 619e099a04a8453365121865cb587447be8174a2 (patch) | |
tree | 7a15a2cd8e7d1ae241e54b2f0727bf21d69c625c | |
parent | faba1e3604808a46c78bb74d8890351ab49ddb5a (diff) | |
download | Essentials-619e099a04a8453365121865cb587447be8174a2.tar Essentials-619e099a04a8453365121865cb587447be8174a2.tar.gz Essentials-619e099a04a8453365121865cb587447be8174a2.tar.lz Essentials-619e099a04a8453365121865cb587447be8174a2.tar.xz Essentials-619e099a04a8453365121865cb587447be8174a2.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() { |