Finish fixing warps
This commit is contained in:
parent
9f79565d56
commit
516f067fb9
9 changed files with 103 additions and 35 deletions
|
@ -9,19 +9,10 @@ import net.minecraft.nbt.NbtIo;
|
|||
|
||||
public class WarpsProvider extends EssentialsDatastore
|
||||
{
|
||||
public static final Path BASE = of("warps");
|
||||
public static final Path WARPS_DATA = BASE.resolve("warps.nbt");
|
||||
public static final Path BASE = of("warps.nbt", false);
|
||||
|
||||
public static final Warps WARPS_INSTANCE;
|
||||
static{
|
||||
if(!BASE.toFile().exists()){
|
||||
try {
|
||||
Files.createDirectory(BASE);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WARPS_INSTANCE = getOrCreate();
|
||||
}
|
||||
|
||||
|
@ -32,10 +23,10 @@ public class WarpsProvider extends EssentialsDatastore
|
|||
private static Warps getOrCreate()
|
||||
{
|
||||
Warps instance = null;
|
||||
if(WARPS_DATA.toFile().exists())
|
||||
if(BASE.toFile().exists())
|
||||
{
|
||||
try{
|
||||
instance= Warps.deserialize(NbtIo.read(WARPS_DATA.toFile()));
|
||||
instance= Warps.deserialize(NbtIo.read(BASE.toFile()));
|
||||
|
||||
}catch(Exception e){
|
||||
instance=Warps.getNew();
|
||||
|
@ -50,7 +41,7 @@ public class WarpsProvider extends EssentialsDatastore
|
|||
public static void updateFile()
|
||||
{
|
||||
try {
|
||||
NbtIo.write(WARPS_INSTANCE.serialize(), WARPS_DATA.toFile());
|
||||
NbtIo.write(WARPS_INSTANCE.serialize(), BASE.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue