Force all kits to lowercase.

This commit is contained in:
KHobbits 2012-03-03 07:03:54 +00:00
parent 301b609e93
commit c0fa03ede2
2 changed files with 38 additions and 17 deletions

View file

@ -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 try
{ {
return (List<String>)els.get("items"); return (List<String>)kit.get("items");
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -13,6 +13,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -208,6 +209,31 @@ public class Settings implements ISettings
{ {
return config.getDouble("heal-cooldown", 0); return config.getDouble("heal-cooldown", 0);
} }
private ConfigurationSection kits;
public ConfigurationSection _getKits()
{
if (config.isConfigurationSection("kits"))
{
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false))
{
if (section.isConfigurationSection(kitItem))
{
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
@Override
public ConfigurationSection getKits()
{
return kits;
}
@Override @Override
public Map<String, Object> getKit(String name) public Map<String, Object> getKit(String name)
@ -224,16 +250,6 @@ public class Settings implements ISettings
return null; return null;
} }
@Override
public ConfigurationSection getKits()
{
if (config.isConfigurationSection("kits"))
{
return config.getConfigurationSection("kits");
}
return null;
}
@Override @Override
public ChatColor getOperatorColor() throws Exception public ChatColor getOperatorColor() throws Exception
{ {
@ -358,8 +374,9 @@ public class Settings implements ISettings
{ {
config.load(); config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds")); noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = getEnabledSigns(); enabledSigns = _getEnabledSigns();
itemSpawnBl = getItemSpawnBlacklist(); itemSpawnBl = _getItemSpawnBlacklist();
kits = _getKits();
chatFormats.clear(); chatFormats.clear();
} }
private List<Integer> itemSpawnBl = new ArrayList<Integer>(); private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -370,7 +387,7 @@ public class Settings implements ISettings
return itemSpawnBl; return itemSpawnBl;
} }
private List<Integer> getItemSpawnBlacklist() private List<Integer> _getItemSpawnBlacklist()
{ {
final List<Integer> epItemSpwn = new ArrayList<Integer>(); final List<Integer> epItemSpwn = new ArrayList<Integer>();
if (ess.getItemDb() == null) if (ess.getItemDb() == null)
@ -405,7 +422,7 @@ public class Settings implements ISettings
return enabledSigns; return enabledSigns;
} }
private List<EssentialsSign> getEnabledSigns() private List<EssentialsSign> _getEnabledSigns()
{ {
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>(); List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();