Let's use UUID instead.
This commit is contained in:
		@@ -18,7 +18,7 @@ import com.massivecraft.mcore.store.Entity;
 | 
				
			|||||||
import com.massivecraft.mcore.util.Txt;
 | 
					import com.massivecraft.mcore.util.Txt;
 | 
				
			||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
					import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Board extends Entity<Board, String> implements BoardInterface
 | 
					public class Board extends Entity<Board> implements BoardInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	public static final transient Type MAP_TYPE = new TypeToken<Map<PS, TerritoryAccess>>(){}.getType();
 | 
						public static final transient Type MAP_TYPE = new TypeToken<Map<PS, TerritoryAccess>>(){}.getType();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ import com.massivecraft.mcore.util.DiscUtil;
 | 
				
			|||||||
import com.massivecraft.mcore.util.MUtil;
 | 
					import com.massivecraft.mcore.util.MUtil;
 | 
				
			||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
					import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class BoardColl extends Coll<Board, String> implements BoardInterface
 | 
					public class BoardColl extends Coll<Board> implements BoardInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// INSTANCE & CONSTRUCT
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
@@ -25,7 +25,7 @@ public class BoardColl extends Coll<Board, String> implements BoardInterface
 | 
				
			|||||||
	public static BoardColl get() { return i; }
 | 
						public static BoardColl get() { return i; }
 | 
				
			||||||
	private BoardColl()
 | 
						private BoardColl()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(MStore.getDb(ConfServer.dburi), Factions.get(), "ai", Const.COLLECTION_BASENAME_BOARD, Board.class, String.class, true);
 | 
							super(MStore.getDb(ConfServer.dburi), Factions.get(), "uuid", Const.COLLECTION_BASENAME_BOARD, Board.class, true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ import com.massivecraft.mcore.util.Txt;
 | 
				
			|||||||
import com.massivecraft.mcore.xlib.gson.annotations.SerializedName;
 | 
					import com.massivecraft.mcore.xlib.gson.annotations.SerializedName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Faction extends Entity<Faction, String> implements EconomyParticipator
 | 
					public class Faction extends Entity<Faction> implements EconomyParticipator
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// META
 | 
						// META
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ import org.bukkit.ChatColor;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.mcore.store.Coll;
 | 
					import com.massivecraft.mcore.store.Coll;
 | 
				
			||||||
import com.massivecraft.mcore.store.MStore;
 | 
					import com.massivecraft.mcore.store.MStore;
 | 
				
			||||||
import com.massivecraft.mcore.store.idstrategy.IdStrategyAiAbstract;
 | 
					 | 
				
			||||||
import com.massivecraft.mcore.util.DiscUtil;
 | 
					import com.massivecraft.mcore.util.DiscUtil;
 | 
				
			||||||
import com.massivecraft.mcore.util.Txt;
 | 
					import com.massivecraft.mcore.util.Txt;
 | 
				
			||||||
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
					import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
				
			||||||
@@ -17,7 +16,7 @@ import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
 | 
				
			|||||||
import com.massivecraft.factions.integration.Econ;
 | 
					import com.massivecraft.factions.integration.Econ;
 | 
				
			||||||
import com.massivecraft.factions.util.MiscUtil;
 | 
					import com.massivecraft.factions.util.MiscUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class FactionColl extends Coll<Faction, String>
 | 
					public class FactionColl extends Coll<Faction>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// INSTANCE & CONSTRUCT
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
@@ -27,7 +26,7 @@ public class FactionColl extends Coll<Faction, String>
 | 
				
			|||||||
	public static FactionColl get() { return i; }
 | 
						public static FactionColl get() { return i; }
 | 
				
			||||||
	private FactionColl()
 | 
						private FactionColl()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(MStore.getDb(ConfServer.dburi), Factions.get(), "ai", Const.COLLECTION_BASENAME_FACTION, Faction.class, String.class, false);
 | 
							super(MStore.getDb(ConfServer.dburi), Factions.get(), "uuid", Const.COLLECTION_BASENAME_FACTION, Faction.class, false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
@@ -65,34 +64,15 @@ public class FactionColl extends Coll<Faction, String>
 | 
				
			|||||||
		Type type = new TypeToken<Map<String, Faction>>(){}.getType();
 | 
							Type type = new TypeToken<Map<String, Faction>>(){}.getType();
 | 
				
			||||||
		Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
 | 
							Map<String, Faction> id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// We need to find the next AI id!
 | 
					 | 
				
			||||||
		int highestId = 0;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Set the data
 | 
							// Set the data
 | 
				
			||||||
		for (Entry<String, Faction> entry : id2faction.entrySet())
 | 
							for (Entry<String, Faction> entry : id2faction.entrySet())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			String factionId = entry.getKey();
 | 
								String factionId = entry.getKey();
 | 
				
			||||||
			Faction faction = entry.getValue();
 | 
								Faction faction = entry.getValue();
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			try
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				int intFactionId = Integer.valueOf(factionId);
 | 
					 | 
				
			||||||
				if (highestId < intFactionId)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					highestId = intFactionId;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			catch (Exception e)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				// Just ignore
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			FactionColl.get().create(factionId).load(faction);
 | 
								FactionColl.get().create(factionId).load(faction);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		IdStrategyAiAbstract idStrategy = (IdStrategyAiAbstract) FactionColl.get().getIdStrategy();
 | 
					 | 
				
			||||||
		idStrategy.setNext(this, highestId + 1);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Mark as migrated
 | 
							// Mark as migrated
 | 
				
			||||||
		oldFile.renameTo(newFile);
 | 
							oldFile.renameTo(newFile);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user