/* * 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("^(?\\d+)\\.(?\\d+)(?:\\.(?\\d+))?\\.(?.*)$"); 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; } }