Fix IO with cache

This commit is contained in:
Xephi 2014-08-28 05:42:09 +02:00
parent 3a2e58d18a
commit 922df85a65

View File

@ -46,6 +46,8 @@ public class FileCache {
} }
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");
if (!file.getParentFile().exists())
file.getParentFile().mkdir();
if (file.exists()) { if (file.exists()) {
return; return;
} }
@ -67,6 +69,7 @@ public class FileCache {
for (int i = 0; i < inv.length; i++) { for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i]; ItemStack item = inv[i];
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();
writer = new FileWriter(file); writer = new FileWriter(file);
writer.write(item.getType().name() + API.newline); writer.write(item.getType().name() + API.newline);
writer.write(item.getDurability() + API.newline); writer.write(item.getDurability() + API.newline);
@ -111,6 +114,7 @@ public class FileCache {
for (int i = 0; i < armors.length; i++) { for (int i = 0; i < armors.length; i++) {
ItemStack item = armors[i]; ItemStack item = armors[i];
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours" + File.separator + i + ".cache"); file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours" + File.separator + i + ".cache");
file.createNewFile();
writer = new FileWriter(file); writer = new FileWriter(file);
if (item != null) { if (item != null) {
writer.write(item.getType().name() + API.newline); writer.write(item.getType().name() + API.newline);