aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0684-fix-converting-txt-to-json-file.patch
blob: 7dfa73f6baa5677605dd48314b017e4b5494ec71 (plain)
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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Mon, 4 Jan 2021 19:49:15 -0800
Subject: [PATCH] fix converting txt to json file


diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
index b13e6f9923a9c5703f4eaeab2d0c112e4726b496..a762cf4c4a52bcbc8dbfd60b3ad7fef5489ba5c5 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
@@ -18,6 +18,11 @@ public class DedicatedPlayerList extends PlayerList {
 
         this.a(dedicatedserverproperties.viewDistance);
         super.setHasWhitelist((Boolean) dedicatedserverproperties.whiteList.get());
+        // Paper start - moved from constructor
+    }
+    @Override
+    public void loadAndSaveFiles() {
+        // Paper end
         this.y();
         this.w();
         this.x();
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index c4df472050622eb2469b2ddb4d2ed917994f6e95..52bb528e75eb43156ee2bf19877bc051a35bb6e3 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -198,6 +198,12 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
         org.spigotmc.SpigotConfig.init((java.io.File) options.valueOf("spigot-settings"));
         org.spigotmc.SpigotConfig.registerCommands();
         // Spigot end
+        // Paper start - moved up to right after PlayerList creation but before file load/save
+        if (this.convertNames()) {
+            this.getUserCache().save(false); // Paper
+        }
+        this.getPlayerList().loadAndSaveFiles(); // Must be after convertNames
+        // Paper end
         // Paper start
         try {
             com.destroystokyo.paper.PaperConfig.init((java.io.File) options.valueOf("paper-settings"));
@@ -260,10 +266,6 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
             DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
         }
 
-        if (this.convertNames()) {
-            this.getUserCache().b(false); // Paper
-        }
-
         if (!NameReferencingFileConverter.e(this)) {
             return false;
         } else {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 24b3a893a2b76a4ecfbc6b2cc1eac242e5c6e9d6..92ed4938d5fe6b76e3a9ac5491d6e9c004ade843 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -175,6 +175,7 @@ public abstract class PlayerList {
         this.maxPlayers = i;
         this.playerFileData = worldnbtstorage;
     }
+    abstract public void loadAndSaveFiles(); // Paper - moved from DedicatedPlayerList constructor
 
     public void a(NetworkManager networkmanager, EntityPlayer entityplayer) {
         EntityPlayer prev = pendingPlayers.put(entityplayer.getUniqueID(), entityplayer);// Paper
diff --git a/src/main/java/net/minecraft/server/players/UserCache.java b/src/main/java/net/minecraft/server/players/UserCache.java
index e17927ecc3ad3e27e436082ac94e3772d7311725..e813d4dd1a46734d16b42905808caa889811afcc 100644
--- a/src/main/java/net/minecraft/server/players/UserCache.java
+++ b/src/main/java/net/minecraft/server/players/UserCache.java
@@ -242,6 +242,7 @@ public class UserCache {
         return arraylist;
     }
 
+    public void save(boolean asyncSave) { b(asyncSave); } // Paper - OBFHELPER
     public void b(boolean asyncSave) { // Paper
         JsonArray jsonarray = new JsonArray();
         DateFormat dateformat = e();