summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/Settings.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/Settings.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java90
1 files changed, 88 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index fff129d52..95123d051 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 (command.charAt(0) == '/')
+ {
+ ess.getLogger().warning("Invalid command cost. '" + command + "' should not start with '/'.");
+ }
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;
}
@@ -213,6 +237,31 @@ public class Settings implements ISettings
}
return 0.0;
}
+ private Set<String> socialSpyCommands = new HashSet<String>();
+
+ public Set<String> _getSocialSpyCommands()
+ {
+ Set<String> socialspyCommands = new HashSet<String>();
+
+ if (config.isConfigurationSection("socialspy-commands"))
+ {
+ for (String c : config.getStringList("socialspy-commands"))
+ {
+ socialspyCommands.add(c.toLowerCase(Locale.ENGLISH));
+ }
+ }
+ else
+ {
+ socialspyCommands.addAll(Arrays.asList("msg", "r", "mail", "m", "whisper", "emsg", "t", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm"));
+ }
+
+ return socialspyCommands;
+ }
+
+ public Set<String> getSocialSpyCommands()
+ {
+ return socialSpyCommands;
+ }
private String nicknamePrefix = "~";
private String _getNicknamePrefix()
@@ -438,7 +487,9 @@ public class Settings implements ISettings
disableSuffix = _disableSuffix();
chatRadius = _getChatRadius();
commandCosts = _getCommandCosts();
+ socialSpyCommands = _getSocialSpyCommands();
warnOnBuildDisallow = _warnOnBuildDisallow();
+ mailsPerMinute = _getMailsPerMinute();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -557,6 +608,8 @@ public class Settings implements ISettings
return config.getString("locale", "");
}
+ //This method should always only return one character due to the implementation of the calling methods
+ //If you need to use a string currency, for example "coins", use the translation key 'currency'.
@Override
public String getCurrencySymbol()
{
@@ -695,6 +748,7 @@ public class Settings implements ISettings
}
private boolean prefixsuffixconfigured = false;
private boolean addprefixsuffix = false;
+ private boolean essentialsChatActive = false;
private boolean _addPrefixSuffix()
{
@@ -707,9 +761,15 @@ public class Settings implements ISettings
}
@Override
+ public void setEssentialsChatActive(boolean essentialsChatActive)
+ {
+ this.essentialsChatActive = essentialsChatActive;
+ }
+
+ @Override
public boolean addPrefixSuffix()
{
- return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
+ return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
}
private boolean disablePrefix = false;
@@ -796,6 +856,12 @@ public class Settings implements ISettings
{
return config.getBoolean("repair-enchanted", true);
}
+
+ @Override
+ public boolean allowUnsafeEnchantments()
+ {
+ return config.getBoolean("unsafe-enchantments", false);
+ }
@Override
public boolean isWorldTeleportPermissions()
@@ -863,7 +929,7 @@ public class Settings implements ISettings
@Override
public long getTpaAcceptCancellation()
{
- return config.getLong("tpa-accept-cancellation", 0);
+ return config.getLong("tpa-accept-cancellation", 120);
}
@Override
@@ -928,10 +994,30 @@ public class Settings implements ISettings
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
+ //This option does not exist in the config.yml because it wasn't yet implemented in bukkit
+ //The code was commented out in the /speed command
@Override
public double getMaxWalkSpeed()
{
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
+ private int mailsPerMinute;
+
+ private int _getMailsPerMinute()
+ {
+ return config.getInt("mails-per-minute", 1000);
+ }
+
+ @Override
+ public int getMailsPerMinute()
+ {
+ return mailsPerMinute;
+ }
+
+ @Override
+ public long getMaxTempban()
+ {
+ return config.getLong("max-tempban-time", -1);
+ }
}