mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-14 20:31:37 +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 relative = patchFolder.relativize(it).toString().replace(".patch", "")
|
||||||
val source = sourceFolder.resolve(relative)
|
val source = sourceFolder.resolve(relative)
|
||||||
val target = targetFolder.resolve(relative)
|
val target = targetFolder.resolve(relative)
|
||||||
|
if (target.isDirectory()) { return@forEach }
|
||||||
if (back) {
|
if (back) {
|
||||||
target.copyTo(source, overwrite = true)
|
target.copyTo(source, overwrite = true)
|
||||||
} else {
|
} 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
|
--- a/net/minecraft/advancements/DisplayInfo.java
|
||||||
+++ b/net/minecraft/advancements/DisplayInfo.java
|
+++ b/net/minecraft/advancements/DisplayInfo.java
|
||||||
@@ -37,6 +37,7 @@
|
@@ -37,6 +_,7 @@
|
||||||
private final boolean hidden;
|
private final boolean hidden;
|
||||||
private float x;
|
private float x;
|
||||||
private float y;
|
private float y;
|
@ -1,11 +1,11 @@
|
|||||||
--- a/net/minecraft/advancements/critereon/LocationPredicate.java
|
--- a/net/minecraft/advancements/critereon/LocationPredicate.java
|
||||||
+++ b/net/minecraft/advancements/critereon/LocationPredicate.java
|
+++ b/net/minecraft/advancements/critereon/LocationPredicate.java
|
||||||
@@ -44,7 +44,7 @@
|
@@ -44,7 +_,7 @@
|
||||||
public boolean matches(ServerLevel world, double x, double y, double z) {
|
public boolean matches(ServerLevel level, double x, double y, double z) {
|
||||||
if (this.position.isPresent() && !this.position.get().matches(x, y, z)) {
|
if (this.position.isPresent() && !this.position.get().matches(x, y, z)) {
|
||||||
return false;
|
return false;
|
||||||
- } else if (this.dimension.isPresent() && this.dimension.get() != world.dimension()) {
|
- } 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 ? 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() != (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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
BlockPos blockPos = BlockPos.containing(x, y, z);
|
BlockPos blockPos = BlockPos.containing(x, y, z);
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
|
--- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
|
||||||
+++ b/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;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
|
||||||
public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.SimpleInstance> implements CriterionTrigger<T> {
|
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
|
+ // private final Map<PlayerAdvancements, Set<CriterionTrigger.Listener<T>>> players = Maps.newIdentityHashMap(); // Paper - fix AdvancementDataPlayer leak; moved into AdvancementDataPlayer to fix memory leak
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void addPlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) {
|
public final void addPlayerListener(PlayerAdvancements playerAdvancements, CriterionTrigger.Listener<T> listener) {
|
||||||
- this.players.computeIfAbsent(manager, managerx -> Sets.newHashSet()).add(conditions);
|
- this.players.computeIfAbsent(playerAdvancements, advancements -> Sets.newHashSet()).add(listener);
|
||||||
+ manager.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(conditions); // Paper - fix AdvancementDataPlayer leak
|
+ playerAdvancements.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix AdvancementDataPlayer leak
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void removePlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) {
|
public final void removePlayerListener(PlayerAdvancements playerAdvancements, CriterionTrigger.Listener<T> listener) {
|
||||||
- Set<CriterionTrigger.Listener<T>> set = this.players.get(manager);
|
|
||||||
+ Set<CriterionTrigger.Listener<T>> set = (Set) manager.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
|
|
||||||
if (set != null) {
|
|
||||||
set.remove(conditions);
|
|
||||||
if (set.isEmpty()) {
|
|
||||||
- this.players.remove(manager);
|
|
||||||
+ manager.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
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = this.players.get(playerAdvancements);
|
||||||
+ Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
|
+ Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
|
||||||
|
if (set != null) {
|
||||||
|
set.remove(listener);
|
||||||
|
if (set.isEmpty()) {
|
||||||
|
- this.players.remove(playerAdvancements);
|
||||||
|
+ playerAdvancements.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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> 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()) {
|
if (set != null && !set.isEmpty()) {
|
||||||
- LootContext lootContext = EntityPredicate.createContext(player, player);
|
- LootContext lootContext = EntityPredicate.createContext(player, player);
|
||||||
+ LootContext lootContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions
|
+ LootContext lootContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions
|
||||||
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
for (CriterionTrigger.Listener<T> listener : set) {
|
for (CriterionTrigger.Listener<T> listener : set) {
|
||||||
T simpleInstance = listener.trigger();
|
T simpleInstance = listener.trigger();
|
||||||
if (predicate.test(simpleInstance)) {
|
if (testTrigger.test(simpleInstance)) {
|
||||||
Optional<ContextAwarePredicate> optional = simpleInstance.player();
|
Optional<ContextAwarePredicate> optional = simpleInstance.player();
|
||||||
- if (optional.isEmpty() || optional.get().matches(lootContext)) {
|
- 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
|
+ 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