aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch184
1 files changed, 184 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch
new file mode 100644
index 0000000000..c5f25216e9
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/server/PlayerAdvancements.java.patch
@@ -0,0 +1,184 @@
+--- a/net/minecraft/server/PlayerAdvancements.java
++++ b/net/minecraft/server/PlayerAdvancements.java
+@@ -62,21 +62,21 @@
+ @Nullable
+ private AdvancementHolder lastSelectedTab;
+ private boolean isFirstPacket = true;
+- private final Codec<PlayerAdvancements.Data> codec;
++ private final Codec<PlayerAdvancements.a> codec;
+
+- public PlayerAdvancements(DataFixer datafixer, PlayerList playerlist, ServerAdvancementManager serveradvancementmanager, Path path, ServerPlayer serverplayer) {
+- this.playerList = playerlist;
+- this.playerSavePath = path;
+- this.player = serverplayer;
+- this.tree = serveradvancementmanager.tree();
++ public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) {
++ this.playerList = playerList;
++ this.playerSavePath = playerSavePath;
++ this.player = player;
++ this.tree = manager.tree();
+ boolean flag = true;
+
+- this.codec = DataFixTypes.ADVANCEMENTS.wrapCodec(PlayerAdvancements.Data.CODEC, datafixer, 1343);
+- this.load(serveradvancementmanager);
++ this.codec = DataFixTypes.ADVANCEMENTS.wrapCodec(PlayerAdvancements.a.CODEC, dataFixer, 1343);
++ this.load(manager);
+ }
+
+- public void setPlayer(ServerPlayer serverplayer) {
+- this.player = serverplayer;
++ public void setPlayer(ServerPlayer player) {
++ this.player = player;
+ }
+
+ public void stopListening() {
+@@ -90,7 +90,7 @@
+
+ }
+
+- public void reload(ServerAdvancementManager serveradvancementmanager) {
++ public void reload(ServerAdvancementManager manager) {
+ this.stopListening();
+ this.progress.clear();
+ this.visible.clear();
+@@ -98,12 +98,12 @@
+ this.progressChanged.clear();
+ this.isFirstPacket = true;
+ this.lastSelectedTab = null;
+- this.tree = serveradvancementmanager.tree();
+- this.load(serveradvancementmanager);
++ this.tree = manager.tree();
++ this.load(manager);
+ }
+
+- private void registerListeners(ServerAdvancementManager serveradvancementmanager) {
+- Iterator iterator = serveradvancementmanager.getAllAdvancements().iterator();
++ private void registerListeners(ServerAdvancementManager manager) {
++ Iterator iterator = manager.getAllAdvancements().iterator();
+
+ while (iterator.hasNext()) {
+ AdvancementHolder advancementholder = (AdvancementHolder) iterator.next();
+@@ -113,8 +113,8 @@
+
+ }
+
+- private void checkForAutomaticTriggers(ServerAdvancementManager serveradvancementmanager) {
+- Iterator iterator = serveradvancementmanager.getAllAdvancements().iterator();
++ private void checkForAutomaticTriggers(ServerAdvancementManager manager) {
++ Iterator iterator = manager.getAllAdvancements().iterator();
+
+ while (iterator.hasNext()) {
+ AdvancementHolder advancementholder = (AdvancementHolder) iterator.next();
+@@ -128,7 +128,7 @@
+
+ }
+
+- private void load(ServerAdvancementManager serveradvancementmanager) {
++ private void load(ServerAdvancementManager manager) {
+ if (Files.isRegularFile(this.playerSavePath, new LinkOption[0])) {
+ try {
+ JsonReader jsonreader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8));
+@@ -136,9 +136,9 @@
+ try {
+ jsonreader.setLenient(false);
+ JsonElement jsonelement = Streams.parse(jsonreader);
+- PlayerAdvancements.Data playeradvancements_data = (PlayerAdvancements.Data) Util.getOrThrow(this.codec.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
++ PlayerAdvancements.a advancementdataplayer_a = (PlayerAdvancements.a) Util.getOrThrow(this.codec.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
+
+- this.applyFrom(serveradvancementmanager, playeradvancements_data);
++ this.applyFrom(manager, advancementdataplayer_a);
+ } catch (Throwable throwable) {
+ try {
+ jsonreader.close();
+@@ -157,8 +157,8 @@
+ }
+ }
+
+- this.checkForAutomaticTriggers(serveradvancementmanager);
+- this.registerListeners(serveradvancementmanager);
++ this.checkForAutomaticTriggers(manager);
++ this.registerListeners(manager);
+ }
+
+ public void save() {
+@@ -191,12 +191,13 @@
+
+ }
+
+- private void applyFrom(ServerAdvancementManager serveradvancementmanager, PlayerAdvancements.Data playeradvancements_data) {
+- playeradvancements_data.forEach((resourcelocation, advancementprogress) -> {
+- AdvancementHolder advancementholder = serveradvancementmanager.get(resourcelocation);
++ private void applyFrom(ServerAdvancementManager advancementdataworld, PlayerAdvancements.a advancementdataplayer_a) {
++ advancementdataplayer_a.forEach((minecraftkey, advancementprogress) -> {
++ AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey);
+
+ if (advancementholder == null) {
+- PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", resourcelocation, this.playerSavePath);
++ if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit
++ PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
+ } else {
+ this.startProgress(advancementholder, advancementprogress);
+ this.progressChanged.add(advancementholder);
+@@ -205,7 +206,7 @@
+ });
+ }
+
+- private PlayerAdvancements.Data asData() {
++ private PlayerAdvancements.a asData() {
+ Map<ResourceLocation, AdvancementProgress> map = new LinkedHashMap();
+
+ this.progress.forEach((advancementholder, advancementprogress) -> {
+@@ -214,7 +215,7 @@
+ }
+
+ });
+- return new PlayerAdvancements.Data(map);
++ return new PlayerAdvancements.a(map);
+ }
+
+ public boolean award(AdvancementHolder advancementholder, String s) {
+@@ -227,10 +228,11 @@
+ this.progressChanged.add(advancementholder);
+ flag = true;
+ if (!flag1 && advancementprogress.isDone()) {
++ this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancementholder.toBukkit())); // CraftBukkit
+ advancementholder.value().rewards().grant(this.player);
+- advancementholder.value().display().ifPresent((displayinfo) -> {
+- if (displayinfo.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+- this.playerList.broadcastSystemMessage(displayinfo.getType().createAnnouncement(advancementholder, this.player), false);
++ advancementholder.value().display().ifPresent((advancementdisplay) -> {
++ if (advancementdisplay.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
++ this.playerList.broadcastSystemMessage(advancementdisplay.getType().createAnnouncement(advancementholder, this.player), false);
+ }
+
+ });
+@@ -312,7 +314,7 @@
+ criterion.trigger().removePlayerListener(this, new CriterionTrigger.Listener<>(criterion.triggerInstance(), advancementholder, s));
+ }
+
+- public void flushDirty(ServerPlayer serverplayer) {
++ public void flushDirty(ServerPlayer serverPlayer) {
+ if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) {
+ Map<ResourceLocation, AdvancementProgress> map = new HashMap();
+ Set<AdvancementHolder> set = new HashSet();
+@@ -338,7 +340,7 @@
+
+ this.progressChanged.clear();
+ if (!map.isEmpty() || !set.isEmpty() || !set1.isEmpty()) {
+- serverplayer.connection.send(new ClientboundUpdateAdvancementsPacket(this.isFirstPacket, set, set1, map));
++ serverPlayer.connection.send(new ClientboundUpdateAdvancementsPacket(this.isFirstPacket, set, set1, map));
+ }
+ }
+
+@@ -396,9 +398,9 @@
+ });
+ }
+
+- private static record Data(Map<ResourceLocation, AdvancementProgress> map) {
++ private static record a(Map<ResourceLocation, AdvancementProgress> map) {
+
+- public static final Codec<PlayerAdvancements.Data> CODEC = Codec.unboundedMap(ResourceLocation.CODEC, AdvancementProgress.CODEC).xmap(PlayerAdvancements.Data::new, PlayerAdvancements.Data::map);
++ public static final Codec<PlayerAdvancements.a> CODEC = Codec.unboundedMap(ResourceLocation.CODEC, AdvancementProgress.CODEC).xmap(PlayerAdvancements.a::new, PlayerAdvancements.a::map);
+
+ public void forEach(BiConsumer<ResourceLocation, AdvancementProgress> biconsumer) {
+ this.map.entrySet().stream().sorted(Entry.comparingByValue()).forEach((entry) -> {