Migrate to UUID usage

This commit is contained in:
ShadowRanger
2015-06-22 18:30:27 +10:00
parent e8476d5b05
commit d988becf1f
4 changed files with 28 additions and 20 deletions

View File

@@ -34,7 +34,7 @@ import com.lishid.openinv.utils.UUIDUtil;
public class OpenEnderPluginCommand implements CommandExecutor {
private final OpenInv plugin;
public static final Map<UUID, UUID> openEnderHistory = new ConcurrentHashMap<UUID, UUID>();
private final Map<UUID, UUID> openEnderHistory = new ConcurrentHashMap<UUID, UUID>();
public OpenEnderPluginCommand(OpenInv plugin) {
this.plugin = plugin;
@@ -49,7 +49,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
}
if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST)) {
sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchests.");
return true;
}
@@ -58,7 +58,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
final Player player = (Player) sender;
// History management
UUID history = openEnderHistory.get(player.getUniqueId());
@@ -85,21 +85,25 @@ public class OpenEnderPluginCommand implements CommandExecutor {
}
final UUID playerUUID = player.getUniqueId();
Player target = Bukkit.getPlayer(uuid);
// Targeted player was not found online, start asynchron lookup in files
if (target == null) {
sender.sendMessage(ChatColor.GREEN + "Starting inventory lookup.");
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
// Targeted player was not found online, start asynchronous lookup in files
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
// Try loading the player's data asynchronly
// Try loading the player's data asynchronously
final Player target = OpenInv.playerLoader.loadPlayer(uuid);
// Back to synchron to send messages and display inventory
if (target == null) {
player.sendMessage(ChatColor.RED + "Player not found!");
return;
}
// Open target's inventory synchronously
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Player player = Bukkit.getPlayer(playerUUID);
// If sender is no longer online after loading the target. Abort!
// If sender is no longer online after loading the target, abort!
if (player == null) {
return;
}