From f4ff8518c2add21c94a69c4c02a888e838a422bf Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 18 Oct 2013 16:43:37 +0200 Subject: [PATCH] Cleanup progress feedback --- .../gmail/nossr50/database/FlatfileDatabaseManager.java | 5 +---- .../com/gmail/nossr50/database/SQLDatabaseManager.java | 5 +---- .../nossr50/runnables/database/FormulaConversionTask.java | 6 ++---- src/main/java/com/gmail/nossr50/util/Misc.java | 8 +++++++- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 041d95e18..2d7787bbc 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -430,10 +430,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { e.printStackTrace(); } convertedUsers++; - if ((convertedUsers % DatabaseManager.progressInterval) == 0) { - // Can't use Bukkit.broadcastMessage because async - System.out.println(String.format("[mcMMO] Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / 1000D))); - } + Misc.printProgress(convertedUsers, progressInterval, startMillis); } } catch (Exception e) { diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index e7bf32182..ae6c10ff3 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -461,10 +461,7 @@ public final class SQLDatabaseManager implements DatabaseManager { // Ignore } convertedUsers++; - if ((convertedUsers % DatabaseManager.progressInterval) == 0) { - // Can't use Bukkit.broadcastMessage because async - System.out.println(String.format("[mcMMO] Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / 1000D))); - } + Misc.printProgress(convertedUsers, progressInterval, startMillis); } } catch (SQLException e) { diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index 781e49b93..099346561 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; public class FormulaConversionTask extends BukkitRunnable { @@ -47,10 +48,7 @@ public class FormulaConversionTask extends BukkitRunnable { editValues(profile); } convertedUsers++; - if ((convertedUsers % DatabaseManager.progressInterval) == 0) { - // Can't use Bukkit.broadcastMessage because async - System.out.println(String.format("[mcMMO] Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / 1000D))); - } + Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); } mcMMO.getFormulaManager().setPreviousFormulaType(formulaType); diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index d7f5c88a1..06cdf771c 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -22,8 +22,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; -import com.gmail.nossr50.config.Config; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.util.player.UserManager; @@ -198,6 +198,12 @@ public final class Misc { } } + public static void printProgress(int convertedUsers, int progressInterval, long startMillis) { + if ((convertedUsers % progressInterval) == 0) { + mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR))); + } + } + public static void resendChunkRadiusAt(Player player, int radius) { Chunk chunk = player.getLocation().getChunk(); int chunkX = chunk.getX();