Skip to content

Commit f09541c

Browse files
authored
Update to Minecraft 1.21.5 (#6109)
1 parent 0cb387f commit f09541c

File tree

6 files changed

+154
-8
lines changed

6 files changed

+154
-8
lines changed

Essentials/src/main/java/com/earth2me/essentials/MobCompat.java

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.bukkit.entity.Axolotl;
1010
import org.bukkit.entity.Boat;
1111
import org.bukkit.entity.Camel;
12+
import org.bukkit.entity.Chicken;
13+
import org.bukkit.entity.Cow;
1214
import org.bukkit.entity.Entity;
1315
import org.bukkit.entity.EntityType;
1416
import org.bukkit.entity.Fox;
@@ -18,22 +20,39 @@
1820
import org.bukkit.entity.Ocelot;
1921
import org.bukkit.entity.Panda;
2022
import org.bukkit.entity.Parrot;
23+
import org.bukkit.entity.Pig;
2124
import org.bukkit.entity.Player;
2225
import org.bukkit.entity.Salmon;
2326
import org.bukkit.entity.TropicalFish;
2427
import org.bukkit.entity.Villager;
2528
import org.bukkit.entity.Wolf;
2629
import org.bukkit.inventory.ItemStack;
2730

31+
import java.lang.invoke.MethodHandle;
32+
import java.lang.invoke.MethodHandles;
33+
import java.lang.invoke.MethodType;
2834
import java.lang.reflect.Method;
2935

3036
import static com.earth2me.essentials.utils.EnumUtil.getEntityType;
3137

3238
public final class MobCompat {
3339

3440
// Constants for mob interfaces added in later versions
35-
@SuppressWarnings("rawtypes")
36-
public static final Class RAIDER = ReflUtil.getClassCached("org.bukkit.entity.Raider");
41+
public static final Class<?> RAIDER = ReflUtil.getClassCached("org.bukkit.entity.Raider");
42+
43+
// Stupid hacks to avoid Commodore rewrites.
44+
private static final Class<?> COW = ReflUtil.getClassCached("org.bukkit.entity.Cow");
45+
private static final Class<?> COW_VARIANT = ReflUtil.getClassCached("org.bukkit.entity.Cow$Variant");
46+
private static final MethodHandle COW_VARIANT_HANDLE;
47+
48+
static {
49+
MethodHandle handle = null;
50+
try {
51+
handle = MethodHandles.lookup().findVirtual(COW, "setVariant", MethodType.methodType(void.class, COW_VARIANT));
52+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
53+
}
54+
COW_VARIANT_HANDLE = handle;
55+
}
3756

3857
// Constants for mobs added in later versions
3958
public static final EntityType LLAMA = getEntityType("LLAMA");
@@ -250,6 +269,41 @@ public static void setSalmonSize(Entity spawned, String s) {
250269
}
251270
}
252271

272+
public static void setCowVariant(final Entity spawned, final String variant) {
273+
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_21_5_R01) || COW_VARIANT_HANDLE == null) {
274+
return;
275+
}
276+
277+
if (spawned instanceof Cow) {
278+
try {
279+
COW_VARIANT_HANDLE.invoke(spawned, RegistryUtil.valueOf(COW_VARIANT, variant));
280+
} catch (Throwable ignored) {
281+
}
282+
}
283+
}
284+
285+
public static void setChickenVariant(final Entity spawned, final String variant) {
286+
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_21_5_R01)) {
287+
return;
288+
}
289+
290+
if (spawned instanceof Chicken) {
291+
//noinspection DataFlowIssue
292+
((Chicken) spawned).setVariant(RegistryUtil.valueOf(Chicken.Variant.class, variant));
293+
}
294+
}
295+
296+
public static void setPigVariant(final Entity spawned, final String variant) {
297+
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_21_5_R01)) {
298+
return;
299+
}
300+
301+
if (spawned instanceof Pig) {
302+
//noinspection DataFlowIssue
303+
((Pig) spawned).setVariant(RegistryUtil.valueOf(Pig.Variant.class, variant));
304+
}
305+
}
306+
253307
public enum CatType {
254308
// These are (loosely) Mojang names for the cats
255309
SIAMESE("SIAMESE", "SIAMESE_CAT"),

Essentials/src/main/java/com/earth2me/essentials/MobData.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.entity.Ageable;
1111
import org.bukkit.entity.Boat;
1212
import org.bukkit.entity.ChestedHorse;
13+
import org.bukkit.entity.Chicken;
1314
import org.bukkit.entity.Creeper;
1415
import org.bukkit.entity.Entity;
1516
import org.bukkit.entity.EntityType;
@@ -221,6 +222,15 @@ public enum MobData {
221222
SMALL_SALMON("small", MobCompat.SALMON, "salmon:SMALL", true),
222223
MEDIUM_SALMON("medium", MobCompat.SALMON, "salmon:MEDIUM", true),
223224
LARGE_SALMON("large", MobCompat.SALMON, "salmon:LARGE", true),
225+
TEMPERATE_COW("temperate", EntityType.COW.getEntityClass(), "cow:TEMPERATE", true),
226+
WARM_COW("warm", EntityType.COW.getEntityClass(), "cow:WARM", true),
227+
COLD_COW("cold", EntityType.COW.getEntityClass(), "cow:COLD", true),
228+
TEMPERATE_CHICKEN("temperate", Chicken.class, "chicken:TEMPERATE", true),
229+
WARM_CHICKEN("warm", Chicken.class, "chicken:WARM", true),
230+
COLD_CHICKEN("cold", Chicken.class, "chicken:COLD", true),
231+
TEMPERATE_PIG("temperate", Pig.class, "pig:TEMPERATE", true),
232+
WARM_PIG("warm", Pig.class, "pig:WARM", true),
233+
COLD_PIG("cold", Pig.class, "pig:COLD", true),
224234
;
225235

226236
final private String nickname;
@@ -442,6 +452,15 @@ public void setData(final Entity spawned, final Player target, final String rawD
442452
case "salmon":
443453
MobCompat.setSalmonSize(spawned, split[1]);
444454
break;
455+
case "cow":
456+
MobCompat.setCowVariant(spawned, split[1]);
457+
break;
458+
case "chicken":
459+
MobCompat.setChickenVariant(spawned, split[1]);
460+
break;
461+
case "pig":
462+
MobCompat.setPigVariant(spawned, split[1]);
463+
break;
445464
}
446465
} else {
447466
Essentials.getWrappedLogger().warning("Unknown mob data type: " + this.toString());

Essentials/src/main/java/com/earth2me/essentials/utils/VersionUtil.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ public final class VersionUtil {
3838
public static final BukkitVersion v1_19_R01 = BukkitVersion.fromString("1.19-R0.1-SNAPSHOT");
3939
public static final BukkitVersion v1_19_4_R01 = BukkitVersion.fromString("1.19.4-R0.1-SNAPSHOT");
4040
public static final BukkitVersion v1_20_1_R01 = BukkitVersion.fromString("1.20.1-R0.1-SNAPSHOT");
41-
public static final BukkitVersion v1_20_4_R01 = BukkitVersion.fromString("1.20.4-R0.1-SNAPSHOT");
4241
public static final BukkitVersion v1_20_6_R01 = BukkitVersion.fromString("1.20.6-R0.1-SNAPSHOT");
4342
public static final BukkitVersion v1_21_R01 = BukkitVersion.fromString("1.21-R0.1-SNAPSHOT");
4443
public static final BukkitVersion v1_21_3_R01 = BukkitVersion.fromString("1.21.3-R0.1-SNAPSHOT");
45-
public static final BukkitVersion v1_21_4_R01 = BukkitVersion.fromString("1.21.4-R0.1-SNAPSHOT");
44+
public static final BukkitVersion v1_21_5_R01 = BukkitVersion.fromString("1.21.5-R0.1-SNAPSHOT");
4645

47-
private static final Set<BukkitVersion> supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01, v1_14_4_R01, v1_15_2_R01, v1_16_5_R01, v1_17_1_R01, v1_18_2_R01, v1_19_4_R01, v1_20_6_R01, v1_21_4_R01);
46+
private static final Set<BukkitVersion> supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01, v1_14_4_R01, v1_15_2_R01, v1_16_5_R01, v1_17_1_R01, v1_18_2_R01, v1_19_4_R01, v1_20_6_R01, v1_21_5_R01);
4847

4948
public static final boolean PRE_FLATTENING = VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01);
5049

Essentials/src/main/resources/items.json

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,11 @@
20032003
"bludye": "blue_dye",
20042004
"bluedye": "blue_dye",
20052005
"minecraft:blue_dye": "blue_dye",
2006+
"blue_egg": {
2007+
"material": "BLUE_EGG"
2008+
},
2009+
"blueegg": "blue_egg",
2010+
"minecraft:blue_egg": "blue_egg",
20062011
"blue_glazed_terracotta": {
20072012
"material": "BLUE_GLAZED_TERRACOTTA"
20082013
},
@@ -2322,6 +2327,11 @@
23222327
"brodye": "brown_dye",
23232328
"browndye": "brown_dye",
23242329
"minecraft:brown_dye": "brown_dye",
2330+
"brown_egg": {
2331+
"material": "BROWN_EGG"
2332+
},
2333+
"brownegg": "brown_egg",
2334+
"minecraft:brown_egg": "brown_egg",
23252335
"brown_glazed_terracotta": {
23262336
"material": "BROWN_GLAZED_TERRACOTTA"
23272337
},
@@ -2469,12 +2479,28 @@
24692479
"burnpotterysherd": "burn_pottery_sherd",
24702480
"burnsherd": "burn_pottery_sherd",
24712481
"minecraft:burn_pottery_sherd": "burn_pottery_sherd",
2482+
"bush": {
2483+
"material": "BUSH"
2484+
},
2485+
"gbush": "bush",
2486+
"grassbush": "bush",
2487+
"minecraft:bush": "bush",
24722488
"cactus": {
24732489
"material": "CACTUS"
24742490
},
24752491
"cacti": "cactus",
24762492
"cactuses": "cactus",
24772493
"minecraft:cactus": "cactus",
2494+
"cactus_flower": {
2495+
"material": "CACTUS_FLOWER"
2496+
},
2497+
"cactiflower": "cactus_flower",
2498+
"cactusflower": "cactus_flower",
2499+
"cflower": "cactus_flower",
2500+
"flowerc": "cactus_flower",
2501+
"flowercacti": "cactus_flower",
2502+
"flowercactus": "cactus_flower",
2503+
"minecraft:cactus_flower": "cactus_flower",
24782504
"cake": {
24792505
"material": "CAKE"
24802506
},
@@ -5712,7 +5738,6 @@
57125738
"dead_bush": {
57135739
"material": "DEAD_BUSH"
57145740
},
5715-
"bush": "dead_bush",
57165741
"dbush": "dead_bush",
57175742
"deadbush": "dead_bush",
57185743
"deadsapling": "dead_bush",
@@ -7425,6 +7450,13 @@
74257450
"firerestarr": "fire_resistance_tipped_arrow",
74267451
"firerestarrow": "fire_resistance_tipped_arrow",
74277452
"firerestippedarrow": "fire_resistance_tipped_arrow",
7453+
"firefly_bush": {
7454+
"material": "FIREFLY_BUSH"
7455+
},
7456+
"ffbush": "firefly_bush",
7457+
"firebush": "firefly_bush",
7458+
"fireflybush": "firefly_bush",
7459+
"minecraft:firefly_bush": "firefly_bush",
74287460
"firework_rocket": {
74297461
"material": "FIREWORK_ROCKET"
74307462
},
@@ -11428,6 +11460,15 @@
1142811460
"material": "LEAD"
1142911461
},
1143011462
"minecraft:lead": "lead",
11463+
"leaf_litter": {
11464+
"material": "LEAF_LITTER"
11465+
},
11466+
"leaflit": "leaf_litter",
11467+
"leaflitter": "leaf_litter",
11468+
"litter": "leaf_litter",
11469+
"llitter": "leaf_litter",
11470+
"minecraft:leaf_litter": "leaf_litter",
11471+
"spottedleaf": "leaf_litter",
1143111472
"leaping_lingering_potion": {
1143211473
"potionData": {
1143311474
"type": "LEAPING",
@@ -27238,6 +27279,14 @@
2723827279
"minecraft:shield": "shield",
2723927280
"woodenshield": "shield",
2724027281
"woodshield": "shield",
27282+
"short_dry_grass": {
27283+
"material": "SHORT_DRY_GRASS"
27284+
},
27285+
"minecraft:short_dry_grass": "short_dry_grass",
27286+
"sdgrass": "short_dry_grass",
27287+
"sdrygrass": "short_dry_grass",
27288+
"shortdgrass": "short_dry_grass",
27289+
"shortdrygrass": "short_dry_grass",
2724127290
"short_grass": {
2724227291
"material": "SHORT_GRASS",
2724327292
"fallbacks": [
@@ -33146,6 +33195,14 @@
3314633195
"tadpolemonsterspawner": "tadpole_spawner",
3314733196
"tadpolemspawner": "tadpole_spawner",
3314833197
"tadpolespawner": "tadpole_spawner",
33198+
"tall_dry_grass": {
33199+
"material": "TALL_DRY_GRASS"
33200+
},
33201+
"minecraft:tall_dry_grass": "tall_dry_grass",
33202+
"talldgrass": "tall_dry_grass",
33203+
"talldrygrass": "tall_dry_grass",
33204+
"tdgrass": "tall_dry_grass",
33205+
"tdrygrass": "tall_dry_grass",
3314933206
"tall_grass": {
3315033207
"material": "TALL_GRASS"
3315133208
},
@@ -33167,6 +33224,16 @@
3316733224
"material": "TERRACOTTA"
3316833225
},
3316933226
"minecraft:terracotta": "terracotta",
33227+
"test_block": {
33228+
"material": "TEST_BLOCK"
33229+
},
33230+
"minecraft:test_block": "test_block",
33231+
"testblock": "test_block",
33232+
"test_instance_block": {
33233+
"material": "TEST_INSTANCE_BLOCK"
33234+
},
33235+
"minecraft:test_instance_block": "test_instance_block",
33236+
"testinstanceblock": "test_instance_block",
3317033237
"thick_lingering_potion": {
3317133238
"potionData": {
3317233239
"type": "THICK",
@@ -46809,6 +46876,13 @@
4680946876
"minecraft:wild_armor_trim_smithing_template": "wild_armor_trim_smithing_template",
4681046877
"wildarmortrimsmithingtemplate": "wild_armor_trim_smithing_template",
4681146878
"wildtrim": "wild_armor_trim_smithing_template",
46879+
"wildflowers": {
46880+
"material": "WILDFLOWERS"
46881+
},
46882+
"minecraft:wildflowers": "wildflowers",
46883+
"wflower": "wildflowers",
46884+
"wflowers": "wildflowers",
46885+
"wildflower": "wildflowers",
4681246886
"wind_charge": {
4681346887
"material": "WIND_CHARGE"
4681446888
},

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ however, have some new requirements:
2626
* **EssentialsX requires CraftBukkit, Spigot or Paper to run.** Other server software may work, but these are not tested
2727
by the team and we may not be able to help with any issues that occur.
2828
* **EssentialsX currently supports Minecraft versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13.2, 1.14.4, 1.15.2,
29-
1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.20.6, and 1.21.4.**
29+
1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.20.6, and 1.21.5.**
3030
* **EssentialsX currently requires Java 8 or higher.** We recommend using the latest Java version supported by your
3131
server software.
3232
* **EssentialsX requires [Vault](http://dev.bukkit.org/bukkit-plugins/vault/) to enable using chat prefix/suffixes and

build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
val baseExtension = extensions.create<EssentialsBaseExtension>("essentials", project)
1111

1212
val checkstyleVersion = "8.36.2"
13-
val spigotVersion = "1.21.4-R0.1-SNAPSHOT"
13+
val spigotVersion = "1.21.5-R0.1-SNAPSHOT"
1414
val junit5Version = "5.10.2"
1515
val mockitoVersion = "3.12.4"
1616

0 commit comments

Comments
 (0)