Java 类cpw.mods.fml.common.versioning.VersionParser 实例源码

项目:4Space-5    文件:ItemElectricBase.java   
public ItemElectricBase()
{
    super();
    this.setMaxStackSize(1);
    this.setMaxDamage(100);
    this.setNoRepair();
    this.setMaxTransfer();

    this.mcVersion = new DefaultArtifactVersion((String) FMLInjectionData.data()[4]);

    if (EnergyConfigHandler.isIndustrialCraft2Loaded())
    {
        if (VersionParser.parseRange("[1.7.2]").containsVersion(mcVersion))
        {
            itemManagerIC2 = new ElectricItemManagerIC2();
        }
        else
        {
            itemManagerIC2 = new ElectricItemManagerIC2_1710();
        }
    }
}
项目:RuneCraftery    文件:ModMetadata.java   
private <T extends Collection<ArtifactVersion>> T processReferences(Object refs, Class<? extends T> retType)
{
    T res = null;
    try
    {
        res = retType.newInstance();
    }
    catch (Exception e)
    {
        // unpossible
    }

    if (refs == null)
    {
        return res;
    }
    for (String ref : ((List<String>)refs))
    {
        res.add(VersionParser.parseVersionReference(ref));
    }
    return res;
}
项目:RuneCraftery    文件:ModMetadata.java   
private <T extends Collection<ArtifactVersion>> T processReferences(Object refs, Class<? extends T> retType)
{
    T res = null;
    try
    {
        res = retType.newInstance();
    }
    catch (Exception e)
    {
        // unpossible
    }

    if (refs == null)
    {
        return res;
    }
    for (String ref : ((List<String>)refs))
    {
        res.add(VersionParser.parseVersionReference(ref));
    }
    return res;
}
项目:BetterNutritionMod    文件:ModMetadata.java   
private <T extends Collection<ArtifactVersion>> T processReferences(Object refs, Class<? extends T> retType)
{
    T res = null;
    try
    {
        res = retType.newInstance();
    }
    catch (Exception e)
    {
        // unpossible
    }

    if (refs == null)
    {
        return res;
    }
    for (String ref : ((List<String>)refs))
    {
        res.add(VersionParser.parseVersionReference(ref));
    }
    return res;
}
项目:4Space-5    文件:MicdoodlePlugin.java   
public static void versionCheck(String reqVersion, String mod)
{
    final String mcVersion = (String) FMLInjectionData.data()[4];

    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion)))
    {
        final String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        System.err.println(err);

        final JEditorPane ep = new JEditorPane("text/html", "<html>" + err + "<br>Remove it from your mods folder and check <a href=\"http://micdoodle8.com\">here</a> for updates" + "</html>");

        ep.setEditable(false);
        ep.setOpaque(false);
        ep.addHyperlinkListener(new HyperlinkListener()
        {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent event)
            {
                try
                {
                    if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                    {
                        Desktop.getDesktop().browse(event.getURL().toURI());
                    }
                }
                catch (final Exception e)
                {
                }
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
项目:4Space-5    文件:CodeChickenCorePlugin.java   
public static void versionCheck(String reqVersion, String mod) {
    String mcVersion = (String) FMLInjectionData.data()[4];
    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion))) {
        String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        logger.error(err);

        JEditorPane ep = new JEditorPane("text/html",
                "<html>" +
                        err +
                        "<br>Remove it from your coremods folder and check <a href=\"http://www.minecraftforum.net/topic/909223-\">here</a> for updates" +
                        "</html>");

        ep.setEditable(false);
        ep.setOpaque(false);
        ep.addHyperlinkListener(new HyperlinkListener()
        {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent event) {
                try {
                    if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                        Desktop.getDesktop().browse(event.getURL().toURI());
                } catch (Exception ignored) {}
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
项目:TRHS_Club_Mod_2016    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:TRHS_Club_Mod_2016    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:TRHS_Club_Mod_2016    文件:Loader.java   
private void readInjectedDependencies()
{
    File injectedDepFile = new File(getConfigDir(),"injectedDependencies.json");
    if (!injectedDepFile.exists())
    {
        FMLLog.getLogger().log(Level.DEBUG, "File {} not found. No dependencies injected", injectedDepFile.getAbsolutePath());
        return;
    }
    JsonParser parser = new JsonParser();
    JsonElement injectedDeps;
    try
    {
        injectedDeps = parser.parse(new FileReader(injectedDepFile));
        for (JsonElement el : injectedDeps.getAsJsonArray())
        {
            JsonObject jo = el.getAsJsonObject();
            String modId = jo.get("modId").getAsString();
            JsonArray deps = jo.get("deps").getAsJsonArray();
            for (JsonElement dep : deps)
            {
                JsonObject depObj = dep.getAsJsonObject();
                String type = depObj.get("type").getAsString();
                if (type.equals("before")) {
                    injectedBefore.put(modId, VersionParser.parseVersionReference(depObj.get("target").getAsString()));
                } else if (type.equals("after")) {
                    injectedAfter.put(modId, VersionParser.parseVersionReference(depObj.get("target").getAsString()));
                } else {
                    FMLLog.getLogger().log(Level.ERROR, "Invalid dependency type {}", type);
                    throw new RuntimeException("Unable to parse type");
                }
            }
        }
    } catch (Exception e)
    {
        FMLLog.getLogger().log(Level.ERROR, "Unable to parse {} - skipping", injectedDepFile);
        FMLLog.getLogger().throwing(Level.ERROR, e);
        return;
    }
    FMLLog.getLogger().log(Level.DEBUG, "Loaded {} injected dependencies on modIds: {}", injectedBefore.size(), injectedBefore.keySet());
}
项目:CauldronGit    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:CauldronGit    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:NEI-Integration    文件:Utils.java   
public static boolean isModLoaded(String modid, String versionRangeString) {
    if (!isModLoaded(modid)) {
        return false;
    }

    ModContainer mod = Loader.instance().getIndexedModList().get(modid);
    VersionRange versionRange = VersionParser.parseRange(versionRangeString);
    DefaultArtifactVersion required = new DefaultArtifactVersion(modid, versionRange);

    return required.containsVersion(mod.getProcessedVersion());
}
项目:Cauldron    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:Cauldron    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:Cauldron    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:Cauldron    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:Cauldron    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:Cauldron    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:Atmatm6_Mods    文件:MicdoodlePlugin.java   
public static void versionCheck(String reqVersion, String mod)
{
    final String mcVersion = (String) FMLInjectionData.data()[4];

    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion)))
    {
        final String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        System.err.println(err);

        final JEditorPane ep = new JEditorPane("text/html", "<html>" + err + "<br>Remove it from your mods folder and check <a href=\"http://micdoodle8.com\">here</a> for updates" + "</html>");

        ep.setEditable(false);
        ep.setOpaque(false);
        ep.addHyperlinkListener(new HyperlinkListener()
        {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent event)
            {
                try
                {
                    if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                    {
                        Desktop.getDesktop().browse(event.getURL().toURI());
                    }
                }
                catch (final Exception e)
                {
                }
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
项目:RuneCraftery    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:RuneCraftery    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:RuneCraftery    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:RuneCraftery    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:BetterNutritionMod    文件:MinecraftDummyContainer.java   
public MinecraftDummyContainer(String actualMCVersion)
{
    super(new ModMetadata());
    getMetadata().modId = "Minecraft";
    getMetadata().name = "Minecraft";
    getMetadata().version = actualMCVersion;
    staticRange = VersionParser.parseRange("["+actualMCVersion+"]");
}
项目:BetterNutritionMod    文件:ModAPIManager.java   
public void addAPIReference(String embedded)
{
    if (currentReferents.add(embedded))
    {
        referredMods.add(VersionParser.parseVersionReference(embedded));
    }
}
项目:4Space-5    文件:VersionUtil.java   
public static boolean mcVersionMatches(String version)
{
    return VersionParser.parseRange("[" + version + "]").containsVersion(mcVersion);
}
项目:4Space-5    文件:MicdoodleTransformer.java   
private boolean mcVersionMatches(String testVersion)
{
    return VersionParser.parseRange(testVersion).containsVersion(this.mcVersion);
}
项目:4Space-5    文件:MicdoodleModContainer.java   
@Override
public VersionRange acceptableMinecraftVersionRange()
{
    return VersionParser.parseRange(MicdoodlePlugin.mcVersion);
}
项目:4Space-5    文件:NEIModContainer.java   
@Override
public VersionRange acceptableMinecraftVersionRange() {
    return VersionParser.parseRange(CodeChickenCorePlugin.mcVersion);
}
项目:4Space-5    文件:CodeChickenCoreModContainer.java   
@Override
public VersionRange acceptableMinecraftVersionRange() {
    return VersionParser.parseRange(CodeChickenCorePlugin.mcVersion);
}
项目:TRHS_Club_Mod_2016    文件:MetadataCollection.java   
@Override
public ArtifactVersion read(JsonReader in) throws IOException
{
    return VersionParser.parseVersionReference(in.nextString());
}
项目:TRHS_Club_Mod_2016    文件:Loader.java   
public void computeDependencies(String dependencyString, Set<ArtifactVersion> requirements, List<ArtifactVersion> dependencies, List<ArtifactVersion> dependants)
{
    if (dependencyString == null || dependencyString.length() == 0)
    {
        return;
    }

    boolean parseFailure = false;

    for (String dep : DEPENDENCYSPLITTER.split(dependencyString))
    {
        List<String> depparts = Lists.newArrayList(DEPENDENCYPARTSPLITTER.split(dep));
        // Need two parts to the string
        if (depparts.size() != 2)
        {
            parseFailure = true;
            continue;
        }
        String instruction = depparts.get(0);
        String target = depparts.get(1);
        boolean targetIsAll = target.startsWith("*");

        // Cannot have an "all" relationship with anything except pure *
        if (targetIsAll && target.length() > 1)
        {
            parseFailure = true;
            continue;
        }

        // If this is a required element, add it to the required list
        if ("required-before".equals(instruction) || "required-after".equals(instruction))
        {
            // You can't require everything
            if (!targetIsAll)
            {
                requirements.add(VersionParser.parseVersionReference(target));
            }
            else
            {
                parseFailure = true;
                continue;
            }
        }

        // You cannot have a versioned dependency on everything
        if (targetIsAll && target.indexOf('@') > -1)
        {
            parseFailure = true;
            continue;
        }
        // before elements are things we are loaded before (so they are our dependants)
        if ("required-before".equals(instruction) || "before".equals(instruction))
        {
            dependants.add(VersionParser.parseVersionReference(target));
        }
        // after elements are things that load before we do (so they are out dependencies)
        else if ("required-after".equals(instruction) || "after".equals(instruction))
        {
            dependencies.add(VersionParser.parseVersionReference(target));
        }
        else
        {
            parseFailure = true;
        }
    }

    if (parseFailure)
    {
        FMLLog.log(Level.WARN, "Unable to parse dependency string %s", dependencyString);
        throw new LoaderException(String.format("Unable to parse dependency string %s", dependencyString));
    }
}
项目:TRHS_Club_Mod_2016    文件:FMLModContainer.java   
@Override
public void bindMetadata(MetadataCollection mc)
{
    modMetadata = mc.getMetadataForId(getModId(), descriptor);

    if (descriptor.containsKey("useMetadata"))
    {
        overridesMetadata = !((Boolean)descriptor.get("useMetadata")).booleanValue();
    }

    if (overridesMetadata || !modMetadata.useDependencyInformation)
    {
        Set<ArtifactVersion> requirements = Sets.newHashSet();
        List<ArtifactVersion> dependencies = Lists.newArrayList();
        List<ArtifactVersion> dependants = Lists.newArrayList();
        annotationDependencies = (String) descriptor.get("dependencies");
        Loader.instance().computeDependencies(annotationDependencies, requirements, dependencies, dependants);
        dependants.addAll(Loader.instance().getInjectedBefore(getModId()));
        dependencies.addAll(Loader.instance().getInjectedAfter(getModId()));
        modMetadata.requiredMods = requirements;
        modMetadata.dependencies = dependencies;
        modMetadata.dependants = dependants;
        FMLLog.log(getModId(), Level.TRACE, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants);
    }
    else
    {
        FMLLog.log(getModId(), Level.TRACE, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants);
    }
    if (Strings.isNullOrEmpty(modMetadata.name))
    {
        FMLLog.log(getModId(), Level.INFO,"Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId());
        modMetadata.name = getModId();
    }
    internalVersion = (String) descriptor.get("version");
    if (Strings.isNullOrEmpty(internalVersion))
    {
        Properties versionProps = searchForVersionProperties();
        if (versionProps != null)
        {
            internalVersion = versionProps.getProperty(getModId()+".version");
            FMLLog.log(getModId(), Level.DEBUG, "Found version %s for mod %s in version.properties, using", internalVersion, getModId());
        }

    }
    if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version))
    {
        FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version);
        internalVersion = modMetadata.version;
    }
    if (Strings.isNullOrEmpty(internalVersion))
    {
        FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId());
        modMetadata.version = internalVersion = "1.0";
    }

    String mcVersionString = (String) descriptor.get("acceptedMinecraftVersions");
    if (!Strings.isNullOrEmpty(mcVersionString))
    {
        minecraftAccepted = VersionParser.parseRange(mcVersionString);
    }
    else
    {
        minecraftAccepted = Loader.instance().getMinecraftModContainer().getStaticVersionRange();
    }
}
项目:CauldronGit    文件:MetadataCollection.java   
@Override
public ArtifactVersion read(JsonReader in) throws IOException
{
    return VersionParser.parseVersionReference(in.nextString());
}
项目:CauldronGit    文件:Loader.java   
public void computeDependencies(String dependencyString, Set<ArtifactVersion> requirements, List<ArtifactVersion> dependencies, List<ArtifactVersion> dependants)
{
    if (dependencyString == null || dependencyString.length() == 0)
    {
        return;
    }

    boolean parseFailure = false;

    for (String dep : DEPENDENCYSPLITTER.split(dependencyString))
    {
        List<String> depparts = Lists.newArrayList(DEPENDENCYPARTSPLITTER.split(dep));
        // Need two parts to the string
        if (depparts.size() != 2)
        {
            parseFailure = true;
            continue;
        }
        String instruction = depparts.get(0);
        String target = depparts.get(1);
        boolean targetIsAll = target.startsWith("*");

        // Cannot have an "all" relationship with anything except pure *
        if (targetIsAll && target.length() > 1)
        {
            parseFailure = true;
            continue;
        }

        // If this is a required element, add it to the required list
        if ("required-before".equals(instruction) || "required-after".equals(instruction))
        {
            // You can't require everything
            if (!targetIsAll)
            {
                requirements.add(VersionParser.parseVersionReference(target));
            }
            else
            {
                parseFailure = true;
                continue;
            }
        }

        // You cannot have a versioned dependency on everything
        if (targetIsAll && target.indexOf('@') > -1)
        {
            parseFailure = true;
            continue;
        }
        // before elements are things we are loaded before (so they are our dependants)
        if ("required-before".equals(instruction) || "before".equals(instruction))
        {
            dependants.add(VersionParser.parseVersionReference(target));
        }
        // after elements are things that load before we do (so they are out dependencies)
        else if ("required-after".equals(instruction) || "after".equals(instruction))
        {
            dependencies.add(VersionParser.parseVersionReference(target));
        }
        else
        {
            parseFailure = true;
        }
    }

    if (parseFailure)
    {
        FMLLog.log(Level.WARN, "Unable to parse dependency string %s", dependencyString);
        throw new LoaderException();
    }
}
项目:CauldronGit    文件:FMLModContainer.java   
@Override
public void bindMetadata(MetadataCollection mc)
{
    modMetadata = mc.getMetadataForId(getModId(), descriptor);

    if (descriptor.containsKey("useMetadata"))
    {
        overridesMetadata = !((Boolean)descriptor.get("useMetadata")).booleanValue();
    }

    if (overridesMetadata || !modMetadata.useDependencyInformation)
    {
        Set<ArtifactVersion> requirements = Sets.newHashSet();
        List<ArtifactVersion> dependencies = Lists.newArrayList();
        List<ArtifactVersion> dependants = Lists.newArrayList();
        annotationDependencies = (String) descriptor.get("dependencies");
        Loader.instance().computeDependencies(annotationDependencies, requirements, dependencies, dependants);
        modMetadata.requiredMods = requirements;
        modMetadata.dependencies = dependencies;
        modMetadata.dependants = dependants;
        FMLLog.log(getModId(), Level.TRACE, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants);
    }
    else
    {
        FMLLog.log(getModId(), Level.TRACE, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants);
    }
    if (Strings.isNullOrEmpty(modMetadata.name))
    {
        FMLLog.log(getModId(), Level.INFO,"Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId());
        modMetadata.name = getModId();
    }
    internalVersion = (String) descriptor.get("version");
    if (Strings.isNullOrEmpty(internalVersion))
    {
        Properties versionProps = searchForVersionProperties();
        if (versionProps != null)
        {
            internalVersion = versionProps.getProperty(getModId()+".version");
            FMLLog.log(getModId(), Level.DEBUG, "Found version %s for mod %s in version.properties, using", internalVersion, getModId());
        }

    }
    if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version))
    {
        FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version);
        internalVersion = modMetadata.version;
    }
    if (Strings.isNullOrEmpty(internalVersion))
    {
        FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId());
        modMetadata.version = internalVersion = "1.0";
    }

    String mcVersionString = (String) descriptor.get("acceptedMinecraftVersions");
    if (!Strings.isNullOrEmpty(mcVersionString))
    {
        minecraftAccepted = VersionParser.parseRange(mcVersionString);
    }
    else
    {
        minecraftAccepted = Loader.instance().getMinecraftModContainer().getStaticVersionRange();
    }
}