|
@@ -1,7 +1,5 @@
|
|
|
package com.gmail.nossr50.runnables.player;
|
|
|
|
|
|
-import java.util.concurrent.locks.ReentrantLock;
|
|
|
-
|
|
|
import org.bukkit.Server;
|
|
|
import org.bukkit.entity.Player;
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
@@ -20,8 +18,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|
|
private static final int MAX_TRIES = 5;
|
|
|
private final Player player;
|
|
|
private int attempt = 0;
|
|
|
- private ReentrantLock lock = new ReentrantLock();
|
|
|
- private boolean cancelled = false;
|
|
|
|
|
|
public PlayerProfileLoadingTask(Player player) {
|
|
|
this.player = player;
|
|
@@ -31,45 +27,30 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|
|
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- lock.lock();
|
|
|
-
|
|
|
- try {
|
|
|
- if (this.cancelled) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // Quit if they logged out
|
|
|
- if (!player.isOnline()) {
|
|
|
- mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
|
|
|
- this.cancel();
|
|
|
- cancelled = true;
|
|
|
- return;
|
|
|
- }
|
|
|
+ // Quit if they logged out
|
|
|
+ if (!player.isOnline()) {
|
|
|
+ mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // Increment attempt counter and try
|
|
|
- attempt++;
|
|
|
+ // Increment attempt counter and try
|
|
|
+ attempt++;
|
|
|
|
|
|
- PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
|
|
- // If successful, schedule the apply
|
|
|
- if (profile.isLoaded()) {
|
|
|
- new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
|
|
- this.cancel();
|
|
|
- cancelled = true;
|
|
|
- return;
|
|
|
- }
|
|
|
+ PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
|
|
+ // If successful, schedule the apply
|
|
|
+ if (profile.isLoaded()) {
|
|
|
+ new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // If we've failed five times, give up
|
|
|
- if (attempt >= MAX_TRIES) {
|
|
|
- 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);
|
|
|
- player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
|
|
|
- this.cancel();
|
|
|
- cancelled = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- } finally {
|
|
|
- lock.unlock();
|
|
|
+ // If we've failed five times, give up
|
|
|
+ if (attempt >= MAX_TRIES) {
|
|
|
+ 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);
|
|
|
+ player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
|
|
|
+ return;
|
|
|
}
|
|
|
+ this.runTaskLaterAsynchronously(mcMMO.p, 100 * attempt);
|
|
|
}
|
|
|
|
|
|
private class ApplySuccessfulProfile extends BukkitRunnable {
|