-
-
Notifications
You must be signed in to change notification settings - Fork 479
Expand file tree
/
Copy path0138-Yatopia-Optimize-advancement-loading.patch
More file actions
100 lines (90 loc) · 4.56 KB
/
Copy path0138-Yatopia-Optimize-advancement-loading.patch
File metadata and controls
100 lines (90 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Simon Gardling <titaniumtown@gmail.com>
Date: Tue, 20 Oct 2020 22:08:26 -0400
Subject: [PATCH] Yatopia-Optimize-advancement-loading
diff --git a/src/main/java/net/minecraft/server/Advancement.java b/src/main/java/net/minecraft/server/Advancement.java
index 384d4090f..486034a82 100644
--- a/src/main/java/net/minecraft/server/Advancement.java
+++ b/src/main/java/net/minecraft/server/Advancement.java
@@ -68,6 +68,7 @@ public class Advancement {
return this.display;
}
+ public final AdvancementRewards getRewards() { return d(); } // Yatopia - OBFHELPER
public AdvancementRewards d() {
return this.rewards;
}
diff --git a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
index c31f4040c..1c625d154 100644
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
@@ -160,12 +160,15 @@ public class AdvancementDataPlayer {
}
Stream<Entry<MinecraftKey, AdvancementProgress>> stream = map.entrySet().stream().sorted(Comparator.comparing(Entry::getValue));
+ /* // Yatopia start - avoid calling collect and iterator
Iterator iterator = ((List) stream.collect(Collectors.toList())).iterator();
while (iterator.hasNext()) {
Entry<MinecraftKey, AdvancementProgress> entry = (Entry) iterator.next();
+ */
+ stream.forEach(entry -> {
Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey());
-
+
if (advancement == null) {
// CraftBukkit start
if (entry.getKey().getNamespace().equals("minecraft")) {
@@ -176,7 +179,7 @@ public class AdvancementDataPlayer {
} else {
this.a(advancement, (AdvancementProgress) entry.getValue());
}
- }
+ }); // Yatopia end
} catch (Throwable throwable1) {
throwable = throwable1;
throw throwable1;
@@ -201,10 +204,35 @@ public class AdvancementDataPlayer {
}
}
+ /* // Yatopia start
this.c(advancementdataworld);
this.c();
this.b(advancementdataworld);
+ */
+ loadAdvancements(advancementdataworld);
+ // Yatopia end
}
+ // Yatopia start - reduce overload by post io load of advancements
+ // this combines c(AdvancementDataWorld), c() and b(AdvancementDataWorld) into 1 method
+ // the changes done: loops thru all the advancements only once, does not create an additional list
+ // and does not loop thru the additional list, does not create an additional set when checking for progress and
+ // does not additionally loop thru it
+ private void loadAdvancements(AdvancementDataWorld serverAdvancementManager) {
+ for (Advancement advancement : serverAdvancementManager.getAdvancements()) {
+ if (advancement.getCriteria().isEmpty()) {
+ grantCriteria(advancement, "");
+ advancement.getRewards().a(player); // todo: too lazy to import AdvancementRewards for an obfhelper
+ }
+ AdvancementProgress progress = getProgress(advancement);
+ if (progress.isDone()) {
+ this.j.add(advancement);
+ updateVisibility(advancement);
+ continue; // Do not double check isDone
+ }
+ beginTracking(advancement);
+ }
+ }
+ // Yatopia end
public void b() {
if (org.spigotmc.SpigotConfig.disableAdvancementSaving) return; // Spigot
@@ -326,6 +354,7 @@ public class AdvancementDataPlayer {
return flag;
}
+ private final void beginTracking(Advancement advancement) { c(advancement); } // Yatopia - OBFHELPER
private void c(Advancement advancement) {
AdvancementProgress advancementprogress = this.getProgress(advancement);
@@ -443,6 +472,7 @@ public class AdvancementDataPlayer {
this.data.put(advancement, advancementprogress);
}
+ private final void updateVisibility(Advancement advancement) { e(advancement); } // Yatopia
private void e(Advancement advancement) {
// Paper start
e(advancement, IterationEntryPoint.ROOT);