From 09a23353a70f3e416c8cf992777306c844c73c3a Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 25 Apr 2013 09:59:25 +0200 Subject: [PATCH] Drop old special factions upon migration. --- src/com/massivecraft/factions/entity/FactionColls.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/massivecraft/factions/entity/FactionColls.java b/src/com/massivecraft/factions/entity/FactionColls.java index f4591eca..4dadcee9 100644 --- a/src/com/massivecraft/factions/entity/FactionColls.java +++ b/src/com/massivecraft/factions/entity/FactionColls.java @@ -4,12 +4,14 @@ import java.io.File; import java.lang.reflect.Type; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.usys.Aspect; import com.massivecraft.mcore.util.DiscUtil; +import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; public class FactionColls extends XColls @@ -61,6 +63,11 @@ public class FactionColls extends XColls // Already migrated? if ( ! oldFile.exists()) return; + // Faction ids /delete + // For simplicity we just drop the old special factions. + // They will be replaced with new autogenerated ones per universe. + Set factionIdsToDelete = MUtil.set("0", "-1", "-2"); + // Read the file content through GSON. Type type = new TypeToken>(){}.getType(); Map id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); @@ -72,6 +79,7 @@ public class FactionColls extends XColls for (Entry entry : id2faction.entrySet()) { String factionId = entry.getKey(); + if (factionIdsToDelete.contains(factionId)) continue; Faction faction = entry.getValue(); coll.attach(faction, factionId); }