Skip to content

Commit 91961af

Browse files
committed
feat: 支持 1.21.11 新增生物
1 parent dbbc2e1 commit 91961af

3 files changed

Lines changed: 68 additions & 12 deletions

File tree

build.gradle.kts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
}
1616

1717
dependencies {
18-
compileOnly("io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT")
18+
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
1919
compileOnly("com.github.SlimefunGuguProject:Slimefun4:2025.1")
2020
compileOnly("me.clip:placeholderapi:2.11.6")
2121
compileOnly("net.guizhanss:GuizhanLibPlugin:2.3.0")
@@ -61,16 +61,17 @@ bukkit {
6161
tasks {
6262
runServer {
6363
downloadPlugins {
64+
val t = 114514
6465
// Slimefun
65-
url("https://builds.guizhanss.com/api/download/SlimefunGuguProject/Slimefun4/master/218")
66+
url("https://builds.guizhanss.com/api/download/SlimefunGuguProject/Slimefun4/master/latest?t=${t}")
6667
// GuizhanLibPlugin
67-
url("https://builds.guizhanss.com/api/download/ybw0014/GuizhanLibPlugin/master/latest")
68+
url("https://builds.guizhanss.com/api/download/ybw0014/GuizhanLibPlugin/master/latest?t=${t}")
6869
// SlimeHUD
69-
url("https://builds.guizhanss.com/api/download/SlimefunGuguProject/SlimeHUD/master/latest")
70+
url("https://builds.guizhanss.com/api/download/SlimefunGuguProject/SlimeHUD/master/latest?t=${t}")
7071
// GuizhanCraft for testing convenient
71-
url("https://builds.guizhanss.com/api/download/ybw0014/GuizhanCraft/master/latest")
72+
url("https://builds.guizhanss.com/api/download/ybw0014/GuizhanCraft/master/latest?t=${t}")
7273
}
7374
jvmArgs("-Dcom.mojang.eula.agree=true")
74-
minecraftVersion("1.21.6")
75+
minecraftVersion("1.21.11")
7576
}
7677
}

src/main/java/io/github/thebusybiscuit/extraheads/setup/ItemSetup.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.logging.Level;
44

5+
import io.github.thebusybiscuit.extraheads.utils.MinecraftVersionUtils;
6+
57
import org.bukkit.entity.EntityType;
68

79
import io.github.thebusybiscuit.extraheads.ExtraHeads;
@@ -68,7 +70,7 @@ public static void setup() {
6870
registerHead(EntityType.GLOW_SQUID, "57327ee11812b764c7ade70b282cce4c58e635b2015244081d1490543da7280e");
6971
registerHead(EntityType.GOAT, "457a0d538fa08a7affe312903468861720f9fa34e86d44b89dcec5639265f03");
7072

71-
if (MinecraftVersionUtil.isAtLeast(19)) {
73+
if (MinecraftVersionUtils.isAtLeast(1, 19)) {
7274
// https://minecraft-heads.com/custom-heads/animals/61373-allay
7375
registerHead(EntityType.ALLAY, "df5de940bfe499c59ee8dac9f9c3919e7535eff3a9acb16f4842bf290f4c679f");
7476
// https://minecraft-heads.com/custom-heads/animals/63169-cold-frog
@@ -77,35 +79,49 @@ public static void setup() {
7779
registerHead(EntityType.TADPOLE, "987035f5352334c2cba6ac4c65c2b9059739d6d0e839c1dd98d75d2e77957847");
7880
}
7981

80-
if (MinecraftVersionUtil.isAtLeast(20)) {
82+
if (MinecraftVersionUtils.isAtLeast(1, 20)) {
8183
// https://minecraft-heads.com/custom-heads/animals/62878-camel
8284
registerHead(EntityType.CAMEL, "3642c9f71131b5df4a8c21c8c6f10684f22abafb8cd68a1d55ac4bf263a53a31");
8385
// https://minecraft-heads.com/custom-heads/animals/64113-sniffer
8486
registerHead(EntityType.SNIFFER, "fe5a8341c478a134302981e6a7758ea4ecfd8d62a0df4067897e75502f9b25de");
8587
}
8688

87-
if (MinecraftVersionUtil.isAtLeast(20, 5)) {
89+
if (MinecraftVersionUtils.isAtLeast(1, 20, 5)) {
8890
// https://minecraft-heads.com/custom-heads/head/91910-armadillo
8991
registerHead(EntityType.ARMADILLO, "9852b33ba294f560090752d113fe728cbc7dd042029a38d5382d65a2146068b7");
9092
}
9193

92-
if (MinecraftVersionUtil.isAtLeast(21)) {
94+
if (MinecraftVersionUtils.isAtLeast(1, 21)) {
9395
// https://minecraft-heads.com/custom-heads/head/87691-bogged
9496
registerHead(EntityType.BOGGED, "a3b9003ba2d05562c75119b8a62185c67130e9282f7acbac4bc2824c21eb95d9");
9597
// https://minecraft-heads.com/custom-heads/head/69108-breeze
9698
registerHead(EntityType.BREEZE, "a275728af7e6a29c88125b675a39d88ae9919bb61fdc200337fed6ab0c49d65c");
9799
}
98100

99-
if (MinecraftVersionUtil.isAtLeast(21, 4)) {
101+
if (MinecraftVersionUtils.isAtLeast(1, 21, 4)) {
100102
// https://minecraft-heads.com/custom-heads/head/111644-creaking
101103
registerHead(EntityType.CREAKING, "3630e03391db6c0e9c8643a59754c2d19a1f938a787150af3b3d516ba8094cda");
102104
}
103105

104-
if (MinecraftVersionUtil.isAtLeast(21, 6)) {
106+
if (MinecraftVersionUtils.isAtLeast(1, 21, 6)) {
105107
// https://minecraft-heads.com/custom-heads/head/117418-happy-ghast
106108
registerHead(EntityType.HAPPY_GHAST, "a1a36cb93d01675c4622dd5c8d872110911ec12c372e89afa8ba03862867f6fb");
107109
}
108110

111+
if (MinecraftVersionUtils.isAtLeast(1, 21, 11)) {
112+
// https://minecraft-heads.com/custom-heads/head/123519-camel-husk
113+
registerHead(EntityType.CAMEL_HUSK, "3bd7a92a6f67b7500d16c4e12f28058ec2859311556ba03be2d1f581170f2db6");
114+
// https://minecraft-heads.com/custom-heads/head/123259-nautilus
115+
registerHead(EntityType.NAUTILUS, "3bb340dd3302615348de5162fe1670b9c5c9c616cd92d2de9d8398cb33e842ae");
116+
// https://minecraft-heads.com/custom-heads/head/123518-parched
117+
registerHead(EntityType.PARCHED, "24aeceff5f26dd8413c5c03547c234ac03108d187af0b9cd834a8ce12598591c");
118+
// https://minecraft-heads.com/custom-heads/head/123260-zombie-nautilus
119+
registerHead(EntityType.ZOMBIE_NAUTILUS, "fd9a933376da44c3391307cb9f4cf03f16f3a54f495fd5a11bad8a373f9d5720");
120+
// https://minecraft-heads.com/custom-heads/head/89401-zombie-horse
121+
registerHead(EntityType.ZOMBIE_HORSE, "ce62ef83bc7ddc9b86a6a1a916d1ddb802f4d14fd75be8cac6d69c7b6e1cf97");
122+
123+
}
124+
109125
ExtraHeads.getRegistry().getConfig().save();
110126
}
111127

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.thebusybiscuit.extraheads.utils;
2+
3+
import lombok.experimental.UtilityClass;
4+
5+
import org.bukkit.Bukkit;
6+
7+
import java.util.regex.Matcher;
8+
import java.util.regex.Pattern;
9+
10+
@UtilityClass
11+
public class MinecraftVersionUtils {
12+
13+
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
14+
15+
public static boolean isAtLeast(int major, int minor) {
16+
return isAtLeast(major, minor, 0);
17+
}
18+
19+
public static boolean isAtLeast(int major, int minor, int patch) {
20+
String currentVersion = Bukkit.getServer().getMinecraftVersion();
21+
Matcher matcher = VERSION_PATTERN.matcher(currentVersion);
22+
23+
if (!matcher.find()) {
24+
return false;
25+
}
26+
27+
int currentMajor = Integer.parseInt(matcher.group(1));
28+
int currentMinor = Integer.parseInt(matcher.group(2));
29+
int currentPatch = matcher.group(3) != null ? Integer.parseInt(matcher.group(3)) : 0;
30+
31+
if (currentMajor != major) {
32+
return currentMajor > major;
33+
}
34+
if (currentMinor != minor) {
35+
return currentMinor > minor;
36+
}
37+
return currentPatch >= patch;
38+
}
39+
}

0 commit comments

Comments
 (0)