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 = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory" + File.separator + i + ".cache");
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
writer = new FileWriter(file);
|
writer = new FileWriter(file);
|
||||||
if (item.getType() == Material.AIR) {
|
if (item != null) {
|
||||||
writer.write("AIR");
|
if (item.getType() == Material.AIR) {
|
||||||
writer.close();
|
writer.write("AIR");
|
||||||
continue;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
writer.write(item.getType().name() + API.newline);
|
||||||
|
writer.write(item.getDurability() + API.newline);
|
||||||
|
writer.write(item.getAmount() + API.newline);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
if (item.hasItemMeta()) {
|
||||||
for (Enchantment ench : item.getEnchantments().keySet()) {
|
ItemMeta meta = item.getItemMeta();
|
||||||
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
if (meta.hasDisplayName())
|
||||||
}
|
writer.write("name=" + meta.getDisplayName() + API.newline);
|
||||||
Attributes attributes = new Attributes(item);
|
if (meta.hasLore()) {
|
||||||
if (attributes != null)
|
String lores = "";
|
||||||
while (attributes.values().iterator().hasNext()) {
|
for (String lore : meta.getLore())
|
||||||
Attribute a = attributes.values().iterator().next();
|
lores = lore + "%newline%";
|
||||||
if (a != null) {
|
writer.write("lore=" + lores + API.newline);
|
||||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
|
||||||
}
|
}
|
||||||
|
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();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,11 +491,15 @@ public class FileCache {
|
|||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
for (File f : file.listFiles())
|
for (File f : file.listFiles()) {
|
||||||
if (f.isDirectory())
|
if (f.isDirectory()) {
|
||||||
for (File a : f.listFiles())
|
for (File a : f.listFiles()) {
|
||||||
a.delete();
|
a.delete();
|
||||||
else f.delete();
|
}
|
||||||
|
f.delete();
|
||||||
|
} else f.delete();
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
} else file.delete();
|
} else file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -505,7 +513,7 @@ public class FileCache {
|
|||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
path = player.getName();
|
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()) {
|
if (!file.exists()) {
|
||||||
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
||||||
}
|
}
|
||||||
|
@ -675,10 +675,7 @@ public class FlatFileThread extends Thread implements DataSource {
|
|||||||
while ((br.readLine()) != null) {
|
while ((br.readLine()) != null) {
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
return result;
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user