mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-01 07:03:34 +01:00
Fix saving and loading from files. This fixes CITIZENS-30.
This commit is contained in:
parent
38e1955825
commit
5e34538bd6
@ -234,10 +234,11 @@ public class Citizens extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
config.save();
|
//config.load();
|
||||||
|
//saves.load();
|
||||||
for (NPC npc : npcManager)
|
for (NPC npc : npcManager)
|
||||||
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
|
((CitizensNPC) npc).save(saves.getKey("npc." + npc.getId()));
|
||||||
|
config.save();
|
||||||
saves.save();
|
saves.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +250,8 @@ public class Citizens extends JavaPlugin {
|
|||||||
if (!key.keyExists("name"))
|
if (!key.keyExists("name"))
|
||||||
throw new NPCLoadException("Could not find a name for the NPC with ID '" + id + "'.");
|
throw new NPCLoadException("Could not find a name for the NPC with ID '" + id + "'.");
|
||||||
|
|
||||||
NPC npc = npcManager.createNPC(EntityType.valueOf(key.getString("traits.type").toUpperCase()), id,
|
NPC npc = npcManager.createNPC(EntityType.valueOf(key.getString("traits.type").toUpperCase()), id, key
|
||||||
key.getString("name"), null);
|
.getString("name"), null);
|
||||||
try {
|
try {
|
||||||
((CitizensNPC) npc).load(key);
|
((CitizensNPC) npc).load(key);
|
||||||
} catch (NPCException ex) {
|
} catch (NPCException ex) {
|
||||||
|
@ -15,6 +15,7 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
config.load();
|
||||||
DataKey root = config.getKey("");
|
DataKey root = config.getKey("");
|
||||||
for (Setting setting : Setting.values()) {
|
for (Setting setting : Setting.values()) {
|
||||||
if (!root.keyExists(setting.path)) {
|
if (!root.keyExists(setting.path)) {
|
||||||
@ -23,7 +24,6 @@ public class Settings {
|
|||||||
} else
|
} else
|
||||||
setting.set(root.getRaw(setting.path));
|
setting.set(root.getRaw(setting.path));
|
||||||
}
|
}
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
Loading…
Reference in New Issue
Block a user