mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-14 04:02:04 +01:00
advancement stuff
This commit is contained in:
parent
ee51737be6
commit
a68b56a864
@ -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 {
|
||||
|
@ -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
|
||||
}
|
@ -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) {
|
@ -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;
|
@ -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);
|
@ -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
|
@ -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
|
||||
}
|
@ -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) {
|
Loading…
Reference in New Issue
Block a user