diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java index d8167333b..8b6951ab8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java @@ -33,6 +33,7 @@ import org.bukkit.entity.Ageable; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Bat; import org.bukkit.entity.Boat; +import org.bukkit.entity.Breedable; import org.bukkit.entity.ChestedHorse; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; @@ -165,7 +166,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { //this.horse.style = horse.getStyle(); //this.horse.color = horse.getColor(); storeTameable(horse); - storeAgeable(horse); + storeBreedable(horse); storeLiving(horse); storeInventory(horse); return; @@ -173,7 +174,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { // END INVENTORY HOLDER // case "WOLF", "OCELOT" -> { storeTameable((Tameable) entity); - storeAgeable((Ageable) entity); + storeBreedable((Breedable) entity); storeLiving((LivingEntity) entity); return; } @@ -187,18 +188,18 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { this.dataByte = (byte) 0; } this.dataByte2 = sheep.getColor().getDyeData(); - storeAgeable(sheep); + storeBreedable(sheep); storeLiving(sheep); return; } case "VILLAGER", "CHICKEN", "COW", "MUSHROOM_COW", "PIG", "TURTLE", "POLAR_BEAR" -> { - storeAgeable((Ageable) entity); + storeBreedable((Breedable) entity); storeLiving((LivingEntity) entity); return; } case "RABBIT" -> { this.dataByte = getOrdinal(Rabbit.Type.values(), ((Rabbit) entity).getRabbitType()); - storeAgeable((Ageable) entity); + storeBreedable((Breedable) entity); storeLiving((LivingEntity) entity); return; } @@ -382,6 +383,11 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { } } + /** + * @deprecated Use {@link #restoreBreedable(Breedable)} instead + * @since TODO + */ + @Deprecated(forRemoval = true, since = "TODO") private void restoreAgeable(Ageable entity) { if (!this.aged.adult) { entity.setBaby(); @@ -392,6 +398,11 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { } } + /** + * @deprecated Use {@link #storeBreedable(Breedable)} instead + * @since TODO + */ + @Deprecated(forRemoval = true, since = "TODO") public void storeAgeable(Ageable aged) { this.aged = new AgeableStats(); this.aged.age = aged.getAge(); @@ -399,6 +410,29 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { this.aged.adult = aged.isAdult(); } + /** + * @since TODO + */ + private void restoreBreedable(Breedable entity) { + if (!this.aged.adult) { + entity.setBaby(); + } + entity.setAgeLock(this.aged.locked); + if (this.aged.age > 0) { + entity.setAge(this.aged.age); + } + } + + /** + * @since TODO + */ + private void storeBreedable(Breedable breedable) { + this.aged = new AgeableStats(); + this.aged.age = breedable.getAge(); + this.aged.locked = breedable.getAgeLock(); + this.aged.adult = breedable.isAdult(); + } + public void storeTameable(Tameable tamed) { this.tamed = new TameableStats(); this.tamed.owner = tamed.getOwner(); @@ -502,7 +536,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { //horse.setStyle(this.horse.style); //horse.setColor(this.horse.color); restoreTameable(horse); - restoreAgeable(horse); + restoreBreedable(horse); restoreLiving(horse); restoreInventory(horse); return entity; @@ -510,7 +544,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { // END INVENTORY HOLDER // case "WOLF", "OCELOT" -> { restoreTameable((Tameable) entity); - restoreAgeable((Ageable) entity); + restoreBreedable((Breedable) entity); restoreLiving((LivingEntity) entity); return entity; } @@ -523,12 +557,12 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { if (this.dataByte2 != 0) { sheep.setColor(DyeColor.getByDyeData(this.dataByte2)); } - restoreAgeable(sheep); + restoreBreedable(sheep); restoreLiving(sheep); return sheep; } case "VILLAGER", "CHICKEN", "COW", "TURTLE", "POLAR_BEAR", "MUSHROOM_COW", "PIG" -> { - restoreAgeable((Ageable) entity); + restoreBreedable((Breedable) entity); restoreLiving((LivingEntity) entity); return entity; } @@ -537,7 +571,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { if (this.dataByte != 0) { ((Rabbit) entity).setRabbitType(Rabbit.Type.values()[this.dataByte]); } - restoreAgeable((Ageable) entity); + restoreBreedable((Breedable) entity); restoreLiving((LivingEntity) entity); return entity; } diff --git a/Core/build.gradle.kts b/Core/build.gradle.kts index bdaab0fb7..87e47df83 100644 --- a/Core/build.gradle.kts +++ b/Core/build.gradle.kts @@ -72,7 +72,8 @@ tasks { opt.links("https://jd.advntr.dev/text-minimessage/4.14.0/") opt.links("https://google.github.io/guice/api-docs/" + libs.guice.get().versionConstraint.toString() + "/javadoc/") opt.links("https://checkerframework.org/api/") - opt.links("https://javadocs.dev/com.intellectualsites.informative-annotations/informative-annotations/latest") + opt.links("https://javadocs.dev/com.intellectualsites.informative-annotations/informative-annotations/" + + libs.informativeAnnotations.get().versionConstraint.toString()) opt.isLinkSource = true opt.bottom(File("$rootDir/javadocfooter.html").readText()) opt.isUse = true diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 73c34cdda..d27758761 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -51,6 +51,8 @@ import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.RegionUtil; import com.plotsquared.core.util.StringMan; +import com.plotsquared.core.util.task.TaskManager; +import com.plotsquared.core.util.task.TaskTime; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; @@ -391,6 +393,28 @@ public abstract class PlotArea implements ComponentLike { } } + this.spawnEggs = config.getBoolean("event.spawn.egg"); + this.spawnCustom = config.getBoolean("event.spawn.custom"); + this.spawnBreeding = config.getBoolean("event.spawn.breeding"); + + if (PlotSquared.get().isWeInitialised()) { + loadFlags(config); + } else { + ConsolePlayer.getConsole().sendMessage( + TranslatableCaption.of("flags.delaying_loading_area_flags"), + TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id))) + ); + TaskManager.runTaskLater(() -> loadFlags(config), TaskTime.ticks(1)); + } + + loadConfiguration(config); + } + + private void loadFlags(ConfigurationSection config) { + ConsolePlayer.getConsole().sendMessage( + TranslatableCaption.of("flags.loading_area_flags"), + TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id))) + ); List flags = config.getStringList("flags.default"); if (flags.isEmpty()) { flags = config.getStringList("flags"); @@ -411,10 +435,6 @@ public abstract class PlotArea implements ComponentLike { TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString()))) ); - this.spawnEggs = config.getBoolean("event.spawn.egg"); - this.spawnCustom = config.getBoolean("event.spawn.custom"); - this.spawnBreeding = config.getBoolean("event.spawn.breeding"); - List roadflags = config.getStringList("road.flags"); if (roadflags.isEmpty()) { roadflags = new ArrayList<>(); @@ -426,14 +446,12 @@ public abstract class PlotArea implements ComponentLike { } } } - this.roadFlags = roadflags.size() > 0; + this.roadFlags = !roadflags.isEmpty(); parseFlags(this.getRoadFlagContainer(), roadflags); ConsolePlayer.getConsole().sendMessage( TranslatableCaption.of("flags.road_flags"), TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString()))) ); - - loadConfiguration(config); } public abstract void loadConfiguration(ConfigurationSection config); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index d50fbe4b9..cdc8a371b 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -632,6 +632,8 @@ "flags.flag_error_double": "Flag value must be a decimal number.", "flags.flag_error_music": "Flag value must be a valid music disc ID.", "flags.flag_error_title": "Flag value must be in the format \"A title\" \"The subtitle\".", + "flags.delaying_loading_area_flags": "Delaying loading flags for area `` as WorldEdit is not initialised yet.", + "flags.loading_area_flags": "Loading flags for area: ", "flags.area_flags": "Area flags: ", "flags.road_flags": "Road flags: ", "commands.description.add": "Allow a user to build in a plot while the plot owner is online.", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0a41046af..89dda239c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ paper = "1.20.2-R0.1-SNAPSHOT" guice = "7.0.0" spotbugs = "4.7.3" -checkerqual = "3.38.0" +checkerqual = "3.39.0" gson = "2.10" guava = "31.1-jre" snakeyaml = "2.0" @@ -28,7 +28,7 @@ squirrelid = "0.3.2" paster = "1.1.5" bstats = "3.0.2" paperlib = "1.0.8" -informative-annotations = "1.3" +informative-annotations = "1.4" vault = "1.7.1" serverlib = "2.3.4" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34e8..3fa8f862f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1a5..1aa94a426 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \