Skip to content

Commit af2c514

Browse files
committed
Throw console warning on slow economy api call.
1 parent 3042151 commit af2c514

File tree

1 file changed

+13
-1
lines changed
  • Essentials/src/com/earth2me/essentials

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public boolean canAfford(final BigDecimal cost)
187187

188188
public boolean canAfford(final BigDecimal cost, final boolean permcheck)
189189
{
190-
if (cost.signum() <= 0)
190+
if (cost.signum() <= 0)
191191
{
192192
return true;
193193
}
@@ -393,6 +393,18 @@ public void setLastOnlineActivity(final long timestamp)
393393

394394
@Override
395395
public BigDecimal getMoney()
396+
{
397+
final long start = System.nanoTime();
398+
final BigDecimal value = _getMoney();
399+
final long elapsed = start - System.nanoTime();
400+
if (elapsed > 20000000L)
401+
{
402+
ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000);
403+
}
404+
return value;
405+
}
406+
407+
private BigDecimal _getMoney()
396408
{
397409
if (ess.getPaymentMethod().hasMethod())
398410
{

0 commit comments

Comments
 (0)