Add a helper for creating a reliable MD5 hash from all mods found in the currently loaded instance
This commit is contained in:
parent
9f12fdcc74
commit
9edf1409a3
1 changed files with 32 additions and 0 deletions
32
src/main/java/com/pahimar/ee3/util/SerializationHelper.java
Normal file
32
src/main/java/com/pahimar/ee3/util/SerializationHelper.java
Normal 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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue