Skip to content

Commit

Permalink
1.21.4 (#4582)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PierreSchwang authored Feb 23, 2025
1 parent 4e2ea67 commit d4f1042
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ body:
description: Which server version are you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false
options:
- '1.21.4'
- '1.21.3'
- '1.21.1'
- '1.20.6'
Expand Down
6 changes: 4 additions & 2 deletions Bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ dependencies {
}
compileOnly(libs.placeholderapi)
compileOnly(libs.luckperms)
compileOnly(libs.essentialsx)
compileOnly(libs.essentialsx) {
exclude(group = "org.spigotmc")
}
compileOnly(libs.mvdwapi) { isTransitive = false }

// Other libraries
Expand Down Expand Up @@ -101,7 +103,7 @@ tasks {
withType<Javadoc> {
val isRelease = if (rootProject.version.toString().endsWith("-SNAPSHOT")) "TODO" else rootProject.version.toString()
val opt = options as StandardJavadocDocletOptions
opt.links("https://jd.papermc.io/paper/1.20/")
opt.links("https://jd.papermc.io/paper/1.20.4/")
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/" + libs.worldeditBukkit.get().versionConstraint.toString())
opt.links("https://intellectualsites.github.io/plotsquared-javadocs/core/")
opt.links("https://jd.advntr.dev/api/" + libs.adventureApi.get().versionConstraint.toString())
Expand Down
28 changes: 17 additions & 11 deletions Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,22 +789,23 @@ private void runEntityTask() {
if (entity.getMetadata("ps_custom_spawned").stream().anyMatch(MetadataValue::asBoolean)) {
continue;
}
// TODO: use (type) pattern matching when targeting java 21
switch (entity.getType().toString()) {
case "EGG":
case "FISHING_HOOK":
case "ENDER_SIGNAL":
case "FISHING_HOOK", "FISHING_BOBBER":
case "ENDER_SIGNAL", "EYE_OF_ENDER":
case "AREA_EFFECT_CLOUD":
case "EXPERIENCE_ORB":
case "LEASH_HITCH":
case "FIREWORK":
case "LIGHTNING":
case "LEASH_HITCH", "LEASH_KNOT":
case "FIREWORK", "FIREWORK_ROCKET":
case "LIGHTNING", "LIGHTNING_BOLT":
case "WITHER_SKULL":
case "UNKNOWN":
case "PLAYER":
// non moving / unmovable
continue;
case "THROWN_EXP_BOTTLE":
case "SPLASH_POTION":
case "THROWN_EXP_BOTTLE", "EXPERIENCE_BOTTLE":
case "SPLASH_POTION", "POTION":
case "SNOWBALL":
case "SHULKER_BULLET":
case "SPECTRAL_ARROW":
Expand Down Expand Up @@ -836,6 +837,11 @@ private void runEntityTask() {
case "TNT_MINECART":
case "CHEST_BOAT":
case "BOAT":
case "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT":
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT":
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
com.plotsquared.core.location.Location location = BukkitUtil.adapt(entity.getLocation());
Plot plot = location.getPlot();
Expand Down Expand Up @@ -864,14 +870,14 @@ private void runEntityTask() {
case "SMALL_FIREBALL":
case "FIREBALL":
case "DRAGON_FIREBALL":
case "DROPPED_ITEM":
case "DROPPED_ITEM", "ITEM":
if (Settings.Enabled_Components.KILL_ROAD_ITEMS
&& plotArea.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation())) == null) {
this.removeRoadEntity(entity, iterator);
}
// dropped item
continue;
case "PRIMED_TNT":
case "PRIMED_TNT", "TNT":
case "FALLING_BLOCK":
// managed elsewhere
continue;
Expand Down Expand Up @@ -949,7 +955,7 @@ private void runEntityTask() {
case "HORSE":
case "IRON_GOLEM":
case "MAGMA_CUBE":
case "MUSHROOM_COW":
case "MUSHROOM_COW", "MOOSHROOM":
case "OCELOT":
case "PIG":
case "PIG_ZOMBIE":
Expand All @@ -958,7 +964,7 @@ private void runEntityTask() {
case "SILVERFISH":
case "SKELETON":
case "SLIME":
case "SNOWMAN":
case "SNOWMAN", "SNOW_GOLEM":
case "SPIDER":
case "SQUID":
case "VILLAGER":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Rotation;
import org.bukkit.TreeSpecies;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.AbstractHorse;
Expand All @@ -34,6 +33,7 @@
import org.bukkit.entity.Bat;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Breedable;
import org.bukkit.entity.ChestBoat;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
Expand All @@ -44,7 +44,6 @@
import org.bukkit.entity.Painting;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder;
Expand Down Expand Up @@ -103,11 +102,19 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
this.noGravity = true;
}
switch (entity.getType().toString()) {
case "BOAT" -> {
case "BOAT", "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT" -> {
Boat boat = (Boat) entity;
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
this.dataByte = getOrdinal(Boat.Type.values(), boat.getBoatType());
return;
}
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT" -> {
ChestBoat boat = (ChestBoat) entity;
this.dataByte = getOrdinal(Boat.Type.values(), boat.getBoatType());
storeInventory(boat);
}
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "EXPERIENCE_ORB", "FALLING_BLOCK", "FIREBALL",
"FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND", "MINECART_MOB_SPAWNER",
"MINECART_TNT", "PLAYER", "PRIMED_TNT", "SLIME", "SMALL_FIREBALL", "SNOWBALL", "MINECART_FURNACE", "SPLASH_POTION",
Expand All @@ -117,7 +124,7 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
return;
}
// MISC //
case "DROPPED_ITEM" -> {
case "DROPPED_ITEM", "ITEM" -> {
Item item = (Item) entity;
this.stack = item.getItemStack();
return;
Expand Down Expand Up @@ -147,14 +154,14 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
}
// END MISC //
// INVENTORY HOLDER //
case "MINECART_CHEST", "MINECART_HOPPER" -> {
case "MINECART_CHEST", "CHEST_MINECART", "MINECART_HOPPER", "HOPPER_MINECART" -> {
storeInventory((InventoryHolder) entity);
return;
}
// START LIVING ENTITY //
// START AGEABLE //
// START TAMEABLE //
case "HORSE", "DONKEY", "LLAMA", "MULE", "SKELETON_HORSE" -> {
case "CAMEL", "HORSE", "DONKEY", "LLAMA", "TRADER_LLAMA", "MULE", "SKELETON_HORSE", "ZOMBIE_HORSE" -> {
AbstractHorse horse = (AbstractHorse) entity;
this.horse = new HorseStats();
this.horse.jump = horse.getJumpStrength();
Expand All @@ -172,22 +179,21 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
return;
}
// END INVENTORY HOLDER //
case "WOLF", "OCELOT" -> {
case "WOLF", "OCELOT", "CAT", "PARROT" -> {
storeTameable((Tameable) entity);
storeBreedable((Breedable) entity);
storeLiving((LivingEntity) entity);
return;
}
// END TAMEABLE //
//todo fix sheep
case "SHEEP" -> {
Sheep sheep = (Sheep) entity;
if (sheep.isSheared()) {
this.dataByte = (byte) 1;
} else {
this.dataByte = (byte) 0;
}
this.dataByte2 = sheep.getColor().getDyeData();
this.dataByte2 = getOrdinal(DyeColor.values(), sheep.getColor());
storeBreedable(sheep);
storeLiving(sheep);
return;
Expand Down Expand Up @@ -268,7 +274,7 @@ public ReplicatingEntityWrapper(Entity entity, short depth) {
}
case "SKELETON", "WITHER_SKELETON", "GUARDIAN", "ELDER_GUARDIAN", "GHAST", "MAGMA_CUBE", "SQUID", "PIG_ZOMBIE", "HOGLIN",
"ZOMBIFIED_PIGLIN", "PIGLIN", "PIGLIN_BRUTE", "ZOMBIE", "WITHER", "WITCH", "SPIDER", "CAVE_SPIDER", "SILVERFISH",
"GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SHULKER", "SNOWMAN" -> {
"GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SHULKER", "SNOWMAN", "SNOW_GOLEM" -> {
storeLiving((LivingEntity) entity);
return;
}
Expand Down Expand Up @@ -450,7 +456,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
}
Entity entity;
switch (this.getType().toString()) {
case "DROPPED_ITEM" -> {
case "DROPPED_ITEM", "ITEM" -> {
return world.dropItem(location, this.stack);
}
case "PLAYER", "LEASH_HITCH" -> {
Expand Down Expand Up @@ -486,15 +492,25 @@ public Entity spawn(World world, int xOffset, int zOffset) {
entity.setGravity(false);
}
switch (entity.getType().toString()) {
case "BOAT" -> {
case "BOAT", "ACACIA_BOAT", "BIRCH_BOAT", "CHERRY_BOAT", "DARK_OAK_BOAT", "JUNGLE_BOAT", "MANGROVE_BOAT",
"OAK_BOAT", "PALE_OAK_BOAT", "SPRUCE_BOAT", "BAMBOO_RAFT" -> {
Boat boat = (Boat) entity;
boat.setWoodType(TreeSpecies.values()[dataByte]);
boat.setBoatType(Boat.Type.values()[dataByte]);
return entity;
}
case "SLIME" -> {
((Slime) entity).setSize(this.dataByte);
case "ACACIA_CHEST_BOAT", "BIRCH_CHEST_BOAT", "CHERRY_CHEST_BOAT", "DARK_OAK_CHEST_BOAT",
"JUNGLE_CHEST_BOAT", "MANGROVE_CHEST_BOAT", "OAK_CHEST_BOAT", "PALE_OAK_CHEST_BOAT",
"SPRUCE_CHEST_BOAT", "BAMBOO_CHEST_RAFT" -> {
ChestBoat boat = (ChestBoat) entity;
boat.setBoatType(Boat.Type.values()[dataByte]);
restoreInventory(boat);
return entity;
}
// SLIME is not even stored
/* case "SLIME" -> {
((Slime) entity).setSize(this.dataByte);
return entity;
} */
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "DROPPED_ITEM", "EXPERIENCE_ORB", "FALLING_BLOCK",
"FIREBALL", "FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND",
"MINECART_MOB_SPAWNER", "MINECART_TNT", "PLAYER", "PRIMED_TNT", "SMALL_FIREBALL", "SNOWBALL",
Expand All @@ -518,14 +534,14 @@ public Entity spawn(World world, int xOffset, int zOffset) {
}
// END MISC //
// INVENTORY HOLDER //
case "MINECART_CHEST", "MINECART_HOPPER" -> {
case "MINECART_CHEST", "CHEST_MINECART", "MINECART_HOPPER", "HOPPER_MINECART" -> {
restoreInventory((InventoryHolder) entity);
return entity;
}
// START LIVING ENTITY //
// START AGEABLE //
// START TAMEABLE //
case "HORSE", "LLAMA", "SKELETON_HORSE", "DONKEY", "MULE" -> {
case "CAMEL", "HORSE", "DONKEY", "LLAMA", "TRADER_LLAMA", "MULE", "SKELETON_HORSE", "ZOMBIE_HORSE" -> {
AbstractHorse horse = (AbstractHorse) entity;
horse.setJumpStrength(this.horse.jump);
if (horse instanceof ChestedHorse) {
Expand All @@ -542,7 +558,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
return entity;
}
// END INVENTORY HOLDER //
case "WOLF", "OCELOT" -> {
case "WOLF", "OCELOT", "CAT", "PARROT" -> {
restoreTameable((Tameable) entity);
restoreBreedable((Breedable) entity);
restoreLiving((LivingEntity) entity);
Expand All @@ -555,7 +571,7 @@ public Entity spawn(World world, int xOffset, int zOffset) {
sheep.setSheared(true);
}
if (this.dataByte2 != 0) {
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
sheep.setColor(DyeColor.values()[this.dataByte2]);
}
restoreBreedable(sheep);
restoreLiving(sheep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.PlotFlagUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Enums;
import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib;
import org.bukkit.Material;
Expand All @@ -57,6 +58,7 @@
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -78,10 +80,17 @@

import java.util.Iterator;
import java.util.List;
import java.util.Objects;

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

private static final Particle EXPLOSION_HUGE = Objects.requireNonNull(Enums.findByValue(
Particle.class,
"EXPLOSION_EMITTER",
"EXPLOSION_HUGE"
));

private final BukkitPlatform platform;
private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher;
Expand Down Expand Up @@ -152,8 +161,8 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
}
}
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
"FROZEN", "SPELL", "DEFAULT" -> {
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
"FROZEN", "SPELL", "DEFAULT" -> {
if (!area.isMobSpawning()) {
event.setCancelled(true);
return;
Expand Down Expand Up @@ -314,7 +323,7 @@ public void onBigBoom(EntityExplodeEvent event) {
if (this.lastRadius != 0) {
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
for (Entity near : nearby) {
if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
if (near instanceof TNTPrimed || near instanceof ExplosiveMinecart) {
if (!near.hasMetadata("plot")) {
near.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
}
Expand All @@ -338,7 +347,7 @@ public void onBigBoom(EntityExplodeEvent event) {
event.setCancelled(true);
//Spawn Explosion Particles when enabled in settings
if (Settings.General.ALWAYS_SHOW_EXPLOSIONS) {
event.getLocation().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, event.getLocation(), 0);
event.getLocation().getWorld().spawnParticle(EXPLOSION_HUGE, event.getLocation(), 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -132,7 +134,7 @@ public void creatureSpawnEvent(EntitySpawnEvent event) {
Plot plot = location.getOwnedPlotAbs();
EntityType type = entity.getType();
if (plot == null) {
if (type == EntityType.DROPPED_ITEM) {
if (entity instanceof Item) {
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setCancelled(true);
}
Expand All @@ -154,7 +156,7 @@ public void creatureSpawnEvent(EntitySpawnEvent event) {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
event.setCancelled(true);
}
if (type == EntityType.ENDER_CRYSTAL || type == EntityType.ARMOR_STAND) {
if (entity instanceof EnderCrystal || type == EntityType.ARMOR_STAND) {
if (BukkitEntityUtil.checkEntity(entity, plot)) {
event.setCancelled(true);
}
Expand Down
Loading

0 comments on commit d4f1042

Please sign in to comment.