mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 19:54:44 +02:00
Fix SQL on 1.17 (hacky) and optimized CompatibilityManager
This commit is contained in:
@ -27,4 +27,37 @@ public class MinecraftGameVersion extends MajorMinorPatchVersion {
|
||||
super(majorVerNumber, minorVerNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the Minecraft version is at least equal to or higher than a target version
|
||||
* @param majorVerNumber target major version number - for example 1.16.5 , the 1 is the major version
|
||||
* @param minorVerNumber target minor version number - for example 1.16.5, the 16 is the minor version
|
||||
* @param patchVerNumber target patch version number - for example 1.16.5, the 5 is the patch version number
|
||||
*
|
||||
* @return returns true if Minecraft is at least a certain version
|
||||
*/
|
||||
public boolean isAtLeast(int majorVerNumber, int minorVerNumber, int patchVerNumber) {
|
||||
//First check if the major version is higher, if it is we have no need to check minor version or patch version
|
||||
|
||||
if(getMajorVersion().asInt() > majorVerNumber) {
|
||||
return true; //Major version is one higher and hierarchically more important than the other versions
|
||||
}
|
||||
|
||||
if(getMajorVersion().asInt() < majorVerNumber) {
|
||||
return false; //Major version is below, so return false
|
||||
}
|
||||
|
||||
//Major version meets the requirement, check minor version
|
||||
|
||||
if(getMinorVersion().asInt() > minorVerNumber) {
|
||||
return true; //Minor version is one higher and hierarchically more important than patch version, so exit here
|
||||
}
|
||||
|
||||
if(getMinorVersion().asInt() < minorVerNumber) {
|
||||
return false; //Minor version is at least one version behind, return false
|
||||
}
|
||||
|
||||
//Minor version meets the requirement, check patch version
|
||||
return getPatchVersion().asInt() >= patchVerNumber;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user