Fix FileCache ... Sleeping is stupid x)

This commit is contained in:
Xephi59 2015-07-13 01:15:18 +02:00
parent 08292b8ac1
commit 5660ccc300
3 changed files with 22 additions and 22 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
@ -104,7 +105,8 @@ public class API {
try {
player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor);
} catch (NullPointerException npe) {
} catch (Exception npe) {
ConsoleLogger.showError("Some error appear while trying to set inventory for " + player.getName());
}
}

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Scanner;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -203,7 +202,7 @@ public class FileCache {
path = player.getName();
}
try {
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + ".playerdatas.cache");
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
String playername = player.getName().toLowerCase();
if (!file.exists()) {
// OLD METHOD
@ -357,7 +356,7 @@ public class FileCache {
for (int i = 0; i < inv.length; i++) {
reader = new Scanner(new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory" + File.separator + i + ".cache"));
ItemStack item = new ItemStack(Material.AIR);
ItemMeta meta = null;
ItemMeta meta = item.getItemMeta();
Attributes attributes = null;
count = 1;
boolean v = true;
@ -365,22 +364,24 @@ public class FileCache {
String line = reader.nextLine();
switch (count) {
case 1:
item.setType(Material.getMaterial(line));
item = new ItemStack(Material.getMaterial(line));
if (item.getType() == Material.AIR)
v = false;
meta = item.getItemMeta();
count++;
continue;
case 2:
item.setDurability(Short.parseShort(line));
item.setDurability((short) Integer.parseInt(line));
count++;
continue;
case 3:
item.setAmount(Integer.parseInt(line));
count++;
continue;
case 4:
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
break;
default:
break;
}
meta = item.getItemMeta();
if (line.startsWith("name=")) {
line = line.substring(5);
meta.setDisplayName(line);
@ -399,6 +400,7 @@ public class FileCache {
if (line.startsWith("enchant=")) {
line = line.substring(8);
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
continue;
}
if (Settings.customAttributes) {
if (line.startsWith("attribute=")) {
@ -429,7 +431,7 @@ public class FileCache {
}
if (reader != null)
reader.close();
if (attributes != null)
if (Settings.customAttributes && attributes != null)
inv[i] = attributes.getStack();
else inv[i] = item;
}
@ -444,22 +446,24 @@ public class FileCache {
String line = reader.nextLine();
switch (count) {
case 1:
item.setType(Material.getMaterial(line));
item = new ItemStack(Material.getMaterial(line));
if (item.getType() == Material.AIR)
v = false;
meta = item.getItemMeta();
count++;
continue;
case 2:
item.setDurability(Short.parseShort(line));
item.setDurability((short) Integer.parseInt(line));
count++;
continue;
case 3:
item.setAmount(Integer.parseInt(line));
count++;
continue;
case 4:
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
break;
default:
break;
}
meta = item.getItemMeta();
if (line.startsWith("name=")) {
line = line.substring(5);
meta.setDisplayName(line);
@ -573,10 +577,7 @@ public class FileCache {
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
}
if (file.exists()) {
return true;
}
return false;
return file.exists();
}
}

View File

@ -79,9 +79,6 @@ public class AsyncronousQuit {
if (limbo.getMessageTaskId() != null)
limbo.getMessageTaskId().cancel();
LimboCache.getInstance().deleteLimboPlayer(name);
if (playerBackup.doesCacheExist(player)) {
playerBackup.removeCache(player);
}
}
if (Settings.isSessionsEnabled && !isKick) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {