summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-12-08 15:50:50 +0000
committerKHobbits <rob@khobbits.co.uk>2012-12-08 15:51:33 +0000
commitba380e61ee332fd096fada109ca43eb072724a9e (patch)
tree9f62a444e8b5f27d94d47b3cd398c11bd647948f
parentbbc306970f8326f6d7b152da0113f06f928fca09 (diff)
downloadEssentials-ba380e61ee332fd096fada109ca43eb072724a9e.tar
Essentials-ba380e61ee332fd096fada109ca43eb072724a9e.tar.gz
Essentials-ba380e61ee332fd096fada109ca43eb072724a9e.tar.lz
Essentials-ba380e61ee332fd096fada109ca43eb072724a9e.tar.xz
Essentials-ba380e61ee332fd096fada109ca43eb072724a9e.zip
Some nice friendly messages to help debugging command costs.
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index b178f4c8e..416602c4d 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -12,6 +12,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
+import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.event.EventPriority;
@@ -189,6 +190,11 @@ public class Settings implements ISettings
final ConfigurationSection newSection = new MemoryConfiguration();
for (String command : section.getKeys(false))
{
+ PluginCommand cmd = ess.getServer().getPluginCommand(command);
+ if (cmd == null || !cmd.getPlugin().equals(ess))
+ {
+ ess.getLogger().warning("Invalid command cost. '" + command + "' is not a command handled by Essentials.");
+ }
if (section.isDouble(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
@@ -197,6 +203,24 @@ public class Settings implements ISettings
{
newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
}
+ else if (section.isString(command))
+ {
+ String costString = section.getString(command);
+ try
+ {
+ double cost = Double.parseDouble(costString.trim().replace(getCurrencySymbol(), "").replaceAll("\\W", ""));
+ newSection.set(command.toLowerCase(Locale.ENGLISH), cost);
+ }
+ catch (NumberFormatException ex)
+ {
+ ess.getLogger().warning("Invalid command cost for: " + command + " (" + costString + ")");
+ }
+
+ }
+ else
+ {
+ ess.getLogger().warning("Invalid command cost for: " + command);
+ }
}
return newSection;
}
@@ -946,12 +970,13 @@ public class Settings implements ISettings
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
-
private int mailsPerMinute;
- private int _getMailsPerMinute() {
+ private int _getMailsPerMinute()
+ {
return config.getInt("mails-per-minute", 1000);
}
+
@Override
public int getMailsPerMinute()
{