mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-19 20:00:05 +00:00
Put in version check for refined relocation
This commit is contained in:
1 parent
e0b4658a95
commit
f0443d5b1d
3 files changed
+43
-1
No files matched your search
@@ -1,11 +1,47 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.InvalidVersionSpecificationException;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class IntegrationModule
|
||||
{
|
||||
public String getModID () {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean versionCheck () {
|
||||
String pattern = versionPattern();
|
||||
if (pattern == null)
|
||||
return true;
|
||||
|
||||
List<ModContainer> modList = Loader.instance().getModList();
|
||||
for (int i = 0, n = modList.size(); i < n; i++) {
|
||||
ModContainer mod = modList.get(i);
|
||||
if (mod.getModId().equals(getModID())) {
|
||||
try {
|
||||
VersionRange validVersions = VersionRange.createFromVersionSpec(pattern);
|
||||
ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion());
|
||||
return validVersions.containsVersion(version);
|
||||
}
|
||||
catch (InvalidVersionSpecificationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String versionPattern () {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void init () throws Throwable;
|
||||
|
||||
public abstract void postInit ();
|
||||
|
||||
@@ -40,7 +40,8 @@ public class IntegrationRegistry
|
||||
}
|
||||
|
||||
public void add (IntegrationModule module) {
|
||||
registry.add(module);
|
||||
if (module.versionCheck())
|
||||
registry.add(module);
|
||||
}
|
||||
|
||||
public void init () {
|
||||
|
||||
@@ -40,6 +40,11 @@ public class RefinedRelocation extends IntegrationModule
|
||||
return "RefinedRelocation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String versionPattern () {
|
||||
return "[1.0.8b,)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init () throws Throwable {
|
||||
fullDrawers1 = new BlockSortingDrawers("fullDrawers1", 1, false);
|
||||
|
||||
Reference in new issue
Block a user