Duplicate Mod display screen.
This commit is contained in:
parent
4d620ade3e
commit
f9db650310
4 changed files with 83 additions and 5 deletions
|
@ -43,6 +43,7 @@ import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
|
|||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.DuplicateModsFoundException;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
|
@ -109,6 +110,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
|
||||
private CustomModLoadingErrorDisplayException customError;
|
||||
|
||||
private DuplicateModsFoundException dupesFound;
|
||||
|
||||
/**
|
||||
* Called to start the whole game off from
|
||||
* {@link MinecraftServer#startServer}
|
||||
|
@ -151,6 +154,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
{
|
||||
wrongMC = wrong;
|
||||
}
|
||||
catch (DuplicateModsFoundException dupes)
|
||||
{
|
||||
dupesFound = dupes;
|
||||
}
|
||||
catch (MissingModsException missing)
|
||||
{
|
||||
modsMissing = missing;
|
||||
|
@ -181,7 +188,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
@SuppressWarnings("deprecation")
|
||||
public void finishMinecraftLoading()
|
||||
{
|
||||
if (modsMissing != null || wrongMC != null)
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -217,6 +224,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
{
|
||||
client.func_71373_a(new GuiModsMissing(modsMissing));
|
||||
}
|
||||
else if (dupesFound != null)
|
||||
{
|
||||
client.func_71373_a(new GuiDupesFound(dupesFound));
|
||||
}
|
||||
else if (customError != null)
|
||||
{
|
||||
client.func_71373_a(new GuiCustomModLoadingErrorScreen(customError));
|
||||
|
|
44
fml/client/cpw/mods/fml/client/GuiDupesFound.java
Normal file
44
fml/client/cpw/mods/fml/client/GuiDupesFound.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import cpw.mods.fml.common.DuplicateModsFoundException;
|
||||
import cpw.mods.fml.common.MissingModsException;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import net.minecraft.src.GuiErrorScreen;
|
||||
|
||||
public class GuiDupesFound extends GuiErrorScreen
|
||||
{
|
||||
|
||||
private DuplicateModsFoundException dupes;
|
||||
|
||||
public GuiDupesFound(DuplicateModsFoundException dupes)
|
||||
{
|
||||
this.dupes = dupes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_73866_w_()
|
||||
{
|
||||
super.func_73866_w_();
|
||||
}
|
||||
@Override
|
||||
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
this.func_73873_v_();
|
||||
int offset = Math.max(85 - dupes.dupes.size() * 10, 10);
|
||||
this.func_73732_a(this.field_73886_k, "Forge Mod Loader has found a problem with your minecraft installation", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, "You have mod sources that are duplicate within your system", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, "Mod Id : File name", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=5;
|
||||
for (Entry<ModContainer, File> mc : dupes.dupes.entries())
|
||||
{
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
public class DuplicateModsFoundException extends LoaderException {
|
||||
|
||||
public SetMultimap<ModContainer,File> dupes;
|
||||
|
||||
public DuplicateModsFoundException(SetMultimap<ModContainer, File> dupes) {
|
||||
this.dupes = dupes;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -31,14 +32,17 @@ import com.google.common.base.CharMatcher;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Multiset.Entry;
|
||||
import com.google.common.collect.Multisets;
|
||||
|
@ -341,7 +345,6 @@ public class Loader
|
|||
|
||||
private void identifyDuplicates(List<ModContainer> mods)
|
||||
{
|
||||
boolean foundDupe = false;
|
||||
TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
|
||||
for (ModContainer mc : mods)
|
||||
{
|
||||
|
@ -352,15 +355,19 @@ public class Loader
|
|||
}
|
||||
|
||||
ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
|
||||
SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
|
||||
for (Entry<ModContainer> e : duplist.entrySet())
|
||||
{
|
||||
if (e.getCount() > 1)
|
||||
{
|
||||
FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
|
||||
foundDupe = true;
|
||||
dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
|
||||
}
|
||||
}
|
||||
if (foundDupe) { throw new LoaderException(); }
|
||||
if (!dupes.isEmpty())
|
||||
{
|
||||
throw new DuplicateModsFoundException(dupes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,7 +458,7 @@ public class Loader
|
|||
{
|
||||
if (nonMod.isFile())
|
||||
{
|
||||
FMLLog.severe("FML has found a non-mod file %s in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.", nonMod.getName());
|
||||
FMLLog.info("FML has found a non-mod file %s in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.", nonMod.getName());
|
||||
try
|
||||
{
|
||||
modClassLoader.addFile(nonMod);
|
||||
|
|
Loading…
Reference in a new issue