From af2c514f2a8321f94812b6e29ea435a205d4c843 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 12 May 2013 04:07:14 +0100 Subject: [PATCH] Throw console warning on slow economy api call. --- Essentials/src/com/earth2me/essentials/User.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 4b9e6e81d..51fdc694f 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -187,7 +187,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser public boolean canAfford(final BigDecimal cost, final boolean permcheck) { - if (cost.signum() <= 0) + if (cost.signum() <= 0) { return true; } @@ -393,6 +393,18 @@ public class User extends UserData implements Comparable, IReplyTo, IUser @Override public BigDecimal getMoney() + { + final long start = System.nanoTime(); + final BigDecimal value = _getMoney(); + final long elapsed = start - System.nanoTime(); + if (elapsed > 20000000L) + { + ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000); + } + return value; + } + + private BigDecimal _getMoney() { if (ess.getPaymentMethod().hasMethod()) {