don't delete all npc files before saving, instead just delete whenever the npc is deleted
This commit is contained in:
parent
e789fe2f9c
commit
197ffaa50b
3 changed files with 5 additions and 5 deletions
|
@ -142,9 +142,10 @@ public class NpcRegistryImpl implements NpcRegistry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
id = id.toLowerCase();
|
NpcEntryImpl entry = npcIdLookupMap.remove(id.toLowerCase());
|
||||||
if (!npcIdLookupMap.containsKey(id)) return;
|
if (entry == null) return;
|
||||||
unregister(npcIdLookupMap.get(id));
|
unregister(entry);
|
||||||
|
storage.deleteNpc(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unload() {
|
public void unload() {
|
||||||
|
|
|
@ -7,4 +7,5 @@ import java.util.Collection;
|
||||||
public interface NpcStorage {
|
public interface NpcStorage {
|
||||||
Collection<NpcEntryImpl> loadNpcs();
|
Collection<NpcEntryImpl> loadNpcs();
|
||||||
void saveNpcs(Collection<NpcEntryImpl> npcs);
|
void saveNpcs(Collection<NpcEntryImpl> npcs);
|
||||||
|
void deleteNpc(NpcEntryImpl npc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,6 @@ public class YamlStorage implements NpcStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveNpcs(Collection<NpcEntryImpl> npcs) {
|
public void saveNpcs(Collection<NpcEntryImpl> npcs) {
|
||||||
File[] files = folder.listFiles();
|
|
||||||
if (files != null && files.length != 0) for (File file : files) file.delete();
|
|
||||||
for (NpcEntryImpl entry : npcs) try {
|
for (NpcEntryImpl entry : npcs) try {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
config.set("id", entry.getId());
|
config.set("id", entry.getId());
|
||||||
|
|
Loading…
Reference in a new issue