diff --git a/build.gradle.kts b/build.gradle.kts index 2540a7c069..28912b4343 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -157,6 +157,7 @@ tasks.register("checkWork") { val relative = patchFolder.relativize(it).toString().replace(".patch", "") val source = sourceFolder.resolve(relative) val target = targetFolder.resolve(relative) + if (target.isDirectory()) { return@forEach } if (back) { target.copyTo(source, overwrite = true) } else { diff --git a/paper-server/patches/sources/net/minecraft/advancements/AdvancementHolder.java.patch b/paper-server/patches/sources/net/minecraft/advancements/AdvancementHolder.java.patch new file mode 100644 index 0000000000..6450499bcb --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/advancements/AdvancementHolder.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/advancements/AdvancementHolder.java ++++ b/net/minecraft/advancements/AdvancementHolder.java +@@ -26,4 +_,10 @@ + public String toString() { + return this.id.toString(); + } ++ ++ // CraftBukkit start ++ public final org.bukkit.advancement.Advancement toBukkit() { ++ return new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); ++ } ++ // CraftBukkit end + } diff --git a/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch new file mode 100644 index 0000000000..aeb4408967 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/advancements/AdvancementTree.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/advancements/AdvancementTree.java ++++ b/net/minecraft/advancements/AdvancementTree.java +@@ -26,7 +_,7 @@ + this.remove(advancementNode); + } + +- LOGGER.info("Forgot about advancement {}", node.holder()); ++ LOGGER.debug("Forgot about advancement {}", node.holder()); // Paper - Improve logging and errors + this.nodes.remove(node.holder().id()); + if (node.parent() == null) { + this.roots.remove(node); +@@ -62,7 +_,7 @@ + } + } + +- LOGGER.info("Loaded {} advancements", this.nodes.size()); ++ // LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload // Paper - Improve logging and errors; you say it was moved... but it wasn't :) it should be moved however, since this is called when the API creates an advancement + } + + private boolean tryInsert(AdvancementHolder advancement) { diff --git a/paper-server/patches/unapplied/net/minecraft/advancements/DisplayInfo.java.patch b/paper-server/patches/sources/net/minecraft/advancements/DisplayInfo.java.patch similarity index 95% rename from paper-server/patches/unapplied/net/minecraft/advancements/DisplayInfo.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/DisplayInfo.java.patch index a0fdd33f43..c7956c2de5 100644 --- a/paper-server/patches/unapplied/net/minecraft/advancements/DisplayInfo.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/DisplayInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/DisplayInfo.java +++ b/net/minecraft/advancements/DisplayInfo.java -@@ -37,6 +37,7 @@ +@@ -37,6 +_,7 @@ private final boolean hidden; private float x; private float y; diff --git a/paper-server/patches/unapplied/net/minecraft/advancements/critereon/LocationPredicate.java.patch b/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch similarity index 72% rename from paper-server/patches/unapplied/net/minecraft/advancements/critereon/LocationPredicate.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch index 7f7873fc42..e43dabe617 100644 --- a/paper-server/patches/unapplied/net/minecraft/advancements/critereon/LocationPredicate.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/critereon/LocationPredicate.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/advancements/critereon/LocationPredicate.java +++ b/net/minecraft/advancements/critereon/LocationPredicate.java -@@ -44,7 +44,7 @@ - public boolean matches(ServerLevel world, double x, double y, double z) { +@@ -44,7 +_,7 @@ + public boolean matches(ServerLevel level, double x, double y, double z) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { return false; -- } else if (this.dimension.isPresent() && this.dimension.get() != world.dimension()) { -+ } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? world.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(world))) { // Paper - Add option for strict advancement dimension checks +- } else if (this.dimension.isPresent() && this.dimension.get() != level.dimension()) { ++ } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? level.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(level))) { // Paper - Add option for strict advancement dimension checks return false; } else { BlockPos blockPos = BlockPos.containing(x, y, z); diff --git a/paper-server/patches/unapplied/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch b/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch similarity index 63% rename from paper-server/patches/unapplied/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch rename to paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch index d080616002..f953971ef6 100644 --- a/paper-server/patches/unapplied/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch +++ b/paper-server/patches/sources/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +++ b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -@@ -15,41 +15,41 @@ +@@ -15,41 +_,41 @@ import net.minecraft.world.level.storage.loot.LootContext; public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.SimpleInstance> implements CriterionTrigger<T> { @@ -8,34 +8,34 @@ + // private final Map<PlayerAdvancements, Set<CriterionTrigger.Listener<T>>> players = Maps.newIdentityHashMap(); // Paper - fix AdvancementDataPlayer leak; moved into AdvancementDataPlayer to fix memory leak @Override - public final void addPlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) { -- this.players.computeIfAbsent(manager, managerx -> Sets.newHashSet()).add(conditions); -+ manager.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(conditions); // Paper - fix AdvancementDataPlayer leak + public final void addPlayerListener(PlayerAdvancements playerAdvancements, CriterionTrigger.Listener<T> listener) { +- this.players.computeIfAbsent(playerAdvancements, advancements -> Sets.newHashSet()).add(listener); ++ playerAdvancements.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix AdvancementDataPlayer leak } @Override - public final void removePlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) { -- Set<CriterionTrigger.Listener<T>> set = this.players.get(manager); -+ Set<CriterionTrigger.Listener<T>> set = (Set) manager.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak + public final void removePlayerListener(PlayerAdvancements playerAdvancements, CriterionTrigger.Listener<T> listener) { +- Set<CriterionTrigger.Listener<T>> set = this.players.get(playerAdvancements); ++ Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak if (set != null) { - set.remove(conditions); + set.remove(listener); if (set.isEmpty()) { -- this.players.remove(manager); -+ manager.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak +- this.players.remove(playerAdvancements); ++ playerAdvancements.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak } } } @Override - public final void removePlayerListeners(PlayerAdvancements tracker) { -- this.players.remove(tracker); -+ tracker.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak + public final void removePlayerListeners(PlayerAdvancements playerAdvancements) { +- this.players.remove(playerAdvancements); ++ playerAdvancements.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak } - protected void trigger(ServerPlayer player, Predicate<T> predicate) { - PlayerAdvancements playerAdvancements = player.getAdvancements(); -- Set<CriterionTrigger.Listener<T>> set = this.players.get(playerAdvancements); -+ Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak + protected void trigger(ServerPlayer player, Predicate<T> testTrigger) { + PlayerAdvancements advancements = player.getAdvancements(); +- Set<CriterionTrigger.Listener<T>> set = this.players.get(advancements); ++ Set<CriterionTrigger.Listener<T>> set = (Set) advancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak if (set != null && !set.isEmpty()) { - LootContext lootContext = EntityPredicate.createContext(player, player); + LootContext lootContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions @@ -43,7 +43,7 @@ for (CriterionTrigger.Listener<T> listener : set) { T simpleInstance = listener.trigger(); - if (predicate.test(simpleInstance)) { + if (testTrigger.test(simpleInstance)) { Optional<ContextAwarePredicate> optional = simpleInstance.player(); - if (optional.isEmpty() || optional.get().matches(lootContext)) { + if (optional.isEmpty() || optional.get().matches(lootContext = (lootContext == null ? EntityPredicate.createContext(player, player) : lootContext))) { // Paper - Perf: lazily create LootContext for criterions diff --git a/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementHolder.java.patch b/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementHolder.java.patch deleted file mode 100644 index d41639df88..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementHolder.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/advancements/AdvancementHolder.java -+++ b/net/minecraft/advancements/AdvancementHolder.java -@@ -5,6 +5,10 @@ - import net.minecraft.network.codec.ByteBufCodecs; - import net.minecraft.network.codec.StreamCodec; - import net.minecraft.resources.ResourceLocation; -+// CraftBukkit start -+import org.bukkit.craftbukkit.advancement.CraftAdvancement; -+import org.bukkit.craftbukkit.util.CraftNamespacedKey; -+// CraftBukkit end - - public record AdvancementHolder(ResourceLocation id, Advancement value) { - -@@ -38,4 +42,10 @@ - public String toString() { - return this.id.toString(); - } -+ -+ // CraftBukkit start -+ public final org.bukkit.advancement.Advancement toBukkit() { -+ return new CraftAdvancement(this); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementTree.java.patch b/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementTree.java.patch deleted file mode 100644 index 4bec8c46eb..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/advancements/AdvancementTree.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/advancements/AdvancementTree.java -+++ b/net/minecraft/advancements/AdvancementTree.java -@@ -35,7 +35,7 @@ - this.remove(advancementnode1); - } - -- AdvancementTree.LOGGER.info("Forgot about advancement {}", advancement.holder()); -+ AdvancementTree.LOGGER.debug("Forgot about advancement {}", advancement.holder()); // Paper - Improve logging and errors - this.nodes.remove(advancement.holder().id()); - if (advancement.parent() == null) { - this.roots.remove(advancement); -@@ -77,7 +77,7 @@ - } - } - -- AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); -+ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload // Paper - Improve logging and errors; you say it was moved... but it wasn't :) it should be moved however, since this is called when the API creates an advancement - } - - private boolean tryInsert(AdvancementHolder advancement) {