summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-05-12 04:32:56 +0100
committerKHobbits <rob@khobbits.co.uk>2013-05-12 16:10:41 +0100
commit8ebe55a2944560446e798fe40f7c39ce2b3c2b26 (patch)
tree6ea5388cf6711f0dde8788078e618fe0bdb8b831
parentaf2c514f2a8321f94812b6e29ea435a205d4c843 (diff)
downloadEssentials-8ebe55a2944560446e798fe40f7c39ce2b3c2b26.tar
Essentials-8ebe55a2944560446e798fe40f7c39ce2b3c2b26.tar.gz
Essentials-8ebe55a2944560446e798fe40f7c39ce2b3c2b26.tar.lz
Essentials-8ebe55a2944560446e798fe40f7c39ce2b3c2b26.tar.xz
Essentials-8ebe55a2944560446e798fe40f7c39ce2b3c2b26.zip
Make the lag warning configurable, useful to debug economy lag on larger servers.
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java48
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java6
4 files changed, 52 insertions, 16 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index 121d72c14..5ce948027 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -44,7 +44,7 @@ public interface ISettings extends IConf
double getHealCooldown();
Set<String> getSocialSpyCommands();
-
+
Map<String, Object> getKit(String name);
ConfigurationSection getKits();
@@ -142,7 +142,7 @@ public interface ISettings extends IConf
boolean getFreezeAfkPlayers();
boolean cancelAfkOnMove();
-
+
boolean cancelAfkOnInteract();
boolean areDeathMessagesEnabled();
@@ -152,7 +152,7 @@ public interface ISettings extends IConf
Set<String> getNoGodWorlds();
boolean getUpdateBedAtDaytime();
-
+
boolean allowUnsafeEnchantments();
boolean getRepairEnchanted();
@@ -187,9 +187,11 @@ public interface ISettings extends IConf
public int getMailsPerMinute();
+ public long getEconomyLagWarning();
+
public void setEssentialsChatActive(boolean b);
long getMaxTempban();
-
+
public Map<String, Object> getListGroupConfig();
}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 2b0c9249f..f8b381b21 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -454,22 +454,25 @@ public class Settings implements ISettings
{
return config.getBoolean("per-warp-permission", false);
}
-
+
@Override
public Map<String, Object> getListGroupConfig()
{
if (config.isConfigurationSection("list"))
- {
+ {
Map<String, Object> values = config.getConfigurationSection("list").getValues(false);
- if (!values.isEmpty()) {
+ if (!values.isEmpty())
+ {
return values;
}
}
Map<String, Object> defaultMap = new HashMap<String, Object>();
- if (config.getBoolean("sort-list-by-groups", false)) {
+ if (config.getBoolean("sort-list-by-groups", false))
+ {
defaultMap.put("ListByGroup", "ListByGroup");
}
- else {
+ else
+ {
defaultMap.put("Players", "*");
}
return defaultMap;
@@ -510,6 +513,9 @@ public class Settings implements ISettings
mailsPerMinute = _getMailsPerMinute();
maxMoney = _getMaxMoney();
minMoney = _getMinMoney();
+ economyLagWarning = _getEconomyLagWarning();
+ economyLog = _isEcoLogEnabled();
+ economyLogUpdate = _isEcoLogUpdateEnabled();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -636,12 +642,14 @@ public class Settings implements ISettings
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
}
+ // #easteregg
@Override
public boolean isTradeInStacks(int id)
{
return config.getBoolean("trade-in-stacks-" + id, false);
}
+ // #easteregg
@Override
public boolean isEcoDisabled()
{
@@ -721,16 +729,29 @@ public class Settings implements ISettings
{
return minMoney;
}
+ private boolean economyLog = false;
@Override
public boolean isEcoLogEnabled()
{
+ return economyLog;
+ }
+
+ public boolean _isEcoLogEnabled()
+ {
return config.getBoolean("economy-log-enabled", false);
}
+ // #easteregg
+ private boolean economyLogUpdate = false;
@Override
public boolean isEcoLogUpdateEnabled()
{
+ return economyLogUpdate;
+ }
+
+ public boolean _isEcoLogUpdateEnabled()
+ {
return config.getBoolean("economy-log-update-enabled", false);
}
@@ -794,6 +815,7 @@ public class Settings implements ISettings
{
return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
}
+ // #easteregg
private boolean disablePrefix = false;
private boolean _disablePrefix()
@@ -806,6 +828,7 @@ public class Settings implements ISettings
{
return disablePrefix;
}
+ // #easteregg
private boolean disableSuffix = false;
private boolean _disableSuffix()
@@ -1035,8 +1058,6 @@ 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()
{
@@ -1055,6 +1076,19 @@ public class Settings implements ISettings
{
return mailsPerMinute;
}
+ // #easteregg
+ private long economyLagWarning;
+
+ private long _getEconomyLagWarning()
+ {
+ return config.getLong("economy-lag-warning", 20000000L); // Default to 20ms
+ }
+
+ @Override
+ public long getEconomyLagWarning()
+ {
+ return economyLagWarning;
+ }
@Override
public long getMaxTempban()
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index 51fdc694f..3f310b0ea 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -396,8 +396,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
final long start = System.nanoTime();
final BigDecimal value = _getMoney();
- final long elapsed = start - System.nanoTime();
- if (elapsed > 20000000L)
+ final long elapsed = System.nanoTime() - start;
+ if (elapsed > ess.getSettings().getEconomyLagWarning())
{
ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000);
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
index 6ca916f11..b8ba3100b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
@@ -106,7 +106,7 @@ public class Commandbalancetop extends EssentialsCommand
{
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
- cache.getLines().clear();
+ cache.getLines().clear();
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
BigDecimal totalMoney = BigDecimal.ZERO;
for (String u : ess.getUserMap().getAllUniqueUsers())
@@ -130,7 +130,7 @@ public class Commandbalancetop extends EssentialsCommand
return entry2.getValue().compareTo(entry1.getValue());
}
});
-
+
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
int pos = 1;
for (Map.Entry<String, BigDecimal> entry : sortedEntries)
@@ -179,7 +179,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
- ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, force), force));
+ ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force));
}
}
}