mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-23 21:59:44 +00:00
Ignore additional tags when deriving the mod version (#2219)
This commit is contained in:
1 parent
12857006c6
commit
b49d37d827
7 files changed
+89
-11
No files matched your search
@@ -31,6 +31,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StandardMacros {
|
||||
@@ -42,21 +44,24 @@ public class StandardMacros {
|
||||
defines.add(new StringPair(key, value));
|
||||
}
|
||||
|
||||
private static final Pattern ANGELICA_VERSION_PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)(?:-(?:alpha|beta|pre|rc)(\\d{1,3}))?");
|
||||
|
||||
private static String makeAngelicaVersion()
|
||||
{
|
||||
String[] parts = Tags.VERSION.split("[.-]");
|
||||
int major = Integer.parseInt(parts[0]);
|
||||
int minor = Integer.parseInt(parts[1]);
|
||||
int patch = Integer.parseInt(parts[2]);
|
||||
int sub = 0;
|
||||
return formatAngelicaVersion(Tags.VERSION);
|
||||
}
|
||||
|
||||
// Handle optional prerelease (like beta62)
|
||||
if (parts.length > 3) {
|
||||
String pre = parts[3];
|
||||
String num = pre.replaceAll("\\D+", ""); // remove all non-digits
|
||||
if (!num.isEmpty())
|
||||
sub = Integer.parseInt(num);
|
||||
static String formatAngelicaVersion(String raw)
|
||||
{
|
||||
final Matcher matcher = ANGELICA_VERSION_PATTERN.matcher(raw);
|
||||
if (!matcher.find()) {
|
||||
Iris.logger.warn("Could not parse Angelica version \"{}\"; defining ANGELICA_VERSION as 99999999", raw);
|
||||
return "99999999";
|
||||
}
|
||||
final int major = Integer.parseInt(matcher.group(1));
|
||||
final int minor = Integer.parseInt(matcher.group(2));
|
||||
final int patch = Integer.parseInt(matcher.group(3));
|
||||
final int sub = matcher.group(4) == null ? 0 : Integer.parseInt(matcher.group(4));
|
||||
return String.format("%d%02d%02d%03d", major, minor, patch, sub);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user