mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-26 16:04:27 +02:00
Create Files, if they don't exist
This commit is contained in:
@@ -68,12 +68,12 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
onException();
|
||||
onException(ex);
|
||||
Bukkit.getLogger().log(Level.INFO, "File not found: " + file.toString());
|
||||
}
|
||||
catch (ObjectLoadException ex)
|
||||
{
|
||||
onException();
|
||||
onException(ex);
|
||||
File broken = new File(file.getAbsolutePath() + ".broken." + System.currentTimeMillis());
|
||||
file.renameTo(broken);
|
||||
Bukkit.getLogger().log(Level.SEVERE, "The file " + file.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
||||
@@ -91,5 +91,5 @@ public abstract class AbstractDelayedYamlFileReader<T extends StorageObject> imp
|
||||
|
||||
public abstract void onSuccess(T object);
|
||||
|
||||
public abstract void onException();
|
||||
public abstract void onException(Exception exception);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.storage;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -94,7 +95,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
|
||||
onReload(true);
|
||||
}
|
||||
|
||||
public void onReload(boolean instant)
|
||||
public void onReload(final boolean instant)
|
||||
{
|
||||
reader.schedule(instant);
|
||||
}
|
||||
@@ -161,7 +162,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException()
|
||||
public void onException(final Exception exception)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
@@ -176,6 +177,10 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
|
||||
}
|
||||
rwl.writeLock().unlock();
|
||||
loaded.set(true);
|
||||
if (exception instanceof FileNotFoundException)
|
||||
{
|
||||
writer.schedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user