Cleanup progress feedback

This commit is contained in:
TfT_02 2013-10-18 16:43:37 +02:00
parent dbd27b641e
commit f4ff8518c2
4 changed files with 11 additions and 13 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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();