Small DB changes

This commit is contained in:
Magnus Ulf 2019-02-05 13:58:44 +01:00
parent 307d9210dd
commit 5fe9d05e1b
3 changed files with 18 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package com.massivecraft.massivecore.store;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.massivecraft.massivecore.collections.MassiveMap;
@ -148,23 +149,28 @@ public class DriverFlatfile extends DriverAbstract
return loadFile(file);
}
public Entry<JsonObject, Long> loadFile(File file)
public static Entry<JsonObject, Long> loadFile(File file)
{
long mtime = file.lastModified();
JsonObject raw = loadFileJson(file);
JsonObject raw = loadFileJsonObject(file);
return new SimpleEntry<>(raw, mtime);
}
public JsonObject loadFileJson(File file)
public static JsonObject loadFileJsonObject(File file)
{
return loadFileJson(file).getAsJsonObject();
}
public static JsonElement loadFileJson(File file)
{
String content = DiscUtil.readCatch(file);
if (content == null) return null;
content = content.trim();
if (content.length() == 0) return null;
return new JsonParser().parse(content).getAsJsonObject();
return new JsonParser().parse(content);
}
@Override

View File

@ -63,8 +63,6 @@ public class IdData implements Identified, Named
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof IdData)) return false;
IdData other = (IdData) obj;
if (id == null)

View File

@ -264,7 +264,12 @@ public class IdUtil implements Listener, Runnable
{
update(id, name, System.currentTimeMillis(), presence);
}
public static void update(IdData data)
{
update(data.getId(), data.getName(), data.getMillis(), null);
}
public static void update(final String id, final String name, final long millis, SenderPresence presence)
{
// First Null Check