WIP of reworking classes involved in querying data, also some work done to the party code rewrite

This commit is contained in:
nossr50
2020-10-15 16:19:47 -07:00
parent 9e450adb0b
commit cf245b02a5
62 changed files with 649 additions and 650 deletions

View File

@@ -31,7 +31,7 @@ public class FormulaConversionTask extends BukkitRunnable {
// If the mmoPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mmoPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
profile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(playerName, false);
if (!profile.isLoaded()) {
mcMMO.p.debug("Profile not loaded.");

View File

@@ -41,33 +41,32 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
return;
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply
if (profile.isLoaded()) {
try {
PlayerProfile profile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(player.getUniqueId());
new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
EventUtils.callPlayerProfileLoadEvent(player, profile);
return;
} catch () {
// Print errors to console/logs if we're failing at least 2 times in a row to load the profile
if (attempt >= 3)
{
//Log the error
mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice",
player.getName(), String.valueOf(attempt)));
//Notify the admins
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
//Notify the player
player.sendMessage(LocaleLoader.getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n"));
}
// Increment attempt counter and try
attempt++;
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100)));
}
// Print errors to console/logs if we're failing at least 2 times in a row to load the profile
if (attempt >= 3)
{
//Log the error
mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice",
player.getName(), String.valueOf(attempt)));
//Notify the admins
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
//Notify the player
player.sendMessage(LocaleLoader.getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n"));
}
// Increment attempt counter and try
attempt++;
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100)));
}
private class ApplySuccessfulProfile extends BukkitRunnable {
@@ -86,7 +85,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
return;
}
mmoPlayer.setupPartyData();
mcMMO.getUserManager().track(mmoPlayer);
mmoPlayer.actualizeRespawnATS();

View File

@@ -39,9 +39,9 @@ public class AlchemyBrewTask extends BukkitRunnable {
if (player != null
&& !Misc.isNPCEntityExcludingVillagers(player)
&& Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS)
&& mcMMO.getUserManager().getPlayer(player) != null) {
&& mcMMO.getUserManager().queryMcMMOPlayer(player) != null) {
double catalysis = mcMMO.getUserManager().getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
double catalysis = mcMMO.getUserManager().queryMcMMOPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
mcMMO.p.getServer().getPluginManager().callEvent(event);