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.java252
1 files changed, 229 insertions, 23 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 9dee4e990..c7a59b763 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -77,11 +77,17 @@ public class Settings implements ISettings
{
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
}
+ private int chatRadius = 0;
+
+ private int _getChatRadius()
+ {
+ return config.getInt("chat.radius", config.getInt("chat-radius", 0));
+ }
@Override
public int getChatRadius()
{
- return config.getInt("chat.radius", config.getInt("chat-radius", 0));
+ return chatRadius;
}
@Override
@@ -113,19 +119,29 @@ public class Settings implements ISettings
{
return isCommandDisabled(cmd.getName());
}
+ private Set<String> disabledCommands = new HashSet<String>();
@Override
public boolean isCommandDisabled(String label)
{
+ return disabledCommands.contains(label);
+ }
+
+ private Set<String> getDisabledCommands()
+ {
+ Set<String> disCommands = new HashSet<String>();
for (String c : config.getStringList("disabled-commands"))
{
- if (!c.equalsIgnoreCase(label))
+ disCommands.add(c.toLowerCase(Locale.ENGLISH));
+ }
+ for (String c : config.getKeys(false))
+ {
+ if (c.startsWith("disable-"))
{
- continue;
+ disCommands.add(c.substring(8).toLowerCase(Locale.ENGLISH));
}
- return true;
}
- return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
+ return disCommands;
}
@Override
@@ -175,6 +191,7 @@ public class Settings implements ISettings
}
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
}
+ private ConfigurationSection commandCosts;
@Override
public double getCommandCost(IEssentialsCommand cmd)
@@ -182,21 +199,49 @@ public class Settings implements ISettings
return getCommandCost(cmd.getName());
}
+ public ConfigurationSection _getCommandCosts()
+ {
+ if (config.isConfigurationSection("command-costs"))
+ {
+ final ConfigurationSection section = config.getConfigurationSection("command-costs");
+ final ConfigurationSection newSection = new MemoryConfiguration();
+ for (String command : section.getKeys(false))
+ {
+ if (section.isDouble(command))
+ {
+ newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
+ }
+ else if (section.isInt(command))
+ {
+ newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
+ }
+ }
+ return newSection;
+ }
+ return null;
+ }
+
@Override
- public double getCommandCost(String label)
+ public double getCommandCost(String name)
{
- double cost = config.getDouble("command-costs." + label, 0.0);
- if (cost == 0.0)
+ name = name.replace('.', '_').replace('/', '_');
+ if (commandCosts != null)
{
- cost = config.getDouble("cost-" + label, 0.0);
+ return commandCosts.getDouble(name, 0.0);
}
- return cost;
+ return 0.0;
+ }
+ private String nicknamePrefix = "~";
+
+ private String _getNicknamePrefix()
+ {
+ return config.getString("nickname-prefix", "~");
}
@Override
public String getNicknamePrefix()
{
- return config.getString("nickname-prefix", "~");
+ return nicknamePrefix;
}
@Override
@@ -240,7 +285,7 @@ public class Settings implements ISettings
public Map<String, Object> getKit(String name)
{
name = name.replace('.', '_').replace('/', '_');
- if (config.isConfigurationSection("kits"))
+ if (getKits() != null)
{
final ConfigurationSection kits = getKits();
if (kits.isConfigurationSection(name))
@@ -250,9 +295,15 @@ public class Settings implements ISettings
}
return null;
}
+ private ChatColor operatorColor = null;
@Override
- public ChatColor getOperatorColor() throws Exception
+ public ChatColor getOperatorColor()
+ {
+ return operatorColor;
+ }
+
+ private ChatColor _getOperatorColor()
{
String colorName = config.getString("ops-name-color", null);
@@ -262,7 +313,7 @@ public class Settings implements ISettings
}
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
{
- throw new Exception();
+ return null;
}
try
@@ -317,7 +368,7 @@ public class Settings implements ISettings
{
return config.getString("backup.command", null);
}
- private Map<String, MessageFormat> chatFormats = new HashMap<String, MessageFormat>();
+ private Map<String, MessageFormat> chatFormats = Collections.synchronizedMap(new HashMap<String, MessageFormat>());
@Override
public MessageFormat getChatFormat(String group)
@@ -382,9 +433,29 @@ public class Settings implements ISettings
config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = _getEnabledSigns();
+ teleportInvulnerability = _isTeleportInvulnerability();
+ disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
+ registerBackInListener = _registerBackInListener();
+ cancelAfkOnMove = _cancelAfkOnMove();
+ getFreezeAfkPlayers = _getFreezeAfkPlayers();
itemSpawnBl = _getItemSpawnBlacklist();
+ loginAttackDelay = _getLoginAttackDelay();
+ signUsePerSecond = _getSignUsePerSecond();
kits = _getKits();
chatFormats.clear();
+ changeDisplayName = _changeDisplayName();
+ disabledCommands = getDisabledCommands();
+ nicknamePrefix = _getNicknamePrefix();
+ operatorColor = _getOperatorColor();
+ changePlayerListName = _changePlayerListName();
+ configDebug = _isDebug();
+ prefixsuffixconfigured = _isPrefixSuffixConfigured();
+ addprefixsuffix = _addPrefixSuffix();
+ disablePrefix = _disablePrefix();
+ disableSuffix = _disableSuffix();
+ chatRadius = _getChatRadius();
+ commandCosts = _getCommandCosts();
+ warnOnBuildDisallow = _warnOnBuildDisallow();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -465,18 +536,30 @@ public class Settings implements ISettings
{
return config.getBoolean("spawn-if-no-home", false);
}
+ private boolean warnOnBuildDisallow;
+
+ private boolean _warnOnBuildDisallow()
+ {
+ return config.getBoolean("protect.disable.warn-on-build-disallow", false);
+ }
@Override
public boolean warnOnBuildDisallow()
{
- return config.getBoolean("protect.disable.warn-on-build-disallow", false);
+ return warnOnBuildDisallow;
}
private boolean debug = false;
+ private boolean configDebug = false;
+
+ private boolean _isDebug()
+ {
+ return config.getBoolean("debug", false);
+ }
@Override
public boolean isDebug()
{
- return debug || config.getBoolean("debug", false);
+ return debug || configDebug;
}
@Override
@@ -603,17 +686,29 @@ public class Settings implements ISettings
{
return config.getBoolean("remove-god-on-disconnect", false);
}
+ private boolean changeDisplayName = true;
+
+ private boolean _changeDisplayName()
+ {
+ return config.getBoolean("change-displayname", true);
+ }
@Override
public boolean changeDisplayName()
{
- return config.getBoolean("change-displayname", true);
+ return changeDisplayName;
+ }
+ private boolean changePlayerListName = false;
+
+ private boolean _changePlayerListName()
+ {
+ return config.getBoolean("change-playerlist", false);
}
@Override
public boolean changePlayerListName()
{
- return config.getBoolean("change-playerlist", false);
+ return changePlayerListName;
}
@Override
@@ -621,23 +716,47 @@ public class Settings implements ISettings
{
return config.getBoolean("use-bukkit-permissions", false);
}
+ private boolean prefixsuffixconfigured = false;
+ private boolean addprefixsuffix = false;
+
+ private boolean _addPrefixSuffix()
+ {
+ return config.getBoolean("add-prefix-suffix", false);
+ }
+
+ private boolean _isPrefixSuffixConfigured()
+ {
+ return config.hasProperty("add-prefix-suffix");
+ }
@Override
public boolean addPrefixSuffix()
{
- return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
+ return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
+ }
+ private boolean disablePrefix = false;
+
+ private boolean _disablePrefix()
+ {
+ return config.getBoolean("disablePrefix", false);
}
@Override
public boolean disablePrefix()
{
- return config.getBoolean("disablePrefix", false);
+ return disablePrefix;
+ }
+ private boolean disableSuffix = false;
+
+ private boolean _disableSuffix()
+ {
+ return config.getBoolean("disableSuffix", false);
}
@Override
public boolean disableSuffix()
{
- return config.getBoolean("disableSuffix", false);
+ return disableSuffix;
}
@Override
@@ -651,12 +770,30 @@ public class Settings implements ISettings
{
return config.getLong("auto-afk-kick", -1);
}
+ private boolean getFreezeAfkPlayers;
@Override
public boolean getFreezeAfkPlayers()
{
+ return getFreezeAfkPlayers;
+ }
+
+ private boolean _getFreezeAfkPlayers()
+ {
return config.getBoolean("freeze-afk-players", false);
}
+ private boolean cancelAfkOnMove;
+
+ @Override
+ public boolean cancelAfkOnMove()
+ {
+ return cancelAfkOnMove;
+ }
+
+ private boolean _cancelAfkOnMove()
+ {
+ return config.getBoolean("cancel-afk-on-move", true);
+ }
@Override
public boolean areDeathMessagesEnabled()
@@ -690,15 +827,33 @@ public class Settings implements ISettings
}
@Override
+ public boolean isWorldHomePermissions()
+ {
+ return config.getBoolean("world-home-permissions", false);
+ }
+ private boolean registerBackInListener;
+
+ @Override
public boolean registerBackInListener()
{
+ return registerBackInListener;
+ }
+
+ private boolean _registerBackInListener()
+ {
return config.getBoolean("register-back-in-listener", false);
}
+ private boolean disableItemPickupWhileAfk;
@Override
public boolean getDisableItemPickupWhileAfk()
{
- return config.getBoolean("disable-item-pickup-while-afk", true);
+ return disableItemPickupWhileAfk;
+ }
+
+ private boolean _getDisableItemPickupWhileAfk()
+ {
+ return config.getBoolean("disable-item-pickup-while-afk", false);
}
@Override
@@ -745,10 +900,61 @@ public class Settings implements ISettings
{
this.metricsEnabled = metricsEnabled;
}
+ private boolean teleportInvulnerability;
@Override
public long getTeleportInvulnerability()
{
return config.getLong("teleport-invulnerability", 0) * 1000;
}
+
+ private boolean _isTeleportInvulnerability()
+ {
+ return (config.getLong("teleport-invulnerability", 0) > 0);
+ }
+
+ @Override
+ public boolean isTeleportInvulnerability()
+ {
+ return teleportInvulnerability;
+ }
+ private long loginAttackDelay;
+
+ private long _getLoginAttackDelay()
+ {
+ return config.getLong("login-attack-delay", 0) * 1000;
+ }
+
+ @Override
+ public long getLoginAttackDelay()
+ {
+ return loginAttackDelay;
+ }
+ private int signUsePerSecond;
+
+ private int _getSignUsePerSecond()
+ {
+ final int perSec = config.getInt("sign-use-per-second", 4);
+ return perSec > 0 ? perSec : 1;
+ }
+
+ @Override
+ public int getSignUsePerSecond()
+ {
+ return signUsePerSecond;
+ }
+
+ @Override
+ public double getMaxFlySpeed()
+ {
+ double maxSpeed = config.getDouble("max-fly-speed", 1.0);
+ return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
+ }
+
+ @Override
+ public double getMaxWalkSpeed()
+ {
+ double maxSpeed = config.getDouble("max-walk-speed", 0.8);
+ return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
+ }
}