Skip to content

Commit

Permalink
跟进新版本Java版本判定
Browse files Browse the repository at this point in the history
增加部分数据类型序列化
  • Loading branch information
Steve-xmh committed Apr 9, 2024
1 parent 6e8bfc6 commit b4de07e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion scl-core/src/semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ impl MinecraftVersion {
/// 目前检测到 1.17+ 的正式版本都会返回 16,其余的返回 8
pub fn required_java_version(&self) -> u8 {
if let Self::Release(mayor, minor, _) = *self {
if mayor >= 1 && minor >= 17 {
if mayor >= 1 && minor >= 21 {
21
} else if mayor >= 1 && minor >= 17 {
16
} else {
8
}
} else if let Self::Snapshot(year, week, num) = *self {
// https://www.minecraft.net/zh-hans/article/minecraft-snapshot-24w14a
if year >= 24 && week >= 14 && num >= 'a' {
21
} else if year >= 21 && week >= 8 {
16
} else {
8
Expand Down
5 changes: 4 additions & 1 deletion scl-core/src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use self::structs::VersionInfo;
use crate::prelude::*;

/// 一个游戏版本的信息
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Version {
/// 版本名称,通常和其文件夹同名
pub name: String,
Expand Down Expand Up @@ -96,7 +98,8 @@ pub async fn get_avaliable_versions(
}

/// 版本类型
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum VersionType {
/// 纯净版本
Vanilla,
Expand Down

0 comments on commit b4de07e

Please sign in to comment.