summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java34
-rw-r--r--Essentials/src/messages.properties2
-rw-r--r--Essentials/src/messages_da.properties2
-rw-r--r--Essentials/src/messages_de.properties2
-rw-r--r--Essentials/src/messages_en.properties2
-rw-r--r--Essentials/src/messages_es.properties2
-rw-r--r--Essentials/src/messages_fr.properties2
-rw-r--r--Essentials/src/messages_nl.properties2
8 files changed, 30 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
index 2212f4664..e6e60ded5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
+import java.text.DateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -16,7 +17,7 @@ public class Commandbalancetop extends EssentialsCommand
{
super("balancetop");
}
- private static final int CACHETIME = 5 * 60 * 1000;
+ private static final int CACHETIME = 2 * 60 * 1000;
public static final int MINUSERS = 50;
private static List<String> cache = new ArrayList<String>();
private static long cacheage = 0;
@@ -26,6 +27,7 @@ public class Commandbalancetop extends EssentialsCommand
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
int max = 10;
+ boolean force = false;
if (args.length > 0)
{
try
@@ -37,11 +39,13 @@ public class Commandbalancetop extends EssentialsCommand
}
catch (NumberFormatException ex)
{
- //catch it because they tried to enter a string not number.
+ if (args[0].equalsIgnoreCase("force") && sender.isOp()) {
+ force = true;
+ }
}
}
- if (lock.readLock().tryLock())
+ if (!force && lock.readLock().tryLock())
{
try
{
@@ -59,7 +63,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
- ess.scheduleAsyncDelayedTask(new Viewer(sender, max));
+ ess.scheduleAsyncDelayedTask(new Viewer(sender, max, force));
}
else
{
@@ -67,14 +71,17 @@ public class Commandbalancetop extends EssentialsCommand
{
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
}
- ess.scheduleAsyncDelayedTask(new Viewer(sender, max));
+ ess.scheduleAsyncDelayedTask(new Viewer(sender, max, force));
}
}
private static void outputCache(final CommandSender sender, int max)
{
- sender.sendMessage(_("balanceTop", max));
+ final Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(cacheage);
+ final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+ sender.sendMessage(_("balanceTop", max, format.format(cal.getTime())));
for (String line : cache)
{
if (max == 0)
@@ -90,10 +97,12 @@ public class Commandbalancetop extends EssentialsCommand
private class Calculator implements Runnable
{
private final transient Viewer viewer;
+ private final boolean force;
- public Calculator(final Viewer viewer)
+ public Calculator(final Viewer viewer, final boolean force)
{
this.viewer = viewer;
+ this.force = force;
}
@Override
@@ -102,8 +111,9 @@ public class Commandbalancetop extends EssentialsCommand
lock.writeLock().lock();
try
{
- if (cacheage < System.currentTimeMillis() - 5 * 60 * 1000)
+ if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
+ cache.clear();
final Map<String, Double> balances = new HashMap<String, Double>();
for (String u : ess.getUserMap().getAllUniqueUsers())
{
@@ -149,11 +159,13 @@ public class Commandbalancetop extends EssentialsCommand
{
private final transient CommandSender sender;
private final transient int max;
+ private final transient boolean force;
- public Viewer(final CommandSender sender, final int max)
+ public Viewer(final CommandSender sender, final int max, final boolean force)
{
this.sender = sender;
this.max = max;
+ this.force = force;
}
@Override
@@ -162,7 +174,7 @@ public class Commandbalancetop extends EssentialsCommand
lock.readLock().lock();
try
{
- if (cacheage > System.currentTimeMillis() - 5 * 60 * 1000)
+ if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
{
outputCache(sender, max);
return;
@@ -172,7 +184,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
- ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, max)));
+ ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, max, force), force));
}
}
}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 5a4c67173..387e07375 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Returning to previous location.
backupFinished=Backup finished
backupStarted=Backup started
balance=\u00a77Balance: {0}
-balanceTop=\u00a77Top {0} balances
+balanceTop=\u00a77Top {0} balances ({1})
banExempt=\u00a7cYou can not ban that player.
banIpAddress=\u00a77Banned IP address
bannedIpsFileError=Error reading banned-ips.txt
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 4dcd2f24a..0178410ec 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Returnere til tidligere placering.
backupFinished=Backup sluttede
backupStarted=Backup startede
balance=\u00a77Balance: {0}
-balanceTop=\u00a77 Top {0} saldi
+balanceTop=\u00a77 Top {0} saldi ({1})
banExempt=\u00a7cDu kan ikke forbyde den p\u00e5g\u00e6ldende spiller.
banIpAddress=\u00a77Bannede IP addresse
bannedIpsFileError=Fejl i l\u00e6sning af banned-ips.txt
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 9cc72bff2..783411356 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Kehre zur letzten Position zur\u00fcck.
backupFinished=Backup beendet
backupStarted=Backup gestartet
balance=\u00a77Geldb\u00f6rse: {0}
-balanceTop=\u00a77 Top {0} Guthaben
+balanceTop=\u00a77 Top {0} Guthaben ({1})
banExempt=\u00a7cDu kannst diesen Spieler nicht sperren.
banIpAddress=\u00a77IP-Adresse gesperrt.
bannedIpsFileError=Fehler beim Lesen von banned-ips.txt
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 704cdfb68..a90364ca6 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Returning to previous location.
backupFinished=Backup finished
backupStarted=Backup started
balance=\u00a77Balance: {0}
-balanceTop=\u00a77 Top {0} balances
+balanceTop=\u00a77 Top {0} balances ({1})
banExempt=\u00a7cYou can not ban that player.
banIpAddress=\u00a77Banned IP address
bannedIpsFileError=Error reading banned-ips.txt
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index c2d6b6ec3..e1e78aa1d 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Volviendo a la localizacion anterior.
backupFinished=Copia de seguridad completada
backupStarted=Comenzando copia de seguridad
balance=\u00a77Cantidad: {0}
-balanceTop=\u00a77Top {0} cantidades
+balanceTop=\u00a77Top {0} cantidades ({1})
banExempt=\u00a7cNo puedes banear a ese jugador
banIpAddress=\u00a77Direccion IP baneada
bannedIpsFileError=Error leyendo banned-ips.txt
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index ae8845bc6..22a093ec5 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Retour \u00e0 votre emplacement pr\u00e9c\u00c3\u00a8dent.
backupFinished=Sauvegarde termin\u00e9
backupStarted=D\u00e9but de la sauvegarde
balance=\u00a77Solde : {0}
-balanceTop=\u00a77 Meilleurs {0} soldes
+balanceTop=\u00a77 Meilleurs {0} soldes ({1})
banExempt=\u00a77Vous ne pouvez pas bannir ce joueur.
banIpAddress=\u00a77Adresse IP bannie
bannedIpsFileError=Erreur de lecture de banned-ips.txt
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 73a88cbb5..efcdf3716 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -15,7 +15,7 @@ backUsageMsg=\u00a77Naar de vorige locatie aan het gaan.
backupFinished=Backup voltooid
backupStarted=Backup gestart
balance=\u00a77Saldo: {0}
-balanceTop=\u00a77 Top {0} saldi
+balanceTop=\u00a77 Top {0} saldi ({1})
banExempt=\u00a77Je kunt deze speler niet verbannen.
banIpAddress=\u00a77Verbannen IP-adres
bannedIpsFileError=Fout bij het lezen van banned-ips.txt