23
23
public class LegacyStorage implements Storage {
24
24
@ Override
25
25
public PlayerData loadPlayerData (UUID uuid ) {
26
- long start = System .nanoTime ();
27
26
Config playerFile = new Config ("data-storage/Slimefun/Players/" + uuid + ".yml" );
28
27
// Not too sure why this is its own file
29
28
Config waypointsFile = new Config ("data-storage/Slimefun/waypoints/" + uuid + ".yml" );
@@ -38,26 +37,6 @@ public PlayerData loadPlayerData(UUID uuid) {
38
37
39
38
// Load backpacks
40
39
HashMap <Integer , PlayerBackpack > backpacks = new HashMap <>();
41
- /*
42
- for (String key : playerFile.getKeys("backpacks")) {
43
- try {
44
- int id = Integer.parseInt(key);
45
- int size = playerFile.getInt("backpacks." + key + ".size");
46
-
47
- HashMap<Integer, ItemStack> items = new HashMap<>();
48
- for (int i = 0; i < size; i++) {
49
- items.put(i, playerFile.getItem("backpacks." + key + ".contents." + i));
50
- }
51
- } catch (Exception x) {
52
- Slimefun.logger()
53
- .log(
54
- Level.WARNING,
55
- x,
56
- () -> "Could not load Backpack \"" + key + "\" for Player \"" + uuid + '"');
57
- }
58
-
59
- }
60
- */
61
40
62
41
// Load waypoints
63
42
Set <Waypoint > waypoints = new HashSet <>();
@@ -78,16 +57,12 @@ public PlayerData loadPlayerData(UUID uuid) {
78
57
}
79
58
}
80
59
81
- long end = System .nanoTime ();
82
- Slimefun .getAnalyticsService ().recordPlayerProfileDataTime ("legacy" , true , end - start );
83
-
84
60
return new PlayerData (researches , backpacks , waypoints );
85
61
}
86
62
87
63
// The current design of saving all at once isn't great, this will be refined.
88
64
@ Override
89
65
public void savePlayerData (UUID uuid , PlayerData data ) {
90
- long start = System .nanoTime ();
91
66
Config playerFile = new Config ("data-storage/Slimefun/Players/" + uuid + ".yml" );
92
67
// Not too sure why this is its own file
93
68
Config waypointsFile = new Config ("data-storage/Slimefun/waypoints/" + uuid + ".yml" );
@@ -108,7 +83,7 @@ public void savePlayerData(UUID uuid, PlayerData data) {
108
83
// Sooooo we're gonna hack this for now while we move away from the Legacy Storage
109
84
// Let's make sure the user doesn't have _any_ research with this ID and _then_ remove it
110
85
} else if (playerFile .contains ("researches." + research .getID ())
111
- && ! data .getResearches ().stream ().anyMatch ((r ) -> r .getID () == research .getID ())) {
86
+ && data .getResearches ().stream ().noneMatch ((r ) -> r .getID () == research .getID ())) {
112
87
playerFile .setValue ("researches." + research .getID (), null );
113
88
}
114
89
}
@@ -140,8 +115,5 @@ public void savePlayerData(UUID uuid, PlayerData data) {
140
115
// Save files
141
116
playerFile .save ();
142
117
waypointsFile .save ();
143
-
144
- long end = System .nanoTime ();
145
- Slimefun .getAnalyticsService ().recordPlayerProfileDataTime ("legacy" , false , end - start );
146
118
}
147
119
}
0 commit comments