diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index e70577f4b..46dcb0714 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceUtil; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index fa94b0145..98065ff3e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.archery.Archery; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.CombatUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 21f7e99e6..048310813 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index c96563680..d94986f4c 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index 21bbb6bf0..152c1eeee 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index ffb36cf66..f60b1c171 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Material; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index fccd1df69..319c0ed6e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index 988160aac..2e62feddb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 59932a781..7fa2a74ee 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Material; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index c9afdb452..5674ffb30 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.SalvageManager; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index c57f8411f..29d78e72a 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index e8655b347..b4dd3727c 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 178fd05ad..b77f94c92 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index 0c2f67975..5fd09e558 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index a548ac693..607b7b83b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index b5409178e..d5fcaf060 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 65dc27b8d..484b70716 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.logging.Logger; public interface DatabaseManager { /** @@ -29,6 +30,19 @@ public interface DatabaseManager { */ public boolean removeUser(String playerName, UUID uuid); + /** + * Prints progress on long database operations + * @param convertedUsers amount of users converted so far + * @param startMillis the start time stamp in millis + * @param logger logger + */ + //TODO: Hacky fix, cleanup later + default void printProgress(int convertedUsers, long startMillis, Logger logger) { + if ((convertedUsers % getDatabaseProgressPrintInterval()) == 0) { + logger.info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / 1000))); + } + } + /** * Removes any cache used for faster lookups * Currently only used for SQL @@ -125,6 +139,12 @@ public interface DatabaseManager { boolean saveUserUUIDs(Map fetchedUUIDs); + /** + * Gets the interval in which any task that does an operation over the whole database should print progress updates to console + * @return the interval in which progress should be reported for database wide operations + */ + int getDatabaseProgressPrintInterval(); + /** * Retrieve the type of database in use. Custom databases should return CUSTOM. * diff --git a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java index 9a724e933..d4733c561 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatFileDatabaseManager.java @@ -85,6 +85,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager { }*/ } + @Override + public int getDatabaseProgressPrintInterval() { + return progressInterval; + } + public void purgePowerlessUsers() { int purgedUsers = 0; diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index fe7bf8877..2c80b3a39 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -23,7 +23,7 @@ public final class SQLDatabaseManager implements DatabaseManager { private final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver"; private final String ALL_QUERY_VERSION = "total"; private final Map cachedUserIDs = new HashMap<>(); - private String tablePrefix = pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix(); + private String tablePrefix; private DataSource miscPool; private DataSource loadPool; private DataSource savePool; @@ -37,6 +37,8 @@ public final class SQLDatabaseManager implements DatabaseManager { protected SQLDatabaseManager(mcMMO pluginRef) { this.pluginRef = pluginRef; + + tablePrefix = pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix(); purgeTime = 2630000000L * pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths(); progressInterval = 200; @@ -113,6 +115,11 @@ public final class SQLDatabaseManager implements DatabaseManager { return poolProperties; } + @Override + public int getDatabaseProgressPrintInterval() { + return progressInterval; + } + public void purgePowerlessUsers() { massUpdateLock.lock(); pluginRef.getLogger().info("Purging powerless users..."); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 12f841180..fe8493e90 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java index 9333fdeab..ed0bdf62f 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java @@ -1,18 +1,21 @@ package com.gmail.nossr50.runnables.database; import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; public class DatabaseConversionTask extends BukkitRunnable { + private final mcMMO pluginRef; private final DatabaseManager sourceDatabase; private final CommandSender sender; private final String message; - public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) { + public DatabaseConversionTask(mcMMO pluginRef, DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) { + this.pluginRef = pluginRef; this.sourceDatabase = sourceDatabase; this.sender = sender; - message = pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Finish", oldType, newType); + this.message = pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Finish", oldType, newType); } @Override 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 4388367ab..15dc0b240 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -1,19 +1,28 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; +//TODO: PUUUUUUUUUUURGE +/** + * This whole design of this thing is Jank + * The name is Jank + * Everything about this is Jank + * + * Fix this at some point in the future + */ public class FormulaConversionTask extends BukkitRunnable { private CommandSender sender; private FormulaType previousFormula; + private mcMMO pluginRef; - public FormulaConversionTask(CommandSender sender, FormulaType previousFormula) { + public FormulaConversionTask(mcMMO pluginRef, CommandSender sender, FormulaType previousFormula) { + this.pluginRef = pluginRef; this.sender = sender; this.previousFormula = previousFormula; } @@ -43,7 +52,7 @@ public class FormulaConversionTask extends BukkitRunnable { editValues(profile); } convertedUsers++; - Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); + pluginRef.getDatabaseManager().printProgress(convertedUsers, startMillis, pluginRef.getLogger()); } sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Finish", pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().toString())); diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index 997463b28..29c98ed4d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.uuid.UUIDFetcher; import org.bukkit.scheduler.BukkitRunnable; @@ -13,19 +11,19 @@ import java.util.UUID; import java.util.logging.Level; public class UUIDUpdateAsyncTask extends BukkitRunnable { - private mcMMO plugin; - private static final int MAX_LOOKUP = 100; - private static final int RATE_LIMIT = 300; - private static final long LIMIT_PERIOD = 6000; - private static final int BATCH_SIZE = MAX_LOOKUP * 3; + private mcMMO pluginRef; + private final int MAX_LOOKUP = 100; + private final int RATE_LIMIT = 300; + private final long LIMIT_PERIOD = 6000; + private final int BATCH_SIZE = MAX_LOOKUP * 3; private List userNames; private int size; private int checkedUsers; private long startMillis; - public UUIDUpdateAsyncTask(mcMMO plugin, List userNames) { - this.plugin = plugin; + public UUIDUpdateAsyncTask(mcMMO pluginRef, List userNames) { + this.pluginRef = pluginRef; this.userNames = userNames; this.checkedUsers = 0; @@ -36,7 +34,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { public void run() { size = userNames.size(); - plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size); + pluginRef.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size); List userNamesSection; Map fetchedUUIDs = new HashMap(); @@ -77,7 +75,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { } } - plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e); + pluginRef.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e); return; } @@ -85,7 +83,8 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { userNamesSection.clear(); size = userNames.size(); - Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); + pluginRef.getDatabaseManager().printProgress(checkedUsers, startMillis, pluginRef.getLogger()); + if (fetchedUUIDs.size() >= BATCH_SIZE) { pluginRef.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); fetchedUUIDs = new HashMap(); @@ -94,7 +93,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { if (fetchedUUIDs.size() == 0 || pluginRef.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { //mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); - plugin.getLogger().info("UUID upgrade completed!"); + pluginRef.getLogger().info("UUID upgrade completed!"); } } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java index 373fa8621..1385016e8 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.runnables.database; +import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.locks.ReentrantLock; public class UserPurgeTask extends BukkitRunnable { - private ReentrantLock lock = new ReentrantLock(); + private final mcMMO pluginRef; + private ReentrantLock lock; + + public UserPurgeTask(mcMMO pluginRef) { + this.pluginRef = pluginRef; + lock = new ReentrantLock(); + } @Override public void run() { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index b348d4553..c125e056a 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -180,12 +180,6 @@ public final class Misc { } } - public static void printProgress(int convertedUsers, int progressInterval, long startMillis) { - if ((convertedUsers % progressInterval) == 0) { - pluginRef.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR))); - } - } - public static String getModName(String materialName) { for (String mod : modNames) { if (materialName.contains(mod)) { diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index d85c30a02..bd26af3f0 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import net.md_5.bungee.api.ChatMessageType;