Skip to content

Commit d4f1042

Browse files
1.21.4 (#4582)
* chore: bump api to 1.21.4 * fix: replace (removed) constants with backwards compatible alternatives * chore: cleanup import * chore: update javadoc link for paper * chore: i like this more * fix: check for vehicle * chore: compile against 1.20.4 again * chore: add 1.21.4 to bug report issue template * chore: add 1.21.4 to runServer supported versions array * chore: update entity type enum name switch * chore: remove 1.18 from supportedVersions for runServer task * fix: attempt to update ReplicatingEntityWrapper * fix/chore: missing boat handling on spawn * chore: cleanup imports
1 parent 4e2ea67 commit d4f1042

File tree

11 files changed

+88
-48
lines changed

11 files changed

+88
-48
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ body:
2727
description: Which server version are you using? If your server version is not listed, it is not supported. Update to a supported version first.
2828
multiple: false
2929
options:
30+
- '1.21.4'
3031
- '1.21.3'
3132
- '1.21.1'
3233
- '1.20.6'

Bukkit/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ dependencies {
3939
}
4040
compileOnly(libs.placeholderapi)
4141
compileOnly(libs.luckperms)
42-
compileOnly(libs.essentialsx)
42+
compileOnly(libs.essentialsx) {
43+
exclude(group = "org.spigotmc")
44+
}
4345
compileOnly(libs.mvdwapi) { isTransitive = false }
4446

4547
// Other libraries
@@ -101,7 +103,7 @@ tasks {
101103
withType<Javadoc> {
102104
val isRelease = if (rootProject.version.toString().endsWith("-SNAPSHOT")) "TODO" else rootProject.version.toString()
103105
val opt = options as StandardJavadocDocletOptions
104-
opt.links("https://jd.papermc.io/paper/1.20/")
106+
opt.links("https://jd.papermc.io/paper/1.20.4/")
105107
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/" + libs.worldeditBukkit.get().versionConstraint.toString())
106108
opt.links("https://intellectualsites.github.io/plotsquared-javadocs/core/")
107109
opt.links("https://jd.advntr.dev/api/" + libs.adventureApi.get().versionConstraint.toString())

Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -789,22 +789,23 @@ private void runEntityTask() {
789789
if (entity.getMetadata("ps_custom_spawned").stream().anyMatch(MetadataValue::asBoolean)) {
790790
continue;
791791
}
792+
// TODO: use (type) pattern matching when targeting java 21
792793
switch (entity.getType().toString()) {
793794
case "EGG":
794-
case "FISHING_HOOK":
795-
case "ENDER_SIGNAL":
795+
case "FISHING_HOOK", "FISHING_BOBBER":
796+
case "ENDER_SIGNAL", "EYE_OF_ENDER":
796797
case "AREA_EFFECT_CLOUD":
797798
case "EXPERIENCE_ORB":
798-
case "LEASH_HITCH":
799-
case "FIREWORK":
800-
case "LIGHTNING":
799+
case "LEASH_HITCH", "LEASH_KNOT":
800+
case "FIREWORK", "FIREWORK_ROCKET":
801+
case "LIGHTNING", "LIGHTNING_BOLT":
801802
case "WITHER_SKULL":
802803
case "UNKNOWN":
803804
case "PLAYER":
804805
// non moving / unmovable
805806
continue;
806-
case "THROWN_EXP_BOTTLE":
807-
case "SPLASH_POTION":
807+
case "THROWN_EXP_BOTTLE", "EXPERIENCE_BOTTLE":
808+
case "SPLASH_POTION", "POTION":
808809
case "SNOWBALL":
809810
case "SHULKER_BULLET":
810811
case "SPECTRAL_ARROW":
@@ -836,6 +837,11 @@ private void runEntityTask() {
836837
case "TNT_MINECART":
837838
case "CHEST_BOAT":
838839
case "BOAT":
840+
case "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
841+
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT":
842+
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
843+
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
844+
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT":
839845
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
840846
com.plotsquared.core.location.Location location = BukkitUtil.adapt(entity.getLocation());
841847
Plot plot = location.getPlot();
@@ -864,14 +870,14 @@ private void runEntityTask() {
864870
case "SMALL_FIREBALL":
865871
case "FIREBALL":
866872
case "DRAGON_FIREBALL":
867-
case "DROPPED_ITEM":
873+
case "DROPPED_ITEM", "ITEM":
868874
if (Settings.Enabled_Components.KILL_ROAD_ITEMS
869875
&& plotArea.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation())) == null) {
870876
this.removeRoadEntity(entity, iterator);
871877
}
872878
// dropped item
873879
continue;
874-
case "PRIMED_TNT":
880+
case "PRIMED_TNT", "TNT":
875881
case "FALLING_BLOCK":
876882
// managed elsewhere
877883
continue;
@@ -949,7 +955,7 @@ private void runEntityTask() {
949955
case "HORSE":
950956
case "IRON_GOLEM":
951957
case "MAGMA_CUBE":
952-
case "MUSHROOM_COW":
958+
case "MUSHROOM_COW", "MOOSHROOM":
953959
case "OCELOT":
954960
case "PIG":
955961
case "PIG_ZOMBIE":
@@ -958,7 +964,7 @@ private void runEntityTask() {
958964
case "SILVERFISH":
959965
case "SKELETON":
960966
case "SLIME":
961-
case "SNOWMAN":
967+
case "SNOWMAN", "SNOW_GOLEM":
962968
case "SPIDER":
963969
case "SQUID":
964970
case "VILLAGER":

Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.bukkit.DyeColor;
2626
import org.bukkit.Location;
2727
import org.bukkit.Rotation;
28-
import org.bukkit.TreeSpecies;
2928
import org.bukkit.World;
3029
import org.bukkit.block.BlockFace;
3130
import org.bukkit.entity.AbstractHorse;
@@ -34,6 +33,7 @@
3433
import org.bukkit.entity.Bat;
3534
import org.bukkit.entity.Boat;
3635
import org.bukkit.entity.Breedable;
36+
import org.bukkit.entity.ChestBoat;
3737
import org.bukkit.entity.ChestedHorse;
3838
import org.bukkit.entity.EnderDragon;
3939
import org.bukkit.entity.Entity;
@@ -44,7 +44,6 @@
4444
import org.bukkit.entity.Painting;
4545
import org.bukkit.entity.Rabbit;
4646
import org.bukkit.entity.Sheep;
47-
import org.bukkit.entity.Slime;
4847
import org.bukkit.entity.Tameable;
4948
import org.bukkit.inventory.EntityEquipment;
5049
import org.bukkit.inventory.InventoryHolder;
@@ -103,11 +102,19 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
103102
this.noGravity = true;
104103
}
105104
switch (entity.getType().toString()) {
106-
case "BOAT" -> {
105+
case "BOAT", "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
106+
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT" -> {
107107
Boat boat = (Boat) entity;
108-
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
108+
this.dataByte = getOrdinal(Boat.Type.values(), boat.getBoatType());
109109
return;
110110
}
111+
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
112+
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
113+
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT" -> {
114+
ChestBoat boat = (ChestBoat) entity;
115+
this.dataByte = getOrdinal(Boat.Type.values(), boat.getBoatType());
116+
storeInventory(boat);
117+
}
111118
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "EXPERIENCE_ORB", "FALLING_BLOCK", "FIREBALL",
112119
"FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND", "MINECART_MOB_SPAWNER",
113120
"MINECART_TNT", "PLAYER", "PRIMED_TNT", "SLIME", "SMALL_FIREBALL", "SNOWBALL", "MINECART_FURNACE", "SPLASH_POTION",
@@ -117,7 +124,7 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
117124
return;
118125
}
119126
// MISC //
120-
case "DROPPED_ITEM" -> {
127+
case "DROPPED_ITEM", "ITEM" -> {
121128
Item item = (Item) entity;
122129
this.stack = item.getItemStack();
123130
return;
@@ -147,14 +154,14 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
147154
}
148155
// END MISC //
149156
// INVENTORY HOLDER //
150-
case "MINECART_CHEST", "MINECART_HOPPER" -> {
157+
case "MINECART_CHEST", "CHEST_MINECART", "MINECART_HOPPER", "HOPPER_MINECART" -> {
151158
storeInventory((InventoryHolder) entity);
152159
return;
153160
}
154161
// START LIVING ENTITY //
155162
// START AGEABLE //
156163
// START TAMEABLE //
157-
case "HORSE", "DONKEY", "LLAMA", "MULE", "SKELETON_HORSE" -> {
164+
case "CAMEL", "HORSE", "DONKEY", "LLAMA", "TRADER_LLAMA", "MULE", "SKELETON_HORSE", "ZOMBIE_HORSE" -> {
158165
AbstractHorse horse = (AbstractHorse) entity;
159166
this.horse = new HorseStats();
160167
this.horse.jump = horse.getJumpStrength();
@@ -172,22 +179,21 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
172179
return;
173180
}
174181
// END INVENTORY HOLDER //
175-
case "WOLF", "OCELOT" -> {
182+
case "WOLF", "OCELOT", "CAT", "PARROT" -> {
176183
storeTameable((Tameable) entity);
177184
storeBreedable((Breedable) entity);
178185
storeLiving((LivingEntity) entity);
179186
return;
180187
}
181188
// END TAMEABLE //
182-
//todo fix sheep
183189
case "SHEEP" -> {
184190
Sheep sheep = (Sheep) entity;
185191
if (sheep.isSheared()) {
186192
this.dataByte = (byte) 1;
187193
} else {
188194
this.dataByte = (byte) 0;
189195
}
190-
this.dataByte2 = sheep.getColor().getDyeData();
196+
this.dataByte2 = getOrdinal(DyeColor.values(), sheep.getColor());
191197
storeBreedable(sheep);
192198
storeLiving(sheep);
193199
return;
@@ -268,7 +274,7 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
268274
}
269275
case "SKELETON", "WITHER_SKELETON", "GUARDIAN", "ELDER_GUARDIAN", "GHAST", "MAGMA_CUBE", "SQUID", "PIG_ZOMBIE", "HOGLIN",
270276
"ZOMBIFIED_PIGLIN", "PIGLIN", "PIGLIN_BRUTE", "ZOMBIE", "WITHER", "WITCH", "SPIDER", "CAVE_SPIDER", "SILVERFISH",
271-
"GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SHULKER", "SNOWMAN" -> {
277+
"GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SHULKER", "SNOWMAN", "SNOW_GOLEM" -> {
272278
storeLiving((LivingEntity) entity);
273279
return;
274280
}
@@ -450,7 +456,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
450456
}
451457
Entity entity;
452458
switch (this.getType().toString()) {
453-
case "DROPPED_ITEM" -> {
459+
case "DROPPED_ITEM", "ITEM" -> {
454460
return world.dropItem(location, this.stack);
455461
}
456462
case "PLAYER", "LEASH_HITCH" -> {
@@ -486,15 +492,25 @@ public Entity spawn(World world, int xOffset, int zOffset) {
486492
entity.setGravity(false);
487493
}
488494
switch (entity.getType().toString()) {
489-
case "BOAT" -> {
495+
case "BOAT", "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
496+
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT" -> {
490497
Boat boat = (Boat) entity;
491-
boat.setWoodType(TreeSpecies.values()[dataByte]);
498+
boat.setBoatType(Boat.Type.values()[dataByte]);
492499
return entity;
493500
}
494-
case "SLIME" -> {
495-
((Slime) entity).setSize(this.dataByte);
501+
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
502+
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
503+
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT" -> {
504+
ChestBoat boat = (ChestBoat) entity;
505+
boat.setBoatType(Boat.Type.values()[dataByte]);
506+
restoreInventory(boat);
496507
return entity;
497508
}
509+
// SLIME is not even stored
510+
/* case "SLIME" -> {
511+
((Slime) entity).setSize(this.dataByte);
512+
return entity;
513+
} */
498514
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "DROPPED_ITEM", "EXPERIENCE_ORB", "FALLING_BLOCK",
499515
"FIREBALL", "FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND",
500516
"MINECART_MOB_SPAWNER", "MINECART_TNT", "PLAYER", "PRIMED_TNT", "SMALL_FIREBALL", "SNOWBALL",
@@ -518,14 +534,14 @@ public Entity spawn(World world, int xOffset, int zOffset) {
518534
}
519535
// END MISC //
520536
// INVENTORY HOLDER //
521-
case "MINECART_CHEST", "MINECART_HOPPER" -> {
537+
case "MINECART_CHEST", "CHEST_MINECART", "MINECART_HOPPER", "HOPPER_MINECART" -> {
522538
restoreInventory((InventoryHolder) entity);
523539
return entity;
524540
}
525541
// START LIVING ENTITY //
526542
// START AGEABLE //
527543
// START TAMEABLE //
528-
case "HORSE", "LLAMA", "SKELETON_HORSE", "DONKEY", "MULE" -> {
544+
case "CAMEL", "HORSE", "DONKEY", "LLAMA", "TRADER_LLAMA", "MULE", "SKELETON_HORSE", "ZOMBIE_HORSE" -> {
529545
AbstractHorse horse = (AbstractHorse) entity;
530546
horse.setJumpStrength(this.horse.jump);
531547
if (horse instanceof ChestedHorse) {
@@ -542,7 +558,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
542558
return entity;
543559
}
544560
// END INVENTORY HOLDER //
545-
case "WOLF", "OCELOT" -> {
561+
case "WOLF", "OCELOT", "CAT", "PARROT" -> {
546562
restoreTameable((Tameable) entity);
547563
restoreBreedable((Breedable) entity);
548564
restoreLiving((LivingEntity) entity);
@@ -555,7 +571,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
555571
sheep.setSheared(true);
556572
}
557573
if (this.dataByte2 != 0) {
558-
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
574+
sheep.setColor(DyeColor.values()[this.dataByte2]);
559575
}
560576
restoreBreedable(sheep);
561577
restoreLiving(sheep);

Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.plotsquared.core.util.EventDispatcher;
4343
import com.plotsquared.core.util.PlotFlagUtil;
4444
import com.sk89q.worldedit.bukkit.BukkitAdapter;
45+
import com.sk89q.worldedit.util.Enums;
4546
import com.sk89q.worldedit.world.block.BlockType;
4647
import io.papermc.lib.PaperLib;
4748
import org.bukkit.Material;
@@ -57,6 +58,7 @@
5758
import org.bukkit.entity.Projectile;
5859
import org.bukkit.entity.TNTPrimed;
5960
import org.bukkit.entity.Vehicle;
61+
import org.bukkit.entity.minecart.ExplosiveMinecart;
6062
import org.bukkit.event.Cancellable;
6163
import org.bukkit.event.EventHandler;
6264
import org.bukkit.event.EventPriority;
@@ -78,10 +80,17 @@
7880

7981
import java.util.Iterator;
8082
import java.util.List;
83+
import java.util.Objects;
8184

8285
@SuppressWarnings("unused")
8386
public class EntityEventListener implements Listener {
8487

88+
private static final Particle EXPLOSION_HUGE = Objects.requireNonNull(Enums.findByValue(
89+
Particle.class,
90+
"EXPLOSION_EMITTER",
91+
"EXPLOSION_HUGE"
92+
));
93+
8594
private final BukkitPlatform platform;
8695
private final PlotAreaManager plotAreaManager;
8796
private final EventDispatcher eventDispatcher;
@@ -152,8 +161,8 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
152161
}
153162
}
154163
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
155-
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
156-
"FROZEN", "SPELL", "DEFAULT" -> {
164+
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
165+
"FROZEN", "SPELL", "DEFAULT" -> {
157166
if (!area.isMobSpawning()) {
158167
event.setCancelled(true);
159168
return;
@@ -314,7 +323,7 @@ public void onBigBoom(EntityExplodeEvent event) {
314323
if (this.lastRadius != 0) {
315324
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
316325
for (Entity near : nearby) {
317-
if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
326+
if (near instanceof TNTPrimed || near instanceof ExplosiveMinecart) {
318327
if (!near.hasMetadata("plot")) {
319328
near.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
320329
}
@@ -338,7 +347,7 @@ public void onBigBoom(EntityExplodeEvent event) {
338347
event.setCancelled(true);
339348
//Spawn Explosion Particles when enabled in settings
340349
if (Settings.General.ALWAYS_SHOW_EXPLOSIONS) {
341-
event.getLocation().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, event.getLocation(), 0);
350+
event.getLocation().getWorld().spawnParticle(EXPLOSION_HUGE, event.getLocation(), 0);
342351
}
343352
}
344353

Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
import org.bukkit.World;
3232
import org.bukkit.block.Block;
3333
import org.bukkit.entity.ArmorStand;
34+
import org.bukkit.entity.EnderCrystal;
3435
import org.bukkit.entity.Entity;
3536
import org.bukkit.entity.EntityType;
37+
import org.bukkit.entity.Item;
3638
import org.bukkit.entity.Vehicle;
3739
import org.bukkit.event.EventHandler;
3840
import org.bukkit.event.EventPriority;
@@ -132,7 +134,7 @@ public void creatureSpawnEvent(EntitySpawnEvent event) {
132134
Plot plot = location.getOwnedPlotAbs();
133135
EntityType type = entity.getType();
134136
if (plot == null) {
135-
if (type == EntityType.DROPPED_ITEM) {
137+
if (entity instanceof Item) {
136138
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
137139
event.setCancelled(true);
138140
}
@@ -154,7 +156,7 @@ public void creatureSpawnEvent(EntitySpawnEvent event) {
154156
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
155157
event.setCancelled(true);
156158
}
157-
if (type == EntityType.ENDER_CRYSTAL || type == EntityType.ARMOR_STAND) {
159+
if (entity instanceof EnderCrystal || type == EntityType.ARMOR_STAND) {
158160
if (BukkitEntityUtil.checkEntity(entity, plot)) {
159161
event.setCancelled(true);
160162
}

0 commit comments

Comments
 (0)