Skip to content

Commit 8ebe55a

Browse files
committed
Make the lag warning configurable, useful to debug economy lag on larger servers.
1 parent af2c514 commit 8ebe55a

File tree

4 files changed

+52
-16
lines changed

4 files changed

+52
-16
lines changed

Essentials/src/com/earth2me/essentials/ISettings.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public interface ISettings extends IConf
4444
double getHealCooldown();
4545

4646
Set<String> getSocialSpyCommands();
47-
47+
4848
Map<String, Object> getKit(String name);
4949

5050
ConfigurationSection getKits();
@@ -142,7 +142,7 @@ public interface ISettings extends IConf
142142
boolean getFreezeAfkPlayers();
143143

144144
boolean cancelAfkOnMove();
145-
145+
146146
boolean cancelAfkOnInteract();
147147

148148
boolean areDeathMessagesEnabled();
@@ -152,7 +152,7 @@ public interface ISettings extends IConf
152152
Set<String> getNoGodWorlds();
153153

154154
boolean getUpdateBedAtDaytime();
155-
155+
156156
boolean allowUnsafeEnchantments();
157157

158158
boolean getRepairEnchanted();
@@ -187,9 +187,11 @@ public interface ISettings extends IConf
187187

188188
public int getMailsPerMinute();
189189

190+
public long getEconomyLagWarning();
191+
190192
public void setEssentialsChatActive(boolean b);
191193

192194
long getMaxTempban();
193-
195+
194196
public Map<String, Object> getListGroupConfig();
195197
}

Essentials/src/com/earth2me/essentials/Settings.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,25 @@ public boolean getPerWarpPermission()
454454
{
455455
return config.getBoolean("per-warp-permission", false);
456456
}
457-
457+
458458
@Override
459459
public Map<String, Object> getListGroupConfig()
460460
{
461461
if (config.isConfigurationSection("list"))
462-
{
462+
{
463463
Map<String, Object> values = config.getConfigurationSection("list").getValues(false);
464-
if (!values.isEmpty()) {
464+
if (!values.isEmpty())
465+
{
465466
return values;
466467
}
467468
}
468469
Map<String, Object> defaultMap = new HashMap<String, Object>();
469-
if (config.getBoolean("sort-list-by-groups", false)) {
470+
if (config.getBoolean("sort-list-by-groups", false))
471+
{
470472
defaultMap.put("ListByGroup", "ListByGroup");
471473
}
472-
else {
474+
else
475+
{
473476
defaultMap.put("Players", "*");
474477
}
475478
return defaultMap;
@@ -510,6 +513,9 @@ public void reloadConfig()
510513
mailsPerMinute = _getMailsPerMinute();
511514
maxMoney = _getMaxMoney();
512515
minMoney = _getMinMoney();
516+
economyLagWarning = _getEconomyLagWarning();
517+
economyLog = _isEcoLogEnabled();
518+
economyLogUpdate = _isEcoLogUpdateEnabled();
513519
}
514520
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
515521

@@ -636,12 +642,14 @@ public String getCurrencySymbol()
636642
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
637643
}
638644

645+
// #easteregg
639646
@Override
640647
public boolean isTradeInStacks(int id)
641648
{
642649
return config.getBoolean("trade-in-stacks-" + id, false);
643650
}
644651

652+
// #easteregg
645653
@Override
646654
public boolean isEcoDisabled()
647655
{
@@ -721,15 +729,28 @@ public BigDecimal getMinMoney()
721729
{
722730
return minMoney;
723731
}
732+
private boolean economyLog = false;
724733

725734
@Override
726735
public boolean isEcoLogEnabled()
736+
{
737+
return economyLog;
738+
}
739+
740+
public boolean _isEcoLogEnabled()
727741
{
728742
return config.getBoolean("economy-log-enabled", false);
729743
}
744+
// #easteregg
745+
private boolean economyLogUpdate = false;
730746

731747
@Override
732748
public boolean isEcoLogUpdateEnabled()
749+
{
750+
return economyLogUpdate;
751+
}
752+
753+
public boolean _isEcoLogUpdateEnabled()
733754
{
734755
return config.getBoolean("economy-log-update-enabled", false);
735756
}
@@ -794,6 +815,7 @@ public boolean addPrefixSuffix()
794815
{
795816
return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
796817
}
818+
// #easteregg
797819
private boolean disablePrefix = false;
798820

799821
private boolean _disablePrefix()
@@ -806,6 +828,7 @@ public boolean disablePrefix()
806828
{
807829
return disablePrefix;
808830
}
831+
// #easteregg
809832
private boolean disableSuffix = false;
810833

811834
private boolean _disableSuffix()
@@ -1035,8 +1058,6 @@ public double getMaxFlySpeed()
10351058
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
10361059
}
10371060

1038-
//This option does not exist in the config.yml because it wasn't yet implemented in bukkit
1039-
//The code was commented out in the /speed command
10401061
@Override
10411062
public double getMaxWalkSpeed()
10421063
{
@@ -1055,6 +1076,19 @@ public int getMailsPerMinute()
10551076
{
10561077
return mailsPerMinute;
10571078
}
1079+
// #easteregg
1080+
private long economyLagWarning;
1081+
1082+
private long _getEconomyLagWarning()
1083+
{
1084+
return config.getLong("economy-lag-warning", 20000000L); // Default to 20ms
1085+
}
1086+
1087+
@Override
1088+
public long getEconomyLagWarning()
1089+
{
1090+
return economyLagWarning;
1091+
}
10581092

10591093
@Override
10601094
public long getMaxTempban()

Essentials/src/com/earth2me/essentials/User.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ public BigDecimal getMoney()
396396
{
397397
final long start = System.nanoTime();
398398
final BigDecimal value = _getMoney();
399-
final long elapsed = start - System.nanoTime();
400-
if (elapsed > 20000000L)
399+
final long elapsed = System.nanoTime() - start;
400+
if (elapsed > ess.getSettings().getEconomyLagWarning())
401401
{
402402
ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000);
403403
}

Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void run()
106106
{
107107
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
108108
{
109-
cache.getLines().clear();
109+
cache.getLines().clear();
110110
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
111111
BigDecimal totalMoney = BigDecimal.ZERO;
112112
for (String u : ess.getUserMap().getAllUniqueUsers())
@@ -130,7 +130,7 @@ public int compare(final Entry<String, BigDecimal> entry1, final Entry<String, B
130130
return entry2.getValue().compareTo(entry1.getValue());
131131
}
132132
});
133-
133+
134134
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
135135
int pos = 1;
136136
for (Map.Entry<String, BigDecimal> entry : sortedEntries)
@@ -179,7 +179,7 @@ public void run()
179179
{
180180
lock.readLock().unlock();
181181
}
182-
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, force), force));
182+
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force));
183183
}
184184
}
185185
}

0 commit comments

Comments
 (0)