Move the Transmutation Knowledge template file from the playerdata/ directory to the data/ directory (more appropriate to keep non-player data in a non-player data spot)
This commit is contained in:
parent
0695041e65
commit
292f78ee49
1 changed files with 17 additions and 13 deletions
|
@ -14,14 +14,18 @@ import java.util.UUID;
|
||||||
public class TransmutationKnowledgeRegistry
|
public class TransmutationKnowledgeRegistry
|
||||||
{
|
{
|
||||||
private static TransmutationKnowledgeRegistry transmutationKnowledgeRegistry = null;
|
private static TransmutationKnowledgeRegistry transmutationKnowledgeRegistry = null;
|
||||||
private static File knowledgeDirectory;
|
private static File playerKnowledgeDirectory;
|
||||||
|
private static File dataKnowledgeDirectory;
|
||||||
private static TransmutationKnowledge templateKnowledge;
|
private static TransmutationKnowledge templateKnowledge;
|
||||||
private static HashMap<UUID, TransmutationKnowledge> playerKnowledgeMap;
|
private static HashMap<UUID, TransmutationKnowledge> playerKnowledgeMap;
|
||||||
|
|
||||||
private TransmutationKnowledgeRegistry()
|
private TransmutationKnowledgeRegistry()
|
||||||
{
|
{
|
||||||
knowledgeDirectory = new File(SerializationHelper.getPlayerDataDirectory(), "knowledge" + File.separator + "transmutation");
|
playerKnowledgeDirectory = new File(SerializationHelper.getPlayerDataDirectory(), "knowledge" + File.separator + "transmutation");
|
||||||
knowledgeDirectory.mkdirs();
|
playerKnowledgeDirectory.mkdirs();
|
||||||
|
|
||||||
|
dataKnowledgeDirectory = new File(SerializationHelper.getDataDirectory(), "knowledge" + File.separator + "transmutation");
|
||||||
|
dataKnowledgeDirectory.mkdirs();
|
||||||
|
|
||||||
loadTemplateKnowledgeFromDisk();
|
loadTemplateKnowledgeFromDisk();
|
||||||
|
|
||||||
|
@ -209,16 +213,16 @@ public class TransmutationKnowledgeRegistry
|
||||||
*/
|
*/
|
||||||
public void loadTemplateKnowledgeFromDisk()
|
public void loadTemplateKnowledgeFromDisk()
|
||||||
{
|
{
|
||||||
File templateFile = new File(knowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
File templateFile = new File(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||||
|
|
||||||
if (!templateFile.exists())
|
if (!templateFile.exists())
|
||||||
{
|
{
|
||||||
templateKnowledge = new TransmutationKnowledge();
|
templateKnowledge = new TransmutationKnowledge();
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
templateKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(knowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
templateKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,12 +230,12 @@ public class TransmutationKnowledgeRegistry
|
||||||
{
|
{
|
||||||
if (templateKnowledge != null)
|
if (templateKnowledge != null)
|
||||||
{
|
{
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
templateKnowledge = new TransmutationKnowledge();
|
templateKnowledge = new TransmutationKnowledge();
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,11 +245,11 @@ public class TransmutationKnowledgeRegistry
|
||||||
{
|
{
|
||||||
TransmutationKnowledge playerTransmutationKnowledge = new TransmutationKnowledge();
|
TransmutationKnowledge playerTransmutationKnowledge = new TransmutationKnowledge();
|
||||||
|
|
||||||
File playerKnowledgeFile = new File(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json");
|
File playerKnowledgeFile = new File(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json");
|
||||||
|
|
||||||
if (playerKnowledgeFile.exists() && playerKnowledgeFile.isFile())
|
if (playerKnowledgeFile.exists() && playerKnowledgeFile.isFile())
|
||||||
{
|
{
|
||||||
playerTransmutationKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json");
|
playerTransmutationKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json");
|
||||||
}
|
}
|
||||||
|
|
||||||
playerKnowledgeMap.put(entityPlayer.getUniqueID(), playerTransmutationKnowledge);
|
playerKnowledgeMap.put(entityPlayer.getUniqueID(), playerTransmutationKnowledge);
|
||||||
|
@ -265,11 +269,11 @@ public class TransmutationKnowledgeRegistry
|
||||||
{
|
{
|
||||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()) && playerKnowledgeMap.get(entityPlayer.getUniqueID()).hasBeenModified())
|
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()) && playerKnowledgeMap.get(entityPlayer.getUniqueID()).hasBeenModified())
|
||||||
{
|
{
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", playerKnowledgeMap.get(entityPlayer.getUniqueID()));
|
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", playerKnowledgeMap.get(entityPlayer.getUniqueID()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", new TransmutationKnowledge());
|
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", new TransmutationKnowledge());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +283,7 @@ public class TransmutationKnowledgeRegistry
|
||||||
|
|
||||||
for (UUID playerUUID : playerKnowledgeMap.keySet())
|
for (UUID playerUUID : playerKnowledgeMap.keySet())
|
||||||
{
|
{
|
||||||
SerializationHelper.writeTransmutationKnowledgeToFile(knowledgeDirectory, playerUUID.toString() + ".json", playerKnowledgeMap.get(playerUUID));
|
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, playerUUID.toString() + ".json", playerKnowledgeMap.get(playerUUID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue