SQLDatabaseManager optimizations, async profile loading -t00thpick1, zreed

This commit changes our shared connection into a connection pool utility to prevent
thread locks from multiple actions attempting to access the database at the same time.
In additon,  profile loading has been moved off the main thread at login time, to
allieviate the performance issues caused by it.

Fixes #2138, Fixes #2119, Fixes #1982, Fixes #1953
This commit is contained in:
t00thpick1
2014-08-01 13:35:36 -04:00
committed by TfT_02
parent c10525ada9
commit 857e12b96e
20 changed files with 1227 additions and 1161 deletions

View File

@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
public final class Misc {
@ -112,7 +113,7 @@ public final class Misc {
if (player != null) {
UserManager.remove(player);
UserManager.addUser(player);
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
}

View File

@ -18,16 +18,12 @@ public final class UserManager {
private UserManager() {}
/**
* Add a new user.
* Track a new user.
*
* @param player The player to create a user record for
* @return the player's {@link McMMOPlayer} object
* @param mcMMOPlayer the player profile to start tracking
*/
public static McMMOPlayer addUser(Player player) {
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player);
player.setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
return mcMMOPlayer;
public static void track(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
}
/**