Added min-game-version 105 enforcement
This commit is contained in:
@@ -707,14 +707,51 @@ public class Mods implements Loadable{
|
||||
|
||||
/** @return whether this mod is supported by the game verison */
|
||||
public boolean isSupported(){
|
||||
if(Version.build <= 0 || meta.minGameVersion == null) return true;
|
||||
if(meta.minGameVersion.contains(".")){
|
||||
String[] split = meta.minGameVersion.split("\\.");
|
||||
if(isOutdated()) return false;
|
||||
|
||||
int major = getMinMinor(), minor = getMinMinor();
|
||||
|
||||
if(Version.build <= 0) return true;
|
||||
|
||||
return Version.build >= major && Version.revision >= minor;
|
||||
}
|
||||
|
||||
/** @return whether this mod is outdated, e.g. not compatible with v6. */
|
||||
public boolean isOutdated(){
|
||||
//must be at least 105 to indicate v6 compat
|
||||
return getMinMinor() < 105;
|
||||
}
|
||||
|
||||
public int getMinMajor(){
|
||||
int major = 0;
|
||||
|
||||
String ver = meta.minGameVersion == null ? "0" : meta.minGameVersion;
|
||||
|
||||
if(ver.contains(".")){
|
||||
String[] split = ver.split("\\.");
|
||||
if(split.length == 2){
|
||||
return Version.build >= Strings.parseInt(split[0], 0) && Version.revision >= Strings.parseInt(split[1], 0);
|
||||
major = Strings.parseInt(split[0], 0);
|
||||
}
|
||||
}else{
|
||||
major = Strings.parseInt(ver, 0);
|
||||
}
|
||||
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getMinMinor(){
|
||||
int minor = 0;
|
||||
|
||||
String ver = meta.minGameVersion == null ? "0" : meta.minGameVersion;
|
||||
|
||||
if(ver.contains(".")){
|
||||
String[] split = ver.split("\\.");
|
||||
if(split.length == 2){
|
||||
return Strings.parseInt(split[1], 0);
|
||||
}
|
||||
}
|
||||
return Version.build >= Strings.parseInt(meta.minGameVersion, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -792,7 +829,7 @@ public class Mods implements Loadable{
|
||||
|
||||
/** Mod metadata information.*/
|
||||
public static class ModMeta{
|
||||
public String name, displayName, author, description, version, main, minGameVersion;
|
||||
public String name, displayName, author, description, version, main, minGameVersion = "0";
|
||||
public Seq<String> dependencies = Seq.with();
|
||||
/** Hidden mods are only server-side or client-side, and do not support adding new content. */
|
||||
public boolean hidden;
|
||||
|
||||
Reference in New Issue
Block a user