mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Numerous tweaks + failsafes added to Loading/Saving of players
This commit is contained in:
parent
f1204f8a2a
commit
426b1304e2
@ -7,6 +7,15 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
|
Version 2.1.40
|
||||||
|
Added new locale string "Profile.Loading.FailureNotice"
|
||||||
|
Added new locale string "Profile.Loading.FailurePlayer"
|
||||||
|
mcMMO no longer gives up forever if a player profile fails to load and the player is still online
|
||||||
|
mcMMO will attempt to save a profile up to 10 times now, previously it would only try one time.
|
||||||
|
Player data for mcMMO is now loaded 3 seconds after a player connects in order to give any ongoing save tasks from other servers a small grace period to finish. This will mostly be useful to Bungee servers.
|
||||||
|
|
||||||
|
NOTES: I received reports from some users saying that saving and loading was failing could fail and not recover, I have implemented some fail safes to greatly reduce the the odds of that happening.
|
||||||
|
|
||||||
Version 2.1.39
|
Version 2.1.39
|
||||||
Salvaging an item should now only play the item break sound (was playing the anvil sound simultaneously before)
|
Salvaging an item should now only play the item break sound (was playing the anvil sound simultaneously before)
|
||||||
Fixed bug where Tall_Grass was not giving full XP
|
Fixed bug where Tall_Grass was not giving full XP
|
||||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.39</version>
|
<version>2.1.40-SNAPSHOT</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -13,6 +13,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
|||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,6 +30,7 @@ public class PlayerProfile {
|
|||||||
/* HUDs */
|
/* HUDs */
|
||||||
private MobHealthbarType mobHealthbarType;
|
private MobHealthbarType mobHealthbarType;
|
||||||
private int scoreboardTipsShown;
|
private int scoreboardTipsShown;
|
||||||
|
private int saveAttempts = 0;
|
||||||
|
|
||||||
/* Skill Data */
|
/* Skill Data */
|
||||||
private final Map<PrimarySkillType, Integer> skills = new HashMap<PrimarySkillType, Integer>(); // Skill & Level
|
private final Map<PrimarySkillType, Integer> skills = new HashMap<PrimarySkillType, Integer>(); // Skill & Level
|
||||||
@ -36,7 +38,7 @@ public class PlayerProfile {
|
|||||||
private final Map<SuperAbilityType, Integer> abilityDATS = new HashMap<SuperAbilityType, Integer>(); // Ability & Cooldown
|
private final Map<SuperAbilityType, Integer> abilityDATS = new HashMap<SuperAbilityType, Integer>(); // Ability & Cooldown
|
||||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
private final Map<UniqueDataType, Integer> uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||||
|
|
||||||
// Store previous XP gains for deminished returns
|
// Store previous XP gains for diminished returns
|
||||||
private DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<SkillXpGain>();
|
private DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<SkillXpGain>();
|
||||||
private HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<PrimarySkillType, Float>();
|
private HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<PrimarySkillType, Float>();
|
||||||
|
|
||||||
@ -94,8 +96,13 @@ public class PlayerProfile {
|
|||||||
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
|
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void scheduleAsyncSaveDelay() {
|
||||||
|
new PlayerProfileSaveTask(this).runTaskLaterAsynchronously(mcMMO.p, 20);
|
||||||
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (!changed || !loaded) {
|
if (!changed || !loaded) {
|
||||||
|
saveAttempts = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +111,29 @@ public class PlayerProfile {
|
|||||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
mcMMO.p.getLogger().warning("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
mcMMO.p.getLogger().severe("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
||||||
|
|
||||||
|
if(saveAttempts > 0)
|
||||||
|
{
|
||||||
|
mcMMO.p.getLogger().severe("Attempted to save profile for player "+getPlayerName()
|
||||||
|
+ " resulted in failure. "+saveAttempts+" have been made so far.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(saveAttempts < 10)
|
||||||
|
{
|
||||||
|
saveAttempts++;
|
||||||
|
scheduleAsyncSaveDelay();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mcMMO.p.getLogger().severe("mcMMO has failed to save the profile for "
|
||||||
|
+getPlayerName()+" numerous times." +
|
||||||
|
" mcMMO will now stop attempting to save this profile." +
|
||||||
|
" Check your console for errors and inspect your DB for issues.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
saveAttempts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
|
@ -484,7 +484,8 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
|
||||||
|
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
|
||||||
|
|
||||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||||
Motd.displayAll(player);
|
Motd.displayAll(player);
|
||||||
|
@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class PlayerProfileLoadingTask extends BukkitRunnable {
|
public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||||
private static final int MAX_TRIES = 5;
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private int attempt = 0;
|
private int attempt = 0;
|
||||||
|
|
||||||
@ -37,9 +36,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment attempt counter and try
|
|
||||||
attempt++;
|
|
||||||
|
|
||||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
||||||
// If successful, schedule the apply
|
// If successful, schedule the apply
|
||||||
if (profile.isLoaded()) {
|
if (profile.isLoaded()) {
|
||||||
@ -47,14 +43,24 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've failed five times, give up
|
// Print errors to console/logs if we're failing at least 2 times in a row to load the profile
|
||||||
if (attempt >= MAX_TRIES) {
|
if (attempt >= 3)
|
||||||
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + player.getName());
|
{
|
||||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.AdminFailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
//Log the error
|
||||||
player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
|
mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice",
|
||||||
return;
|
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"));
|
||||||
}
|
}
|
||||||
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, 100 * attempt);
|
|
||||||
|
// Increment attempt counter and try
|
||||||
|
attempt++;
|
||||||
|
|
||||||
|
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||||
@ -90,7 +96,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
player.sendMessage(LocaleLoader.getString("Profile.Loading.Success"));
|
player.sendMessage(LocaleLoader.getString("Profile.Loading.Success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,11 @@ public class PlayerProfileSaveTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
playerProfile.save();
|
boolean saveSuccess = playerProfile.save();
|
||||||
|
|
||||||
|
if(!saveSuccess)
|
||||||
|
{
|
||||||
|
playerProfile.scheduleAsyncSaveDelay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,8 +1069,8 @@ Scoreboard.Misc.Overall=[[GOLD]]Overall
|
|||||||
Scoreboard.Misc.Ability=Ability
|
Scoreboard.Misc.Ability=Ability
|
||||||
#DATABASE RECOVERY
|
#DATABASE RECOVERY
|
||||||
Profile.Loading.Success=[[GREEN]]Your mcMMO profile has been loaded.
|
Profile.Loading.Success=[[GREEN]]Your mcMMO profile has been loaded.
|
||||||
Profile.Loading.Failure=[[RED]]mcMMO still cannot load your data. You may want to [[AQUA]]contact the server owner.\n[[YELLOW]]You can still play on the server, but you will have [[BOLD]]no mcMMO levels[[YELLOW]] and any XP you get [[BOLD]]will not be saved[[YELLOW]].
|
Profile.Loading.FailurePlayer=[[RED]]mcMMO is having trouble loading your data, we have attempted to load it [[GREEN]]{0}[[RED]] times.[[LIGHT_GRAY]] You may want to contact the server admins about this issue. mcMMO will attempt to load your data until you disconnect, you will not gain XP or be able to use skills while the data is not loaded.
|
||||||
Profile.Loading.AdminFailureNotice=[[DARK_RED]][A][[RED]] mcMMO was unable to load the player data for [[YELLOW]]{0}[[RED]]. [[LIGHT_PURPLE]]Please inspect your database setup.
|
Profile.Loading.FailureNotice=[[DARK_RED]][A][[RED]] mcMMO was unable to load the player data for [[YELLOW]]{0}[[RED]]. [[LIGHT_PURPLE]]Please inspect your database setup. Attempts made so far {1}.
|
||||||
#Holiday
|
#Holiday
|
||||||
Holiday.AprilFools.Levelup=[[GOLD]]{0} is now level [[GREEN]]{1}[[GOLD]]!
|
Holiday.AprilFools.Levelup=[[GOLD]]{0} is now level [[GREEN]]{1}[[GOLD]]!
|
||||||
Holiday.Anniversary=[[BLUE]]Happy {0} Year Anniversary!\n[[BLUE]]In honor of all of nossr50's work and all the devs, here's a firework show!
|
Holiday.Anniversary=[[BLUE]]Happy {0} Year Anniversary!\n[[BLUE]]In honor of all of nossr50's work and all the devs, here's a firework show!
|
||||||
|
Loading…
Reference in New Issue
Block a user