Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
60 lines
1.8 KiB
Java
60 lines
1.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.annotation.Nullable
|
|
*/
|
|
package de.maxhenkel.voicechat;
|
|
|
|
import de.maxhenkel.voicechat.Version;
|
|
import de.maxhenkel.voicechat.compatibility.ReflectionUtils;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import javax.annotation.Nullable;
|
|
|
|
public class PaperVersion
|
|
extends Version {
|
|
public static final Pattern PAPER_VERSION_REGEX = Pattern.compile("^(?<major>\\d+)\\.(?<minor>\\d+)(?:\\.(?<patch>\\d+))?\\.(?<build>.*)$");
|
|
private final String build;
|
|
|
|
public PaperVersion(int major, int minor, int patch, String build) {
|
|
super(major, minor, patch);
|
|
this.build = build;
|
|
}
|
|
|
|
private static PaperVersion fromRegex(Matcher matcher) {
|
|
String major = matcher.group("major");
|
|
String minor = matcher.group("minor");
|
|
String patch = matcher.group("patch");
|
|
String build = matcher.group("build");
|
|
if (patch == null || patch.isEmpty()) {
|
|
patch = "0";
|
|
}
|
|
return new PaperVersion(Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch), build);
|
|
}
|
|
|
|
public static boolean isPaper() {
|
|
return ReflectionUtils.doesClassExist("io.papermc.paper.ServerBuildInfo");
|
|
}
|
|
|
|
@Nullable
|
|
public static PaperVersion parsePaperVersion(String version) {
|
|
if (!PaperVersion.isPaper()) {
|
|
return null;
|
|
}
|
|
Matcher targetMatcher = PAPER_VERSION_REGEX.matcher(version);
|
|
if (!targetMatcher.matches()) {
|
|
return null;
|
|
}
|
|
return PaperVersion.fromRegex(targetMatcher);
|
|
}
|
|
|
|
public String toString() {
|
|
if (this.patch <= 0) {
|
|
return this.major + "." + this.minor + "." + this.build;
|
|
}
|
|
return this.major + "." + this.minor + "." + this.patch + "." + this.build;
|
|
}
|
|
}
|
|
|