Add a helper for creating a reliable MD5 hash from all mods found in the currently loaded instance

This commit is contained in:
Pahimar 2014-08-25 16:00:51 -04:00
parent 9f12fdcc74
commit 9edf1409a3

View file

@ -0,0 +1,32 @@
package com.pahimar.ee3.util;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SerializationHelper
{
public static String getModListMD5()
{
List<String> modList = new ArrayList<String>();
for (ModContainer modContainer : Loader.instance().getModList())
{
modList.add("[" + modContainer.getModId() + "-" + modContainer.getName() + "-" + modContainer.getVersion() + "]");
}
Collections.sort(modList);
StringBuilder modListString = new StringBuilder();
for (String modEntry : modList)
{
modListString.append(modEntry);
}
return DigestUtils.md5Hex(modListString.toString());
}
}