summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/Kit.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java24
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkit.java8
4 files changed, 26 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index b7a128ebc..e567673b6 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.ChatColor;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventPriority;
@@ -39,9 +40,9 @@ public interface ISettings extends IConf
double getHealCooldown();
- Object getKit(String name);
+ Map<String, Object> getKit(String name);
- Map<String, Object> getKits();
+ ConfigurationSection getKits();
String getLocale();
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java
index 53d2e8784..88816368c 100644
--- a/Essentials/src/com/earth2me/essentials/Kit.java
+++ b/Essentials/src/com/earth2me/essentials/Kit.java
@@ -5,6 +5,7 @@ import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.*;
import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@@ -15,16 +16,16 @@ public class Kit
{
try
{
- final Map<String, Object> kits = ess.getSettings().getKits();
+ final ConfigurationSection kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
- for (String kiteItem : kits.keySet())
+ for (String kiteItem : kits.getKeys(false))
{
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
{
list.append(" ").append(kiteItem);
}
}
- return list.toString();
+ return list.toString().trim();
}
catch (Exception ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 218a9163c..40fb47f6c 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -14,6 +14,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
@@ -211,23 +212,28 @@ public class Settings implements ISettings
}
@Override
- public Object getKit(String name)
+ public Map<String, Object> getKit(String name)
{
- Map<String, Object> kits = (Map<String, Object>)config.get("kits");
- for (Map.Entry<String, Object> entry : kits.entrySet())
+ name = name.replace('.', '_').replace('/', '_');
+ if (config.isConfigurationSection("kits"))
{
- if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
+ final ConfigurationSection kits = getKits();
+ if (kits.isConfigurationSection(name))
{
- return entry.getValue();
- }
+ return kits.getConfigurationSection(name).getValues(true);
+ }
}
return null;
}
@Override
- public Map<String, Object> getKits()
+ public ConfigurationSection getKits()
{
- return (Map<String, Object>)config.get("kits");
+ if (config.isConfigurationSection("kits"))
+ {
+ return config.getConfigurationSection("kits");
+ }
+ return null;
}
@Override
@@ -328,7 +334,7 @@ public class Settings implements ISettings
@Override
public IText getAnnounceNewPlayerFormat()
{
- return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
+ return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
}
@Override
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
index c003d28ac..aee0af910 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
@@ -32,16 +32,16 @@ public class Commandkit extends EssentialsCommand
else
{
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
- final Object kit = ess.getSettings().getKit(kitName);
+ final Map<String, Object> kit = ess.getSettings().getKit(kitName);
if (!user.isAuthorized("essentials.kit." + kitName))
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
- final Map<String, Object> els = (Map<String, Object>)kit;
- final List<String> items = Kit.getItems(user, els);
+
+ final List<String> items = Kit.getItems(user, kit);
- Kit.checkTime(user, kitName, els);
+ Kit.checkTime(user, kitName, kit);
final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(user);