mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-07 10:57:45 +02:00
Fix the Cache
This commit is contained in:
parent
907d70d60d
commit
6e17b540f5
@ -71,43 +71,47 @@ public class FileCache {
|
||||
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory" + File.separator + i + ".cache");
|
||||
file.createNewFile();
|
||||
writer = new FileWriter(file);
|
||||
if (item.getType() == Material.AIR) {
|
||||
writer.write("AIR");
|
||||
writer.close();
|
||||
continue;
|
||||
}
|
||||
writer.write(item.getType().name() + API.newline);
|
||||
writer.write(item.getDurability() + API.newline);
|
||||
writer.write(item.getAmount() + API.newline);
|
||||
writer.flush();
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta.hasDisplayName())
|
||||
writer.write("name=" + meta.getDisplayName() + API.newline);
|
||||
if (meta.hasLore()) {
|
||||
String lores = "";
|
||||
for (String lore : meta.getLore())
|
||||
lores = lore + "%newline%";
|
||||
writer.write("lore=" + lores + API.newline);
|
||||
}
|
||||
if (meta.hasEnchants()) {
|
||||
for (Enchantment ench : meta.getEnchants().keySet()) {
|
||||
writer.write("metaenchant=" + ench.getName() + ":" + meta.getEnchants().get(ench) + API.newline);
|
||||
}
|
||||
if (item != null) {
|
||||
if (item.getType() == Material.AIR) {
|
||||
writer.write("AIR");
|
||||
writer.close();
|
||||
continue;
|
||||
}
|
||||
writer.write(item.getType().name() + API.newline);
|
||||
writer.write(item.getDurability() + API.newline);
|
||||
writer.write(item.getAmount() + API.newline);
|
||||
writer.flush();
|
||||
}
|
||||
for (Enchantment ench : item.getEnchantments().keySet()) {
|
||||
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
||||
}
|
||||
Attributes attributes = new Attributes(item);
|
||||
if (attributes != null)
|
||||
while (attributes.values().iterator().hasNext()) {
|
||||
Attribute a = attributes.values().iterator().next();
|
||||
if (a != null) {
|
||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta.hasDisplayName())
|
||||
writer.write("name=" + meta.getDisplayName() + API.newline);
|
||||
if (meta.hasLore()) {
|
||||
String lores = "";
|
||||
for (String lore : meta.getLore())
|
||||
lores = lore + "%newline%";
|
||||
writer.write("lore=" + lores + API.newline);
|
||||
}
|
||||
if (meta.hasEnchants()) {
|
||||
for (Enchantment ench : meta.getEnchants().keySet()) {
|
||||
writer.write("metaenchant=" + ench.getName() + ":" + meta.getEnchants().get(ench) + API.newline);
|
||||
}
|
||||
}
|
||||
writer.flush();
|
||||
}
|
||||
for (Enchantment ench : item.getEnchantments().keySet()) {
|
||||
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
||||
}
|
||||
Attributes attributes = new Attributes(item);
|
||||
if (attributes != null)
|
||||
while (attributes.values().iterator().hasNext()) {
|
||||
Attribute a = attributes.values().iterator().next();
|
||||
if (a != null) {
|
||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
writer.write("AIR");
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@ -487,11 +491,15 @@ public class FileCache {
|
||||
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles())
|
||||
if (f.isDirectory())
|
||||
for (File a : f.listFiles())
|
||||
for (File f : file.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
for (File a : f.listFiles()) {
|
||||
a.delete();
|
||||
else f.delete();
|
||||
}
|
||||
f.delete();
|
||||
} else f.delete();
|
||||
}
|
||||
file.delete();
|
||||
} else file.delete();
|
||||
}
|
||||
}
|
||||
@ -505,7 +513,7 @@ public class FileCache {
|
||||
} catch (Error e) {
|
||||
path = player.getName();
|
||||
}
|
||||
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path);
|
||||
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
|
||||
if (!file.exists()) {
|
||||
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
||||
}
|
||||
|
@ -675,10 +675,7 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
while ((br.readLine()) != null) {
|
||||
result++;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return result;
|
||||
} catch (IOException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return result;
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user