Fix FileCache ... Sleeping is stupid x)
This commit is contained in:
parent
08292b8ac1
commit
5660ccc300
@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.Utils;
|
import fr.xephi.authme.Utils;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
@ -104,7 +105,8 @@ public class API {
|
|||||||
try {
|
try {
|
||||||
player.getInventory().setContents(content);
|
player.getInventory().setContents(content);
|
||||||
player.getInventory().setArmorContents(armor);
|
player.getInventory().setArmorContents(armor);
|
||||||
} catch (NullPointerException npe) {
|
} catch (Exception npe) {
|
||||||
|
ConsoleLogger.showError("Some error appear while trying to set inventory for " + player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import java.util.List;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -203,7 +202,7 @@ public class FileCache {
|
|||||||
path = player.getName();
|
path = player.getName();
|
||||||
}
|
}
|
||||||
try {
|
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();
|
String playername = player.getName().toLowerCase();
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
// OLD METHOD
|
// OLD METHOD
|
||||||
@ -357,7 +356,7 @@ public class FileCache {
|
|||||||
for (int i = 0; i < inv.length; i++) {
|
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"));
|
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);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
ItemMeta meta = null;
|
ItemMeta meta = item.getItemMeta();
|
||||||
Attributes attributes = null;
|
Attributes attributes = null;
|
||||||
count = 1;
|
count = 1;
|
||||||
boolean v = true;
|
boolean v = true;
|
||||||
@ -365,22 +364,24 @@ public class FileCache {
|
|||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
switch (count) {
|
switch (count) {
|
||||||
case 1:
|
case 1:
|
||||||
item.setType(Material.getMaterial(line));
|
item = new ItemStack(Material.getMaterial(line));
|
||||||
if (item.getType() == Material.AIR)
|
if (item.getType() == Material.AIR)
|
||||||
v = false;
|
v = false;
|
||||||
|
meta = item.getItemMeta();
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 2:
|
case 2:
|
||||||
item.setDurability(Short.parseShort(line));
|
item.setDurability((short) Integer.parseInt(line));
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 3:
|
case 3:
|
||||||
item.setAmount(Integer.parseInt(line));
|
item.setAmount(Integer.parseInt(line));
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 4:
|
|
||||||
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
meta = item.getItemMeta();
|
||||||
if (line.startsWith("name=")) {
|
if (line.startsWith("name=")) {
|
||||||
line = line.substring(5);
|
line = line.substring(5);
|
||||||
meta.setDisplayName(line);
|
meta.setDisplayName(line);
|
||||||
@ -399,6 +400,7 @@ public class FileCache {
|
|||||||
if (line.startsWith("enchant=")) {
|
if (line.startsWith("enchant=")) {
|
||||||
line = line.substring(8);
|
line = line.substring(8);
|
||||||
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (Settings.customAttributes) {
|
if (Settings.customAttributes) {
|
||||||
if (line.startsWith("attribute=")) {
|
if (line.startsWith("attribute=")) {
|
||||||
@ -429,7 +431,7 @@ public class FileCache {
|
|||||||
}
|
}
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
reader.close();
|
reader.close();
|
||||||
if (attributes != null)
|
if (Settings.customAttributes && attributes != null)
|
||||||
inv[i] = attributes.getStack();
|
inv[i] = attributes.getStack();
|
||||||
else inv[i] = item;
|
else inv[i] = item;
|
||||||
}
|
}
|
||||||
@ -444,22 +446,24 @@ public class FileCache {
|
|||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
switch (count) {
|
switch (count) {
|
||||||
case 1:
|
case 1:
|
||||||
item.setType(Material.getMaterial(line));
|
item = new ItemStack(Material.getMaterial(line));
|
||||||
if (item.getType() == Material.AIR)
|
if (item.getType() == Material.AIR)
|
||||||
v = false;
|
v = false;
|
||||||
|
meta = item.getItemMeta();
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 2:
|
case 2:
|
||||||
item.setDurability(Short.parseShort(line));
|
item.setDurability((short) Integer.parseInt(line));
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 3:
|
case 3:
|
||||||
item.setAmount(Integer.parseInt(line));
|
item.setAmount(Integer.parseInt(line));
|
||||||
|
count++;
|
||||||
continue;
|
continue;
|
||||||
case 4:
|
|
||||||
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
meta = item.getItemMeta();
|
||||||
if (line.startsWith("name=")) {
|
if (line.startsWith("name=")) {
|
||||||
line = line.substring(5);
|
line = line.substring(5);
|
||||||
meta.setDisplayName(line);
|
meta.setDisplayName(line);
|
||||||
@ -573,10 +577,7 @@ public class FileCache {
|
|||||||
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.exists()) {
|
return file.exists();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,9 +79,6 @@ public class AsyncronousQuit {
|
|||||||
if (limbo.getMessageTaskId() != null)
|
if (limbo.getMessageTaskId() != null)
|
||||||
limbo.getMessageTaskId().cancel();
|
limbo.getMessageTaskId().cancel();
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
if (playerBackup.doesCacheExist(player)) {
|
|
||||||
playerBackup.removeCache(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Settings.isSessionsEnabled && !isKick) {
|
if (Settings.isSessionsEnabled && !isKick) {
|
||||||
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user